To improve the I/O performance of a disk on your virtual machine (VM), you can configure a dedicated IOThread that is used to manage the I/O operations of the VM’s disk.
About this task
Normally, the I/O operations of a disk are a part of the main QEMU thread, which can decrease the responsiveness of the VM as a whole during intensive I/O workloads. By separating the I/O operations to a dedicated IOThread, you can significantly increase the responsiveness and performance of your VM.
Procedure
-
Shut down the selected VM if it is running.
-
On the host, add or edit the
<iothreads> tag in the XML configuration of the VM. For example, to create a single IOThread for a testguest1 VM:
# virsh edit <testguest1>
<domain type='kvm'>
<name>testguest1</name>
...
<vcpu placement='static'>8</vcpu>
<iothreads>1</iothreads>
...
</domain>
Note
For optimal results, use only 1-2 IOThreads per CPU on the host.
-
Assign a dedicated
IOThread to a VM disk. For example, to assign an IOThread with ID of 1 to a disk on the testguest1 VM:
# virsh edit <testguest1>
<domain type='kvm'>
<name>testguest1</name>
...
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none' io='native' iothread='1'/>
<source file='/var/lib/libvirt/images/test-disk.raw'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</disk>
...
</devices>
...
</domain>
Note
IOThread IDs start from 1 and you must dedicate only a single IOThread to a disk.
Usually, a one dedicated IOThread per VM is sufficient for optimal performance.
-
When using
virtio-scsi storage devices, assign a dedicated IOThread to the virtio-scsi controller. For example, to assign an IOThread with ID of 1 to a controller on the testguest1 VM:
# virsh edit <testguest1>
<domain type='kvm'>
<name>testguest1</name>
...
<devices>
<controller type='scsi' index='0' model='virtio-scsi'>
<driver iothread='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</controller>
...
</devices>
...
</domain>