From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEbfJ-0001j3-Fx for qemu-devel@nongnu.org; Mon, 13 Jul 2015 07:12:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEbfG-00027i-99 for qemu-devel@nongnu.org; Mon, 13 Jul 2015 07:12:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEbfG-00027S-1N for qemu-devel@nongnu.org; Mon, 13 Jul 2015 07:12:50 -0400 From: Juan Quintela In-Reply-To: <1434450415-11339-21-git-send-email-dgilbert@redhat.com> (David Alan Gilbert's message of "Tue, 16 Jun 2015 11:26:33 +0100") References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-21-git-send-email-dgilbert@redhat.com> Date: Mon, 13 Jul 2015 13:12:46 +0200 Message-ID: <87bnfgl39t.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 20/42] Modify save_live_pending for postcopy Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au "Dr. David Alan Gilbert (git)" wrote: > From: "Dr. David Alan Gilbert" > > Modify save_live_pending to return separate postcopiable and > non-postcopiable counts. > > Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela I think that if you make a small change of meaning, everything gots easier: > -static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size) > +static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, > + uint64_t *non_postcopiable_pending, > + uint64_t *postcopiable_pending) > { > /* Estimate pending number of bytes to send */ > uint64_t pending; > @@ -773,7 +775,8 @@ static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size) > qemu_mutex_unlock_iothread(); > > DPRINTF("Enter save live pending %" PRIu64 "\n", pending); > - return pending; > + *non_postcopiable_pending = pending; > + *postcopiable_pending = 0; Change that two lines to: *non_postcopiable_pending += pending; *postcopiable_pending += 0; /* ok, equivalent of doing nothing */ This way, chaining gots easier? > diff --git a/migration/savevm.c b/migration/savevm.c > index 2c4cbe1..ebd3d31 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -1012,10 +1012,20 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f) > qemu_fflush(f); > } > > -uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size) > +/* Give an estimate of the amount left to be transferred, > + * the result is split into the amount for units that can and > + * for units that can't do postcopy. > + */ > +void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, > + uint64_t *res_non_postcopiable, > + uint64_t *res_postcopiable) > { > SaveStateEntry *se; > - uint64_t ret = 0; > + uint64_t tmp_non_postcopiable, tmp_postcopiable; > + > + *res_non_postcopiable = 0; > + *res_postcopiable = 0; > + > > QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { > if (!se->ops || !se->ops->save_live_pending) { > @@ -1026,9 +1036,12 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size) > continue; > } > } > - ret += se->ops->save_live_pending(f, se->opaque, max_size); > + se->ops->save_live_pending(f, se->opaque, max_size, > + &tmp_non_postcopiable, &tmp_postcopiable); > + > + *res_postcopiable += tmp_postcopiable; > + *res_non_postcopiable += tmp_non_postcopiable; > } > - return ret; With the change, we don't care in the other functions, and this one gets simpler IMHO.