From patchwork Wed Jun 20 08:02:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 165910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75E99B708D for ; Wed, 20 Jun 2012 18:03:22 +1000 (EST) Received: from localhost ([::1]:58733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShFsl-0001H3-NS for incoming@patchwork.ozlabs.org; Wed, 20 Jun 2012 04:03:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShFsU-0001Fc-L6 for qemu-devel@nongnu.org; Wed, 20 Jun 2012 04:03:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShFsO-0004W2-E7 for qemu-devel@nongnu.org; Wed, 20 Jun 2012 04:03:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShFsO-0004Vq-6B for qemu-devel@nongnu.org; Wed, 20 Jun 2012 04:02:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5K82sdM022389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Jun 2012 04:02:54 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-5-129.ams2.redhat.com [10.36.5.129]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5K82qi5023010; Wed, 20 Jun 2012 04:02:53 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 20 Jun 2012 10:02:51 +0200 Message-Id: <1340179371-8128-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, agraf@suse.de Subject: [Qemu-devel] [PATCH] raw-posix: Fix build without is_allocated support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move the declaration of s into the #ifdef sections that actually make use of it. Signed-off-by: Kevin Wolf Tested-by: Alexander Graf --- block/raw-posix.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index bf7700a..0dce089 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -606,7 +606,6 @@ static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - BDRVRawState *s = bs->opaque; off_t start, data, hole; int ret; @@ -616,11 +615,15 @@ static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs, } start = sector_num * BDRV_SECTOR_SIZE; + #ifdef CONFIG_FIEMAP + + BDRVRawState *s = bs->opaque; struct { struct fiemap fm; struct fiemap_extent fe; } f; + f.fm.fm_start = start; f.fm.fm_length = (int64_t)nb_sectors * BDRV_SECTOR_SIZE; f.fm.fm_flags = 0; @@ -643,7 +646,11 @@ static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs, data = f.fe.fe_logical; hole = f.fe.fe_logical + f.fe.fe_length; } + #elif defined SEEK_HOLE && defined SEEK_DATA + + BDRVRawState *s = bs->opaque; + hole = lseek(s->fd, start, SEEK_HOLE); if (hole == -1) { /* -ENXIO indicates that sector_num was past the end of the file.