[PATCH 06/17] qemu: monitor: Add support for 'write-blocking' copy mode for blockdev-mirror

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c       |  3 ++-
 src/qemu/qemu_migration.c    |  3 ++-
 src/qemu/qemu_monitor.c      | 10 ++++++----
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c |  8 +++++++-
 src/qemu/qemu_monitor_json.h |  3 ++-
 tests/qemumonitorjsontest.c  |  2 +-
 7 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6333d0af36..4cc1d20b89 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15150,7 +15150,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 */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f2ea73c923..00c33c869e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 26b59801b8..072739f5da 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3059,17 +3059,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);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 99ecebc648..b58c637baf 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -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)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7cb6795a58..64739762b0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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);
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index f7fb13f56c..0dec49ec28 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -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)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 4c882fa5d3..1ad2912b08 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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")
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux