]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/gluster-backupserver.patch
Fix CVE-2016-2841, CVE-2016-2857, CVE-2016-2858
[pve-qemu-kvm.git] / debian / patches / gluster-backupserver.patch
CommitLineData
b6285005
DM
1Allow to specify a backup volfile server
2
3Unfortunately, it dos now work as expected:
4
5 # qemu-img info gluster://<myserverip>/myvolume/test.raw
6
7works, but (1.2.3.4 is a non-existent server)
8
9 # qemu-img info gluster://1.2.3.4/myvolume/test.raw?s2=<myserverip>
10
11does not work. Also
12
13 # qemu-img info gluster://<myserverip>/myvolume/test.raw?s2=<myserverip>
14
15simply hangs forever.
16
4f7586cf
DM
17Index: 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
21@@ -26,6 +26,7 @@
22
23 typedef struct GlusterConf {
24 char *server;
25+ char *backupserver;
26 int port;
27 char *volname;
28 char *image;
29@@ -36,6 +37,7 @@
30 {
31 if (gconf) {
32 g_free(gconf->server);
33+ g_free(gconf->backupserver);
34 g_free(gconf->volname);
35 g_free(gconf->image);
36 g_free(gconf->transport);
37@@ -69,7 +71,7 @@
38 }
39
40 /*
41- * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...]
42+ * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...]
43 *
44 * 'gluster' is the protocol.
45 *
46@@ -85,6 +87,8 @@
47 * The 'socket' field needs to be populated with the path to unix domain
48 * socket.
49 *
50+ * 's2' can be used to specifies a second volfile server.
51+ *
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
55@@ -97,6 +101,7 @@
56 * Examples:
57 *
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
63@@ -111,6 +116,8 @@
64 QueryParams *qp = NULL;
65 bool is_unix = false;
66 int ret = 0;
67+ int i;
68+ char *socket = NULL;
69
70 uri = uri_parse(filename);
71 if (!uri) {
72@@ -138,21 +145,28 @@
73 }
74
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;
82+ } else {
83+ ret = -EINVAL;
84+ goto out;
85+ }
86+ }
87+
88+ if (is_unix && !socket) {
89 ret = -EINVAL;
90 goto out;
91 }
92
93 if (is_unix) {
94- if (uri->server || uri->port) {
95+ if (!socket || uri->server || uri->port) {
96 ret = -EINVAL;
97 goto out;
98 }
99- if (strcmp(qp->p[0].name, "socket")) {
100- ret = -EINVAL;
101- goto out;
102- }
103- gconf->server = g_strdup(qp->p[0].value);
104+ gconf->server = g_strdup(socket);
105 } else {
106 gconf->server = g_strdup(uri->server ? uri->server : "localhost");
107 gconf->port = uri->port;
108@@ -176,7 +190,7 @@
109 ret = qemu_gluster_parseuri(gconf, filename);
110 if (ret < 0) {
111 error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
112- "volname/image[?socket=...]");
113+ "volname/image[?socket=...|?s2=...]");
114 errno = -ret;
115 goto out;
116 }
117@@ -192,6 +206,14 @@
118 goto out;
119 }
120
121+ if (gconf->backupserver) {
122+ ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver,
123+ gconf->port);
124+ if (ret < 0) {
125+ goto out;
126+ }
127+ }
128+
129 /*
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.