From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VChv0-0002aE-9C for qemu-devel@nongnu.org; Thu, 22 Aug 2013 23:20:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VChur-0001iT-2l for qemu-devel@nongnu.org; Thu, 22 Aug 2013 23:20:10 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:51593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VChuq-0001hA-Gz for qemu-devel@nongnu.org; Thu, 22 Aug 2013 23:20:01 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 23 Aug 2013 13:11:27 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 119822CE804D for ; Fri, 23 Aug 2013 13:19:53 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7N3JXF97602558 for ; Fri, 23 Aug 2013 13:19:41 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7N3JigA010612 for ; Fri, 23 Aug 2013 13:19:44 +1000 Message-ID: <5216D488.2090305@linux.vnet.ibm.com> Date: Fri, 23 Aug 2013 11:18:32 +0800 From: Lei Li MIME-Version: 1.0 References: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> <1377069536-12658-5-git-send-email-lilei@linux.vnet.ibm.com> <52149998.7070004@redhat.com> In-Reply-To: <52149998.7070004@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [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: Paolo Bonzini Cc: aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, mrhines@linux.vnet.ibm.com, lagarcia@br.ibm.com, rcj@linux.vnet.ibm.com On 08/21/2013 06:42 PM, Paolo Bonzini wrote: > Il 21/08/2013 09:18, Lei Li ha scritto: >> 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. > When there is an error it returns "time to stop" so that ultimately we > get to the migration_thread function and check qemu_file_get_error there. > > Why doesn't this work for you? Hi Paolo, Say, In ram_save_iterate(), the current logic is: ret = qemu_file_rate_limit(); while(ret == 0) { save RAM blocks until no more to send. } if (ret < 0) { return ret; } ... And in savevm layer, qemu_savevm_state_iterate() set an error if the return value of ram_save_iterate < 0. Obviously the return value of qemu_file_rate_limit() should have an negative value for there has been an error. Otherwise we need to modify the logic above. > Paolo > >> 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; >> > -- Lei