提交 6d7cdec6 编写于 作者: P Peter Krempa

util: storage: Always deflatten JSON pseudo-protocol objects

Now that the JSON deflattener is working sanely we can always attempt
the deflattening so that we can then parse the tree as expected.
上级 428d1752
...@@ -3249,24 +3249,22 @@ static int ...@@ -3249,24 +3249,22 @@ static int
virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
virJSONValuePtr json) virJSONValuePtr json)
{ {
virJSONValuePtr fixedroot = NULL; virJSONValuePtr deflattened = NULL;
virJSONValuePtr file; virJSONValuePtr file;
const char *drvname; const char *drvname;
char *str = NULL; char *str = NULL;
size_t i; size_t i;
int ret = -1; int ret = -1;
if (!(file = virJSONValueObjectGetObject(json, "file"))) { if (!(deflattened = virJSONValueObjectDeflatten(json)))
if (!(fixedroot = virJSONValueObjectDeflatten(json))) goto cleanup;
goto cleanup;
if (!(file = virJSONValueObjectGetObject(fixedroot, "file"))) { if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
str = virJSONValueToString(json, false); str = virJSONValueToString(json, false);
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("JSON backing volume defintion '%s' lacks 'file' object"), _("JSON backing volume defintion '%s' lacks 'file' object"),
NULLSTR(str)); NULLSTR(str));
goto cleanup; goto cleanup;
}
} }
if (!(drvname = virJSONValueObjectGetString(file, "driver"))) { if (!(drvname = virJSONValueObjectGetString(file, "driver"))) {
...@@ -3290,7 +3288,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, ...@@ -3290,7 +3288,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
cleanup: cleanup:
VIR_FREE(str); VIR_FREE(str);
virJSONValueFree(fixedroot); virJSONValueFree(deflattened);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册