From: Peter Krempa Date: Tue, 10 Aug 2021 13:14:08 +0000 (+0200) Subject: qemuMonitorJSONSetBlockIoThrottle: Switch to standard error reporting X-Git-Tag: v7.7.0-rc1~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=059103869edc7dd0b86b08dc9468272fbdd31dc6;p=thirdparty%2Flibvirt.git qemuMonitorJSONSetBlockIoThrottle: Switch to standard error reporting Use qemuMonitorJSONCheckError instead of handcrafted error reporting. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9931313baa..7727d1e7fb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5431,10 +5431,6 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) result = NULL; g_autoptr(virJSONValue) args = NULL; - const char *errdev = drivealias; - - if (!errdev) - errdev = qomid; if (!(cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle", NULL))) return -1; @@ -5492,22 +5488,8 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &result) < 0) return -1; - if (virJSONValueObjectHasKey(result, "error")) { - if (qemuMonitorJSONHasError(result, "DeviceNotActive")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("No active operation on device: %s"), errdev); - } else if (qemuMonitorJSONHasError(result, "NotSupported")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("Operation is not supported for device: %s"), errdev); - } else { - virJSONValue *error = virJSONValueObjectGet(result, "error"); - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to execute '%s', unexpected error: '%s'"), - qemuMonitorJSONCommandName(cmd), - qemuMonitorJSONStringifyError(error)); - } + if (qemuMonitorJSONCheckError(cmd, result) < 0) return -1; - } return 0; }