]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainBlockCopy: Implement VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES
authorPeter Krempa <pkrempa@redhat.com>
Wed, 1 Dec 2021 14:15:34 +0000 (15:15 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 08:00:39 +0000 (09:00 +0100)
Wire up the flag to enable the 'write-blocking' 'copy-mode' of
'blockdev-mirror'.

It's not supported by all qemu versions but it is with those which we
use -blockdev with so we can use that instead of adding another custom
capability as we use blockdev for some time now.

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

index 1a24fe8f2721d63db9ca4a5922ddbacef22ef318..8093b8f69bf39eacc90b49f3858b4db6f36111b5 100644 (file)
@@ -14901,12 +14901,14 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
     virStorageSource *n;
     virStorageSource *mirrorBacking = NULL;
     g_autoptr(GHashTable) blockNamedNodeData = NULL;
+    bool syncWrites = !!(flags & VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES);
     int rc = 0;
 
     /* Preliminaries: find the disk we are editing, sanity checks */
     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
                   VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
-                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB |
+                  VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES, -1);
 
     if (virStorageSourceIsRelative(mirror)) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -14944,6 +14946,12 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
         virDomainDiskDefSourceLUNValidate(mirror) < 0)
         goto endjob;
 
+    if (syncWrites && !blockdev) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES is not supported by this VM"));
+        goto endjob;
+    }
+
     if (!(flags & VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB) &&
         vm->persistent) {
         /* XXX if qemu ever lets us start a new domain with mirroring
@@ -15150,7 +15158,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
                                         qemuDomainDiskGetTopNodename(disk),
                                         mirror->nodeformat, bandwidth,
                                         granularity, buf_size, mirror_shallow,
-                                        false);
+                                        syncWrites);
     } else {
         /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
          * by the user */
@@ -15285,7 +15293,9 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
 
     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
                   VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
-                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB |
+                  VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES, -1);
+
     if (virTypedParamsValidate(params, nparams,
                                VIR_DOMAIN_BLOCK_COPY_BANDWIDTH,
                                VIR_TYPED_PARAM_ULLONG,