From: Dietmar Maurer Date: Tue, 26 Aug 2014 10:53:39 +0000 (+0200) Subject: gluster: allow to specify a backup server X-Git-Url: https://git.proxmox.com/?p=pve-qemu-kvm.git;a=commitdiff_plain;h=4f7586cfdf97acf0462592f119da12bcb1b78394 gluster: allow to specify a backup server --- diff --git a/debian/patches/gluster-backupserver.patch b/debian/patches/gluster-backupserver.patch new file mode 100644 index 0000000..ad241ee --- /dev/null +++ b/debian/patches/gluster-backupserver.patch @@ -0,0 +1,115 @@ +Index: new/block/gluster.c +=================================================================== +--- new.orig/block/gluster.c 2014-08-26 11:48:49.000000000 +0200 ++++ new/block/gluster.c 2014-08-26 12:51:53.000000000 +0200 +@@ -26,6 +26,7 @@ + + typedef struct GlusterConf { + char *server; ++ char *backupserver; + int port; + char *volname; + char *image; +@@ -36,6 +37,7 @@ + { + if (gconf) { + g_free(gconf->server); ++ g_free(gconf->backupserver); + g_free(gconf->volname); + g_free(gconf->image); + g_free(gconf->transport); +@@ -69,7 +71,7 @@ + } + + /* +- * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...] ++ * file=gluster[+transport]://[server[:port]]/volname/image[?socket=...|?s2=...] + * + * 'gluster' is the protocol. + * +@@ -85,6 +87,8 @@ + * The 'socket' field needs to be populated with the path to unix domain + * socket. + * ++ * 's2' can be used to specifies a second volfile server. ++ * + * 'port' is the port number on which glusterd is listening. This is optional + * and if not specified, QEMU will send 0 which will make gluster to use the + * default port. If the transport type is unix, then 'port' should not be +@@ -97,6 +101,7 @@ + * Examples: + * + * file=gluster://1.2.3.4/testvol/a.img ++ * file=gluster://1.2.3.4/testvol/a.img?s2=1.2.3.5 + * file=gluster+tcp://1.2.3.4/testvol/a.img + * file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img + * file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img +@@ -111,6 +116,8 @@ + QueryParams *qp = NULL; + bool is_unix = false; + int ret = 0; ++ int i; ++ char *socket = NULL; + + uri = uri_parse(filename); + if (!uri) { +@@ -138,21 +145,28 @@ + } + + qp = query_params_parse(uri->query); +- if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) { ++ for (i = 0; i < qp->n; i++) { ++ if (!is_unix && strcmp(qp->p[i].name, "s2") == 0) { ++ gconf->backupserver = g_strdup(qp->p[i].value); ++ } else if (is_unix && strcmp(qp->p[i].name, "socket") == 0) { ++ socket = qp->p[i].value; ++ } else { ++ ret = -EINVAL; ++ goto out; ++ } ++ } ++ ++ if (is_unix && !socket) { + ret = -EINVAL; + goto out; + } + + if (is_unix) { +- if (uri->server || uri->port) { ++ if (!socket || uri->server || uri->port) { + ret = -EINVAL; + goto out; + } +- if (strcmp(qp->p[0].name, "socket")) { +- ret = -EINVAL; +- goto out; +- } +- gconf->server = g_strdup(qp->p[0].value); ++ gconf->server = g_strdup(socket); + } else { + gconf->server = g_strdup(uri->server ? uri->server : "localhost"); + gconf->port = uri->port; +@@ -176,7 +190,7 @@ + ret = qemu_gluster_parseuri(gconf, filename); + if (ret < 0) { + error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/" +- "volname/image[?socket=...]"); ++ "volname/image[?socket=...|?s2=...]"); + errno = -ret; + goto out; + } +@@ -192,6 +206,14 @@ + goto out; + } + ++ if (gconf->backupserver) { ++ ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->backupserver, ++ gconf->port); ++ if (ret < 0) { ++ goto out; ++ } ++ } ++ + /* + * TODO: Use GF_LOG_ERROR instead of hard code value of 4 here when + * GlusterFS makes GF_LOG_* macros available to libgfapi users. diff --git a/debian/patches/series b/debian/patches/series index 72c4dde..1381414 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -26,3 +26,4 @@ internal-snapshot-async.patch disable-efi-enable-pxe-roms.patch backup-vma-allow-empty-backups.patch glusterfs-daemonize.patch +gluster-backupserver.patch