diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 59a8bb9229..8efd6af01d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2280,7 +2280,7 @@
gluster |
a server running glusterd daemon |
- only one |
+ one or more (Since 2.1.0), just one prior to that |
24007 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d90571eb43..4abe8e4c83 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -689,6 +689,100 @@ qemuBuildRBDSecinfoURI(virBufferPtr buf,
#define QEMU_DEFAULT_NBD_PORT "10809"
+#define QEMU_DEFAULT_GLUSTER_PORT "24007"
+
+/* builds the hosts array */
+static virJSONValuePtr
+qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src)
+{
+ virJSONValuePtr servers = NULL;
+ virJSONValuePtr server = NULL;
+ virJSONValuePtr ret = NULL;
+ virStorageNetHostDefPtr host;
+ const char *transport;
+ const char *portstr;
+ size_t i;
+
+ if (!(servers = virJSONValueNewArray()))
+ goto cleanup;
+
+ for (i = 0; i < src->nhosts; i++) {
+ host = src->hosts + i;
+ transport = virStorageNetHostTransportTypeToString(host->transport);
+ portstr = host->port;
+
+ if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) < 0)
+ goto cleanup;
+
+ if (!portstr)
+ portstr = QEMU_DEFAULT_GLUSTER_PORT;
+
+ switch ((virStorageNetHostTransport) host->transport) {
+ case VIR_STORAGE_NET_HOST_TRANS_TCP:
+ if (virJSONValueObjectAdd(server,
+ "s:host", host->name,
+ "s:port", portstr,
+ NULL) < 0)
+ goto cleanup;
+ break;
+
+ case VIR_STORAGE_NET_HOST_TRANS_UNIX:
+ if (virJSONValueObjectAdd(server,
+ "s:socket", host->socket,
+ NULL) < 0)
+ goto cleanup;
+ break;
+
+ case VIR_STORAGE_NET_HOST_TRANS_RDMA:
+ case VIR_STORAGE_NET_HOST_TRANS_LAST:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("transport protocol '%s' is not yet supported"),
+ transport);
+ goto cleanup;
+ }
+
+ if (virJSONValueArrayAppend(servers, server) < 0)
+ goto cleanup;
+
+ server = NULL;
+ }
+
+ ret = servers;
+ servers = NULL;
+
+ cleanup:
+ virJSONValueFree(servers);
+ virJSONValueFree(server);
+
+ return ret;
+}
+
+
+static virJSONValuePtr
+qemuBuildGlusterDriveJSON(virStorageSourcePtr src)
+{
+ const char *protocol = virStorageNetProtocolTypeToString(src->protocol);
+ virJSONValuePtr servers = NULL;
+ virJSONValuePtr ret = NULL;
+
+ if (!(servers = qemuBuildGlusterDriveJSONHosts(src)))
+ return NULL;
+
+ /* { driver:"gluster",
+ * volume:"testvol",
+ * path:"/a.img",
+ * server :[{type:"tcp", host:"1.2.3.4", port:24007},
+ * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]}
+ */
+ if (virJSONValueObjectCreate(&ret,
+ "s:driver", protocol,
+ "s:volume", src->volume,
+ "s:path", src->path,
+ "a:server", servers, NULL) < 0)
+ virJSONValueFree(servers);
+
+ return ret;
+}
static char *
@@ -932,7 +1026,14 @@ qemuGetDriveSourceProps(virStorageSourcePtr src,
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
case VIR_STORAGE_TYPE_LAST:
+ break;
+
case VIR_STORAGE_TYPE_NETWORK:
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
+ src->nhosts > 1) {
+ if (!(fileprops = qemuBuildGlusterDriveJSON(src)))
+ return -1;
+ }
break;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
index 5668f154f8..634ed75d02 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
@@ -24,4 +24,11 @@ id=virtio-disk0 \
-drive 'file=gluster+unix:///Volume2/Image?socket=/path/to/sock,format=raw,\
if=none,id=drive-virtio-disk1' \
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,\
-id=virtio-disk1
+id=virtio-disk1 \
+-drive file.driver=gluster,file.volume=Volume3,file.path=/Image.qcow2,\
+file.server.0.type=tcp,file.server.0.host=example.org,file.server.0.port=6000,\
+file.server.1.type=tcp,file.server.1.host=example.org,file.server.1.port=24007,\
+file.server.2.type=unix,file.server.2.socket=/path/to/sock,format=qcow2,\
+if=none,id=drive-virtio-disk2 \
+-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk2,\
+id=virtio-disk2
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
index 0c66e7fd7e..ef30e8cc74 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
@@ -28,6 +28,15 @@
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
index 160fd9d4bd..8e0add5d44 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
@@ -30,6 +30,16 @@
+
+
+
+
+
+