]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Propagate 'legacy' parameter when formatting disk backing
authorPeter Krempa <pkrempa@redhat.com>
Thu, 22 Mar 2018 15:42:47 +0000 (16:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 7 May 2018 13:31:48 +0000 (15:31 +0200)
The gluster protocol in qemu uses two styles, one of which is legacy and
not covered by the QAPI schema.

To allow using of the new style in the blockdev-add code, add a
parameter for qemuBlockStorageSourceGetBackendProps which will switch
between the two modes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_block.h
src/qemu/qemu_command.c
tests/qemublocktest.c

index b77dfaea7276ec508196c19bf8c99bf1ab6f7995..bc7bbfad3538896ca2e0da45f45695b173cdf9bc 100644 (file)
@@ -655,13 +655,14 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr src)
 
 
 static virJSONValuePtr
-qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src)
+qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src,
+                                      bool legacy)
 {
     virJSONValuePtr servers = NULL;
     virJSONValuePtr props = NULL;
     virJSONValuePtr ret = NULL;
 
-    if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, true)))
+    if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, legacy)))
         return NULL;
 
      /* { driver:"gluster",
@@ -1022,12 +1023,14 @@ qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src)
 /**
  * qemuBlockStorageSourceGetBackendProps:
  * @src: disk source
+ * @legacy: use legacy formatting of attributes (for -drive / old qemus)
  *
  * Creates a JSON object describing the underlying storage or protocol of a
  * storage source. Returns NULL on error and reports an appropriate error message.
  */
 virJSONValuePtr
-qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
+qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
+                                      bool legacy)
 {
     int actualType = virStorageSourceGetActualType(src);
     virJSONValuePtr fileprops = NULL;
@@ -1054,7 +1057,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
     case VIR_STORAGE_TYPE_NETWORK:
         switch ((virStorageNetProtocol) src->protocol) {
         case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
-            if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src)))
+            if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src, legacy)))
                 return NULL;
             break;
 
index 45485733fc887ed36711c11fcc42c09b5565028c..0e674437f44e6ec9296fc500598b3aa8dd9e9ce0 100644 (file)
@@ -58,7 +58,8 @@ bool
 qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
 
 virJSONValuePtr
-qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src);
+qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
+                                      bool legacy);
 
 virURIPtr
 qemuBlockStorageSourceGetURI(virStorageSourcePtr src);
index a189aeee7d420e1c95eafc5677c9d181da01eb18..c6bf6d5837991b6221c4c999a8514334c868aa7c 100644 (file)
@@ -1458,7 +1458,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
     virJSONValuePtr props;
     virJSONValuePtr ret;
 
-    if (!(props = qemuBlockStorageSourceGetBackendProps(src)))
+    if (!(props = qemuBlockStorageSourceGetBackendProps(src, true)))
         return NULL;
 
     if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) {
index 99584c759c95f252261e3debf85fc326d8cd8918..bd628295ff8929c05ca72e9cb4dc61851d684c08 100644 (file)
@@ -62,7 +62,7 @@ testBackingXMLjsonXML(const void *args)
         goto cleanup;
     }
 
-    if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc))) {
+    if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc, true))) {
         fprintf(stderr, "failed to format disk source json\n");
         goto cleanup;
     }