]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/pve/0027-gluster-possiblity-to-specify-a-secondary-server.patch
adding 2.5 pve patches and left-over extra fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0027-gluster-possiblity-to-specify-a-secondary-server.patch
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
5
6 ---
7 block/gluster.c | 40 +++++++++++++++++++++++++++++++---------
8 1 file changed, 31 insertions(+), 9 deletions(-)
9
10 diff --git a/block/gluster.c b/block/gluster.c
11 index e3c0dbc..8946e82 100644
12 --- a/block/gluster.c
13 +++ b/block/gluster.c
14 @@ -26,6 +26,7 @@ typedef struct BDRVGlusterState {
15
16 typedef struct GlusterConf {
17 char *server;
18 + char *backupserver;
19 int port;
20 char *volname;
21 char *image;
22 @@ -36,6 +37,7 @@ static void qemu_gluster_gconf_free(GlusterConf *gconf)
23 {
24 if (gconf) {
25 g_free(gconf->server);
26 + g_free(gconf->backupserver);
27 g_free(gconf->volname);
28 g_free(gconf->image);
29 g_free(gconf->transport);
30 @@ -69,7 +71,7 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
31 }
32
33 /*
34 - * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...]
35 + * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...]
36 *
37 * 'gluster' is the protocol.
38 *
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
41 * socket.
42 *
43 + * 's2' can be used to specifies a second volfile server.
44 + *
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)
49 * Examples:
50 *
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;
58 bool is_unix = false;
59 int ret = 0;
60 + int i;
61 + char *socket = NULL;
62
63 uri = uri_parse(filename);
64 if (!uri) {
65 @@ -138,21 +145,28 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
66 }
67
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;
75 + } else {
76 + ret = -EINVAL;
77 + goto out;
78 + }
79 + }
80 +
81 + if (is_unix && !socket) {
82 ret = -EINVAL;
83 goto out;
84 }
85
86 if (is_unix) {
87 - if (uri->server || uri->port) {
88 + if (!socket || uri->server || uri->port) {
89 ret = -EINVAL;
90 goto out;
91 }
92 - if (strcmp(qp->p[0].name, "socket")) {
93 - ret = -EINVAL;
94 - goto out;
95 - }
96 - gconf->server = g_strdup(qp->p[0].value);
97 + gconf->server = g_strdup(socket);
98 } else {
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);
103 if (ret < 0) {
104 error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
105 - "volname/image[?socket=...]");
106 + "volname/image[?socket=...|?s2=...]");
107 errno = -ret;
108 goto out;
109 }
110 @@ -192,6 +206,14 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
111 goto out;
112 }
113
114 + if (gconf->backupserver) {
115 + ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver,
116 + gconf->port);
117 + if (ret < 0) {
118 + goto out;
119 + }
120 + }
121 +
122 /*
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.
125 --
126 2.1.4
127