From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21JY-0006gz-6b for qemu-devel@nongnu.org; Wed, 24 Jul 2013 11:49:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V21JV-0006Ye-0Q for qemu-devel@nongnu.org; Wed, 24 Jul 2013 11:49:20 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:52901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21JU-0006Y6-AN for qemu-devel@nongnu.org; Wed, 24 Jul 2013 11:49:16 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 24 Jul 2013 21:10:37 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id D7692394002D for ; Wed, 24 Jul 2013 21:19:01 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6OFo0aq30015632 for ; Wed, 24 Jul 2013 21:20:00 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6OFn67e004226 for ; Thu, 25 Jul 2013 01:49:06 +1000 Message-ID: <51EFF74D.7050805@linux.vnet.ibm.com> Date: Wed, 24 Jul 2013 23:48:29 +0800 From: Lei Li MIME-Version: 1.0 References: <1374411399-17535-1-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1374411399-17535-1-git-send-email-lilei@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [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: pbonzini@redhat.com, qemu-devel Cc: Lei Li , quintela@redhat.com In the logic of ram_save_iterate(), it checks the ret of qemu_file_rate_limit(f) by ret < 0 if there has been an error. But now it will never return negative value because qemu_file_rate_limit() return 1 if qemu_file_get_error(). Also the original implementation of qemu_file_rate_limit() as function buffered_rate_limit() did return negative for this situation. On 07/21/2013 08:56 PM, Lei Li wrote: > 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; -- Lei