]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Add new fields for 'block-commit' command
authorPeter Krempa <pkrempa@redhat.com>
Thu, 16 Aug 2018 16:20:25 +0000 (18:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 18 Jul 2019 15:59:33 +0000 (17:59 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.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 ce422141d4395077a9cd8c9ffccc940e42556955..0c89f10489a24286a74759a800d026c295ee3056 100644 (file)
@@ -18058,8 +18058,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 < 0) {
         ret = -1;
index e1ccb324b4d94f58088e99af7a92e1c13c047c8c..3862a00d7b3a375fab137b95877c0e09dfccb569 100644 (file)
@@ -3257,18 +3257,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);
 }
 
 
index 572a5f84cfe13588fc5f3f62f08d8e59cffcd2d9..53b5777a84f98d7df5a941a2c012ba3be654292e 100644 (file)
@@ -918,11 +918,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,
index e946c0aeb16e7ce8a843460a4b5010bde44e732a..4edf4f8dbc5d981f0387404708a6c035edafc7e2 100644 (file)
@@ -4507,21 +4507,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;
index 72255eefbb3f698fc5a9e4128681a8deb5aa5dee..2e242a49230b2726116b063a955916de98663597 100644 (file)
@@ -270,8 +270,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);
index b60df6f35b3aff772299d4fd674ca960eeb9cd48..f77f4da9a3c9a5a509703b56d678b362bf498dd2 100644 (file)
@@ -1327,7 +1327,7 @@ 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(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)