[PATCH 3/9] qemu: monitor: Add new fields for 'blockdev-mirror' command

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

 



Allow using the delayed dismiss of the job so that we can reap the state
even if libvirtd was not running when qemu emitted the job completion
event.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c    |  2 +-
 src/qemu/qemu_monitor.c      |  9 +++++----
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c | 10 ++++++++++
 src/qemu/qemu_monitor_json.h |  3 ++-
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2436f5051b..1fb88c11b6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -840,7 +840,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
     mon_ret = qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm), data);

     if (mon_ret == 0)
-        mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NULL,
+        mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NULL, false,
                                             diskAlias, copysrc->nodeformat,
                                             mirror_speed, 0, 0, mirror_shallow);

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3862a00d7b..1a7cfd291b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3224,6 +3224,7 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon,
 int
 qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
                           const char *jobname,
+                          bool persistjob,
                           const char *device,
                           const char *target,
                           unsigned long long bandwidth,
@@ -3231,15 +3232,15 @@ qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
                           unsigned long long buf_size,
                           bool shallow)
 {
-    VIR_DEBUG("jobname=%s, device=%s, target=%s, bandwidth=%lld, "
+    VIR_DEBUG("jobname=%s, persistjob=%d, device=%s, target=%s, bandwidth=%lld, "
               "granularity=%#x, buf_size=%lld, shallow=%d",
-              NULLSTR(jobname), device, target, bandwidth, granularity,
+              NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
               buf_size, shallow);

     QEMU_CHECK_MONITOR(mon);

-    return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, bandwidth,
-                                         granularity, buf_size, shallow);
+    return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
+                                         bandwidth, granularity, buf_size, shallow);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 53b5777a84..42d6e36b4d 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -905,13 +905,14 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon,
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
                               const char *jobname,
+                              bool persistjob,
                               const char *device,
                               const char *target,
                               unsigned long long bandwidth,
                               unsigned int granularity,
                               unsigned long long buf_size,
                               bool shallow)
-    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
 int qemuMonitorDrivePivot(qemuMonitorPtr mon,
                           const char *jobname)
     ATTRIBUTE_NONNULL(2);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 4edf4f8dbc..98846740e5 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4415,6 +4415,7 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
 int
 qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
                               const char *jobname,
+                              bool persistjob,
                               const char *device,
                               const char *target,
                               unsigned long long speed,
@@ -4424,6 +4425,13 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
 {
     VIR_AUTOPTR(virJSONValue) cmd = NULL;
     VIR_AUTOPTR(virJSONValue) reply = NULL;
+    virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
+    virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT;
+
+    if (persistjob) {
+        autofinalize = VIR_TRISTATE_BOOL_YES;
+        autodismiss = VIR_TRISTATE_BOOL_NO;
+    }

     cmd = qemuMonitorJSONMakeCommand("blockdev-mirror",
                                      "S:job-id", jobname,
@@ -4433,6 +4441,8 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
                                      "z:granularity", granularity,
                                      "P:buf-size", buf_size,
                                      "s:sync", shallow ? "top" : "full",
+                                     "T:auto-finalize", autofinalize,
+                                     "T:auto-dismiss", autodismiss,
                                      NULL);
     if (!cmd)
         return -1;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 2e242a4923..069f6dca62 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -254,13 +254,14 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
                                   const char *jobname,
+                                  bool persistjob,
                                   const char *device,
                                   const char *target,
                                   unsigned long long speed,
                                   unsigned int granularity,
                                   unsigned long long buf_size,
                                   bool shallow)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
 int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
                               const char *jobname)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index f77f4da9a3..07dd746850 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1325,7 +1325,7 @@ GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
 GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
 GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
 GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true)
-GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode", 1024, 1234, 31234, true)
+GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, 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.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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