From patchwork Mon May 17 16:46:04 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: 52752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8882AB7D91 for ; Mon, 17 May 2010 13:01:35 +1000 (EST) Received: from localhost ([127.0.0.1]:36103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ODqaC-0007yx-NV for incoming@patchwork.ozlabs.org; Sun, 16 May 2010 23:01:32 -0400 Received: from [140.186.70.92] (port=56870 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ODqXb-00073O-6q for qemu-devel@nongnu.org; Sun, 16 May 2010 22:58:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ODqXa-0001rq-36 for qemu-devel@nongnu.org; Sun, 16 May 2010 22:58:51 -0400 Received: from smtp125.sbc.mail.sp1.yahoo.com ([69.147.65.184]:26456) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1ODqXZ-0001re-Oi for qemu-devel@nongnu.org; Sun, 16 May 2010 22:58:50 -0400 Received: (qmail 5954 invoked from network); 17 May 2010 02:58:48 -0000 Received: from adsl-70-231-246-220.dsl.snfc21.sbcglobal.net (nab@70.231.246.220 with login) by smtp125.sbc.mail.sp1.yahoo.com with SMTP; 16 May 2010 19:58:48 -0700 PDT X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: n43B8uYVM1np3zoZCLU4wwpk3FCOH1EoQOutjDr6gurioIZNLeOGL5tdFWbh6laDm0N0iDyT4UxXAnIyLqGeCEHqp7wqzt5htdh..gnC7lua17n2U_OJIuyjWlLIcTEWF_feTMT.yWFmE3QLAMV4YxY7n7e1eHugRHPjrW3oDD9gM.WdoN0MuM5BF69PMawBznDGxDFy2kC4z7J8VZGadJ_93s2h4uB0ElxN6RR3YhIrd_J5DneLqhgVXJQWwY7CRROog_s9bbTEh9h5Zh3.pdaqREcWT1F8bCVTf3RS0z9U5R3qjQQ22AKg2BimxKmiGKBYcgd.12NhTceMTPwOTY6e0yNb_JSubQUE_VwLnLgpvg-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: Kevin Wolf , Christoph Hellwig , Gerd Hoffmann , Hannes Reinecke , kvm-devel , qemu-devel Date: Mon, 17 May 2010 09:46:04 -0700 Message-Id: <1274114764-27975-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) Cc: Nicholas Bellinger Subject: [Qemu-devel] [PATCH 2/2] [block]: Add SG_IO device check in refresh_total_sectors() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Nicholas Bellinger This patch adds a special case check for scsi-generic devices in refresh_total_sectors() to skip the subsequent BlockDriver->bdrv_getlength() that will be returning -ESPIPE from block/raw-posic.c:raw_getlength() for BlockDriverState->sg=1 devices. Signed-off-by: Nicholas A. Bellinger --- block.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index f419ee6..7917712 100644 --- a/block.c +++ b/block.c @@ -364,6 +364,10 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint) { BlockDriver *drv = bs->drv; + /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */ + if (bs->sg) + return 0; + /* query actual device if possible, otherwise just trust the hint */ if (drv->bdrv_getlength) { int64_t length = drv->bdrv_getlength(bs);