From patchwork Tue Jul 3 13:52:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 168819 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 14AEB2C00CA for ; Wed, 4 Jul 2012 00:11:30 +1000 (EST) Received: from localhost ([::1]:49103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm3Yl-0006PZ-Mz for incoming@patchwork.ozlabs.org; Tue, 03 Jul 2012 09:54:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm3Y4-0004PU-Ez for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sm3Xy-0004qh-6t for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm3Xx-0004qH-Vg for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:42 -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 q63DrbjW022197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Jul 2012 09:53:37 -0400 Received: from dhcp-1-120.tlv.redhat.com (vpn-200-144.tlv.redhat.com [10.35.200.144]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q63Dr3Xu004090; Tue, 3 Jul 2012 09:53:34 -0400 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2012 16:52:49 +0300 Message-Id: <1341323574-23206-9-git-send-email-owasserm@redhat.com> In-Reply-To: <1341323574-23206-1-git-send-email-owasserm@redhat.com> References: <1341323574-23206-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 v14 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 | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index ee20c33..e763909 100644 --- a/arch_init.c +++ b/arch_init.c @@ -188,7 +188,7 @@ static int ram_save_block(QEMUFile *f) { RAMBlock *block = last_block; ram_addr_t offset = last_offset; - int bytes_sent = 0; + int bytes_sent = -1; MemoryRegion *mr; if (!block) @@ -354,8 +354,11 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) int bytes_sent; bytes_sent = ram_save_block(f); - bytes_transferred += bytes_sent; - if (bytes_sent == 0) { /* no more blocks */ + /* 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)) != -1) { bytes_transferred += bytes_sent; } memory_global_dirty_log_stop();