]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not...
authorPeter Krempa <pkrempa@redhat.com>
Sat, 25 Sep 2021 07:04:55 +0000 (09:04 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 08:26:01 +0000 (10:26 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virqemu.c

index 3e9311e3c7583fbea51dfc15a28136480e02f2f8..aef6006dd7b46c73bb88b21aebad42d613a2ae8c 100644 (file)
@@ -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++) {