]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: blockcopy: Explicitly assert 'reuse' for block devices
authorPeter Krempa <pkrempa@redhat.com>
Tue, 11 Jul 2017 06:23:38 +0000 (08:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Jul 2017 08:07:48 +0000 (10:07 +0200)
When copying to a block device, the block device will already exist. To
allow users using a block device without any preparation, they need to
use the block copy without VIR_DOMAIN_BLOCK_COPY_REUSE_EXT.

This means that if the target is an existing block device we don't need
to prepare it, but we can't reject it as being existing.

To avoid breaking this feature, explicitly assume that existing block
devices will be reused even without that flag explicitly specified,
while skipping attempts to create it.

qemuMonitorDriveMirror still needs to honor the flag as specified by the
user, since qemu overwrites the metadata otherwise.

src/qemu/qemu_driver.c

index eb02bb3633e091945613540ec9a7fcbb200848ed..3ab31764c52ac502c213296d1eec5a7f5fc86f92 100644 (file)
@@ -16811,6 +16811,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
                            disk->dst, mirror->path);
             goto endjob;
         }
+    } else {
+        /* if the target is a block device, assume that we are reusing it, so
+         * there are no attempts to create it */
+        reuse = true;
     }
 
     if (!mirror->format) {
@@ -16850,6 +16854,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
 
     /* Actually start the mirroring */
     qemuDomainObjEnterMonitor(driver, vm);
+    /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
+     * by the user regardless of how @reuse was modified */
     ret = qemuMonitorDriveMirror(priv->mon, device, mirror->path, format,
                                  bandwidth, granularity, buf_size, flags);
     virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0);