Skip to contentSkip to conversation

[5478] Introduce TCP live migration protocol

Qemu-devel Anthony Liguori 1 participant 1 message Oct 13, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 5478

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5478
Author:   aliguori
Date:     2008-10-13 03:14:31 +0000 (Mon, 13 Oct 2008)

Log Message:
-----------
Introduce TCP live migration protocol

This patch introduces a tcp protocol for live migration. It can be used as follows:

qemu-system-x86_64 -hda ~/images/linux-test.img -monitor stdio
<vm runs for a while>
(qemu) migrate tcp:localhost:1025

On the same system:

qemu-system-x86_64 -hda ~/images/linux-test.img -incoming tcp:localhost:1025

The monitor can be interacted with while waiting for an incoming live migration.

Modified Paths:
--------------
trunk/Makefile.target
trunk/migration.c
trunk/migration.h

Added Paths:
-----------
trunk/migration-tcp.c

Modified: trunk/Makefile.target
===================================================================

Makefile.target +1 -1
@@ -474,7 +474,7 @@
 ifndef CONFIG_USER_ONLY
 
 OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o net-checksum.o
-OBJS+=fw_cfg.o aio.o buffered_file.o migration.o
+OBJS+=fw_cfg.o aio.o buffered_file.o migration.o migration-tcp.o
 ifdef CONFIG_WIN32
 OBJS+=block-raw-win32.o
 else

Added: trunk/migration-tcp.c
===================================================================

migration-tcp.c +371 -0

371 lines not on this page · raw message

Modified: trunk/migration.c
===================================================================

migration.c +22 -2
@@ -22,12 +22,32 @@
 
 void qemu_start_incoming_migration(const char *uri)
 {
-    fprintf(stderr, "unknown migration protocol: %s\n", uri);
+    const char *p;
+
+    if (strstart(uri, "tcp:", &p))
+        tcp_start_incoming_migration(p);
+    else
+        fprintf(stderr, "unknown migration protocol: %s\n", uri);
 }
 
 void do_migrate(int detach, const char *uri)
 {
-    term_printf("unknown migration protocol: %s\n", uri);
+    MigrationState *s = NULL;
+    const char *p;
+
+    if (strstart(uri, "tcp:", &p))
+	s = tcp_start_outgoing_migration(p, max_throttle, detach);
+    else
+        term_printf("unknown migration protocol: %s\n", uri);
+
+    if (s == NULL)
+	term_printf("migration failed\n");
+    else {
+	if (current_migration)
+	    current_migration->release(current_migration);
+
+	current_migration = s;
+    }
 }
 
 void do_migrate_cancel(void)

Modified: trunk/migration.h
===================================================================

migration.h +6 -0
@@ -39,5 +39,11 @@
 
 void do_info_migrate(void);
 
+int tcp_start_incoming_migration(const char *host_port);
+
+MigrationState *tcp_start_outgoing_migration(const char *host_port,
+					     int64_t bandwidth_limit,
+					     int detach);
+
 #endif