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(a)redhat.com>
---
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 ec08dd939e..f6178ddd0b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17080,8 +17080,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 731be2e5a6..e1ccb324b4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -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);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c41428b048..572a5f84cf 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -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);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8723ff49c7..e946c0aeb1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d0b519c88e..72255eefbb 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -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);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 2ed9133c06..b60df6f35b 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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")
--
2.21.0