From patchwork Thu May 20 13:10:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 53067 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 E0DB5B7D30 for ; Thu, 20 May 2010 23:20:20 +1000 (EST) Received: from localhost ([127.0.0.1]:46725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5fd-0006Es-TE for incoming@patchwork.ozlabs.org; Thu, 20 May 2010 09:20:17 -0400 Received: from [140.186.70.92] (port=33332 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5XD-0000nW-8I for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF5Wy-00073j-T3 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48594) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OF5Wy-00073X-Dq for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:20 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4KDBH6W015472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 May 2010 09:11:18 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4KDB1Nb004450; Thu, 20 May 2010 09:11:12 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Thu, 20 May 2010 15:10:41 +0200 Message-Id: <1274361043-25862-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1274361043-25862-1-git-send-email-kwolf@redhat.com> References: <1274361043-25862-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 6/8] 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 Signed-off-by: Kevin Wolf --- block.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 6a95768..0b0966c 100644 --- a/block.c +++ b/block.c @@ -361,6 +361,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);