]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/gluster-backupserver.patch
refer to the new repository
[pve-qemu-kvm.git] / debian / patches / gluster-backupserver.patch
1 Index: new/block/gluster.c
2 ===================================================================
3 --- new.orig/block/gluster.c 2014-08-26 11:48:49.000000000 +0200
4 +++ new/block/gluster.c 2014-08-26 12:51:53.000000000 +0200
5 @@ -26,6 +26,7 @@
6
7 typedef struct GlusterConf {
8 char *server;
9 + char *backupserver;
10 int port;
11 char *volname;
12 char *image;
13 @@ -36,6 +37,7 @@
14 {
15 if (gconf) {
16 g_free(gconf->server);
17 + g_free(gconf->backupserver);
18 g_free(gconf->volname);
19 g_free(gconf->image);
20 g_free(gconf->transport);
21 @@ -69,7 +71,7 @@
22 }
23
24 /*
25 - * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...]
26 + * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...]
27 *
28 * 'gluster' is the protocol.
29 *
30 @@ -85,6 +87,8 @@
31 * The 'socket' field needs to be populated with the path to unix domain
32 * socket.
33 *
34 + * 's2' can be used to specifies a second volfile server.
35 + *
36 * 'port' is the port number on which glusterd is listening. This is optional
37 * and if not specified, QEMU will send 0 which will make gluster to use the
38 * default port. If the transport type is unix, then 'port' should not be
39 @@ -97,6 +101,7 @@
40 * Examples:
41 *
42 * file=gluster://1.2.3.4/testvol/a.img
43 + * file=gluster://1.2.3.4/testvol/a.img?s2=1.2.3.5
44 * file=gluster+tcp://1.2.3.4/testvol/a.img
45 * file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img
46 * file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img
47 @@ -111,6 +116,8 @@
48 QueryParams *qp = NULL;
49 bool is_unix = false;
50 int ret = 0;
51 + int i;
52 + char *socket = NULL;
53
54 uri = uri_parse(filename);
55 if (!uri) {
56 @@ -138,21 +145,28 @@
57 }
58
59 qp = query_params_parse(uri->query);
60 - if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {
61 + for (i = 0; i < qp->n; i++) {
62 + if (!is_unix && strcmp(qp->p[i].name, "s2") == 0) {
63 + gconf->backupserver = g_strdup(qp->p[i].value);
64 + } else if (is_unix && strcmp(qp->p[i].name, "socket") == 0) {
65 + socket = qp->p[i].value;
66 + } else {
67 + ret = -EINVAL;
68 + goto out;
69 + }
70 + }
71 +
72 + if (is_unix && !socket) {
73 ret = -EINVAL;
74 goto out;
75 }
76
77 if (is_unix) {
78 - if (uri->server || uri->port) {
79 + if (!socket || uri->server || uri->port) {
80 ret = -EINVAL;
81 goto out;
82 }
83 - if (strcmp(qp->p[0].name, "socket")) {
84 - ret = -EINVAL;
85 - goto out;
86 - }
87 - gconf->server = g_strdup(qp->p[0].value);
88 + gconf->server = g_strdup(socket);
89 } else {
90 gconf->server = g_strdup(uri->server ? uri->server : "localhost");
91 gconf->port = uri->port;
92 @@ -176,7 +190,7 @@
93 ret = qemu_gluster_parseuri(gconf, filename);
94 if (ret < 0) {
95 error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
96 - "volname/image[?socket=...]");
97 + "volname/image[?socket=...|?s2=...]");
98 errno = -ret;
99 goto out;
100 }
101 @@ -192,6 +206,14 @@
102 goto out;
103 }
104
105 + if (gconf->backupserver) {
106 + ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver,
107 + gconf->port);
108 + if (ret < 0) {
109 + goto out;
110 + }
111 + }
112 +
113 /*
114 * TODO: Use GF_LOG_ERROR instead of hard code value of 4 here when
115 * GlusterFS makes GF_LOG_* macros available to libgfapi users.