Blame SOURCES/kvm-block-gluster-code-movements-state-storage-changes.patch

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