]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0027-gluster-possiblity-to-specify-a-secondary-server.patch
bump version to 2.6.2-2
[pve-qemu-kvm.git] / debian / patches / pve / 0027-gluster-possiblity-to-specify-a-secondary-server.patch
CommitLineData
6fb04df7 1From 15c3d8e19c9d7534441226229dd509e3a61ce82a Mon Sep 17 00:00:00 2001
ca0fe5f5
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Wed, 9 Dec 2015 16:33:25 +0100
6fb04df7 4Subject: [PATCH 27/55] gluster: possiblity to specify a secondary server
ca0fe5f5
WB
5
6---
7 block/gluster.c | 40 +++++++++++++++++++++++++++++++---------
8 1 file changed, 31 insertions(+), 9 deletions(-)
9
10diff --git a/block/gluster.c b/block/gluster.c
6fb04df7 11index 9cf33e9..0377725 100644
ca0fe5f5
WB
12--- a/block/gluster.c
13+++ b/block/gluster.c
6fb04df7 14@@ -28,6 +28,7 @@ typedef struct BDRVGlusterState {
ca0fe5f5
WB
15
16 typedef struct GlusterConf {
17 char *server;
18+ char *backupserver;
19 int port;
20 char *volname;
21 char *image;
6fb04df7 22@@ -38,6 +39,7 @@ static void qemu_gluster_gconf_free(GlusterConf *gconf)
ca0fe5f5
WB
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);
6fb04df7 30@@ -71,7 +73,7 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
ca0fe5f5
WB
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 *
6fb04df7 39@@ -87,6 +89,8 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
ca0fe5f5
WB
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
6fb04df7 48@@ -99,6 +103,7 @@ static int parse_volume_options(GlusterConf *gconf, char *path)
ca0fe5f5
WB
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
6fb04df7 56@@ -113,6 +118,8 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
ca0fe5f5
WB
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) {
6fb04df7 65@@ -140,21 +147,28 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
ca0fe5f5
WB
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;
6fb04df7 101@@ -178,7 +192,7 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
ca0fe5f5
WB
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 }
6fb04df7 110@@ -194,6 +208,14 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
ca0fe5f5
WB
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--
1262.1.4
127