]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
migrate_fd_close: delete associated io-handler before closing the fd
authorUri Lublin <uril@redhat.com>
Mon, 8 Jun 2009 11:28:01 +0000 (14:28 +0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 16 Jun 2009 22:11:19 +0000 (17:11 -0500)
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.

(cherry picked from commit e19252d32c45e92c919109ec32616382eb2afe6b)

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
migration.c

index 06ea795cf1f235c8aa8c429bc2cc7455a9b5f5f7..41a703af4f4cd21220021212f0d2b9549346c819 100644 (file)
@@ -283,5 +283,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque)
 int migrate_fd_close(void *opaque)
 {
     FdMigrationState *s = opaque;
+
+    qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
     return s->close(s);
 }