aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--migration-exec.c14
-rw-r--r--migration-fd.c14
-rw-r--r--migration-tcp.c15
-rw-r--r--migration-unix.c15
-rw-r--r--migration.c13
-rw-r--r--migration.h2
6 files changed, 21 insertions, 52 deletions
diff --git a/migration-exec.c b/migration-exec.c
index a8813b4fbf..14718dd1d1 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -121,20 +121,8 @@ err_after_alloc:
static void exec_accept_incoming_migration(void *opaque)
{
QEMUFile *f = opaque;
- int ret;
- ret = qemu_loadvm_state(f);
- if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
- goto err;
- }
- qemu_announce_self();
- DPRINTF("successfully loaded vm state\n");
-
- if (autostart)
- vm_start();
-
-err:
+ process_incoming_migration(f);
qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
qemu_fclose(f);
}
diff --git a/migration-fd.c b/migration-fd.c
index 0abd372af5..6d14505632 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -104,20 +104,8 @@ err_after_alloc:
static void fd_accept_incoming_migration(void *opaque)
{
QEMUFile *f = opaque;
- int ret;
- ret = qemu_loadvm_state(f);
- if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
- goto err;
- }
- qemu_announce_self();
- DPRINTF("successfully loaded vm state\n");
-
- if (autostart)
- vm_start();
-
-err:
+ process_incoming_migration(f);
qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
qemu_fclose(f);
}
diff --git a/migration-tcp.c b/migration-tcp.c
index 43af2e0450..78b56dc3f6 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -141,7 +141,7 @@ static void tcp_accept_incoming_migration(void *opaque)
socklen_t addrlen = sizeof(addr);
int s = (unsigned long)opaque;
QEMUFile *f;
- int c, ret;
+ int c;
do {
c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
@@ -160,18 +160,7 @@ static void tcp_accept_incoming_migration(void *opaque)
goto out;
}
- ret = qemu_loadvm_state(f);
- if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
- goto out_fopen;
- }
- qemu_announce_self();
- DPRINTF("successfully loaded vm state\n");
-
- if (autostart)
- vm_start();
-
-out_fopen:
+ process_incoming_migration(f);
qemu_fclose(f);
out:
qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
diff --git a/migration-unix.c b/migration-unix.c
index 49de1b9e84..57232c07a9 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -149,7 +149,7 @@ static void unix_accept_incoming_migration(void *opaque)
socklen_t addrlen = sizeof(addr);
int s = (unsigned long)opaque;
QEMUFile *f;
- int c, ret;
+ int c;
do {
c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
@@ -168,18 +168,7 @@ static void unix_accept_incoming_migration(void *opaque)
goto out;
}
- ret = qemu_loadvm_state(f);
- if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
- goto out_fopen;
- }
- qemu_announce_self();
- DPRINTF("successfully loaded vm state\n");
-
- if (autostart)
- vm_start();
-
-out_fopen:
+ process_incoming_migration(f);
qemu_fclose(f);
out:
qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
diff --git a/migration.c b/migration.c
index 85c81e0983..b49964c5e3 100644
--- a/migration.c
+++ b/migration.c
@@ -58,6 +58,19 @@ int qemu_start_incoming_migration(const char *uri)
return ret;
}
+void process_incoming_migration(QEMUFile *f)
+{
+ if (qemu_loadvm_state(f) < 0) {
+ fprintf(stderr, "load of migration failed\n");
+ exit(0);
+ }
+ qemu_announce_self();
+ DPRINTF("successfully loaded vm state\n");
+
+ if (autostart)
+ vm_start();
+}
+
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
MigrationState *s = NULL;
diff --git a/migration.h b/migration.h
index e048bb2e8b..d13ed4fca9 100644
--- a/migration.h
+++ b/migration.h
@@ -50,6 +50,8 @@ struct FdMigrationState
void *opaque;
};
+void process_incoming_migration(QEMUFile *f);
+
int qemu_start_incoming_migration(const char *uri);
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);