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