[PATCH 13/22] qemuMonitorJSONSetBlockIoThrottle: Switch to standard error reporting

Peter Krempa pkrempa at redhat.com
Thu Aug 12 14:49:06 UTC 2021


Use qemuMonitorJSONCheckError instead of handcrafted error reporting.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 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.31.1




More information about the libvir-list mailing list