[PATCH 02/15] virStorageSourceParseBackingJSON: Move deflattening of json: URIs out of recursion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 bdf82b04bb..fd0069a4fa 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.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux