]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move shareable disk check for block copy
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Jan 2019 16:24:56 +0000 (17:24 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 7 Feb 2019 13:32:32 +0000 (14:32 +0100)
The writing to an image actually starts when the copy job is initiated,
so checking this at the time of the pivot operation is too late.

Move the check to qemuDomainBlockCopyCommon. Note that modern qemu would
have prevented two writers with qcow2 so the slim possibility of a job
started with libvirtd without this patch missing the check is not really
worth worrying about.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index daaf86ad6d4527e832a7ccb8a7103793d8a57167..4980f9f0ef6a4e5f695fa02963e5cc1a997c60c1 100644 (file)
@@ -17142,16 +17142,6 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    /* When pivoting to a shareable disk we need to make sure that the disk can
-     * be safely shared, since block copy might have changed the format. */
-    if (disk->src->shared && !disk->src->readonly &&
-        !qemuBlockStorageSourceSupportsConcurrentAccess(disk->mirror)) {
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                       _("can't pivot a shared disk to a storage volume not "
-                         "supporting sharing"));
-        goto cleanup;
-    }
-
     /* Attempt the pivot.  Record the attempt now, to prevent duplicate
      * attempts; but the actual disk change will be made when emitting
      * the event.
@@ -17782,6 +17772,16 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
         }
     }
 
+    /* When copying a shareable disk we need to make sure that the disk can
+     * be safely shared, since block copy may change the format. */
+    if (disk->src->shared && !disk->src->readonly &&
+        !qemuBlockStorageSourceSupportsConcurrentAccess(mirror)) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("can't pivot a shared disk to a storage volume not "
+                         "supporting sharing"));
+        goto endjob;
+    }
+
     /* pre-create the image file */
     if (!reuse) {
         if (virStorageFileCreate(mirror) < 0) {