[PATCH 028/103] virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided

Peter Krempa pkrempa at redhat.com
Thu Oct 7 15:17:16 UTC 2021


For conversion of '-device' we'll try to avoid usage of arrays if
possible, so for now if the array coversion function is not provided the
convertor will error out.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virqemu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 3e9311e3c7..aef6006dd7 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -219,7 +219,13 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
             return -1;
         }

-        if (!arrayFunc || arrayFunc(key, value, buf, skipKey) < 0) {
+        if (!arrayFunc) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("JSON array -> commandline conversion function not provided"));
+            return -1;
+        }
+
+        if (arrayFunc(key, value, buf, skipKey) < 0) {
             /* fallback, treat the array as a non-bitmap, adding the key
              * for each member */
             for (i = 0; i < virJSONValueArraySize(value); i++) {
-- 
2.31.1




More information about the libvir-list mailing list