New name is qemuBlockStorageSourceBuildHostsJSONSocketAddress since it formats the JSON object in accordance with qemu's SocketAddress type. Since the new naming in qemu uses 'inet' instead of 'tcp' add a compatibility layer for gluster which uses the old name. --- src/qemu/qemu_block.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 3dbb5586d..73f209060 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -430,9 +430,17 @@ qemuBlockGetNodeData(virJSONValuePtr data) } -/* builds the hosts array */ +/** + * qemuBlockStorageSourceBuildHostsJSONSocketAddress: + * @src: disk storage source + * @legacy: use 'tcp' instead of 'inet' for compatibility reasons + * + * Formats src->hosts into a json object conforming to the 'SocketAddress' type + * in qemu. + */ static virJSONValuePtr -qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) +qemuBlockStorageSourceBuildHostsJSONSocketAddress(virStorageSourcePtr src, + bool legacy) { virJSONValuePtr servers = NULL; virJSONValuePtr server = NULL; @@ -446,24 +454,27 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) for (i = 0; i < src->nhosts; i++) { host = src->hosts + i; - transport = virStorageNetHostTransportTypeToString(host->transport); - - if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) < 0) - goto cleanup; switch ((virStorageNetHostTransport) host->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: - if (virJSONValueObjectAdd(server, - "s:host", host->name, - "s:port", host->port, - NULL) < 0) + if (legacy) + transport = "tcp"; + else + transport = "inet"; + + if (virJSONValueObjectCreate(&server, + "s:type", transport, + "s:host", host->name, + "s:port", host->port, + NULL) < 0) goto cleanup; break; case VIR_STORAGE_NET_HOST_TRANS_UNIX: - if (virJSONValueObjectAdd(server, - "s:socket", host->socket, - NULL) < 0) + if (virJSONValueObjectCreate(&server, + "s:type", "unix", + "s:socket", host->socket, + NULL) < 0) goto cleanup; break; @@ -481,8 +492,7 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) server = NULL; } - ret = servers; - servers = NULL; + VIR_STEAL_PTR(ret, servers); cleanup: virJSONValueFree(servers); @@ -499,7 +509,7 @@ qemuBuildGlusterDriveJSON(virStorageSourcePtr src) virJSONValuePtr servers = NULL; virJSONValuePtr ret = NULL; - if (!(servers = qemuBuildGlusterDriveJSONHosts(src))) + if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, true))) return NULL; /* { driver:"gluster", -- 2.12.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list