From 059103869edc7dd0b86b08dc9468272fbdd31dc6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 10 Aug 2021 15:14:08 +0200 Subject: [PATCH] qemuMonitorJSONSetBlockIoThrottle: Switch to standard error reporting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use qemuMonitorJSONCheckError instead of handcrafted error reporting. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor_json.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) 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; } -- 2.47.2