qemu: monitor: Add new fields for 'blockdev-mirror' command

Allow using the 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-16 18:47:20 +02:00
parent ac6c579af3
commit e53adccebd
6 changed files with 21 additions and 8 deletions

View File

@ -840,7 +840,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
mon_ret = qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm), data); mon_ret = qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm), data);
if (mon_ret == 0) if (mon_ret == 0)
mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NULL, mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NULL, false,
diskAlias, copysrc->nodeformat, diskAlias, copysrc->nodeformat,
mirror_speed, 0, 0, mirror_shallow); mirror_speed, 0, 0, mirror_shallow);

View File

@ -3224,6 +3224,7 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon,
int int
qemuMonitorBlockdevMirror(qemuMonitorPtr mon, qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
const char *jobname, const char *jobname,
bool persistjob,
const char *device, const char *device,
const char *target, const char *target,
unsigned long long bandwidth, unsigned long long bandwidth,
@ -3231,15 +3232,15 @@ qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
unsigned long long buf_size, unsigned long long buf_size,
bool shallow) bool shallow)
{ {
VIR_DEBUG("jobname=%s, device=%s, target=%s, bandwidth=%lld, " VIR_DEBUG("jobname=%s, persistjob=%d, device=%s, target=%s, bandwidth=%lld, "
"granularity=%#x, buf_size=%lld, shallow=%d", "granularity=%#x, buf_size=%lld, shallow=%d",
NULLSTR(jobname), device, target, bandwidth, granularity, NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
buf_size, shallow); buf_size, shallow);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, bandwidth, return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
granularity, buf_size, shallow); bandwidth, granularity, buf_size, shallow);
} }

View File

@ -905,13 +905,14 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon,
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
const char *jobname, const char *jobname,
bool persistjob,
const char *device, const char *device,
const char *target, const char *target,
unsigned long long bandwidth, unsigned long long bandwidth,
unsigned int granularity, unsigned int granularity,
unsigned long long buf_size, unsigned long long buf_size,
bool shallow) bool shallow)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
int qemuMonitorDrivePivot(qemuMonitorPtr mon, int qemuMonitorDrivePivot(qemuMonitorPtr mon,
const char *jobname) const char *jobname)
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);

View File

@ -4415,6 +4415,7 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
int int
qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
const char *jobname, const char *jobname,
bool persistjob,
const char *device, const char *device,
const char *target, const char *target,
unsigned long long speed, unsigned long long speed,
@ -4424,6 +4425,13 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
{ {
VIR_AUTOPTR(virJSONValue) cmd = NULL; VIR_AUTOPTR(virJSONValue) cmd = NULL;
VIR_AUTOPTR(virJSONValue) reply = NULL; VIR_AUTOPTR(virJSONValue) 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("blockdev-mirror", cmd = qemuMonitorJSONMakeCommand("blockdev-mirror",
"S:job-id", jobname, "S:job-id", jobname,
@ -4433,6 +4441,8 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
"z:granularity", granularity, "z:granularity", granularity,
"P:buf-size", buf_size, "P:buf-size", buf_size,
"s:sync", shallow ? "top" : "full", "s:sync", shallow ? "top" : "full",
"T:auto-finalize", autofinalize,
"T:auto-dismiss", autodismiss,
NULL); NULL);
if (!cmd) if (!cmd)
return -1; return -1;

View File

@ -254,13 +254,14 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
const char *jobname, const char *jobname,
bool persistjob,
const char *device, const char *device,
const char *target, const char *target,
unsigned long long speed, unsigned long long speed,
unsigned int granularity, unsigned int granularity,
unsigned long long buf_size, unsigned long long buf_size,
bool shallow) bool shallow)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
const char *jobname) const char *jobname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

View File

@ -1325,7 +1325,7 @@ GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr") GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true) 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(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true)
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024)
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/bar1", "topnode", "/foo/bar2", "basenode", "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(qemuMonitorJSONDrivePivot, "vdb")