Update an existing OpenStack instance after a global flag change

If a nova-compute flag ( for instance libvirt_use_virtio_for_bridges ) is changed after instances have been created, the existing instances won’t be changed accordingly. The libvirt XML description can be modified, both in /var/lib/nova/instances and in /etc/libvirt/qemu to reflect the desired change. The corresponding instance can then be rebooted with nova reboot so that kvm is run again with the new options.

libvirt related flags

A number of nova options are related to libvirt. When a virtual machine is created with nova boot, a libvirt XML file is created. For an instance named instance-00000063 it will be in /var/lib/nova/instances/instance-00000063/libvirt.xml. When launched, it will be copied over to /etc/libvirt/qemu/instance-00000063.xml and parsed to compute the arguments of the kvm process.
When libvirt related options such as libvirt_use_virtio_for_bridges are changed in /etc/nova/nova.conf, existing instances are not modified. They stay as they are and the XML files generated with the previous set of options are not migrated to match the new set of options.
When libvirt_use_virtio_for_bridges is set to true for instance, it means that the

<model type='virtio'/>

element is not added. As a consequence, only new instances will be run with

/usr/bin/kvm ... --device virtio-net-pc,netdev=hostnet0,id=net0,mac=fa:16:3e:55:6c:ee,bus=pci.0,addr=0x3  ...

but the old ones will still run with

/usr/bin/kvm ... --device rtl8139,netdev=hostnet0,id=net0,mac=fa:16:3e:55:6c:ee,bus=pci.0,addr=0x3 ...

manual file modifications

To change the libvirt options for the existing instances, the xml files can be edited manually.

# nova show 07ed9c9c-3961-4073-a859-7384445f7520 | grep SRV-ATTR
| OS-EXT-SRV-ATTR:host                | bm0001.the.re                                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                                     |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000063                                        |

The nova show command helps locate the files for a given instance. It is on the host OS-EXT-SRV-ATTR:host and in the files /var/lib/nova/instances/OS-EXT-SRV-ATTR:instance_name/libvirt.xml and /etc/libvirt/qemu/OS-EXT-SRV-ATTR:instance_name.xml.
To figure out how the xml files should be changed, a new instance can be created to compare both files, the old and the new.
Changing /var/lib/nova/instances/OS-EXT-SRV-ATTR:instance_name/libvirt.xml to add

<model type='virtio'/>

can be done with a regular text editor. It will be used when the instance is migrated to another host. However, modifying /etc/libvirt/qemu/OS-EXT-SRV-ATTR:instance_name.xml must be done with

# virsh edit /etc/libvirt/qemu/OS-EXT-SRV-ATTR:instance_name.xml

so that the libvirt daemon is notified of the change. When both files are modified, the instance can be rebooted with

# nova reboot instancename

which will kill the kvm process and run it again with the new options.

This entry was posted in Essex, debian, openstack. Bookmark the permalink.

2 Responses to Update an existing OpenStack instance after a global flag change

  1. Mark says:

    So if you have shared storage and the node where this VM was running dies, what is the procedure to turn this libvirt.xml file into a VM on a new node? I tried virsh define but didn’t have any luck.

    My current process is to back up both the qemu and nwfilter files in /etc/libvirt but that is a terrible process when the definition is right there with the disk instance.

    • Loic Dachary says:

      I don’t have a better solution but I don’t mind this for now. It will eventually be better and I can wait ;-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>