mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-21 05:29:18 +00:00
qemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockJobError
Report the generic errors using the existing function so that we don't reimplement the same functionality multiple times. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
f3b7607f6a
commit
0ab2a65314
@ -4793,29 +4793,20 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMonitorJSONBlockJobError(virJSONValuePtr reply,
|
qemuMonitorJSONBlockJobError(virJSONValuePtr cmd,
|
||||||
const char *cmd_name,
|
virJSONValuePtr reply,
|
||||||
const char *device)
|
const char *device)
|
||||||
{
|
{
|
||||||
virJSONValuePtr error;
|
virJSONValuePtr error;
|
||||||
|
|
||||||
if (!(error = virJSONValueObjectGet(reply, "error")))
|
if ((error = virJSONValueObjectGet(reply, "error")) &&
|
||||||
return 0;
|
(qemuMonitorJSONErrorIsClass(error, "DeviceNotActive"))) {
|
||||||
|
|
||||||
if (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive")) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("No active operation on device: %s"), device);
|
_("No active operation on device: %s"), device);
|
||||||
} else if (qemuMonitorJSONErrorIsClass(error, "CommandNotFound")) {
|
return -1;
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("Command '%s' is not found"), cmd_name);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unexpected error: (%s) '%s'"),
|
|
||||||
NULLSTR(virJSONValueObjectGetString(error, "class")),
|
|
||||||
NULLSTR(virJSONValueObjectGetString(error, "desc")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return qemuMonitorJSONCheckError(cmd, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4843,7 +4834,7 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
|
|||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0)
|
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -4872,7 +4863,7 @@ qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon,
|
|||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0)
|
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -4903,7 +4894,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
|
|||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0)
|
if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user