Usage:
-incoming file:/path/to/vm_statefile

Signed-off-by: Benoit Canet <ben...@irqsave.net>
---
 migration-fd.c |    5 ++---
 migration.c    |   14 +++++++++++++-
 migration.h    |    2 +-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/migration-fd.c b/migration-fd.c
index d39e44a..bf500a0 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -108,14 +108,13 @@ static void fd_accept_incoming_migration(void *opaque)
     qemu_fclose(f);
 }
 
-int fd_start_incoming_migration(const char *infd)
+int fd_start_incoming_migration(const char *infd, int fd)
 {
-    int fd;
     QEMUFile *f;
 
     DPRINTF("Attempting to start an incoming migration via fd\n");
 
-    fd = strtol(infd, NULL, 0);
+    fd = fd ? fd : strtol(infd, NULL, 0);
     f = qemu_fdopen(fd, "rb");
     if(f == NULL) {
         DPRINTF("Unable to apply qemu wrapper to file descriptor\n");
diff --git a/migration.c b/migration.c
index 679847d..e4b228e 100644
--- a/migration.c
+++ b/migration.c
@@ -64,6 +64,16 @@ static MigrationState *migrate_get_current(void)
     return &current_migration;
 }
 
+static int file_start_incoming_migration(const char *filename)
+{
+    int fd;
+    fd = open(filename, O_RDONLY);
+    if (fd < 0) {
+        return -errno;
+    }
+    return fd_start_incoming_migration(NULL, fd);
+}
+
 int qemu_start_incoming_migration(const char *uri, Error **errp)
 {
     const char *p;
@@ -77,7 +87,9 @@ int qemu_start_incoming_migration(const char *uri, Error 
**errp)
     else if (strstart(uri, "unix:", &p))
         ret = unix_start_incoming_migration(p);
     else if (strstart(uri, "fd:", &p))
-        ret = fd_start_incoming_migration(p);
+        ret = fd_start_incoming_migration(p, 0);
+    else if (strstart(uri, "file:", &p))
+        ret = file_start_incoming_migration(p);
 #endif
     else {
         fprintf(stderr, "unknown migration protocol: %s\n", uri);
diff --git a/migration.h b/migration.h
index d431284..dbdaf72 100644
--- a/migration.h
+++ b/migration.h
@@ -67,7 +67,7 @@ int unix_start_incoming_migration(const char *path);
 
 int unix_start_outgoing_migration(MigrationState *s, const char *path);
 
-int fd_start_incoming_migration(const char *path);
+int fd_start_incoming_migration(const char *path, int fd);
 
 int fd_start_outgoing_migration(MigrationState *s, const char *fdname, int fd);
 
-- 
1.7.9.5


Reply via email to