* Juan Quintela (quint...@redhat.com) wrote: > "Dr. David Alan Gilbert (git)" <dgilb...@redhat.com> wrote: > > From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> > > > > Modify save_live_pending to return separate postcopiable and > > non-postcopiable counts. > > > > Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > > Reviewed-by: Juan Quintela <quint...@redhat.com>
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 / dgilb...@redhat.com / Manchester, UK