From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH90s-0002kB-Tz for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VH90g-0007Pc-Nr for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:04:34 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:53402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH90g-0007PE-4j for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:04:22 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Sep 2013 18:53:30 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id B6D252BB0053 for ; Wed, 4 Sep 2013 19:04:13 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r848loZ150397236 for ; Wed, 4 Sep 2013 18:47:50 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r8494CJ8029513 for ; Wed, 4 Sep 2013 19:04:13 +1000 From: Lei Li Date: Wed, 4 Sep 2013 17:02:36 +0800 Message-Id: <1378285356-5308-4-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1378285356-5308-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1378285356-5308-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Lei Li , anthony@codemonkey.ws, mrhines@linux.vnet.ibm.com, quintela@redhat.com qemu_file_rate_limit() never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjust bytes_transferred and return value correspondingly in ram_save_iterate(). 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; } -- 1.7.7.6