]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBlockGetBackingStoreString: Add extra wrapping object to JSON strings
authorPeter Krempa <pkrempa@redhat.com>
Mon, 23 Mar 2020 15:09:31 +0000 (16:09 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Mar 2020 13:17:47 +0000 (14:17 +0100)
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 <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_block.c
tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json
tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json
tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe-srconly.json
tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encryption_auth-srconly.json
tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json

index a44cfeb99c1af27d61a1b1184e4e8da336db5491..3365ee677b73e9b1583341264a1e988c4eb96fc8 100644 (file)
@@ -2104,7 +2104,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);
 }
 
 
index 2fa27c1933ccfb9b31e243f3ece1a1d632ef3587..2526740b9a2c638c853f6bec7fd66e6b02c00782 100644 (file)
@@ -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"
 }
index 761002afd9c6917ed2937afe8f233630f0084e15..e76221da163a8ca55c8cedd718ab8b67c12bb8e0 100644 (file)
@@ -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"
 }
index 2d7eeb3bcac2fa4b67369535a2e813742874092a..0fb0b8eff994d8b4ca58992e63f4ad0d8931109f 100644 (file)
@@ -16,7 +16,7 @@
     ]
   }
   backing store string:
-  json:{
+  json:{"file":{
     "driver": "rbd",
     "pool": "rbdpool",
     "image": "rbdimg",
@@ -31,6 +31,7 @@
       }
     ]
   }
+  }
 )
 (
   source only properties:
index 5679318fbe8c984da1e77c280802f340cf87d44d..777a3724712c8feb0fae83770d9eb89907c19bce 100644 (file)
@@ -16,7 +16,7 @@
     ]
   }
   backing store string:
-  json:{
+  json:{"file":{
     "driver": "rbd",
     "pool": "rbdpool",
     "image": "rbdimg",
@@ -31,6 +31,7 @@
       }
     ]
   }
+  }
 )
 (
   source only properties:
index 970e1bb8af31c2f0eb4872f262bf267d56ff9b01..26f9557c804d71944a55c0849ec405f2ca4f56bf 100644 (file)
@@ -6,9 +6,10 @@
     "namespace": 1
   }
   backing store string:
-  json:{
+  json:{"file":{
     "driver": "nvme",
     "device": "0000:01:00.0",
     "namespace": 1
   }
+  }
 )