Example Using spice and qxl for improved graphics experience in the guest
This example is based on qemu-KVM (0.15.0) as installed in fedora 15. Will first show how to do this manually, and second how to do it using the virt-manager tool.
For extensive details on spice, visit http://spice-space.org
[Edit]
Manually, using qemu-KVM command line directly
The simplest part is adding the qxl graphics device to the guest. By adding <cdoe>-VGA qxl </code>:
#/Usr/bin/qemu-KVM-M 1024-name F15-drive file =/images/f15.img, if = virtio-VGA qxl
You'll see a normal SDL window pop up, and if you poke inside the guest you'll find that X is using the qxl device to display:
$ Lspci
...
00:02. 0 VGA compatible Controller: Red Hat, Inc. device 0100 (Rev 03)
$ Grep qxl/var/log/xorg.0.log
[15.878] (ii) qxl: Driver for qxl virtual graphics: qxl 1
However, this is not enough to use spice. we need to enable the spice server in qemu-KVM. we also need a client to view the guest. so first be sure the client is installed:
# Yum install spice-Client
To keep it simple, we'll not require authentication and simply bind the server to 127.0.0.1 on port 5900.
#/Usr/bin/qemu-KVM-M 1024-name F15-drive file =/images/f15.img, if = virtio-VGA qxl-spice Port = 5900, ADDR = 127.0.0.1, disable-Ticketing
This will not pop up an SDL window, so launch the client to connect to the guest.
$ Spicec-H 127.0.0.1-P 5900
We're re getting closer. now the only thing left is to improve the experience by enabling the spice agent communication channel between the host and the guest (you wanted copy and paste between host and guest right? ;)
This part is a bit arcane. we need to add a virtio-serial device to the guest, and open a port for the spice vdagent. we also need to install the spice vdagent in guest. be sure the agent is running (and for future, started automatically ).
First the guest side, since the guest is running.
# Yum install spice-vdagent
# Chkconfig -- add spice-vdagentd
Now stop the guest and we'll build up the hostside qemu-KVM CommandLine. We need to add the virtio-serial device:-Device virtio-serial-PCI
We need to add a port for spice in that device:-Device token SerialPort, chardev = spicechannel0, name = com. RedHat. spice.0
And we need a spicevmc chardev for that Port:-Chardev spicevmc, id = spicechannel0, name = vdagent
It's important that the virserialportChardev =
Option matches the <cdoe> id = </code> given the chardev (Spicechannel0
In this example). It's also important that the port'sName =
IsCom. RedHat. spice.0
, Because that's the namespace spice-vdagentd is looking for in the guest. And finally, you need to specifyName = vdagent
So spice knows what this channel is.
So we launch the guest one last time with the complete command line:
#/Usr/bin/qemu-KVM-M 1024-name F15-drive file =/images/f15.img, if = virtio-VGA qxl-spice Port = 5900, ADDR = 127.0.0.1, disable-ticketing-device virtio-serial-PCI
-Device token SerialPort, chardev = spicechannel0, name = com. RedHat. spice.0-chardev spicevmc, id = spicechannel0, name = vdagent
And kick off a spice client:
$ Spicec-H 127.0.0.1-P 5900
Now you can login to the guest, and you'll still see the qxl display device. In addition, you'll see the virtio-Serial Port:
$ Ls/dev/virtio-ports/
Com. RedHat. spice.0
Now test it out. grab some text and copy it to the clipboard in the guest. (In gnome-terminal It's shift-Ctrl-C to copy ). and paste it in the host (again, shift-Ctrl-V to paste in gnome-terminal ).
[Edit]
Enabling spice using virt-Manager
This assumes you 've already installed a guest with virt-manager or virt-install and it's shut off.
Start virt-manager, and open your VM by double clicking on it. Click the Virtual Hardware details (Lightbulb ).
First we need to make the video card a qxl device. Click on video, and in the model pulldown, choose, qxl. and apply.
Next we need to change the display from VNC to spice. click on display VNC, and in the type pulldown, choose spice. and apply. you'll be prompted to add the spice agent channels, click yes. (Notice the additional controller virtio serial too ).
Now start the VM. virt-manager has a spice-GTK client built-in. so you don't need to fuss with a manual spice client like you did above. you still need to be sure that the guest has spice-vdagent installed and running. in the guest:
# Yum install spice-vdagent
# Chkconfig -- add spice-vdagentd
# Service start spice-vdagentd
... Log out of X, and log back in, verify agent is running...
$ PS-Ef | grep vdagent
Root 1653 1 0 14: 54? 00:00:00/usr/sbin/spice-vdagentd
What are the values of the following parameters? 00:00:00/usr/bin/spice-vdagent
Chrisw 1932 1 0? 00:00:00/usr/bin/spice-vdagent
And you're done. test copy and paste and enjoy.
Link: http://www.linux-kvm.org/page/SPICE