]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBlockGetBackingStoreString: Add 'pretty' argument
authorPeter Krempa <pkrempa@redhat.com>
Mon, 23 Mar 2020 10:48:10 +0000 (11:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Mar 2020 13:17:47 +0000 (14:17 +0100)
Add support for pretty-printing of the JSON variant of the output for
consumption in tests. All current callers pass 'false'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_block.h
src/qemu/qemu_driver.c

index 22ea2fe0189c359f815f1ee226ff5e838a17cf1d..d6cc999a43a6c0c509a0125710690af84c104eae 100644 (file)
@@ -2027,13 +2027,15 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk)
 /**
  * qemuBlockGetBackingStoreString:
  * @src: storage source to get the string for
+ * @pretty: pretty-print the JSON (if applicable, used by tests)
  *
  * Formats a string used in the backing store field of a disk image which
  * supports backing store. Non-local storage may result in use of the json:
  * pseudo protocol for any complex configuration.
  */
 char *
-qemuBlockGetBackingStoreString(virStorageSourcePtr src)
+qemuBlockGetBackingStoreString(virStorageSourcePtr src,
+                               bool pretty)
 {
     int actualType = virStorageSourceGetActualType(src);
     g_autoptr(virJSONValue) backingProps = NULL;
@@ -2100,7 +2102,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
         props = sliceProps;
     }
 
-    if (!(backingJSON = virJSONValueToString(props, false)))
+    if (!(backingJSON = virJSONValueToString(props, pretty)))
         return NULL;
 
     ret = g_strdup_printf("json:%s", backingJSON);
@@ -2128,7 +2130,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing,
             backingFormatStr = virStorageFileFormatTypeToString(backing->format);
     }
 
-    if (!(backingFileStr = qemuBlockGetBackingStoreString(backing)))
+    if (!(backingFileStr = qemuBlockGetBackingStoreString(backing, false)))
         return -1;
 
     if (virJSONValueObjectAdd(props,
index 28475b25c14a8494001b3373ff328232ef8397d9..9bffe20bfb199f07c6274dce5ea57439f2b8f76e 100644 (file)
@@ -178,7 +178,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions,
                              virStorageSourcePtr newsrc);
 
 char *
-qemuBlockGetBackingStoreString(virStorageSourcePtr src)
+qemuBlockGetBackingStoreString(virStorageSourcePtr src,
+                               bool pretty)
     ATTRIBUTE_NONNULL(1);
 
 int
index 8a2cd35fa74795ca576bb70ef99afe1bda73ea0a..209f8279bd409dc9d8d58139458298eb9e44f87e 100644 (file)
@@ -17499,7 +17499,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
         if (baseSource) {
             nodebase = baseSource->nodeformat;
             if (!backingPath &&
-                !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
+                !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
                 goto endjob;
         }
         device = disk->src->nodeformat;
@@ -18667,7 +18667,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
         nodebase = baseSource->nodeformat;
         device = qemuDomainDiskGetTopNodename(disk);
         if (!backingPath && top_parent &&
-            !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
+            !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
             goto endjob;
 
         if (bitmapDisableActions) {