On one of our host machine, we get around 70MB/second disk write speed, but KVM guest machine was giving us around 18MB/s write performance.
At that point we came to know about virtio driver. Here is guide to enable virtio
Backup VM config
virsh dumpxml <vmname> > ~/vmname.xml
vmname with Virtual Machine (Domain) name. You can find correct name by running
virsh list --all
Edit VM Config
Run following command to open editor.
virsh edit <vmname>
Find lines like below:
<disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/ubuntu-kvm/tmpU2z98r.qcow2'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk>
Make following changes:
- Remove following line:
<address type='drive' controller='0' bus='0' unit='0'/>
cache='none' io='native'option to
Your update config will look like below:
<disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none' io='native'/> <source file='/var/lib/libvirt/images/ubuntu-kvm/tmpU2z98r.qcow2'/> <target dev='vda' bus='virtio'/> </disk>
Save your changes and exit editor.
Changes to Guest VM’s filesystem
I am not sure if this step is necessary but one tutorial mentions this. I did not try outcome without this step as VM’s I was playing with has some critical data.
Anyway, login to Guest VM’s shell and open in editor
Fine lines like
/dev/sda1 will become
/dev/sda2 will become
/dev/vda2 and so on.
For changes to reflect
Shutdown Guest VM for its shell. You can use command
Next, from Host machine, run following commands:
virsh destroy <vmname> virsh start <vmname>
virsh reboot won’t work.
At this point you can run your disk I/O benchmarks again to check speed.
In our case performance shoot-up from 18MB/s to 40.8 MB/s.