From patchwork Tue Jun 19 15:43:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 165809 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 00FCBB700D for ; Wed, 20 Jun 2012 02:25:01 +1000 (EST) Received: from localhost ([::1]:59066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh1Eg-0007nX-Qq for incoming@patchwork.ozlabs.org; Tue, 19 Jun 2012 12:24:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh0c0-0001Oj-Ou for qemu-devel@nongnu.org; Tue, 19 Jun 2012 11:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sh0bu-0005He-Fn for qemu-devel@nongnu.org; Tue, 19 Jun 2012 11:45:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh0bu-0005HF-7t for qemu-devel@nongnu.org; Tue, 19 Jun 2012 11:44:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5JFiALS023914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 19 Jun 2012 11:44:10 -0400 Received: from dhcp-1-120.tlv.redhat.com (vpn-200-13.tlv.redhat.com [10.35.200.13]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5JFhCkY007577; Tue, 19 Jun 2012 11:44:04 -0400 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Tue, 19 Jun 2012 18:43:16 +0300 Message-Id: <1340120601-24747-9-git-send-email-owasserm@redhat.com> In-Reply-To: <1340120601-24747-1-git-send-email-owasserm@redhat.com> References: <1340120601-24747-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, Orit Wasserman , chegu_vinod@hp.com, avi@redhat.com, pbonzini@redhat.com, eblake@redhat.com Subject: [Qemu-devel] [PATCH v12 08/13] Change ram_save_block to return -1 if there are no more changes 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 It will return 0 if the page is unmodifed. Signed-off-by: Orit Wasserman --- arch_init.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch_init.c b/arch_init.c index fbed5ea..c9ab66a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -184,11 +184,11 @@ static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, static RAMBlock *last_block; static ram_addr_t last_offset; -static int ram_save_block(QEMUFile *f) +static int ram_save_block(QEMUFile *f, int stage) { RAMBlock *block = last_block; ram_addr_t offset = last_offset; - int bytes_sent = 0; + int bytes_sent = -1; MemoryRegion *mr; if (!block) @@ -353,9 +353,12 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) 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 */ + bytes_sent = ram_save_block(f, stage); + /* bytes_sent 0 represent unchanged page, + bytes_sent -1 represent no more blocks*/ + if (bytes_sent > 0) { + bytes_transferred += bytes_sent; + } else if (bytes_sent == -1) { /* no more blocks */ break; } } @@ -378,7 +381,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) int bytes_sent; /* flush all remaining blocks regardless of rate limiting */ - while ((bytes_sent = ram_save_block(f)) != 0) { + while ((bytes_sent = ram_save_block(f, stage)) != -1) { bytes_transferred += bytes_sent; } memory_global_dirty_log_stop();