qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Gerd Hoffmann <kraxel@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: kvm-devel <kvm@vger.kernel.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Nicholas Bellinger <nab@linux-iscsi.org>,
	Hannes Reinecke <hare@suse.de>, Christoph Hellwig <hch@lst.de>,
	Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH 2/5] [block]: Add BSG qemu_open() in block/raw.c:raw_open()
Date: Mon, 14 Jun 2010 02:44:24 -0700	[thread overview]
Message-ID: <1276508664-3043-1-git-send-email-nab@linux-iscsi.org> (raw)

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch adds a BSG specific qemu_open() call in block/raw.c:raw_open() that
saves the opened file descriptor for BSG AIO into BlockDriverState->fd.

It also adds the reverse close() call to block/raw.c:raw_close()

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 block/raw.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/block/raw.c b/block/raw.c
index 4406b8c..7820c78 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -5,7 +5,25 @@
 
 static int raw_open(BlockDriverState *bs, int flags)
 {
+    int fd, ret;
+
     bs->sg = bs->file->sg;
+    /*
+     * scsi-generic and other raw types do not call qemu_open()
+      */
+    if (bs->sg != BDS_BSG)
+        return 0;
+    /*
+     * Obtain a file descriptor for the underlying BSG device for AIO w/ iovecs
+     */
+    fd = qemu_open(bs->filename, flags, 0644);
+    if (fd < 0) {
+        ret = -errno;
+        if (ret == -EROFS)
+            ret = -EACCES;
+        return ret;
+    }
+    bs->fd = fd;
     return 0;
 }
 
@@ -37,6 +55,8 @@ static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
 
 static void raw_close(BlockDriverState *bs)
 {
+    if (bs->fd > 0)
+        close(bs->fd);
 }
 
 static void raw_flush(BlockDriverState *bs)
-- 
1.5.6.5

             reply	other threads:[~2010-06-14  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14  9:44 Nicholas A. Bellinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-11-24  8:40 [Qemu-devel] [PATCH 2/5] block: Add BSG qemu_open() in block/raw.c:raw_open() Nicholas A. Bellinger

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=1276508664-3043-1-git-send-email-nab@linux-iscsi.org \
    --to=nab@linux-iscsi.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=paul@codesourcery.com \
    --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).