]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Add support for 'write-blocking' copy mode for blockdev-mirror
authorPeter Krempa <pkrempa@redhat.com>
Tue, 30 Nov 2021 19:22:46 +0000 (20:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 08:00:39 +0000 (09:00 +0100)
Forces the data to be written synchronously to both the original and the
mirrored images which ensures that the job will reach synchronized
phase.

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

index 13e33a22892868b7feddfaba1f8243ae53a3368b..1a24fe8f2721d63db9ca4a5922ddbacef22ef318 100644 (file)
@@ -15149,7 +15149,8 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
         ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
                                         qemuDomainDiskGetTopNodename(disk),
                                         mirror->nodeformat, bandwidth,
-                                        granularity, buf_size, mirror_shallow);
+                                        granularity, buf_size, mirror_shallow,
+                                        false);
     } else {
         /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
          * by the user */
index f2ea73c92326c6446dfed769805d12c6f604d74e..00c33c869e6478c3da6830aa7bd5770e32e077a3 100644 (file)
@@ -959,7 +959,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriver *driver,
     if (mon_ret == 0)
         mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), jobname, persistjob,
                                             sourcename, copysrc->nodeformat,
-                                            mirror_speed, 0, 0, mirror_shallow);
+                                            mirror_speed, 0, 0, mirror_shallow,
+                                            false);
 
     if (mon_ret != 0)
         qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data);
index 6beb23e9f7f13dd251458c3fad0e5deb8895f214..75e0e4ed92334500ae3176811beea73d9de47bb2 100644 (file)
@@ -3058,17 +3058,19 @@ qemuMonitorBlockdevMirror(qemuMonitor *mon,
                           unsigned long long bandwidth,
                           unsigned int granularity,
                           unsigned long long buf_size,
-                          bool shallow)
+                          bool shallow,
+                          bool syncWrite)
 {
     VIR_DEBUG("jobname=%s, persistjob=%d, device=%s, target=%s, bandwidth=%lld, "
-              "granularity=%#x, buf_size=%lld, shallow=%d",
+              "granularity=%#x, buf_size=%lld, shallow=%d syncWrite=%d",
               NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
-              buf_size, shallow);
+              buf_size, shallow, syncWrite);
 
     QEMU_CHECK_MONITOR(mon);
 
     return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
-                                         bandwidth, granularity, buf_size, shallow);
+                                         bandwidth, granularity, buf_size, shallow,
+                                         syncWrite);
 }
 
 
index 8b0c8a99ab6aafe115f47e7877613406219f966d..edc2b01a66c9934bad6d9aa6a3712d2c493b1bb0 100644 (file)
@@ -1079,7 +1079,8 @@ int qemuMonitorBlockdevMirror(qemuMonitor *mon,
                               unsigned long long bandwidth,
                               unsigned int granularity,
                               unsigned long long buf_size,
-                              bool shallow)
+                              bool shallow,
+                              bool syncWrite)
     ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
 int qemuMonitorDrivePivot(qemuMonitor *mon,
                           const char *jobname)
index 4896f0b3175d38f0ac67a8f976bed47634525d52..e00d785c206f7e0d9422eec32be341e6b7481d65 100644 (file)
@@ -4305,17 +4305,22 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                               unsigned long long speed,
                               unsigned int granularity,
                               unsigned long long buf_size,
-                              bool shallow)
+                              bool shallow,
+                              bool syncWrite)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
     virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT;
     const char *syncmode = "full";
+    const char *copymode = NULL;
 
     if (shallow)
         syncmode = "top";
 
+    if (syncWrite)
+        copymode = "write-blocking";
+
     if (persistjob) {
         autofinalize = VIR_TRISTATE_BOOL_YES;
         autodismiss = VIR_TRISTATE_BOOL_NO;
@@ -4329,6 +4334,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                                      "z:granularity", granularity,
                                      "P:buf-size", buf_size,
                                      "s:sync", syncmode,
+                                     "S:copy-mode", copymode,
                                      "T:auto-finalize", autofinalize,
                                      "T:auto-dismiss", autodismiss,
                                      NULL);
index 3b88ae73638a2181fc4053e03f6c025c33e846fe..0984717675cc8a309345a6e163daafb6ef495551 100644 (file)
@@ -266,7 +266,8 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                                   unsigned long long speed,
                                   unsigned int granularity,
                                   unsigned long long buf_size,
-                                  bool shallow)
+                                  bool shallow,
+                                  bool syncWrite)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
 int qemuMonitorJSONDrivePivot(qemuMonitor *mon,
                               const char *jobname)
index 4c882fa5d3c732a5acb21f29613becdfd86e0bb7..1ad2912b0825db44ac6ba1bd5af1cfc350c668f7 100644 (file)
@@ -1175,7 +1175,7 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
 GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
 GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
 GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true)
-GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true)
+GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true, true)
 GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024)
 GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/bar1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024)
 GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb")