Commit e19252d32c45e92c919109ec32616382eb2afe6b

Authored by Uri Lublin
Committed by Anthony Liguori
1 parent 8a67ec4d

migrate_fd_close: delete associated io-handler before closing the fd

It may happen that the io-handler is still registered. That causes
select() to return with EBADF, not calling handlers for other fds.

The io-handler would be registered when (on the source) the whole state
was written but not yet flushed. For example when using QEMUFileBuffered,
(tcp-migration) there may be data left in a buffer waiting to be transferred.
In such a case buffered_close() calls buffered_flush() which calls
migrate_fd_put_buffer, which may, upon EAGAIN, register migrate_fd_put_notify
as a handler.

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 2 additions and 0 deletions
migration.c
... ... @@ -301,5 +301,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque)
301 301 int migrate_fd_close(void *opaque)
302 302 {
303 303 FdMigrationState *s = opaque;
  304 +
  305 + qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
304 306 return s->close(s);
305 307 }
... ...