virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided

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>
This commit is contained in:
Peter Krempa 2021-09-25 09:04:55 +02:00
parent 5204578993
commit 93cdb1cae2

View 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++) {