render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From 47842f81b667134e873f4380dfb432ca86a1e50d Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <47842f81b667134e873f4380dfb432ca86a1e50d@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Tue, 24 Mar 2020 16:26:00 +0100
d76c62
Subject: [PATCH] qemuBlockGetBackingStoreString: Add 'pretty' argument
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Add support for pretty-printing of the JSON variant of the output for
d76c62
consumption in tests. All current callers pass 'false'.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
d76c62
(cherry picked from commit a83c1dc70e724b9313436c63f57ea24023fd7076)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
d76c62
Message-Id: <9b133a1d7bf6304e0dc9017222bdc09640c11518.1585063415.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_block.c  | 8 +++++---
d76c62
 src/qemu/qemu_block.h  | 3 ++-
d76c62
 src/qemu/qemu_driver.c | 4 ++--
d76c62
 3 files changed, 9 insertions(+), 6 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
d76c62
index 5697d4fc73..279b4a38b8 100644
d76c62
--- a/src/qemu/qemu_block.c
d76c62
+++ b/src/qemu/qemu_block.c
d76c62
@@ -2014,13 +2014,15 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk)
d76c62
 /**
d76c62
  * qemuBlockGetBackingStoreString:
d76c62
  * @src: storage source to get the string for
d76c62
+ * @pretty: pretty-print the JSON (if applicable, used by tests)
d76c62
  *
d76c62
  * Formats a string used in the backing store field of a disk image which
d76c62
  * supports backing store. Non-local storage may result in use of the json:
d76c62
  * pseudo protocol for any complex configuration.
d76c62
  */
d76c62
 char *
d76c62
-qemuBlockGetBackingStoreString(virStorageSourcePtr src)
d76c62
+qemuBlockGetBackingStoreString(virStorageSourcePtr src,
d76c62
+                               bool pretty)
d76c62
 {
d76c62
     int actualType = virStorageSourceGetActualType(src);
d76c62
     g_autoptr(virJSONValue) backingProps = NULL;
d76c62
@@ -2087,7 +2089,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
d76c62
         props = sliceProps;
d76c62
     }
d76c62
 
d76c62
-    if (!(backingJSON = virJSONValueToString(props, false)))
d76c62
+    if (!(backingJSON = virJSONValueToString(props, pretty)))
d76c62
         return NULL;
d76c62
 
d76c62
     ret = g_strdup_printf("json:%s", backingJSON);
d76c62
@@ -2115,7 +2117,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing,
d76c62
             backingFormatStr = virStorageFileFormatTypeToString(backing->format);
d76c62
     }
d76c62
 
d76c62
-    if (!(backingFileStr = qemuBlockGetBackingStoreString(backing)))
d76c62
+    if (!(backingFileStr = qemuBlockGetBackingStoreString(backing, false)))
d76c62
         return -1;
d76c62
 
d76c62
     if (virJSONValueObjectAdd(props,
d76c62
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
d76c62
index 75b25bfea5..506957c3d5 100644
d76c62
--- a/src/qemu/qemu_block.h
d76c62
+++ b/src/qemu/qemu_block.h
d76c62
@@ -178,7 +178,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions,
d76c62
                              virStorageSourcePtr newsrc);
d76c62
 
d76c62
 char *
d76c62
-qemuBlockGetBackingStoreString(virStorageSourcePtr src)
d76c62
+qemuBlockGetBackingStoreString(virStorageSourcePtr src,
d76c62
+                               bool pretty)
d76c62
     ATTRIBUTE_NONNULL(1);
d76c62
 
d76c62
 int
d76c62
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d76c62
index 175a1961c2..3c3c7b6041 100644
d76c62
--- a/src/qemu/qemu_driver.c
d76c62
+++ b/src/qemu/qemu_driver.c
d76c62
@@ -17773,7 +17773,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
d76c62
         if (baseSource) {
d76c62
             nodebase = baseSource->nodeformat;
d76c62
             if (!backingPath &&
d76c62
-                !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
d76c62
+                !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
d76c62
                 goto endjob;
d76c62
         }
d76c62
         device = disk->src->nodeformat;
d76c62
@@ -18941,7 +18941,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
d76c62
         nodebase = baseSource->nodeformat;
d76c62
         device = qemuDomainDiskGetTopNodename(disk);
d76c62
         if (!backingPath && top_parent &&
d76c62
-            !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
d76c62
+            !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
d76c62
             goto endjob;
d76c62
 
d76c62
         if (bitmapDisableActions) {
d76c62
-- 
d76c62
2.26.0
d76c62