From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC2ib-0000HN-DK for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VC2iS-0000vl-EZ for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:20:37 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:35596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC2iR-0000vI-DA for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:20:28 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Aug 2013 12:41:25 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id BD50E3940058 for ; Wed, 21 Aug 2013 12:50:12 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7L7KIa144564512 for ; Wed, 21 Aug 2013 12:50:18 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7L7KKdc025668 for ; Wed, 21 Aug 2013 12:50:21 +0530 From: Lei Li Date: Wed, 21 Aug 2013 15:18:41 +0800 Message-Id: <1377069536-12658-5-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 04/18] savevm: set right return value for qemu_file_rate_limit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, aliguori@us.ibm.com, Lei Li , quintela@redhat.com, mrhines@linux.vnet.ibm.com, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com Commit 1964a397063967acc5ce71a2a24ed26e74824ee1 refactors rate limiting to QEMUFile, but set the return value for qemu_file_rate_limit to 1 in the case of qemu_file_get_error. It is wrong and should be negative compared to the original function buffered_rate_limit and the current logic in ram_save_iterate. As qemu_file_rate_limit is called manually to determine if it has to exit, add the definition of the meaning of the return values as well. Signed-off-by: Lei Li --- savevm.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/savevm.c b/savevm.c index 68552a7..6362275 100644 --- a/savevm.c +++ b/savevm.c @@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f) return f->pos; } +/* + * The meaning of the return values is: + * 0: We can continue sending + * 1: Time to stop + * negative: There has been an error + */ + int qemu_file_rate_limit(QEMUFile *f) { - if (qemu_file_get_error(f)) { - return 1; + int ret; + + ret = qemu_file_get_error(f); + if (ret) { + return ret; } if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) { return 1; -- 1.7.7.6