Creating virtIO disks for virtual machines
To improve I/O performance of virtual machines, you can use virtIO disks with them. By default, virtual machines are created with disks attached to the SCSI bus, which cannot be changed later. You can create a volume for a VM and attach this volume to the virtIO bus during the VM deployment. To do this, use the --volume bus=virtio
option of the vinfra service compute server create command. This option can be applied for creating boot volumes from both ISO and QCOW2 images. You can also use it to attach non-boot volumes. Note that you need to specify this option each time you create a virtual machine and you cannot attach more volumes after the VM is created. For example:
-
To create a VM from the
mytemplate
QCOW2 image, run:# vinfra service compute server create myvm1 --network id=private,fixed-ip=192.168.128.100 --flavor medium\ --volume source=image,id=mytemplate,bus=virtio,size=100
-
To create a VM from the
myiso
ISO image, run:# vinfra service compute server create myvm2 --network id=private,fixed-ip=192.168.128.100 --flavor medium\ --volume source=blank,size=100,bus=virtio,boot-index=0,type=disk \ --volume source=image,id=myiso,size=5,boot-index=1,type=cdrom
Alternatively, it is possible to apply the virtIO bus property to an image via the OpenStack command-line tool. This property allows you to create multiple VMs from configured images in the command-line interface, as well as in the admin and self-service panels. However, it only works for QCOW2 images. For example, to configure the mytemplate
QCOW2 image, do the following:
-
Connect to the OpenStack command-line interface as a system administrator to authorize further OpenStack commands (refer to Connecting to OpenStack command-line interface):
# kolla-ansible post-deploy # source /etc/kolla/admin-openrc.sh
-
Run the command:
# openstack --insecure image set mytemplate --property hw_disk_bus=virtio
After the VM is created, all volumes that you add to it will be attached to the virtIO bus.