1 Allow to specify a backup volfile server
3 Unfortunately, it dos now work as expected:
5 # qemu-img info gluster://<myserverip>/myvolume/test.raw
7 works, but (1.2.3.4 is a non-existent server)
9 # qemu-img info gluster://1.2.3.4/myvolume/test.raw?s2=<myserverip>
13 # qemu-img info gluster://<myserverip>/myvolume/test.raw?s2=<myserverip>
17 Index: new/block/gluster.c
18 ===================================================================
19 --- new.orig/block/gluster.c 2014-08-26 11:48:49.000000000 +0200
20 +++ new/block/gluster.c 2014-08-26 12:51:53.000000000 +0200
23 typedef struct GlusterConf {
32 g_free(gconf->server);
33 + g_free(gconf->backupserver);
34 g_free(gconf->volname);
36 g_free(gconf->transport);
41 - * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...]
42 + * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...]
44 * 'gluster' is the protocol.
47 * The 'socket' field needs to be populated with the path to unix domain
50 + * 's2' can be used to specifies a second volfile server.
52 * 'port' is the port number on which glusterd is listening. This is optional
53 * and if not specified, QEMU will send 0 which will make gluster to use the
54 * default port. If the transport type is unix, then 'port' should not be
58 * file=gluster://1.2.3.4/testvol/a.img
59 + * file=gluster://1.2.3.4/testvol/a.img?s2=1.2.3.5
60 * file=gluster+tcp://1.2.3.4/testvol/a.img
61 * file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img
62 * file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img
64 QueryParams *qp = NULL;
68 + char *socket = NULL;
70 uri = uri_parse(filename);
75 qp = query_params_parse(uri->query);
76 - if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {
77 + for (i = 0; i < qp->n; i++) {
78 + if (!is_unix && strcmp(qp->p[i].name, "s2") == 0) {
79 + gconf->backupserver = g_strdup(qp->p[i].value);
80 + } else if (is_unix && strcmp(qp->p[i].name, "socket") == 0) {
81 + socket = qp->p[i].value;
88 + if (is_unix && !socket) {
94 - if (uri->server || uri->port) {
95 + if (!socket || uri->server || uri->port) {
99 - if (strcmp(qp->p[0].name, "socket")) {
103 - gconf->server = g_strdup(qp->p[0].value);
104 + gconf->server = g_strdup(socket);
106 gconf->server = g_strdup(uri->server ? uri->server : "localhost");
107 gconf->port = uri->port;
109 ret = qemu_gluster_parseuri(gconf, filename);
111 error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
112 - "volname/image[?socket=...]");
113 + "volname/image[?socket=...|?s2=...]");
121 + if (gconf->backupserver) {
122 + ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver,
130 * TODO: Use GF_LOG_ERROR instead of hard code value of 4 here when
131 * GlusterFS makes GF_LOG_* macros available to libgfapi users.