A while back, I wrote
an article about taking consistent snapshots of your virtual machines in your OpenStack environment. However this method was really intrusive since
it required to be inside the virtual machine and to manually summon a filesystem freeze. In this article, I will use a different approach to achieve the same goal without the need to be inside
the virtual machine. The only requirement is to have a virtual machine running the qemu-guest-agent.
OpenStack Nova and QEMU guest agent
The QEMU guest support landed in Nova during the
Havana cycle, so basically we are two release ahead. This functionality is based on Glance properties.
But how does that work?
The principle is quite easy. A virtual machine boots with a new virtio device attached pointing to unix socket on the hypervisor. Inside the virtual machine this socket will appear as a new character device, commonly under /dev/virtio-ports/.
A picture is always better:
Configure the QEMU agent
For Ubuntu, you need to apply this fix since AppArmor will not allow the creation of the socket:
[color=#268BD2!important]$ sudo [color=#859900!important]echo [color=#2AA198!important]"/var/lib/libvirt/qemu/*.sock rw," | sudo tee -a /etc/apparmor.d/abstractions/libvirt-qemu
[color=#268BD2!important]$ sudo service libvirt-bin restart
[color=#268BD2!important]$ sudo service nova-compute restart
[color=#268BD2!important]$ sudo service apparmor reload
ubuntu@agent:~[color=#268BD2!important]$ file /dev/virtio-ports/org.qemu.guest_agent.0
/dev/virtio-ports/org.qemu.guest_agent.0: symbolic link to `../vport2p1[color=#DC322F!important]'
For a more concrete example, have a look
at this work for a database from Chromium.
OpenStack Nova and Snapshots
Several patches have been submitted to quiesce the filesystem prior to run the snapshot. The initial work to support fs-freeze while performing a snapshot of an instance was introduced in Juno with a spec.
However the commit only got merged in
December… This will be available in Kilo. Another effort to support this feature while booting from a volume is currently under review.
The original blueprint can be found here.
Ultimately this option will be available via a Glance property:
When this option will be set and the virtual machine running the QEMU guest agent, when a user will snapshot an instance, the filesystem will get frozen and thawed after the operation.