qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [5476] Introduce UI for live migration


From: Anthony Liguori
Subject: [Qemu-devel] [5476] Introduce UI for live migration
Date: Mon, 13 Oct 2008 03:12:02 +0000

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.

Signed-off-by: Anthony Liguori <address@hidden>

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
===================================================================
--- trunk/Makefile.target       2008-10-13 03:10:22 UTC (rev 5475)
+++ trunk/Makefile.target       2008-10-13 03:12:02 UTC (rev 5476)
@@ -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
===================================================================
--- trunk/migration.c                           (rev 0)
+++ trunk/migration.c   2008-10-13 03:12:02 UTC (rev 5476)
@@ -0,0 +1,83 @@
+/*
+ * QEMU live migration
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu-common.h"
+#include "migration.h"
+#include "console.h"
+
+/* Migration speed throttling */
+static uint32_t max_throttle = (32 << 20);
+
+static MigrationState *current_migration;
+
+void qemu_start_incoming_migration(const char *uri)
+{
+    fprintf(stderr, "unknown migration protocol: %s\n", uri);
+}
+
+void do_migrate(int detach, const char *uri)
+{
+    term_printf("unknown migration protocol: %s\n", uri);
+}
+
+void do_migrate_cancel(void)
+{
+    MigrationState *s = current_migration;
+
+    if (s)
+       s->cancel(s);
+}
+
+void do_migrate_set_speed(const char *value)
+{
+    double d;
+    char *ptr;
+
+    d = strtod(value, &ptr);
+    switch (*ptr) {
+    case 'G': case 'g':
+       d *= 1024;
+    case 'M': case 'm':
+       d *= 1024;
+    case 'K': case 'k':
+       d *= 1024;
+    default:
+       break;
+    }
+
+    max_throttle = (uint32_t)d;
+}
+
+void do_info_migrate(void)
+{
+    MigrationState *s = current_migration;
+    
+    if (s) {
+       term_printf("Migration status: ");
+       switch (s->get_status(s)) {
+       case MIG_STATE_ACTIVE:
+           term_printf("active\n");
+           break;
+       case MIG_STATE_COMPLETED:
+           term_printf("completed\n");
+           break;
+       case MIG_STATE_ERROR:
+           term_printf("failed\n");
+           break;
+       case MIG_STATE_CANCELLED:
+           term_printf("cancelled\n");
+           break;
+       }
+    }
+}
+

Added: trunk/migration.h
===================================================================
--- trunk/migration.h                           (rev 0)
+++ trunk/migration.h   2008-10-13 03:12:02 UTC (rev 5476)
@@ -0,0 +1,43 @@
+/*
+ * QEMU live migration
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_H
+#define QEMU_MIGRATION_H
+
+#define MIG_STATE_ERROR                -1
+#define MIG_STATE_COMPLETED    0
+#define MIG_STATE_CANCELLED    1
+#define MIG_STATE_ACTIVE       2
+
+typedef struct MigrationState MigrationState;
+
+struct MigrationState
+{
+    /* FIXME: add more accessors to print migration info */
+    void (*cancel)(MigrationState *s);
+    int (*get_status)(MigrationState *s);
+    void (*release)(MigrationState *s);
+};
+
+void qemu_start_incoming_migration(const char *uri);
+
+void do_migrate(int detach, const char *uri);
+
+void do_migrate_cancel(void);
+
+void do_migrate_set_speed(const char *value);
+
+void do_info_migrate(void);
+
+#endif
+

Modified: trunk/monitor.c
===================================================================
--- trunk/monitor.c     2008-10-13 03:10:22 UTC (rev 5475)
+++ trunk/monitor.c     2008-10-13 03:12:02 UTC (rev 5476)
@@ -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
===================================================================
--- trunk/qemu_socket.h 2008-10-13 03:10:22 UTC (rev 5475)
+++ trunk/qemu_socket.h 2008-10-13 03:12:02 UTC (rev 5476)
@@ -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
===================================================================
--- trunk/vl.c  2008-10-13 03:10:22 UTC (rev 5475)
+++ trunk/vl.c  2008-10-13 03:12:02 UTC (rev 5476)
@@ -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();






reply via email to

[Prev in Thread] Current Thread [Next in Thread]