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

d76c62
From dd5ec4a68ef2858ff8d98942d87b59fa09ab819f Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <dd5ec4a68ef2858ff8d98942d87b59fa09ab819f@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Wed, 19 Feb 2020 15:10:07 +0100
d76c62
Subject: [PATCH] virStorageSourceParseBackingJSON: Move deflattening of json:
d76c62
 URIs out of recursion
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Originally virStorageSourceParseBackingJSON didn't recurse, but when
d76c62
the 'raw' driver support was added we need to parse it's information
d76c62
which contains nested 'file' object.
d76c62
d76c62
Since the deflattening helper recurses already there's no need to call
d76c62
it again. Move it one level up to the entry point.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit aadb34be3428a5e467289709290b536ae6bf5d2a)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
d76c62
Message-Id: <be49eb68dbd29d1075713483472f32d5e995a263.1582120424.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/util/virstoragefile.c | 12 ++++++------
d76c62
 1 file changed, 6 insertions(+), 6 deletions(-)
d76c62
d76c62
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
d76c62
index 05f17224f4..c97a3a9d6e 100644
d76c62
--- a/src/util/virstoragefile.c
d76c62
+++ b/src/util/virstoragefile.c
d76c62
@@ -3600,15 +3600,11 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
d76c62
                                          virJSONValuePtr json,
d76c62
                                          const char *jsonstr)
d76c62
 {
d76c62
-    g_autoptr(virJSONValue) deflattened = NULL;
d76c62
     virJSONValuePtr file;
d76c62
     const char *drvname;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(deflattened = virJSONValueObjectDeflatten(json)))
d76c62
-        return -1;
d76c62
-
d76c62
-    if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
d76c62
+    if (!(file = virJSONValueObjectGetObject(json, "file"))) {
d76c62
         virReportError(VIR_ERR_INVALID_ARG,
d76c62
                        _("JSON backing volume definition '%s' lacks 'file' object"),
d76c62
                        jsonstr);
d76c62
@@ -3639,11 +3635,15 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr src,
d76c62
                                  const char *json)
d76c62
 {
d76c62
     g_autoptr(virJSONValue) root = NULL;
d76c62
+    g_autoptr(virJSONValue) deflattened = NULL;
d76c62
 
d76c62
     if (!(root = virJSONValueFromString(json)))
d76c62
         return -1;
d76c62
 
d76c62
-    return virStorageSourceParseBackingJSONInternal(src, root, json);
d76c62
+    if (!(deflattened = virJSONValueObjectDeflatten(root)))
d76c62
+        return -1;
d76c62
+
d76c62
+    return virStorageSourceParseBackingJSONInternal(src, deflattened, json);
d76c62
 }
d76c62
 
d76c62
 
d76c62
-- 
d76c62
2.25.0
d76c62