Orit Wasserman <owass...@redhat.com> writes: > Signed-off-by: Orit Wasserman <owass...@redhat.com> > --- > migration.c | 3 +-- > 1 files changed, 1 insertions(+), 2 deletions(-) > > diff --git a/migration.c b/migration.c > index 1edeec5..c20a2fe 100644 > --- a/migration.c > +++ b/migration.c > @@ -240,8 +240,6 @@ static int migrate_fd_cleanup(MigrationState *s) > { > int ret = 0; > > - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > - > if (s->file) { > DPRINTF("closing file\n"); > ret = qemu_fclose(s->file); > @@ -249,6 +247,7 @@ static int migrate_fd_cleanup(MigrationState *s) > } > > if (s->fd != -1) { > + qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > close(s->fd); > s->fd = -1; > }
As far as I can see, qemu_set_fd_handler2() treats invalid file descriptor -1 just like any other. If it's in io_handlers, it gets deleted, else it's a nop. Thus, the old code works. But I agree passing invalid file descriptors is abusing the interface. I'm not sufficiently familiar with the migration code to judge whether moving the handler reset down is safe.