qemu: monitor: Rename 'device' argument for block job control APIs

Starting from qemu 2.7 the 'device' argument is in fact a name of the
job itself. Change our APIs accordingly and adjust the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Peter Krempa 2018-08-14 13:11:05 +02:00
parent 29dd778d16
commit ee06cd36e3
4 changed files with 26 additions and 26 deletions

View File

@ -3323,13 +3323,13 @@ qemuMonitorDiskNameLookup(qemuMonitorPtr mon,
/* Use the block-job-complete monitor command to pivot a block copy job. */ /* Use the block-job-complete monitor command to pivot a block copy job. */
int int
qemuMonitorDrivePivot(qemuMonitorPtr mon, qemuMonitorDrivePivot(qemuMonitorPtr mon,
const char *device) const char *jobname)
{ {
VIR_DEBUG("device=%s", device); VIR_DEBUG("jobname=%s", jobname);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONDrivePivot(mon, device); return qemuMonitorJSONDrivePivot(mon, jobname);
} }
@ -3403,26 +3403,26 @@ qemuMonitorBlockStream(qemuMonitorPtr mon,
int int
qemuMonitorBlockJobCancel(qemuMonitorPtr mon, qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
const char *device) const char *jobname)
{ {
VIR_DEBUG("device=%s", device); VIR_DEBUG("jobname=%s", jobname);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONBlockJobCancel(mon, device); return qemuMonitorJSONBlockJobCancel(mon, jobname);
} }
int int
qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon, qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
const char *device, const char *jobname,
unsigned long long bandwidth) unsigned long long bandwidth)
{ {
VIR_DEBUG("device=%s, bandwidth=%lluB", device, bandwidth); VIR_DEBUG("jobname=%s, bandwidth=%lluB", jobname, bandwidth);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONBlockJobSetSpeed(mon, device, bandwidth); return qemuMonitorJSONBlockJobSetSpeed(mon, jobname, bandwidth);
} }

View File

@ -872,7 +872,7 @@ int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
unsigned int flags) unsigned int flags)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
int qemuMonitorDrivePivot(qemuMonitorPtr mon, int qemuMonitorDrivePivot(qemuMonitorPtr mon,
const char *device) const char *jobname)
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);
int qemuMonitorBlockCommit(qemuMonitorPtr mon, int qemuMonitorBlockCommit(qemuMonitorPtr mon,
@ -914,11 +914,11 @@ int qemuMonitorBlockStream(qemuMonitorPtr mon,
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);
int qemuMonitorBlockJobCancel(qemuMonitorPtr mon, int qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
const char *device) const char *jobname)
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);
int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon, int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
const char *device, const char *jobname,
unsigned long long bandwidth); unsigned long long bandwidth);
typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo; typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo;

View File

@ -4768,14 +4768,14 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
static int static int
qemuMonitorJSONBlockJobError(virJSONValuePtr cmd, qemuMonitorJSONBlockJobError(virJSONValuePtr cmd,
virJSONValuePtr reply, virJSONValuePtr reply,
const char *device) const char *jobname)
{ {
virJSONValuePtr error; virJSONValuePtr error;
if ((error = virJSONValueObjectGet(reply, "error")) && if ((error = virJSONValueObjectGet(reply, "error")) &&
(qemuMonitorJSONErrorIsClass(error, "DeviceNotActive"))) { (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive"))) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("No active operation on device: %s"), device); _("No active block job '%s'"), jobname);
return -1; return -1;
} }
@ -4820,21 +4820,21 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
int int
qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon,
const char *device) const char *jobname)
{ {
int ret = -1; int ret = -1;
virJSONValuePtr cmd = NULL; virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("block-job-cancel", if (!(cmd = qemuMonitorJSONMakeCommand("block-job-cancel",
"s:device", device, "s:device", jobname,
NULL))) NULL)))
return -1; return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
@ -4848,7 +4848,7 @@ qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon,
int int
qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
const char *device, const char *jobname,
unsigned long long speed) unsigned long long speed)
{ {
int ret = -1; int ret = -1;
@ -4856,7 +4856,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("block-job-set-speed", if (!(cmd = qemuMonitorJSONMakeCommand("block-job-set-speed",
"s:device", device, "s:device", jobname,
"J:speed", speed, "J:speed", speed,
NULL))) NULL)))
return -1; return -1;
@ -4864,7 +4864,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
@ -4878,14 +4878,14 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
int int
qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
const char *device) const char *jobname)
{ {
int ret = -1; int ret = -1;
virJSONValuePtr cmd; virJSONValuePtr cmd;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
cmd = qemuMonitorJSONMakeCommand("block-job-complete", cmd = qemuMonitorJSONMakeCommand("block-job-complete",
"s:device", device, "s:device", jobname,
NULL); NULL);
if (!cmd) if (!cmd)
return -1; return -1;
@ -4893,7 +4893,7 @@ qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;

View File

@ -267,7 +267,7 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
unsigned int flags) unsigned int flags)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
const char *device) const char *jobname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon,
@ -310,11 +310,11 @@ int qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon,
const char *device) const char *jobname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
const char *device, const char *jobname,
unsigned long long speed) unsigned long long speed)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);