提交 d94aa38f 编写于 作者: P Peter Krempa

qemu: block: Propagate 'legacy' parameter when formatting disk backing

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 01455fe8
...@@ -655,13 +655,14 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr src) ...@@ -655,13 +655,14 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr src)
static virJSONValuePtr static virJSONValuePtr
qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src) qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src,
bool legacy)
{ {
virJSONValuePtr servers = NULL; virJSONValuePtr servers = NULL;
virJSONValuePtr props = NULL; virJSONValuePtr props = NULL;
virJSONValuePtr ret = NULL; virJSONValuePtr ret = NULL;
if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, true))) if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, legacy)))
return NULL; return NULL;
/* { driver:"gluster", /* { driver:"gluster",
...@@ -1022,12 +1023,14 @@ qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src) ...@@ -1022,12 +1023,14 @@ qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src)
/** /**
* qemuBlockStorageSourceGetBackendProps: * qemuBlockStorageSourceGetBackendProps:
* @src: disk source * @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 * Creates a JSON object describing the underlying storage or protocol of a
* storage source. Returns NULL on error and reports an appropriate error message. * storage source. Returns NULL on error and reports an appropriate error message.
*/ */
virJSONValuePtr virJSONValuePtr
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src) qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
bool legacy)
{ {
int actualType = virStorageSourceGetActualType(src); int actualType = virStorageSourceGetActualType(src);
virJSONValuePtr fileprops = NULL; virJSONValuePtr fileprops = NULL;
...@@ -1054,7 +1057,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src) ...@@ -1054,7 +1057,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) src->protocol) { switch ((virStorageNetProtocol) src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_GLUSTER: case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src))) if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src, legacy)))
return NULL; return NULL;
break; break;
......
...@@ -58,7 +58,8 @@ bool ...@@ -58,7 +58,8 @@ bool
qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src); qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
virJSONValuePtr virJSONValuePtr
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src); qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
bool legacy);
virURIPtr virURIPtr
qemuBlockStorageSourceGetURI(virStorageSourcePtr src); qemuBlockStorageSourceGetURI(virStorageSourcePtr src);
......
...@@ -1458,7 +1458,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src) ...@@ -1458,7 +1458,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
virJSONValuePtr props; virJSONValuePtr props;
virJSONValuePtr ret; virJSONValuePtr ret;
if (!(props = qemuBlockStorageSourceGetBackendProps(src))) if (!(props = qemuBlockStorageSourceGetBackendProps(src, true)))
return NULL; return NULL;
if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) { if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) {
......
...@@ -62,7 +62,7 @@ testBackingXMLjsonXML(const void *args) ...@@ -62,7 +62,7 @@ testBackingXMLjsonXML(const void *args)
goto cleanup; goto cleanup;
} }
if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc))) { if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc, true))) {
fprintf(stderr, "failed to format disk source json\n"); fprintf(stderr, "failed to format disk source json\n");
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册