qemu: monitor: Add new fields for 'block-stream' command

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>
This commit is contained in:
Peter Krempa 2018-08-15 13:13:53 +02:00
parent f0430d069a
commit a4f10a6821
6 changed files with 38 additions and 6 deletions

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

View 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);
}

View 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);

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

View 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);

View 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")