From patchwork Fri Apr 9 14:22:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 49852 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 DABA9B7CF7 for ; Sat, 10 Apr 2010 01:59:16 +1000 (EST) Received: from localhost ([127.0.0.1]:39922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0GPV-0007P4-EI for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2010 11:46:21 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0F5c-0004pB-NC for qemu-devel@nongnu.org; Fri, 09 Apr 2010 10:21:44 -0400 Received: from [140.186.70.92] (port=43213 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0F5a-0004mc-0w for qemu-devel@nongnu.org; Fri, 09 Apr 2010 10:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0F5X-0006Uk-E3 for qemu-devel@nongnu.org; Fri, 09 Apr 2010 10:21:41 -0400 Received: from mtagate3.de.ibm.com ([195.212.17.163]:44960) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0F5X-0006UF-5K for qemu-devel@nongnu.org; Fri, 09 Apr 2010 10:21:39 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.1/8.13.1) with ESMTP id o39ELbc2014292 for ; Fri, 9 Apr 2010 14:21:37 GMT Received: from d12av03.megacenter.de.ibm.com (d12av03.megacenter.de.ibm.com [9.149.165.213]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o39ELbcI1708270 for ; Fri, 9 Apr 2010 16:21:37 +0200 Received: from d12av03.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o39ELb55030349 for ; Fri, 9 Apr 2010 16:21:37 +0200 Received: from localhost.localdomain (dyn-9-174-219-79.manchester-maybrook.uk.ibm.com [9.174.219.79]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o39ELalG030332; Fri, 9 Apr 2010 16:21:37 +0200 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Fri, 9 Apr 2010 15:22:13 +0100 Message-Id: <1270822934-8623-2-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1270822934-8623-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1270822934-8623-1-git-send-email-stefanha@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Fri, 09 Apr 2010 11:39:33 -0400 Cc: Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/2] block: Do not export bdrv_first 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 The bdrv_first linked list of BlockDriverStates is currently extern so that block migration can iterate the list. However, since there is already a bdrv_iterate() function there is no need to expose bdrv_first. Signed-off-by: Stefan Hajnoczi --- block-migration.c | 63 +++++++++++++++++++++++++++------------------------- block.c | 2 +- block_int.h | 2 - 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/block-migration.c b/block-migration.c index 92349a2..7d04d6d 100644 --- a/block-migration.c +++ b/block-migration.c @@ -230,12 +230,42 @@ static void set_dirty_tracking(int enable) } } -static void init_blk_migration(Monitor *mon, QEMUFile *f) +static void init_blk_migration_it(void *opaque, BlockDriverState *bs) { + Monitor *mon = opaque; BlkMigDevState *bmds; - BlockDriverState *bs; int64_t sectors; + if (bs->type == BDRV_TYPE_HD) { + sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; + if (sectors == 0) { + return; + } + + bmds = qemu_mallocz(sizeof(BlkMigDevState)); + bmds->bs = bs; + bmds->bulk_completed = 0; + bmds->total_sectors = sectors; + bmds->completed_sectors = 0; + bmds->shared_base = block_mig_state.shared_base; + + block_mig_state.total_sector_sum += sectors; + + if (bmds->shared_base) { + monitor_printf(mon, "Start migration for %s with shared base " + "image\n", + bs->device_name); + } else { + monitor_printf(mon, "Start full migration for %s\n", + bs->device_name); + } + + QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry); + } +} + +static void init_blk_migration(Monitor *mon, QEMUFile *f) +{ block_mig_state.submitted = 0; block_mig_state.read_done = 0; block_mig_state.transferred = 0; @@ -245,34 +275,7 @@ static void init_blk_migration(Monitor *mon, QEMUFile *f) block_mig_state.total_time = 0; block_mig_state.reads = 0; - for (bs = bdrv_first; bs != NULL; bs = bs->next) { - if (bs->type == BDRV_TYPE_HD) { - sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; - if (sectors == 0) { - continue; - } - - bmds = qemu_mallocz(sizeof(BlkMigDevState)); - bmds->bs = bs; - bmds->bulk_completed = 0; - bmds->total_sectors = sectors; - bmds->completed_sectors = 0; - bmds->shared_base = block_mig_state.shared_base; - - block_mig_state.total_sector_sum += sectors; - - if (bmds->shared_base) { - monitor_printf(mon, "Start migration for %s with shared base " - "image\n", - bs->device_name); - } else { - monitor_printf(mon, "Start full migration for %s\n", - bs->device_name); - } - - QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry); - } - } + bdrv_iterate(init_blk_migration_it, mon); } static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f) diff --git a/block.c b/block.c index ed4c819..61da183 100644 --- a/block.c +++ b/block.c @@ -55,7 +55,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); -BlockDriverState *bdrv_first; +static BlockDriverState *bdrv_first; static BlockDriver *first_drv; diff --git a/block_int.h b/block_int.h index e7e1e7e..d5a808d 100644 --- a/block_int.h +++ b/block_int.h @@ -200,8 +200,6 @@ void qemu_aio_release(void *p); void *qemu_blockalign(BlockDriverState *bs, size_t size); -extern BlockDriverState *bdrv_first; - #ifdef _WIN32 int is_windows_drive(const char *filename); #endif