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

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