From patchwork Mon Jun 14 09:44:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 105905 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5E9iNma029234 for ; Mon, 14 Jun 2010 09:44:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755662Ab0FNJoA (ORCPT ); Mon, 14 Jun 2010 05:44:00 -0400 Received: from smtp110.sbc.mail.gq1.yahoo.com ([67.195.14.95]:30353 "HELO smtp110.sbc.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753234Ab0FNJn7 (ORCPT ); Mon, 14 Jun 2010 05:43:59 -0400 Received: (qmail 34376 invoked from network); 14 Jun 2010 09:43:58 -0000 Received: from adsl-70-231-239-201.dsl.snfc21.sbcglobal.net (nab@70.231.239.201 with login) by smtp110.sbc.mail.gq1.yahoo.com with SMTP; 14 Jun 2010 02:43:58 -0700 PDT X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: 3xcSNTYVM1kBDQW0eURKfwR.6wShoq_bxtIyWWSSW3zTWmqTxa9O0292tEIgGYos_f1DlKRJNZNHQ3v53JqVdHS6wsqgWYUyoBojMQ_F9guV.CKhel_A1xT.Gvx9Qxi4PwXsoBUGD11z506IspxcMy1YS3O2m6z5P7WPfzTUyg1QEWGsvILHq4KV329X6YpKRR7gfoK1HD6TnUj1SsVGLLmeEKeBh9EeEfExEP_7ABDbuq7bolOM_nO4z.cRJ72v5Zynz2M2xyJTOAstLR55ejD3Pw2M5mnShauAZG2D8PHgWLRJ5fmjFyPGBqeYzm3u3WUCcSuKNQn_ViQBI4KOrYVWl0g2zUe.YUVA_hD_aGDjhw-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: Gerd Hoffmann , Kevin Wolf , FUJITA Tomonori Cc: Hannes Reinecke , Paul Brook , Christoph Hellwig , kvm-devel , qemu-devel , Nicholas Bellinger Subject: [PATCH 2/5] [block]: Add BSG qemu_open() in block/raw.c:raw_open() Date: Mon, 14 Jun 2010 02:44:24 -0700 Message-Id: <1276508664-3043-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 14 Jun 2010 09:44:23 +0000 (UTC) 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)