|
|
9ae3a8 |
From 8c40036dd1ac888d9565d6d96c8478a00bce696b Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 6 Mar 2014 21:13:14 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 04/16] block: gluster - code movements, state storage changes
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Message-id: <8b4867e7eb4ab7db9f9e7900570daf718e62851d.1394129674.git.jcody@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58040
|
|
|
9ae3a8 |
O-Subject: [RHEL7 qemu-kvm PATCH 1/2] block: gluster - code movements, state storage changes
|
|
|
9ae3a8 |
Bugzilla: 1031526
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In preparation for supporting reopen on gluster, move flag
|
|
|
9ae3a8 |
parsing out to a function. Also, add a NULL check in the
|
|
|
9ae3a8 |
gconf cleanup.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 1b37b3442f78a77844fdaf7f53e5f04e4ce8f1d6)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/gluster.c | 41 ++++++++++++++++++++++++++---------------
|
|
|
9ae3a8 |
1 file changed, 26 insertions(+), 15 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/gluster.c | 41 ++++++++++++++++++++++++++---------------
|
|
|
9ae3a8 |
1 files changed, 26 insertions(+), 15 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/gluster.c b/block/gluster.c
|
|
|
9ae3a8 |
index bf39264..95cb05a 100644
|
|
|
9ae3a8 |
--- a/block/gluster.c
|
|
|
9ae3a8 |
+++ b/block/gluster.c
|
|
|
9ae3a8 |
@@ -50,11 +50,13 @@ typedef struct GlusterConf {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void qemu_gluster_gconf_free(GlusterConf *gconf)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- g_free(gconf->server);
|
|
|
9ae3a8 |
- g_free(gconf->volname);
|
|
|
9ae3a8 |
- g_free(gconf->image);
|
|
|
9ae3a8 |
- g_free(gconf->transport);
|
|
|
9ae3a8 |
- g_free(gconf);
|
|
|
9ae3a8 |
+ if (gconf) {
|
|
|
9ae3a8 |
+ g_free(gconf->server);
|
|
|
9ae3a8 |
+ g_free(gconf->volname);
|
|
|
9ae3a8 |
+ g_free(gconf->image);
|
|
|
9ae3a8 |
+ g_free(gconf->transport);
|
|
|
9ae3a8 |
+ g_free(gconf);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int parse_volume_options(GlusterConf *gconf, char *path)
|
|
|
9ae3a8 |
@@ -296,11 +298,28 @@ static QemuOptsList runtime_opts = {
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ assert(open_flags != NULL);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ *open_flags |= O_BINARY;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (bdrv_flags & BDRV_O_RDWR) {
|
|
|
9ae3a8 |
+ *open_flags |= O_RDWR;
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ *open_flags |= O_RDONLY;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if ((bdrv_flags & BDRV_O_NOCACHE)) {
|
|
|
9ae3a8 |
+ *open_flags |= O_DIRECT;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
|
|
9ae3a8 |
int bdrv_flags, Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVGlusterState *s = bs->opaque;
|
|
|
9ae3a8 |
- int open_flags = O_BINARY;
|
|
|
9ae3a8 |
+ int open_flags = 0;
|
|
|
9ae3a8 |
int ret = 0;
|
|
|
9ae3a8 |
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
|
|
|
9ae3a8 |
QemuOpts *opts;
|
|
|
9ae3a8 |
@@ -325,15 +344,7 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (bdrv_flags & BDRV_O_RDWR) {
|
|
|
9ae3a8 |
- open_flags |= O_RDWR;
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- open_flags |= O_RDONLY;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if ((bdrv_flags & BDRV_O_NOCACHE)) {
|
|
|
9ae3a8 |
- open_flags |= O_DIRECT;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ qemu_gluster_parse_flags(bdrv_flags, &open_flags);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->fd = glfs_open(s->glfs, gconf->image, open_flags);
|
|
|
9ae3a8 |
if (!s->fd) {
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|