From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLCvp-00066L-Jj for qemu-devel@nongnu.org; Fri, 31 Jul 2015 12:13:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLCvi-0007UM-TD for qemu-devel@nongnu.org; Fri, 31 Jul 2015 12:13:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLCvi-0007UC-M7 for qemu-devel@nongnu.org; Fri, 31 Jul 2015 12:13:06 -0400 Date: Fri, 31 Jul 2015 17:13:00 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150731161259.GB6794@work-vm> References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-21-git-send-email-dgilbert@redhat.com> <87bnfgl39t.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bnfgl39t.fsf@neno.neno> Subject: Re: [Qemu-devel] [PATCH v7 20/42] Modify save_live_pending for postcopy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, liang.z.li@intel.com, "Dr. David Alan Gilbert (git)" , qemu-devel@nongnu.org, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au * Juan Quintela (quintela@redhat.com) wrote: > "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 Thanks, > 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? OK, done; I did it as: + /* We can do postcopy, and all the data is postcopiable */ + *postcopiable_pending += remaining_size; rather than having the odd += 0; > > 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. Yep, Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK