render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
fbe740
From d4877aae453a0ed1104dfd8aa12806a110f08b07 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <d4877aae453a0ed1104dfd8aa12806a110f08b07@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Tue, 24 Mar 2020 16:26:05 +0100
fbe740
Subject: [PATCH] qemuBlockGetBackingStoreString: Add extra wrapping object to
fbe740
 JSON strings
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
QEMU requires an extra wrapper object where only the "file" member is
fbe740
populated. This is basically a placeholder for establishing the format
fbe740
layer. We did the same in qemuDiskSourceGetProps for the old-school
fbe740
JSON usage with -drive but forgot to adopt this for -blockdev.
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
fbe740
(cherry picked from commit 7ba2208addf1cad4d6c06d3c172cca93f84ead11)
fbe740
Message-Id: <9a56b9f7e03d41bf99399b14f399bc9007ed1a4e.1585063415.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_block.c                                          | 2 +-
fbe740
 .../imagecreate/qcow2-backing-qcow2-slice.json                 | 2 +-
fbe740
 .../qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json | 2 +-
fbe740
 .../network-qcow2-backing-chain-cache-unsafe-srconly.json      | 3 ++-
fbe740
 .../network-qcow2-backing-chain-encryption_auth-srconly.json   | 3 ++-
fbe740
 tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json  | 3 ++-
fbe740
 6 files changed, 9 insertions(+), 6 deletions(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
fbe740
index 5a7364576a..73a424f7a8 100644
fbe740
--- a/src/qemu/qemu_block.c
fbe740
+++ b/src/qemu/qemu_block.c
fbe740
@@ -2091,7 +2091,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
fbe740
     if (!(backingJSON = virJSONValueToString(props, pretty)))
fbe740
         return NULL;
fbe740
 
fbe740
-    return g_strdup_printf("json:%s", backingJSON);
fbe740
+    return g_strdup_printf("json:{\"file\":%s}", backingJSON);
fbe740
 }
fbe740
 
fbe740
 
fbe740
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json
fbe740
index 2fa27c1933..2526740b9a 100644
fbe740
--- a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json
fbe740
+++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json
fbe740
@@ -10,6 +10,6 @@ format:
fbe740
   "driver": "qcow2",
fbe740
   "file": "0123456789ABCDEF0123456789ABCDE",
fbe740
   "size": 8589934590,
fbe740
-  "backing-file": "json:{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow2\"}}",
fbe740
+  "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow2\"}}}",
fbe740
   "backing-fmt": "qcow2"
fbe740
 }
fbe740
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json
fbe740
index 761002afd9..e76221da16 100644
fbe740
--- a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json
fbe740
+++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json
fbe740
@@ -10,6 +10,6 @@ format:
fbe740
   "driver": "qcow2",
fbe740
   "file": "0123456789ABCDEF0123456789ABCDE",
fbe740
   "size": 8589934590,
fbe740
-  "backing-file": "json:{\"driver\":\"raw\",\"offset\":9876,\"size\":54321,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img\"}}",
fbe740
+  "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":9876,\"size\":54321,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img\"}}}",
fbe740
   "backing-fmt": "raw"
fbe740
 }
fbe740
diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe-srconly.json
fbe740
index 2d7eeb3bca..0fb0b8eff9 100644
fbe740
--- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe-srconly.json
fbe740
+++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe-srconly.json
fbe740
@@ -16,7 +16,7 @@
fbe740
     ]
fbe740
   }
fbe740
   backing store string:
fbe740
-  json:{
fbe740
+  json:{"file":{
fbe740
     "driver": "rbd",
fbe740
     "pool": "rbdpool",
fbe740
     "image": "rbdimg",
fbe740
@@ -31,6 +31,7 @@
fbe740
       }
fbe740
     ]
fbe740
   }
fbe740
+  }
fbe740
 )
fbe740
 (
fbe740
   source only properties:
fbe740
diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encryption_auth-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encryption_auth-srconly.json
fbe740
index 5679318fbe..777a372471 100644
fbe740
--- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encryption_auth-srconly.json
fbe740
+++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encryption_auth-srconly.json
fbe740
@@ -16,7 +16,7 @@
fbe740
     ]
fbe740
   }
fbe740
   backing store string:
fbe740
-  json:{
fbe740
+  json:{"file":{
fbe740
     "driver": "rbd",
fbe740
     "pool": "rbdpool",
fbe740
     "image": "rbdimg",
fbe740
@@ -31,6 +31,7 @@
fbe740
       }
fbe740
     ]
fbe740
   }
fbe740
+  }
fbe740
 )
fbe740
 (
fbe740
   source only properties:
fbe740
diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json
fbe740
index 970e1bb8af..26f9557c80 100644
fbe740
--- a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json
fbe740
+++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json
fbe740
@@ -6,9 +6,10 @@
fbe740
     "namespace": 1
fbe740
   }
fbe740
   backing store string:
fbe740
-  json:{
fbe740
+  json:{"file":{
fbe740
     "driver": "nvme",
fbe740
     "device": "0000:01:00.0",
fbe740
     "namespace": 1
fbe740
   }
fbe740
+  }
fbe740
 )
fbe740
-- 
fbe740
2.26.0
fbe740