render / rpms / libvirt

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