home

Aug 24, 2020

Create a windows 10 VM on QEMU

I’m switching from virtualbox to qemu.
It seems lighter, faster and cooler.

Now, I use archlinux on my main machine, but my company tool of (poor) choice for instant messaging and audio conferencing is Skype for Business, so I have a vagrant/virtualbox windows 10 machine booted up all the time only to have Lync 2013 running.

With virtualbox was all good and dandy, but I wanted to switch to qemu and see if the situation could improve.

First thing was to check the invaluable archwiki and search for qemu.

Installation is easily done via pacman. Good.

Then I grabbed the latest windows 10 Pro N iso and checked the archwiki qemu page again to read how to prepare a windows guest.

Basically you have to attach the virtio drivers iso to the VM to make windows load those drivers during installation phase.
Without them the installation wizard cannot detect the disk drive.

With the disk detected I’ve gone through the boring windows installation, which is: de-flagging all the shit they propose to you.

Ok, windows booted fine, but no network at first.
I had to check the device manager and update the drivers of the network card, taking them from the virtio drivers iso I mounted before (let windows recursively search the cdrom).

Network was rolling at this point \o/.

Now, I didn’t have audio and microphone, so back to the mighty wiki page I checked the audio part.

It was a matter of adding the right options (as always):
I have an xps 13 9070 with archlinux and pulseaudio, so I added

-audiodev pa,id=snd0
-device ich9-intel-hda
-device hda-micro,audiodev=snd0

and all worked, sound was fine and microphone was picking up. Good.

Installed a few thing with scoop and chocolatey, then I tried to access to Lync but that asshole was keeping saying that my credentials were wrong.
I found, with deep shame, that I was trying to paste my password copying it from my archlinux host. Doesn’t work that way.

Back to the wiki checking how to solve the clipboard problem I found that I need to use SPICE in order to enable that and other features (e.g. display autoresizing).

So, back again to the heavens wiki page searching for SPICE.

In order to setup qemu and the VM to use SPICE I had to

    spicechannel="spicechannel0"
    
    ...stuff...
    -vga qxl
    -device virtio-serial-pci
    -spice unix,addr=/tmp/vm_spice.socket,disable-ticketing
    -device virtserialport,chardev=$spicechannel,name=com.redhat.spice.0
    -chardev spicevmc,id=$spicechannel,name=vdagent
    -display spice-app

with this I got a working windows 10 on qemu with audio and clipboard.

Here’s the complete script:

# creating a disk
# qemu-img create -f qcow2 windows.qcow2 128g

first_boot_opts="-drive file=./Win10_2004_EnglishInternational_x64.iso,media=cdrom,index=0"
first_boot_opts="$first_boot_opts -drive file=./virtio-win-0.1.185.iso,media=cdrom,index=1"
spicechannel="spicechannel0"

qemu-system-x86_64 \
    -enable-kvm \
    -cpu host \
    -smp 1,sockets=1,cores=1 \
    -m 1028 \
    -nic user,model=virtio \
    -drive file=windows.qcow2,media=disk,if=virtio \
    -rtc clock=host,base=localtime \
    -audiodev pa,id=snd0 \
    -device ich9-intel-hda \
    -device hda-micro,audiodev=snd0 \
    -vga qxl \
    -device virtio-serial-pci \
    -spice unix,addr=/tmp/vm_spice.socket,disable-ticketing \
    -device virtserialport,chardev=$spicechannel,name=com.redhat.spice.0 \
    -chardev spicevmc,id=$spicechannel,name=vdagent \
    -display spice-app

Have any comments?
Send me an email mapperr@sdf.ee
or post on my public mailing list ~mapperr/public-inbox@lists.sr.ht