From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoIcB-00012W-1x for qemu-devel@nongnu.org; Mon, 09 Jul 2012 14:23:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoIc9-0005BK-Az for qemu-devel@nongnu.org; Mon, 09 Jul 2012 14:23:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoIc9-0005B2-2n for qemu-devel@nongnu.org; Mon, 09 Jul 2012 14:23:17 -0400 From: Orit Wasserman Date: Mon, 9 Jul 2012 21:22:46 +0300 Message-Id: <1341858170-1903-6-git-send-email-owasserm@redhat.com> In-Reply-To: <1341858170-1903-1-git-send-email-owasserm@redhat.com> References: <1341858170-1903-1-git-send-email-owasserm@redhat.com> Subject: [Qemu-devel] [PATCH v16 5/9] Change ram_save_block to return -1 if there are no more changes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 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 9fd6346..e36899e 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) @@ -349,8 +349,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; } /* we want to check in the 1st loop, just in case it was the 1st time @@ -387,7 +390,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; } migration_end(); -- 1.7.7.6