|
|
6ae9ed |
From 4351bb2a4232883bccf4596a80ebeedb4bf8bd91 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <4351bb2a4232883bccf4596a80ebeedb4bf8bd91@dist-git>
|
|
|
6ae9ed |
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
6ae9ed |
Date: Tue, 2 Aug 2016 13:42:04 +0200
|
|
|
6ae9ed |
Subject: [PATCH] qemu: command: Add support for multi-host gluster disks
|
|
|
6ae9ed |
|
|
|
6ae9ed |
To allow using failover with gluster it's necessary to specify multiple
|
|
|
6ae9ed |
volume hosts. Add support for starting qemu with such configurations.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
6ae9ed |
(cherry picked from commit 7b7da9e28332517cfe47d5cf627aa9f7fd88aa3d)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1247521 [gluster multi-host]
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
docs/formatdomain.html.in | 2 +-
|
|
|
6ae9ed |
src/qemu/qemu_command.c | 101 +++++++++++++++++++++
|
|
|
6ae9ed |
.../qemuxml2argv-disk-drive-network-gluster.args | 9 +-
|
|
|
6ae9ed |
.../qemuxml2argv-disk-drive-network-gluster.xml | 9 ++
|
|
|
6ae9ed |
.../qemuxml2xmlout-disk-drive-network-gluster.xml | 10 ++
|
|
|
6ae9ed |
5 files changed, 129 insertions(+), 2 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
6ae9ed |
index d206f6a..f006179 100644
|
|
|
6ae9ed |
--- a/docs/formatdomain.html.in
|
|
|
6ae9ed |
+++ b/docs/formatdomain.html.in
|
|
|
6ae9ed |
@@ -2280,7 +2280,7 @@
|
|
|
6ae9ed |
|
|
|
6ae9ed |
gluster
|
|
|
6ae9ed |
a server running glusterd daemon
|
|
|
6ae9ed |
- only one
|
|
|
6ae9ed |
+ one or more (Since 2.1.0), just one prior to that
|
|
|
6ae9ed |
24007
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
6ae9ed |
index b33c39c..88b5da1 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_command.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_command.c
|
|
|
6ae9ed |
@@ -689,6 +689,100 @@ qemuBuildRBDSecinfoURI(virBufferPtr buf,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
#define QEMU_DEFAULT_NBD_PORT "10809"
|
|
|
6ae9ed |
+#define QEMU_DEFAULT_GLUSTER_PORT "24007"
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+/* builds the hosts array */
|
|
|
6ae9ed |
+static virJSONValuePtr
|
|
|
6ae9ed |
+qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ virJSONValuePtr servers = NULL;
|
|
|
6ae9ed |
+ virJSONValuePtr server = NULL;
|
|
|
6ae9ed |
+ virJSONValuePtr ret = NULL;
|
|
|
6ae9ed |
+ virStorageNetHostDefPtr host;
|
|
|
6ae9ed |
+ const char *transport;
|
|
|
6ae9ed |
+ const char *portstr;
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!(servers = virJSONValueNewArray()))
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ for (i = 0; i < src->nhosts; i++) {
|
|
|
6ae9ed |
+ host = src->hosts + i;
|
|
|
6ae9ed |
+ transport = virStorageNetHostTransportTypeToString(host->transport);
|
|
|
6ae9ed |
+ portstr = host->port;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!portstr)
|
|
|
6ae9ed |
+ portstr = QEMU_DEFAULT_GLUSTER_PORT;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ switch ((virStorageNetHostTransport) host->transport) {
|
|
|
6ae9ed |
+ case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
|
|
6ae9ed |
+ if (virJSONValueObjectAdd(server,
|
|
|
6ae9ed |
+ "s:host", host->name,
|
|
|
6ae9ed |
+ "s:port", portstr,
|
|
|
6ae9ed |
+ NULL) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ case VIR_STORAGE_NET_HOST_TRANS_UNIX:
|
|
|
6ae9ed |
+ if (virJSONValueObjectAdd(server,
|
|
|
6ae9ed |
+ "s:socket", host->socket,
|
|
|
6ae9ed |
+ NULL) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ case VIR_STORAGE_NET_HOST_TRANS_RDMA:
|
|
|
6ae9ed |
+ case VIR_STORAGE_NET_HOST_TRANS_LAST:
|
|
|
6ae9ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
6ae9ed |
+ _("transport protocol '%s' is not yet supported"),
|
|
|
6ae9ed |
+ transport);
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virJSONValueArrayAppend(servers, server) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ server = NULL;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ ret = servers;
|
|
|
6ae9ed |
+ servers = NULL;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ cleanup:
|
|
|
6ae9ed |
+ virJSONValueFree(servers);
|
|
|
6ae9ed |
+ virJSONValueFree(server);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return ret;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+static virJSONValuePtr
|
|
|
6ae9ed |
+qemuBuildGlusterDriveJSON(virStorageSourcePtr src)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ const char *protocol = virStorageNetProtocolTypeToString(src->protocol);
|
|
|
6ae9ed |
+ virJSONValuePtr servers = NULL;
|
|
|
6ae9ed |
+ virJSONValuePtr ret = NULL;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!(servers = qemuBuildGlusterDriveJSONHosts(src)))
|
|
|
6ae9ed |
+ return NULL;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* { driver:"gluster",
|
|
|
6ae9ed |
+ * volume:"testvol",
|
|
|
6ae9ed |
+ * path:"/a.img",
|
|
|
6ae9ed |
+ * server :[{type:"tcp", host:"1.2.3.4", port:24007},
|
|
|
6ae9ed |
+ * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]}
|
|
|
6ae9ed |
+ */
|
|
|
6ae9ed |
+ if (virJSONValueObjectCreate(&ret,
|
|
|
6ae9ed |
+ "s:driver", protocol,
|
|
|
6ae9ed |
+ "s:volume", src->volume,
|
|
|
6ae9ed |
+ "s:path", src->path,
|
|
|
6ae9ed |
+ "a:server", servers, NULL) < 0)
|
|
|
6ae9ed |
+ virJSONValueFree(servers);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return ret;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
static char *
|
|
|
6ae9ed |
@@ -932,7 +1026,14 @@ qemuGetDriveSourceProps(virStorageSourcePtr src,
|
|
|
6ae9ed |
case VIR_STORAGE_TYPE_VOLUME:
|
|
|
6ae9ed |
case VIR_STORAGE_TYPE_NONE:
|
|
|
6ae9ed |
case VIR_STORAGE_TYPE_LAST:
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
case VIR_STORAGE_TYPE_NETWORK:
|
|
|
6ae9ed |
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
|
|
|
6ae9ed |
+ src->nhosts > 1) {
|
|
|
6ae9ed |
+ if (!(fileprops = qemuBuildGlusterDriveJSON(src)))
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
break;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
|
|
|
6ae9ed |
index 7851dee..a7a1ae6 100644
|
|
|
6ae9ed |
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
|
|
|
6ae9ed |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
|
|
|
6ae9ed |
@@ -24,4 +24,11 @@ id=virtio-disk0 \
|
|
|
6ae9ed |
-drive 'file=gluster+unix:///Volume2/Image?socket=/path/to/sock,format=raw,\
|
|
|
6ae9ed |
if=none,id=drive-virtio-disk1' \
|
|
|
6ae9ed |
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,\
|
|
|
6ae9ed |
-id=virtio-disk1
|
|
|
6ae9ed |
+id=virtio-disk1 \
|
|
|
6ae9ed |
+-drive file.driver=gluster,file.volume=Volume3,file.path=/Image.qcow2,\
|
|
|
6ae9ed |
+file.server.0.type=tcp,file.server.0.host=example.org,file.server.0.port=6000,\
|
|
|
6ae9ed |
+file.server.1.type=tcp,file.server.1.host=example.org,file.server.1.port=24007,\
|
|
|
6ae9ed |
+file.server.2.type=unix,file.server.2.socket=/path/to/sock,format=qcow2,\
|
|
|
6ae9ed |
+if=none,id=drive-virtio-disk2 \
|
|
|
6ae9ed |
+-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk2,\
|
|
|
6ae9ed |
+id=virtio-disk2
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
index 0c66e7f..ef30e8c 100644
|
|
|
6ae9ed |
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
@@ -28,6 +28,15 @@
|
|
|
6ae9ed |
</source>
|
|
|
6ae9ed |
<target dev='vdb' bus='virtio'/>
|
|
|
6ae9ed |
</disk>
|
|
|
6ae9ed |
+ <disk type='network' device='disk'>
|
|
|
6ae9ed |
+ <driver name='qemu' type='qcow2'/>
|
|
|
6ae9ed |
+ <source protocol='gluster' name='Volume3/Image.qcow2'>
|
|
|
6ae9ed |
+ <host name='example.org' port='6000'/>
|
|
|
6ae9ed |
+ <host name='example.org'/>
|
|
|
6ae9ed |
+ <host transport='unix' socket='/path/to/sock'/>
|
|
|
6ae9ed |
+ </source>
|
|
|
6ae9ed |
+ <target dev='vdc' bus='virtio'/>
|
|
|
6ae9ed |
+ </disk>
|
|
|
6ae9ed |
<controller type='usb' index='0'/>
|
|
|
6ae9ed |
<controller type='pci' index='0' model='pci-root'/>
|
|
|
6ae9ed |
<input type='mouse' bus='ps2'/>
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
index 160fd9d..8e0add5 100644
|
|
|
6ae9ed |
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml
|
|
|
6ae9ed |
@@ -30,6 +30,16 @@
|
|
|
6ae9ed |
<target dev='vdb' bus='virtio'/>
|
|
|
6ae9ed |
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
|
|
6ae9ed |
</disk>
|
|
|
6ae9ed |
+ <disk type='network' device='disk'>
|
|
|
6ae9ed |
+ <driver name='qemu' type='qcow2'/>
|
|
|
6ae9ed |
+ <source protocol='gluster' name='Volume3/Image.qcow2'>
|
|
|
6ae9ed |
+ <host name='example.org' port='6000'/>
|
|
|
6ae9ed |
+ <host name='example.org'/>
|
|
|
6ae9ed |
+ <host transport='unix' socket='/path/to/sock'/>
|
|
|
6ae9ed |
+ </source>
|
|
|
6ae9ed |
+ <target dev='vdc' bus='virtio'/>
|
|
|
6ae9ed |
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
|
|
6ae9ed |
+ </disk>
|
|
|
6ae9ed |
<controller type='usb' index='0'>
|
|
|
6ae9ed |
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
|
|
6ae9ed |
</controller>
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|