Enable multi-queue on storage devices

When using virtio-blk or virtio-scsi storage devices in your virtual machines (VMs), you can improve storage performance and scalability by using the multi-queue feature. With multi-queue, each vCPU has a separate queue and interrupt without affecting other vCPUs.

About this task

Note that _multi-queue feature is enabled by default for the Q35 machine type, but on the i440fx machine type, you must enable it manually. You can tune the number of queues to be optimal for your workload, but the optimal number differs for each type of workload and you must test which number of queues works best in your case.

Procedure

  1. To enable multi-queue on a storage device, edit the XML configuration of the VM.
    # virsh edit <example_vm>
  2. In the XML configuration, find the intended storage device and change the queues parameter to use multiple I/O queues. Replace N with the number of vCPUs in the VM, up to 16.
    • A virtio-blk example:
      <disk type='block' device='disk'>
        <driver name='qemu' type='raw' queues='N'/>
        <source dev='/dev/sda'/>
        <target dev='vda' bus='virtio'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      </disk>
    • A virtio-scsi example:
      <controller type='scsi' index='0' model='virtio-scsi'>
         <driver queues='N' />
      </controller>
  3. Restart the VM for the changes to take effect.