[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine |
Date: |
Thu, 18 Oct 2012 12:22:38 +0200 |
The final part of incoming migration, which now consists of
process_incoming_migration for all protocols, is thus made non-blocking.
Signed-off-by: Paolo Bonzini <address@hidden>
---
migration.c | 21 ++++++++++++++++++++-
1 file modificato, 20 inserzioni(+). 1 rimozione(-)
diff --git a/migration.c b/migration.c
index 0d74753..32d43e7 100644
--- a/migration.c
+++ b/migration.c
@@ -86,11 +86,13 @@ int qemu_start_incoming_migration(const char *uri, Error
**errp)
return ret;
}
-void process_incoming_migration(QEMUFile *f)
+static void process_incoming_migration_co(void *opaque)
{
+ QEMUFile *f = opaque;
int ret;
ret = qemu_loadvm_state(f);
+ qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL);
qemu_fclose(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
@@ -110,6 +112,23 @@ void process_incoming_migration(QEMUFile *f)
}
}
+static void enter_migration_coroutine(void *opaque)
+{
+ Coroutine *co = opaque;
+ qemu_coroutine_enter(co, NULL);
+}
+
+void process_incoming_migration(QEMUFile *f)
+{
+ Coroutine *co = qemu_coroutine_create(process_incoming_migration_co);
+ int fd = qemu_get_fd(f);
+
+ assert(fd != -1);
+ socket_set_nonblock(fd);
+ qemu_set_fd_handler(fd, enter_migration_coroutine, NULL, co);
+ qemu_coroutine_enter(co, f);
+}
+
/* amount of nanoseconds we are willing to wait for migration to be down.
* the choice of nanoseconds is because it is the maximum resolution that
* get_clock() can achieve. It is an internal measure. All user-visible
--
1.7.12.1
- [Qemu-devel] [PATCH 09/12] migration: close socket QEMUFile from socket_close, (continued)
- [Qemu-devel] [PATCH 09/12] migration: close socket QEMUFile from socket_close, Paolo Bonzini, 2012/10/18
- [Qemu-devel] [PATCH 07/12] migration: use closesocket, not close, Paolo Bonzini, 2012/10/18
- [Qemu-devel] [PATCH 08/12] migration: xxx_close will only be called once, Paolo Bonzini, 2012/10/18
- [Qemu-devel] [PATCH 10/12] migration: move qemu_fclose to process_incoming_migration, Paolo Bonzini, 2012/10/18
- [Qemu-devel] [PATCH 11/12] migration: handle EAGAIN while reading QEMUFile, Paolo Bonzini, 2012/10/18
- [Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine,
Paolo Bonzini <=