[PATCH RFC 39/51] qemu: monitor: Add new fields for 'block-commit' command

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

 



Allow using the node name to specify the base and top of the 'commit'
operation, allow specifying explicit job name and add support for
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_driver.c       |  4 ++--
 src/qemu/qemu_monitor.c      | 21 +++++++++++++++------
 src/qemu/qemu_monitor.h      |  6 +++++-
 src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++--
 src/qemu/qemu_monitor_json.h |  4 ++++
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 133bfcfbf3..f62d153c03 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18226,8 +18226,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
     topPath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
                                         topSource);
     if (basePath && topPath)
-        ret = qemuMonitorBlockCommit(priv->mon, device,
-                                     topPath, basePath, backingPath,
+        ret = qemuMonitorBlockCommit(priv->mon, device, NULL, false,
+                                     topPath, NULL, basePath, NULL, backingPath,
                                      speed);
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         ret = -1;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index d6cad63863..fe8d8d1bf7 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3280,18 +3280,27 @@ qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)

 /* Start a block-commit block job.  bandwidth is in bytes/sec.  */
 int
-qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device,
-                       const char *top, const char *base,
+qemuMonitorBlockCommit(qemuMonitorPtr mon,
+                       const char *device,
+                       const char *jobname,
+                       bool persistjob,
+                       const char *top,
+                       const char *topNode,
+                       const char *base,
+                       const char *baseNode,
                        const char *backingName,
                        unsigned long long bandwidth)
 {
-    VIR_DEBUG("device=%s, top=%s, base=%s, backingName=%s, bandwidth=%llu",
-              device, top, base, NULLSTR(backingName), bandwidth);
+    VIR_DEBUG("device=%s, jobname=%s, persistjob=%d, top=%s, topNode=%s, "
+              "base=%s, baseNode=%s, backingName=%s, bandwidth=%llu",
+              device, NULLSTR(jobname), persistjob, NULLSTR(top), NULLSTR(topNode),
+              NULLSTR(base), NULLSTR(baseNode), NULLSTR(backingName), bandwidth);

     QEMU_CHECK_MONITOR(mon);

-    return qemuMonitorJSONBlockCommit(mon, device, top, base,
-                                         backingName, bandwidth);
+    return qemuMonitorJSONBlockCommit(mon, device, jobname, persistjob, top,
+                                      topNode, base, baseNode, backingName,
+                                      bandwidth);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index bbdf88ae60..9cbd442f6c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -877,11 +877,15 @@ int qemuMonitorDrivePivot(qemuMonitorPtr mon,

 int qemuMonitorBlockCommit(qemuMonitorPtr mon,
                            const char *device,
+                           const char *jobname,
+                           bool persistjob,
                            const char *top,
+                           const char *topNode,
                            const char *base,
+                           const char *baseNode,
                            const char *backingName,
                            unsigned long long bandwidth)
-    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(2);
 bool qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon);
 char *qemuMonitorDiskNameLookup(qemuMonitorPtr mon,
                                 const char *device,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index fe16a3d13c..03e14ad79c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4401,21 +4401,39 @@ qemuMonitorJSONSupportsActiveCommit(qemuMonitorPtr mon)
 /* speed is in bytes/sec. Returns 0 on success, -1 with error message
  * emitted on failure. */
 int
-qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const char *device,
-                           const char *top, const char *base,
+qemuMonitorJSONBlockCommit(qemuMonitorPtr mon,
+                           const char *device,
+                           const char *jobname,
+                           bool persistjob,
+                           const char *top,
+                           const char *topNode,
+                           const char *base,
+                           const char *baseNode,
                            const char *backingName,
                            unsigned long long speed)
 {
     int ret = -1;
     virJSONValuePtr cmd;
     virJSONValuePtr 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("block-commit",
                                      "s:device", device,
+                                     "S:job-id", jobname,
                                      "Y:speed", speed,
                                      "S:top", top,
+                                     "S:top-node", topNode,
                                      "S:base", base,
+                                     "S:base-node", baseNode,
                                      "S:backing-file", backingName,
+                                     "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 7420a4aec0..339c569684 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -275,8 +275,12 @@ bool qemuMonitorJSONSupportsActiveCommit(qemuMonitorPtr mon)

 int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon,
                                const char *device,
+                               const char *jobname,
+                               bool persistjob,
                                const char *top,
+                               const char *topNode,
                                const char *base,
+                               const char *baseNode,
                                const char *backingName,
                                unsigned long long bandwidth)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 49982084af..940edcfb01 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1348,7 +1348,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024,
 GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode", 1024, 1234, 31234,
               VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
 GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024)
-GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2", "backingfilename", 1024)
+GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/bar1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024)
 GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb")
 GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, "/foo/bar")
 GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false)
-- 
2.19.2

--
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