[PATCH 05/16] qemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types

Peter Krempa pkrempa at redhat.com
Thu Nov 18 16:33:30 UTC 2021


Use 'virReportEnumRangeError' for the invalid cases and keep the
original error for known but unsupported chardevs.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b036cc4112..1ced942161 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6737,16 +6737,14 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
     case VIR_DOMAIN_CHR_TYPE_PIPE:
     case VIR_DOMAIN_CHR_TYPE_STDIO:
     case VIR_DOMAIN_CHR_TYPE_NMDM:
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("Hotplug unsupported for char device type '%s'"),
+                       virDomainChrTypeToString(chr->type));
+        return NULL;
+
     case VIR_DOMAIN_CHR_TYPE_LAST:
-        if (virDomainChrTypeToString(chr->type)) {
-            virReportError(VIR_ERR_OPERATION_FAILED,
-                           _("Hotplug unsupported for char device type '%s'"),
-                           virDomainChrTypeToString(chr->type));
-        } else {
-            virReportError(VIR_ERR_OPERATION_FAILED,
-                           _("Hotplug unsupported for char device type '%d'"),
-                           chr->type);
-        }
+    default:
+        virReportEnumRangeError(virDomainChrType, chr->type);
         return NULL;
     }

-- 
2.31.1




More information about the libvir-list mailing list