qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 2/9] block: gluster - code movements, state storage changes
Date: Fri, 28 Feb 2014 19:33:36 +0100	[thread overview]
Message-ID: <1393612423-26267-3-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1393612423-26267-1-git-send-email-stefanha@redhat.com>

From: Jeff Cody <jcody@redhat.com>

In preparation for supporting reopen on gluster, move flag
parsing out to a function.  Also, add a NULL check in the
gconf cleanup.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/gluster.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index 14d390b..d09824d 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -45,11 +45,13 @@ typedef struct GlusterConf {
 
 static void qemu_gluster_gconf_free(GlusterConf *gconf)
 {
-    g_free(gconf->server);
-    g_free(gconf->volname);
-    g_free(gconf->image);
-    g_free(gconf->transport);
-    g_free(gconf);
+    if (gconf) {
+        g_free(gconf->server);
+        g_free(gconf->volname);
+        g_free(gconf->image);
+        g_free(gconf->transport);
+        g_free(gconf);
+    }
 }
 
 static int parse_volume_options(GlusterConf *gconf, char *path)
@@ -272,11 +274,28 @@ static QemuOptsList runtime_opts = {
     },
 };
 
+static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
+{
+    assert(open_flags != NULL);
+
+    *open_flags |= O_BINARY;
+
+    if (bdrv_flags & BDRV_O_RDWR) {
+        *open_flags |= O_RDWR;
+    } else {
+        *open_flags |= O_RDONLY;
+    }
+
+    if ((bdrv_flags & BDRV_O_NOCACHE)) {
+        *open_flags |= O_DIRECT;
+    }
+}
+
 static int qemu_gluster_open(BlockDriverState *bs,  QDict *options,
                              int bdrv_flags, Error **errp)
 {
     BDRVGlusterState *s = bs->opaque;
-    int open_flags = O_BINARY;
+    int open_flags = 0;
     int ret = 0;
     GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
     QemuOpts *opts;
@@ -299,15 +318,7 @@ static int qemu_gluster_open(BlockDriverState *bs,  QDict *options,
         goto out;
     }
 
-    if (bdrv_flags & BDRV_O_RDWR) {
-        open_flags |= O_RDWR;
-    } else {
-        open_flags |= O_RDONLY;
-    }
-
-    if ((bdrv_flags & BDRV_O_NOCACHE)) {
-        open_flags |= O_DIRECT;
-    }
+    qemu_gluster_parse_flags(bdrv_flags, &open_flags);
 
     s->fd = glfs_open(s->glfs, gconf->image, open_flags);
     if (!s->fd) {
-- 
1.8.5.3

  parent reply	other threads:[~2014-02-28 18:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 18:33 [Qemu-devel] [PULL 0/9] Block patches Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 1/9] qemu-iotests: add more tests to the "quick" group Stefan Hajnoczi
2014-02-28 18:33 ` Stefan Hajnoczi [this message]
2014-02-28 18:33 ` [Qemu-devel] [PULL 3/9] block: gluster - add reopen support Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 4/9] qmp: Fix BlockdevOptionQuorum Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 5/9] qmp: Make Quorum error events more palatable Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 6/9] qemu-io-test: Disable Quorum test when not compiled in Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 7/9] block: use /var/tmp instead of /tmp for -snapshot Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 8/9] discard rbd error output when not relevant in qemu-iotests Stefan Hajnoczi
2014-02-28 18:33 ` [Qemu-devel] [PULL 9/9] block/vmdk: do not report file offset for compressed extents Stefan Hajnoczi
2014-03-04 17:02 ` [Qemu-devel] [PULL 0/9] Block patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393612423-26267-3-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).