From patchwork Mon Aug 26 09:29:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Li X-Patchwork-Id: 269838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 026062C00A8 for ; Mon, 26 Aug 2013 19:31:35 +1000 (EST) Received: from localhost ([::1]:50241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDt92-0002qh-Hf for incoming@patchwork.ozlabs.org; Mon, 26 Aug 2013 05:31:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDt8Z-0002qU-MF for qemu-devel@nongnu.org; Mon, 26 Aug 2013 05:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDt8Q-0003dV-OY for qemu-devel@nongnu.org; Mon, 26 Aug 2013 05:31:03 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:51416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDt8Q-0003dF-55 for qemu-devel@nongnu.org; Mon, 26 Aug 2013 05:30:54 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Aug 2013 19:19:41 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 26 Aug 2013 19:19:39 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 1DB182BB0052 for ; Mon, 26 Aug 2013 19:30:49 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7Q9EjLD6095276 for ; Mon, 26 Aug 2013 19:14:45 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7Q9UlkL020643 for ; Mon, 26 Aug 2013 19:30:48 +1000 Received: from localhost.cn.ibm.com ([9.115.122.43]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r7Q9Ugpl020517; Mon, 26 Aug 2013 19:30:46 +1000 From: Lei Li To: qemu-devel@nongnu.org Date: Mon, 26 Aug 2013 17:29:28 +0800 Message-Id: <1377509368-24921-3-git-send-email-lilei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1377509368-24921-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1377509368-24921-1-git-send-email-lilei@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13082609-6102-0000-0000-00000412D275 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.145 Cc: pbonzini@redhat.com, anthony@codemonkey.ws, mrhines@linux.vnet.ibm.com, Lei Li Subject: [Qemu-devel] [PATCH 3/3 v2] arch_init: right return for ram_save_iterate 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: Lei Li Signed-off-by: Paolo Bonzini --- Change since v1: Return fixes and improvement from Paolo Bonzini. arch_init.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch_init.c b/arch_init.c index 94d45e1..a26bc89 100644 --- a/arch_init.c +++ b/arch_init.c @@ -709,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) */ ram_control_after_iterate(f, RAM_CONTROL_ROUND); + bytes_transferred += total_sent; + + /* + * Do not count these 8 bytes into total_sent, so that we can + * return 0 if no page had been dirtied. + */ + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + bytes_transferred += 8; + + ret = qemu_file_get_error(f); if (ret < 0) { - bytes_transferred += total_sent; return ret; } - qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - total_sent += 8; - bytes_transferred += total_sent; - return total_sent; }