提交 ac6c579a 编写于 作者: P Peter Krempa

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

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 a4f10a68
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册