[libvirt] [PATCH] qemu: snapshot: Don't mark all block disks for metadata reuse

For block devices used as snapshot source the new snapshot code would set the reuse flag. This inhibits to take snapshot without specially preparing the block image before taking the snapshot. Fortunately this is not a regression as only the new way of specifying snapshot source is affected. For the followin snapshot XML: <domainsnapshot> <disks> <disk name='vda' type='block'> <driver type='qcow2'/> <source dev="/dev/andariel/testsnap" /> </disk> </disks> </domainsnapshot> You'd get: error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format After this patch the snapshot is created successfully. --- src/qemu/qemu_driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7bf2020..7ac7aa2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12885,13 +12885,11 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, switch ((virStorageType)snap->src->type) { case VIR_STORAGE_TYPE_BLOCK: - reuse = true; - /* fallthrough */ case VIR_STORAGE_TYPE_FILE: /* create the stub file and set selinux labels; manipulate disk in * place, in a way that can be reverted on failure. */ - if (!reuse) { + if (!reuse && snap->src->type != VIR_STORAGE_TYPE_BLOCK) { fd = qemuOpenFile(driver, vm, source, O_WRONLY | O_TRUNC | O_CREAT, &need_unlink, NULL); if (fd < 0) -- 1.9.3

On 06/16/2014 06:29 AM, Peter Krempa wrote:
For block devices used as snapshot source the new snapshot code would set the reuse flag. This inhibits to take snapshot without specially preparing the block image before taking the snapshot.
Fortunately this is not a regression as only the new way of specifying snapshot source is affected.
For the followin snapshot XML: <domainsnapshot> <disks> <disk name='vda' type='block'> <driver type='qcow2'/> <source dev="/dev/andariel/testsnap" /> </disk> </disks> </domainsnapshot>
You'd get: error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format
After this patch the snapshot is created successfully. --- src/qemu/qemu_driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 06/16/14 16:00, Eric Blake wrote:
On 06/16/2014 06:29 AM, Peter Krempa wrote:
For block devices used as snapshot source the new snapshot code would set the reuse flag. This inhibits to take snapshot without specially preparing the block image before taking the snapshot.
Fortunately this is not a regression as only the new way of specifying snapshot source is affected.
For the followin snapshot XML: <domainsnapshot> <disks> <disk name='vda' type='block'> <driver type='qcow2'/> <source dev="/dev/andariel/testsnap" /> </disk> </disks> </domainsnapshot>
You'd get: error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format
After this patch the snapshot is created successfully. --- src/qemu/qemu_driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
ACK.
Pushed; Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa