libvirt/SOURCES/libvirt-virStorageSourceParseBackingJSON-Move-deflattening-of-json-URIs-out-of-recursion.patch

70 lines
2.5 KiB
Diff
Raw Normal View History

From dd5ec4a68ef2858ff8d98942d87b59fa09ab819f Mon Sep 17 00:00:00 2001
Message-Id: <dd5ec4a68ef2858ff8d98942d87b59fa09ab819f@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 19 Feb 2020 15:10:07 +0100
Subject: [PATCH] virStorageSourceParseBackingJSON: Move deflattening of json:
URIs out of recursion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
(cherry picked from commit aadb34be3428a5e467289709290b536ae6bf5d2a)
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
Message-Id: <be49eb68dbd29d1075713483472f32d5e995a263.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/virstoragefile.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 05f17224f4..c97a3a9d6e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3600,15 +3600,11 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
virJSONValuePtr json,
const char *jsonstr)
{
- g_autoptr(virJSONValue) deflattened = NULL;
virJSONValuePtr file;
const char *drvname;
size_t i;
- if (!(deflattened = virJSONValueObjectDeflatten(json)))
- return -1;
-
- if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
+ if (!(file = virJSONValueObjectGetObject(json, "file"))) {
virReportError(VIR_ERR_INVALID_ARG,
_("JSON backing volume definition '%s' lacks 'file' object"),
jsonstr);
@@ -3639,11 +3635,15 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr src,
const char *json)
{
g_autoptr(virJSONValue) root = NULL;
+ g_autoptr(virJSONValue) deflattened = NULL;
if (!(root = virJSONValueFromString(json)))
return -1;
- return virStorageSourceParseBackingJSONInternal(src, root, json);
+ if (!(deflattened = virJSONValueObjectDeflatten(root)))
+ return -1;
+
+ return virStorageSourceParseBackingJSONInternal(src, deflattened, json);
}
--
2.25.0