]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Add new fields for 'block-stream' command
authorPeter Krempa <pkrempa@redhat.com>
Wed, 15 Aug 2018 11:13:53 +0000 (13:13 +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 of the 'stream' 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 d3a144aabddf6410e54d07e485e86c1526bedb92..ce422141d4395077a9cd8c9ffccc940e42556955 100644 (file)
@@ -17092,8 +17092,8 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver,
         basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
                                              baseSource);
     if (!baseSource || basePath)
-        ret = qemuMonitorBlockStream(priv->mon, device, basePath, backingPath,
-                                     speed);
+        ret = qemuMonitorBlockStream(priv->mon, device, NULL, false, basePath,
+                                     NULL, backingPath, speed);
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         ret = -1;
 
index 731be2e5a66ed6999ecd57085b2d95fccc10ac94..e1ccb324b4d94f58088e99af7a92e1c13c047c8c 100644 (file)
@@ -3365,16 +3365,28 @@ qemuMonitorScreendump(qemuMonitorPtr mon,
 int
 qemuMonitorBlockStream(qemuMonitorPtr mon,
                        const char *device,
+                       const char *jobname,
+                       bool persistjob,
                        const char *base,
+                       const char *baseNode,
                        const char *backingName,
                        unsigned long long bandwidth)
 {
-    VIR_DEBUG("device=%s, base=%s, backingName=%s, bandwidth=%lluB",
-              device, NULLSTR(base), NULLSTR(backingName), bandwidth);
+    VIR_DEBUG("device=%s, jobname=%s, persistjob=%d, base=%s, baseNode=%s, "
+              "backingName=%s, bandwidth=%lluB",
+              device, NULLSTR(jobname), persistjob, NULLSTR(base),
+              NULLSTR(baseNode), NULLSTR(backingName), bandwidth);
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONBlockStream(mon, device, base, backingName, bandwidth);
+    if (base && baseNode) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("'base' and 'baseNode' can't be used together"));
+        return -1;
+    }
+
+    return qemuMonitorJSONBlockStream(mon, device, jobname, persistjob, base,
+                                      baseNode, backingName, bandwidth);
 }
 
 
index c41428b0480c0a1cb8e659df1d10d661db74e355..572a5f84cfe13588fc5f3f62f08d8e59cffcd2d9 100644 (file)
@@ -949,7 +949,10 @@ int qemuMonitorSendKey(qemuMonitorPtr mon,
 
 int qemuMonitorBlockStream(qemuMonitorPtr mon,
                            const char *device,
+                           const char *jobname,
+                           bool persistjob,
                            const char *base,
+                           const char *baseNode,
                            const char *backingName,
                            unsigned long long bandwidth)
     ATTRIBUTE_NONNULL(2);
index 8723ff49c7786fa52cc5768da62cc2f14d9fce2b..e946c0aeb16e7ce8a843460a4b5010bde44e732a 100644 (file)
@@ -4907,19 +4907,33 @@ qemuMonitorJSONBlockJobError(virJSONValuePtr cmd,
 int
 qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
                            const char *device,
+                           const char *jobname,
+                           bool persistjob,
                            const char *base,
+                           const char *baseNode,
                            const char *backingName,
                            unsigned long long speed)
 {
     int ret = -1;
     virJSONValuePtr cmd = NULL;
     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;
+    }
 
     if (!(cmd = qemuMonitorJSONMakeCommand("block-stream",
                                            "s:device", device,
+                                           "S:job-id", jobname,
                                            "Y:speed", speed,
                                            "S:base", base,
+                                           "S:base-node", baseNode,
                                            "S:backing-file", backingName,
+                                           "T:auto-finalize", autofinalize,
+                                           "T:auto-dismiss", autodismiss,
                                            NULL)))
         return -1;
 
index d0b519c88ecb943a17da3963666ca478833921a9..72255eefbb3f698fc5a9e4128681a8deb5aa5dee 100644 (file)
@@ -302,7 +302,10 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
 
 int qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
                                const char *device,
+                               const char *jobname,
+                               bool persistjob,
                                const char *base,
+                               const char *baseNode,
                                const char *backingName,
                                unsigned long long speed)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
index 2ed9133c06dc664b28e9f01994d01ae6a7a764b6..b60df6f35b3aff772299d4fd674ca960eeb9cd48 100644 (file)
@@ -1326,7 +1326,7 @@ 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(qemuMonitorJSONBlockStream, "vdb", "/foo/bar1", "backingfilename", 1024)
+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(qemuMonitorJSONDrivePivot, "vdb")
 GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, "/foo/bar")