1 From 7b58868a321a38585c20a6eecdaa52d2a85e8385 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 16:33:25 +0100
4 Subject: [PATCH 27/41] gluster: possiblity to specify a secondary server
7 block/gluster.c | 40 +++++++++++++++++++++++++++++++---------
8 1 file changed, 31 insertions(+), 9 deletions(-)
10 diff --git a/block/gluster.c b/block/gluster.c
11 index e3c0dbc..8946e82 100644
14 @@ -26,6 +26,7 @@ typedef struct BDRVGlusterState {
16 typedef struct GlusterConf {
22 @@ -36,6 +37,7 @@ static void qemu_gluster_gconf_free(GlusterConf *gconf)
25 g_free(gconf->server);
26 + g_free(gconf->backupserver);
27 g_free(gconf->volname);
29 g_free(gconf->transport);
30 @@ -69,7 +71,7 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
34 - * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...]
35 + * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...]
37 * 'gluster' is the protocol.
39 @@ -85,6 +87,8 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
40 * The 'socket' field needs to be populated with the path to unix domain
43 + * 's2' can be used to specifies a second volfile server.
45 * 'port' is the port number on which glusterd is listening. This is optional
46 * and if not specified, QEMU will send 0 which will make gluster to use the
47 * default port. If the transport type is unix, then 'port' should not be
48 @@ -97,6 +101,7 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
51 * file=gluster://1.2.3.4/testvol/a.img
52 + * file=gluster://1.2.3.4/testvol/a.img?s2=1.2.3.5
53 * file=gluster+tcp://1.2.3.4/testvol/a.img
54 * file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img
55 * file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img
56 @@ -111,6 +116,8 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
57 QueryParams *qp = NULL;
61 + char *socket = NULL;
63 uri = uri_parse(filename);
65 @@ -138,21 +145,28 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
68 qp = query_params_parse(uri->query);
69 - if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {
70 + for (i = 0; i < qp->n; i++) {
71 + if (!is_unix && strcmp(qp->p[i].name, "s2") == 0) {
72 + gconf->backupserver = g_strdup(qp->p[i].value);
73 + } else if (is_unix && strcmp(qp->p[i].name, "socket") == 0) {
74 + socket = qp->p[i].value;
81 + if (is_unix && !socket) {
87 - if (uri->server || uri->port) {
88 + if (!socket || uri->server || uri->port) {
92 - if (strcmp(qp->p[0].name, "socket")) {
96 - gconf->server = g_strdup(qp->p[0].value);
97 + gconf->server = g_strdup(socket);
99 gconf->server = g_strdup(uri->server ? uri->server : "localhost");
100 gconf->port = uri->port;
101 @@ -176,7 +190,7 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
102 ret = qemu_gluster_parseuri(gconf, filename);
104 error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
105 - "volname/image[?socket=...]");
106 + "volname/image[?socket=...|?s2=...]");
110 @@ -192,6 +206,14 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
114 + if (gconf->backupserver) {
115 + ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver,
123 * TODO: Use GF_LOG_ERROR instead of hard code value of 4 here when
124 * GlusterFS makes GF_LOG_* macros available to libgfapi users.