I am trying to create a Windows 7 virtual machine on a Gentoo x86_64 host (kernel 3.18.9 hardened) using qemu-system-x86_64 2.3.0 with kvm enabled. I have successfully compiled the kernel and have installed the guest machine (Windows 7) although the guest is suffering from major performance issues which I believe are IO related.
The specs of the host are 1.7ghz (2.6ghz turbo) i5-3317U (2 cores, 4 threads) with 6gb ddr3 ram and a 5300rpm hard drive. The host runs AES luks encrypted file volumes mounted on /home where the VMs image is stored. The specs of the guest are 2 cores, 4 threads, 4gb ram, 15gb image (which leaves 1gb of disk space for testing). The container of the guest is qcow2, compat 1.1, lazy refcounts: true, recount bits: 16, with cache set to none. I have also tried converting this qcow2 container to
raw format and it helped with the issue a tiny bit.
I have installed and enabled virtio drivers where ever possible and have verified that qemu is using kvm via issuing the
info kvm command inside qemus terminal. I have also tried hand tuning my launch script shown below:
#!/bin/bash export QEMU_AUDIO_DRV=alsa exec qemu-system-x86_64 \ --enable-kvm \ -machine type=pc,accel=kvm \ -smp cores=2,threads=4 \ -vga std \ -soundhw ac97 \ -drive file=/WindowsVM.img2,cache=none,if=virtio \ -netdev user,id=vmnic -device virtio-net,netdev=vmnic \ -cpu host \ -m 4G \ -balloon virtio \ -name Windows \ -usbdevice tablet \ -monitor stdio \ "$@"
The problem is that the image takes for ever to boot and to shutdown. It also takes a substantial amount of time to open applications (15-20 seconds to open internet explorer for testing), although once opened a few times speeds increase for the applications opening as if they are being cached. Another fact I've notice is extracting zip files never exceed 50-60kb/s and file downloads download at my regular download speed, but once they hit 100% they stall for a bit before it finishes. I have ran crystal disk mark to benchmark the virtual disk IO and I am getting sequential 400mb/s reads and 300mb/s writes which is blatantly incorrect. These high benches are when I boot the VM from an image stored in the encrypted file volume as mentioned above. When moving the image to an unencrypted mount point benches read 70mb/s read and 35mb/s writes which seem more sane. Coincidentally the VM suffers much less of this "lag" when the image is stored in an unencrypted location. The boot/shutdown times are still fairly lengthy but no where near the time it takes while the image is stored in an encrypted location nor is the opening/closing of software.
As I've seen through testing, the encrypted file volume where I want the image to live may be causing the issues, but I would like a second opinion or other options I could try. Is it possible to encrypt the image itself through some method that may have less performance impact than storing the unencrypted image on an encrypted mount point? Is there encryption built into the container I could enable or is there a better way to use cryptsetup/luks to encrypt specifically the container to improve performance?
Thanks for your help.