virStorageSourceParseBackingJSON: Move deflattening of json: URIs out of recursion

Originally virStorageSourceParseBackingJSON didn't recurse, but when
the 'raw' driver support was added we need to parse it's information
which contains nested 'file' object.

Since the deflattening helper recurses already there's no need to call
it again. Move it one level up to the entry point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-02-03 13:21:42 +01:00
parent 4a6bc568cd
commit aadb34be34

View File

@ -3600,15 +3600,11 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
virJSONValuePtr json, virJSONValuePtr json,
const char *jsonstr) const char *jsonstr)
{ {
g_autoptr(virJSONValue) deflattened = NULL;
virJSONValuePtr file; virJSONValuePtr file;
const char *drvname; const char *drvname;
size_t i; size_t i;
if (!(deflattened = virJSONValueObjectDeflatten(json))) if (!(file = virJSONValueObjectGetObject(json, "file"))) {
return -1;
if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("JSON backing volume definition '%s' lacks 'file' object"), _("JSON backing volume definition '%s' lacks 'file' object"),
jsonstr); jsonstr);
@ -3639,11 +3635,15 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr src,
const char *json) const char *json)
{ {
g_autoptr(virJSONValue) root = NULL; g_autoptr(virJSONValue) root = NULL;
g_autoptr(virJSONValue) deflattened = NULL;
if (!(root = virJSONValueFromString(json))) if (!(root = virJSONValueFromString(json)))
return -1; return -1;
return virStorageSourceParseBackingJSONInternal(src, root, json); if (!(deflattened = virJSONValueObjectDeflatten(root)))
return -1;
return virStorageSourceParseBackingJSONInternal(src, deflattened, json);
} }