Skip to contentSkip to conversation

[5476] Introduce UI for live migration

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

lore
Share & tools
lore
#0 lore raw

Revision: 5476

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

Log Message:
-----------
Introduce UI for live migration

This patch introduces a command line parameter and monitor command for starting a live migration. The next patch will provide an example of how to use these parameters.

Modified Paths:
--------------
trunk/Makefile.target
trunk/monitor.c
trunk/qemu_socket.h
trunk/vl.c

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

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
+OBJS+=fw_cfg.o aio.o buffered_file.o migration.o
 ifdef CONFIG_WIN32
 OBJS+=block-raw-win32.o
 else

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

migration.c +83 -0

83 lines not on this page · raw message

Added: trunk/migration.h
===================================================================

migration.h +43 -0

43 lines not on this page · raw message

Modified: trunk/monitor.c
===================================================================

monitor.c +8 -0
@@ -36,6 +36,7 @@
 #include "disas.h"
 #include <dirent.h>
 #include "qemu-timer.h"
+#include "migration.h"
 
 //#define DEBUG
 //#define DEBUG_COMPLETION
@@ -1454,6 +1455,12 @@
     { "nmi", "i", do_inject_nmi,
       "cpu", "inject an NMI on the given CPU", },
 #endif
+    { "migrate", "-ds", do_migrate,
+      "[-d] uri", "migrate to URI (using -d to not wait for completion)" },
+    { "migrate_cancel", "", do_migrate_cancel,
+      "", "cancel the current VM migration" },
+    { "migrate_set_speed", "s", do_migrate_set_speed,
+      "value", "set maximum speed (in bytes) for migrations" },
     { NULL, NULL, },
 };
 
@@ -1516,6 +1523,7 @@
     { "slirp", "", do_info_slirp,
       "", "show SLIRP statistics", },
 #endif
+    { "migrate", "", do_info_migrate, "", "show migration status" },
     { NULL, NULL, },
 };
 

Modified: trunk/qemu_socket.h
===================================================================

qemu_socket.h +1 -0
@@ -31,5 +31,6 @@
 #endif /* !_WIN32 */
 
 void socket_set_nonblock(int fd);
+int parse_host_port(struct sockaddr_in *saddr, const char *str);
 
 #endif /* QEMU_SOCKET_H */

Modified: trunk/vl.c
===================================================================

vl.c +14 -1
@@ -38,6 +38,7 @@
 #include "qemu-char.h"
 #include "block.h"
 #include "audio/audio.h"
+#include "migration.h"
 
 #include <unistd.h>
 #include <fcntl.h>
@@ -3364,7 +3365,6 @@
     }
 }
 
-int parse_host_port(struct sockaddr_in *saddr, const char *str);
 #ifndef _WIN32
 static int parse_unix_path(struct sockaddr_un *uaddr, const char *str);
 #endif
@@ -6766,6 +6766,8 @@
     saved_vm_running = vm_running;
     vm_stop(0);
 
+    bdrv_flush_all();
+
     ret = qemu_savevm_state_begin(f);
     if (ret < 0)
         goto out;
@@ -8338,6 +8340,7 @@
     QEMU_OPTION_tb_size,
     QEMU_OPTION_icount,
     QEMU_OPTION_uuid,
+    QEMU_OPTION_incoming,
 };
 
 typedef struct QEMUOption {
@@ -8450,6 +8453,7 @@
     { "startdate", HAS_ARG, QEMU_OPTION_startdate },
     { "tb-size", HAS_ARG, QEMU_OPTION_tb_size },
     { "icount", HAS_ARG, QEMU_OPTION_icount },
+    { "incoming", HAS_ARG, QEMU_OPTION_incoming },
     { NULL },
 };
 
@@ -8742,6 +8746,7 @@
     const char *pid_file = NULL;
     VLANState *vlan;
     int autostart;
+    const char *incoming = NULL;
 
     LIST_INIT (&vm_change_state_head);
 #ifndef _WIN32
@@ -9349,6 +9354,9 @@
                     icount_time_shift = strtol(optarg, NULL, 0);
                 }
                 break;
+            case QEMU_OPTION_incoming:
+                incoming = optarg;
+                break;
             }
         }
     }
@@ -9691,6 +9699,11 @@
     if (loadvm)
         do_loadvm(loadvm);
 
+    if (incoming) {
+        autostart = 0; /* fixme how to deal with -daemonize */
+        qemu_start_incoming_migration(incoming);
+    }
+
     {
         /* XXX: simplify init */
         read_passwords();