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 via the vinfra
tool. This method works for creating boot volumes from both ISO images and templates (QCOW2). You can also use it to attach non-boot volumes. Note that you need to run the vinfra
command each time you create a virtual machine.
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 templates.
Prerequisites
- You have an image uploaded to the compute cluster, as described in Preparing boot media for virtual machines.
- To authorize further OpenStack commands, the OpenStack command-line client must be configured, as outlined in Connecting to OpenStack command-line interface.
To create a virtual machine with virtIO volume
Use the --volume bus=virtio
option with the vinfra service compute server create
command.
Example 1. 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
Example 2. 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
After the VM is created, all volumes that you add to it will be attached to the virtIO bus.
To create a virtual machine with virtIO template
-
Apply the virtIO bus property to a template. For example:
# openstack --insecure image set mytemplate --property hw_disk_bus=virtio
-
Create a volume from the virtIO template. For example:
# openstack --insecure volume create --image=mytemplate --size=10 myvolume
-
Create a VM from the new volume. For example:
# openstack --insecure server create myvm --volume=myvolume --flavor small --network public
After the VM is created, all volumes that you add to it will be attached to the virtIO bus.