From patchwork Thu Jan 24 18:02:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishvananda Ishaya X-Patchwork-Id: 215462 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 381562C00B2 for ; Fri, 25 Jan 2013 05:02:39 +1100 (EST) Received: from localhost ([::1]:43263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyR8H-0000d7-Cz for incoming@patchwork.ozlabs.org; Thu, 24 Jan 2013 13:02:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyR82-0000d1-Ud for qemu-devel@nongnu.org; Thu, 24 Jan 2013 13:02:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyR7x-0008SK-3m for qemu-devel@nongnu.org; Thu, 24 Jan 2013 13:02:22 -0500 Received: from mail-pb0-f54.google.com ([209.85.160.54]:36553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyR7w-0008S9-Tf; Thu, 24 Jan 2013 13:02:17 -0500 Received: by mail-pb0-f54.google.com with SMTP id rr4so3754178pbb.41 for ; Thu, 24 Jan 2013 10:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=HkZoMm5U+rx9jQjIHjxUlU6dQkBWpz+0oNxEmFaYCLk=; b=YJBCJwhfrOujsIMtRJGrYYTCY0pZv80OGKiXGzWD41fN2JZKq2SNnhne1nlLwM3M9S PopcuGckm1ZLp7FuXXXZqY8mRvApBhJtrMTdpXoORsHwAAyQ/wF9uDDL/GSixhBQoaIX gM2bccvsHpmXZvI4WprlQDiPiE13NBoZevxeJCNCGo0qw1o3YYNboRuS9VvCzJnIn5CR ZmIVNarVvqicxYVNmJhak9ax4O5lKHfKbWoCVkYZGvIvQTtziXZDdpSaDZtht9i72J+O fR3CsTMxrFr7YrqiZv6OE/17wMDSKKRmiCtgipUhQJZa7IzdYGCGdIibTCBb6FbZHiaO pImQ== X-Received: by 10.68.135.40 with SMTP id pp8mr7247222pbb.63.1359050535961; Thu, 24 Jan 2013 10:02:15 -0800 (PST) Received: from localhost.localdomain (108-71-89-7.lightspeed.sntcca.sbcglobal.net. [108.71.89.7]) by mx.google.com with ESMTPS id qt3sm15256963pbb.32.2013.01.24.10.02.14 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jan 2013 10:02:15 -0800 (PST) From: Vishvananda Ishaya To: qemu-devel@nongnu.org Date: Thu, 24 Jan 2013 10:02:08 -0800 Message-Id: <1359050528-52668-1-git-send-email-vishvananda@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.54 Cc: qemu-trivial@nongnu.org, Kevin Wolf , Vishvananda Ishaya , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] block: Fix is_allocated_above with resized files 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 In an image chain, if the base image is smaller than the current image, we need to make sure to use the current images count of unallocated blocks once we get to the end of the base image. Without this change the code will return 0 blocks when it gets to the end of the base image and mirror_run will fail its assertion. Signed-off-by: Vishvananda Ishaya --- Fixes https://bugs.launchpad.net/qemu/+bug/1103868 block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 6fa7c90..6474d9e 100644 --- a/block.c +++ b/block.c @@ -2831,7 +2831,9 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top, * * [sector_num+x, nr_sectors] allocated. */ - if (n > pnum_inter) { + if (n > pnum_inter && + (intermediate == top || + sector_num + pnum_inter < intermediate->total_sectors)) { n = pnum_inter; }