Sunday, September 22. 2013

A quick entry this time, it is just a tip I had been looking for for a long time. Sometimes I need to use a windows box inside the KVM virtualization of my debian box. I know, I do not like it either, but sometimes you have no other choice. I always complained about the copy-n-paste thing, what I copied inside the virtual windows guest cannot be pasted to my debian host and vice-versa. I always supposed that there should be any solution but I had never found any, although I have to admit that I did not spend much time on it. These last weeks I have had to use the windows guest more continuously and finally I was forced to find a proper solution.

The solution is based on spice, a project to provide a high-quality remote access to QEMU and, therefore, KVM. In theory there are a lot of advantages in using spice instead normal VNC protocol and one of those is the copy-n-paste feature. The steps to provide this functionality between KVM guest and host are more or less explained inside the kvm documentation, but the problem is that the example is for a fedora guest, not windows. My dummy how-to is presented below.

First the spice virtual drivers were installed inside the windows OS. I tried first the spice-guest-tools version 0.59 (the version that is listed in the downloads page) but virtual IO serial device for copy-n-paste hanged (exactly what I wanted to use, you know, Murphy's law). Finally I discovered that there was also a version 0.65 but it is still not listed as a download, and with that one I got it working.

Once the spice tools are installed in the guest box I configured my KVM machine to use spice (using graphical tool, virt-manager). The display was changed from VNC to SPICE.

Then a channel should be added in order to provide the copy-n-paste feature.

After that configuration I checked that the following options had been added to the kvm command line:

The first one activates the SPICE server. Now you can connect to the host using the spice client:

$ spicec -h localhost -p 5900

But it is not needed cos virt-manager already has an integrated spice client. The other two options are for the copy-n-paste (very weird options indeed). All this options are also explained in the KVM page I linked before.

The last step is booting again the windows guest. At startup time it discovered the new hardware, I selected not to connect to windows update or the internet and then to install the software automatically. The system found the drivers previously installed and chose two of them (the QLX driver for the display and a VirtIO for the character device).

As I explained in the first point I had several problems with the virtIO serial driver for copy-n-paste. It hanged at installation, exactly at this point. After a lot of hangs and reboots it let me replace 0.59 version for the new 0.65 and finally it booted without any issue.

So That is all. I finally has copy-n-paste in my windows guest using KVM and virt-manager. This entry is a little summary of what I did just to remember the next time I need it again. I hope that it helps someone else too.