From 93cdb1cae2efdf2d7c2e7516c53cd252c35ac089 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Sat, 25 Sep 2021 09:04:55 +0200 Subject: [PATCH] virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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++) {