We used to set nonblocking mode for incoming live migration. It was
required because while running inside a coroutine we cannot block in a
syscall. Instead of that, when a syscall needs blocking, we need to
register to the iochannel's GIO events and proactively yield the coroutine
so as to make sure other things can keep running on the QEMU main
thread. When the migration channel has pending data to read, QEMU main
thread will re-enter the blocked incoming migration coroutine.
Now, incoming migration is completely run inside a thread now. We can
safely switch to blocking mode for the main incoming channel.
It's still slightly more efficient to use blocking mode than nonblocking,
because QEMU can avoid creating temporary mainloops and avoid the extra
poll() syscall. Now it's safe to directly block in the iochannel's
syscall (e.g. io_readv()).
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/migration/migration.c b/migration/migration.c
index 728d02dbee..abd76801c2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -973,7 +973,9 @@ static void migration_incoming_setup(QEMUFile *f)
assert(!mis->from_src_file);
mis->from_src_file = f;
- qemu_file_set_blocking(f, false, &error_abort);
+
+ /* Incoming migration runs in a thread now, nonblocking is not needed */
+ qemu_file_set_blocking(f, true, &error_abort);
}
void migration_incoming_process(void)
--
2.50.1