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

Peter Krempa posted 103 patches 4 years, 4 months ago
Only 102 patches received!
[PATCH 028/103] virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided
Posted by Peter Krempa 4 years, 4 months ago
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>
---
 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

Re: [PATCH 028/103] virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided
Posted by Ján Tomko 4 years, 4 months ago
On a Thursday in 2021, Peter Krempa wrote:
>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>
>---
> src/util/virqemu.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano