[libvirt] RFC: using a network device as a destination for a disk snapshot

Right now, when creating an external snapshot, the snapshot xml requires that the destination be in the local file system: http://libvirt.org/formatsnapshot.html <domainsnapshot> ... <disks> <disk name='vda' snapshot='external'> <driver type='qcow2'/> <source file='/path/to/new'/> </disk> ... But libvirt already allows for a network device with qcow2 contents, provided that there is no backing chain: # qemu-img info gluster://red/vol1/img2 image: gluster://red/vol1/img2 file format: qcow2 virtual size: 10M (10485760 bytes) disk size: 193K cluster_size: 65536 # virsh dumpxml dom <domain type='kvm'> ... <disk type='network' device='disk'> <driver name='qemu' type='qcow2'/> <source protocol='gluster' name='vol1/img2'> <host name='red'/> </source> <target dev='vdc' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </disk> ... I'm working on patches to the backing chain code to allow a gluster (or other network device) with qcow2 contents to have a backing file, but for the code to be useful, we also need to patch <domainsnapshot> xml to allow the destination file to be a gluster or other network device, rather than forcing it to be a local file name. Here's the XML I think we need to add to domainsnapshot: <domainsnapshot> ... <disks> <disk name='vda' snapshot='external' type='network'> <driver type='qcow2'/> <source protocol='gluster' name='vol1/img2'> <host name='red'/> </source> </disk> that is, add an optional /disk@type attribute (if absent, it defaults to type='file'), and where if present, the <source> subelement then takes on alternate forms in the same manner in which //domain/devices/disk handles alternates (here, allowing a protocol, name, and host specification). [Ultimately, we need to fix //domain/devices/disk to specify a full backing chain, but one step at a time...] -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Oct 30, 2013 at 08:44:32AM -0600, Eric Blake wrote:
Right now, when creating an external snapshot, the snapshot xml requires that the destination be in the local file system:
http://libvirt.org/formatsnapshot.html
<domainsnapshot> ... <disks> <disk name='vda' snapshot='external'> <driver type='qcow2'/> <source file='/path/to/new'/> </disk> ...
Interesting - we're missing the 'type' attribute here to distinguish file vs block too - which impacts on the attribute name in the <source> element - eg <source dev="/dev/foo1"/>
But libvirt already allows for a network device with qcow2 contents, provided that there is no backing chain:
# qemu-img info gluster://red/vol1/img2 image: gluster://red/vol1/img2 file format: qcow2 virtual size: 10M (10485760 bytes) disk size: 193K cluster_size: 65536 # virsh dumpxml dom <domain type='kvm'> ... <disk type='network' device='disk'> <driver name='qemu' type='qcow2'/> <source protocol='gluster' name='vol1/img2'> <host name='red'/> </source> <target dev='vdc' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </disk> ...
I'm working on patches to the backing chain code to allow a gluster (or other network device) with qcow2 contents to have a backing file, but for the code to be useful, we also need to patch <domainsnapshot> xml to allow the destination file to be a gluster or other network device, rather than forcing it to be a local file name.
Here's the XML I think we need to add to domainsnapshot:
<domainsnapshot> ... <disks> <disk name='vda' snapshot='external' type='network'> <driver type='qcow2'/> <source protocol='gluster' name='vol1/img2'> <host name='red'/> </source> </disk>
that is, add an optional /disk@type attribute (if absent, it defaults to type='file'), and where if present, the <source> subelement then takes on alternate forms in the same manner in which //domain/devices/disk handles alternates (here, allowing a protocol, name, and host specification).
We should wire up type=block while fixing this, so we have consistent representations. Indeed, is there a way to share the parsing code for this between the two schemas, to guarantee consistency ? Likely just want to share the source specification part of the schema (eg the QEMU "backend" config equivalent).
[Ultimately, we need to fix //domain/devices/disk to specify a full backing chain, but one step at a time...]
Yep, we'd want to fix the <domain> <disk> schema to deal with this before we consider what it means for <domainsnapshot> (if anything) Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 10/30/2013 10:44 AM, Eric Blake wrote:
Here's the XML I think we need to add to domainsnapshot:
<domainsnapshot> ... <disks> <disk name='vda' snapshot='external' type='network'> <driver type='qcow2'/> <source protocol='gluster' name='vol1/img2'> <host name='red'/> </source> </disk>
that is, add an optional /disk@type attribute (if absent, it defaults to type='file'), and where if present, the <source> subelement then takes on alternate forms in the same manner in which //domain/devices/disk handles alternates (here, allowing a protocol, name, and host specification).
[Ultimately, we need to fix //domain/devices/disk to specify a full backing chain, but one step at a time...]
This does match the XML that my (prototype) Nova code generated in hopes that this would work, except that I didn't have a <driver> element. (Makes sense, I can add this.) <domainsnapshot> <disks> <disk name="vdb" snapshot="external" type="network"> <source protocol="gluster" name="gvol1/volume-931536e0-65a7-4bd9-85ed-48bdd0160642.f6e62e4c-17b9-49bd-8941-10e8d11a22ca"> <host name="127.0.0.1"/> </source> </disk> <disk name="/opt/stack/data/nova/instances/6ff2075e-7b23-492a-865a-e7f8269d95bb/disk" snapshot="no"/> </disks> </domainsnapshot> $ qemu-img info volume-931536e0-65a7-4bd9-85ed-48bdd0160642.f6e62e4c-17b9-49bd-8941-10e8d11a22ca image: volume-931536e0-65a7-4bd9-85ed-48bdd0160642.f6e62e4c-17b9-49bd-8941-10e8d11a22ca file format: qcow2 virtual size: 1.0G (1073741824 bytes) disk size: 193K cluster_size: 65536 backing file: volume-931536e0-65a7-4bd9-85ed-48bdd0160642 backing file format: raw
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Eric Harney