From patchwork Mon Nov 30 17:21:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 39841 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 332031007D2 for ; Tue, 1 Dec 2009 05:11:54 +1100 (EST) Received: from localhost ([127.0.0.1]:43076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFAj0-0001eJ-JF for incoming@patchwork.ozlabs.org; Mon, 30 Nov 2009 13:11:50 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFA2n-0003t2-0k for qemu-devel@nongnu.org; Mon, 30 Nov 2009 12:28:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFA2c-0003jN-27 for qemu-devel@nongnu.org; Mon, 30 Nov 2009 12:28:04 -0500 Received: from [199.232.76.173] (port=36087 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFA2Y-0003iL-8N for qemu-devel@nongnu.org; Mon, 30 Nov 2009 12:27:58 -0500 Received: from david.siemens.de ([192.35.17.14]:22234) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NFA2X-0004gE-7K for qemu-devel@nongnu.org; Mon, 30 Nov 2009 12:27:57 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nAUHRqbC025488; Mon, 30 Nov 2009 18:27:52 +0100 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id nAUHRoMN001975; Mon, 30 Nov 2009 18:27:51 +0100 Resent-From: Jan Kiszka Resent-To: Anthony Liguori Resent-Cc: qemu-devel , Liran Schour , Pierre Riteau Resent-Date: Mon, 30 Nov 2009 18:27:50 +0100 Resent-Message-Id: <4B140096.8050103@siemens.com> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 From: Jan Kiszka To: Anthony Liguori Date: Mon, 30 Nov 2009 18:21:20 +0100 Message-ID: <20091130172120.22889.64304.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20091130172119.22889.28114.stgit@mchn012c.ww002.siemens.net> References: <20091130172119.22889.28114.stgit@mchn012c.ww002.siemens.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Resent-Date: Mon, 30 Nov 2009 12:28:04 -0500 Cc: qemu-devel@nongnu.org, Liran Schour , Pierre Riteau Subject: [Qemu-devel] [PATCH 12/23] block migration: Clean up use of 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 We already save total_sectors in BlkMigDevState, let's use this value during the migration and avoid to recalculate it needlessly. Signed-off-by: Jan Kiszka --- block-migration.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block-migration.c b/block-migration.c index ec32ee2..2f89a4e 100644 --- a/block-migration.c +++ b/block-migration.c @@ -96,10 +96,10 @@ static int mig_read_device_bulk(QEMUFile *f, BlkMigDevState *bms) blk->buf = qemu_malloc(BLOCK_SIZE); cur_sector = bms->cur_sector; - total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; + total_sectors = bms->total_sectors; if (bms->shared_base) { - while (cur_sector < bms->total_sectors && + while (cur_sector < total_sectors && !bdrv_is_allocated(bms->bs, cur_sector, MAX_IS_ALLOCATED_SEARCH, &nr_sectors)) { cur_sector += nr_sectors; @@ -165,7 +165,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds) cur_sector = bmds->cur_sector; if (bmds->shared_base) { - while (cur_sector < bmds->total_sectors && + while (cur_sector < total_sectors && !bdrv_is_allocated(bmds->bs, cur_sector, MAX_IS_ALLOCATED_SEARCH, &nr_sectors)) { cur_sector += nr_sectors;