render / rpms / libvirt

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