On Wed, Jan 03, 2018 at 12:18:54PM +0100, Juan Quintela wrote: > Peter Xu <pet...@redhat.com> wrote: > > On Wed, Jan 03, 2018 at 11:21:31AM +0100, Juan Quintela wrote: > >> Peter Xu <pet...@redhat.com> wrote: > >> > On Wed, Jan 03, 2018 at 10:15:41AM +0100, Juan Quintela wrote: > >> >> Peter Xu <pet...@redhat.com> wrote: > >> >> > Moving existing callers all into migrate_fd_cleanup(). It simplifies > >> >> > migration_thread() a bit. > >> >> > > >> >> > Signed-off-by: Peter Xu <pet...@redhat.com> > >> >> > >> >> Reviewed-by: Juan Quintela <quint...@redhat.com> > >> > > >> > Thanks. > >> > > >> >> > >> >> I am trying to see if we can call migrate_fd_cleanup() twice. As far as > >> >> I can see, we are not doing it. But, and it is a big but, we are not > >> >> checking that we are not calling qemu_savevm_state_cleanup() twice. If > >> >> that happens, we can get double frees and similar. > >> >> > >> >> I put the reviewed-by anyways, because I *think* that we are doing it > >> >> right now, and otherwise, we should make sure that we are not calling it > >> >> twice, not papering over it. > >> >> > >> >> Once here, I have notice that we call block_cleanup_parameters() in > >> >> *three* places. We call notifier_list_notify() on two of this places (I > >> >> can't see any good reason *why* we don't call the notifier for > >> >> migrate_fd_cancel). > >> > > >> > Indeed. > >> > > >> > IMHO we can remove two calls of block_cleanup_parameters(), only keep > >> > the one in migrate_fd_cleanup(), and remove on notifier_list_notify() > >> > in migrate_fd_error() (these can be two more patches). What do you > >> > think? > >> > >> I think we need to make sure that we have a function that we always > >> call at the end. I think that we have that on migration_fd_cleanup(), > >> so put everything there should be ok, no? > > > > IMHO that's exactly what I mean, no? :) > > > > For notifier_list_notify(), it's different - I just remove the extra > > one in migrate_fd_error() because it'll be called in > > migrate_fd_cleanup() as well, which is a duplicate. > > then what call the one when we do a cancel? the one in cleanup also?
Yes, IIUC migrate_fd_cancel() tells the thread to cancel, then the migrate_fd_cleanup() is called there (finally in the bottom half of main loop, of course). -- Peter Xu