Skip to contentSkip to conversation

migration to/from file (v3 aio)

PATCH New Uri Lublin 1 participant 1 message Feb 22, 2009 Kbuild

lore
Share & tools
lore

Uri Lublin

author
#0 lore raw

PATCH 1/1 migration to/from file (v3 aio)

Hello,

Attached for review is an implementation of migration to/from a file.

migrate-to-file: uses posix-aio-compat and FdMigration
migrate-from-file: uses qemu-fopen directly.

This patch is incomplete as currently it uses polling of aio-completion (we fake EAGAIN, and select finds the fd writeable, so file_write will be called again).

As Anthony suggested I plan to implement s->set_fd in FdMigration code, and use signal based aio-completion notifications (SIGUSR1).
Anthony mentioned we need only a single aio operation at a time. Although I'm not sure what the reasoning for that, I modified the code to support a single operation (my previous implementation used multiple aio operations).

Differences from v2:
use aio writes (posix-aio-compat) instead of select and/or write. compile migration-to-file only if AIO is configured.

An alternative (v4) would be to use a single thread and a pipe which is also asynchronous, much easier to implement and possibly faster (need to be measured).

Regards,
Uri.

Quoted 1 line

From 34e539ca774d14aa9950fbc4404148d7a5e49101 Mon Sep 17 00:00:00 2001

From: Uri Lublin <[email protected]>
Date: Thu, 12 Feb 2009 11:04:59 +0200
Subject: [PATCH] Adding migration to/from file (v3 - aio)

Migration to file, reuses migration-to-fd.
Migration from file, uses qemu-fopen directly.

The saved state-file should be used only once and removed (or used with -snapshot, or a the disk-image should be copied), as the disk image is not saved, only the VM state.

I recommend to stop the VM before migrating its state to a file. This version supports live migration to file. Can be used later for VM-checkpointing.

An advantage migration-to-file over savevm/loadvm is that for the latter a qcow2 is a requirement, while the former works for any image-format.

This version uses posix-aio-compat (which uses worker threads). Additional memory is allocated to hold the data, so it's not changed while written to file.

---
 Makefile         |    3 +
 migration-file.c |  245 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 migration.c      |    8 ++
 migration.h      |    6 ++
 4 files changed, 262 insertions(+), 0 deletions(-)
 create mode 100644 migration-file.c
Makefile +3 -0
index 4f7a55a..60170d1 100644
@@ -95,6 +95,9 @@ ifdef CONFIG_WIN32
 OBJS+=tap-win32.o
 else
 OBJS+=migration-exec.o
+ifdef CONFIG_AIO
+OBJS+=migration-file.o
+endif
 endif
 
 AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
migration-file.c new file +245 -0

245 lines not on this page · raw message

migration.c +8 -0
index 0ef777a..234dcf6 100644
@@ -43,6 +43,10 @@ void qemu_start_incoming_migration(const char *uri)
 #if !defined(WIN32)
     else if (strstart(uri, "exec:", &p))
         exec_start_incoming_migration(p);
+#ifdef CONFIG_AIO
+    else if (strstart(uri, "file:", &p))
+        file_start_incoming_migration(p);
+#endif
 #endif
     else
         fprintf(stderr, "unknown migration protocol: %s\n", uri);
@@ -58,6 +62,10 @@ void do_migrate(int detach, const char *uri)
 #if !defined(WIN32)
     else if (strstart(uri, "exec:", &p))
         s = exec_start_outgoing_migration(p, max_throttle, detach);
+#ifdef CONFIG_AIO
+    else if (strstart(uri, "file:", &p))
+        s = file_start_outgoing_migration(p, max_throttle, detach);
+#endif
 #endif
     else
         term_printf("unknown migration protocol: %s\n", uri);
migration.h +6 -0
index d9771ad..ae78792 100644
@@ -67,6 +67,12 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
 					     int64_t bandwidth_limit,
 					     int detach);
 
+
+int file_start_incoming_migration(const char *filename);
+MigrationState *file_start_outgoing_migration(const char *filename,
+                                              int64_t bandwidth_limit,
+                                              int detach);
+
 void migrate_fd_error(FdMigrationState *s);
 
 void migrate_fd_cleanup(FdMigrationState *s);
Signature · 1 line
1.6.0.6