From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0tCa-00013x-7k for qemu-devel@nongnu.org; Sun, 21 Jul 2013 08:57:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0tCV-0007fd-RN for qemu-devel@nongnu.org; Sun, 21 Jul 2013 08:57:28 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:35234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0tCV-0007e4-7H for qemu-devel@nongnu.org; Sun, 21 Jul 2013 08:57:23 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 21 Jul 2013 22:44:52 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 29EF5357804E for ; Sun, 21 Jul 2013 22:57:15 +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 r6LCfrTE8520180 for ; Sun, 21 Jul 2013 22:41:54 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6LCvD3A027768 for ; Sun, 21 Jul 2013 22:57:14 +1000 From: Lei Li Date: Sun, 21 Jul 2013 20:56:39 +0800 Message-Id: <1374411399-17535-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] 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: pbonzini@redhat.com, Lei Li , quintela@redhat.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 defination 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 e0491e7..f406790 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