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

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

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c       |  4 ++--
 src/qemu/qemu_monitor.c      | 18 +++++++++++++++---
 src/qemu/qemu_monitor.h      |  3 +++
 src/qemu/qemu_monitor_json.c | 14 ++++++++++++++
 src/qemu/qemu_monitor_json.h |  3 +++
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1b31132807..133bfcfbf3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17276,8 +17276,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;

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1d40aef127..d6cad63863 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3388,16 +3388,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);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 66bfdb0e5c..bbdf88ae60 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -908,7 +908,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);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index dfcc6d88b5..fe16a3d13c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4797,19 +4797,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;

diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index c3abd0ddf0..7420a4aec0 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -307,7 +307,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);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 5c77db337f..49982084af 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1347,7 +1347,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024,
               VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
 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", "/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")
-- 
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