From patchwork Mon Jun 4 09:57:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 162720 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 B2AD0B6FAB for ; Mon, 4 Jun 2012 20:42:32 +1000 (EST) Received: from localhost ([::1]:38118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU3k-000177-NO for incoming@patchwork.ozlabs.org; Mon, 04 Jun 2012 05:58:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU32-0008TD-6g for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbU2q-0004cL-D8 for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:03 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:46505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU2p-0004at-UR for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:57:52 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 65A9248985; Mon, 4 Jun 2012 18:57:45 +0900 (JST) Received: (nullmailer pid 5107 invoked by uid 1000); Mon, 04 Jun 2012 09:57:44 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Mon, 4 Jun 2012 18:57:13 +0900 Message-Id: <62b3c00d2aa6c549dc39632d00c0f805f219bb1e.1338802192.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 210.128.90.3 Cc: benoit.hudzia@gmail.com, aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, t.hirofuchi@aist.go.jp, dlaor@redhat.com, satoshi.itoh@aist.go.jp, mdroth@linux.vnet.ibm.com, yoshikawa.takuya@oss.ntt.co.jp, owasserm@redhat.com, avi@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2 11/41] arch_init: factor out counting transferred bytes 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 Signed-off-by: Isaku Yamahata --- arch_init.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch_init.c b/arch_init.c index 73bf250..2617478 100644 --- a/arch_init.c +++ b/arch_init.c @@ -155,8 +155,9 @@ static int is_dup_page(uint8_t *page) } static RAMBlock *last_block_sent = NULL; +static uint64_t bytes_transferred; -int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) +static int ram_save_page_int(QEMUFile *f, RAMBlock *block, ram_addr_t offset) { MemoryRegion *mr = block->mr; uint8_t *p; @@ -192,6 +193,13 @@ int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) return TARGET_PAGE_SIZE; } +int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) +{ + int bytes_sent = ram_save_page_int(f, block, offset); + bytes_transferred += bytes_sent; + return bytes_sent; +} + static RAMBlock *last_block; static ram_addr_t last_offset; @@ -228,8 +236,6 @@ int ram_save_block(QEMUFile *f) return bytes_sent; } -static uint64_t bytes_transferred; - static ram_addr_t ram_save_remaining(void) { RAMBlock *block; @@ -357,11 +363,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) bwidth = qemu_get_clock_ns(rt_clock); while ((ret = qemu_file_rate_limit(f)) == 0) { - int bytes_sent; - - bytes_sent = ram_save_block(f); - bytes_transferred += bytes_sent; - if (bytes_sent == 0) { /* no more blocks */ + if (ram_save_block(f) == 0) { /* no more blocks */ break; } } @@ -381,11 +383,9 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) /* try transferring iterative blocks of memory */ if (stage == 3) { - int bytes_sent; - /* flush all remaining blocks regardless of rate limiting */ - while ((bytes_sent = ram_save_block(f)) != 0) { - bytes_transferred += bytes_sent; + while (ram_save_block(f) != 0) { + /* nothing */ } memory_global_dirty_log_stop(); }