qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/3] Pass optional destination version hint to migra


From: Dr. David Alan Gilbert (git)
Subject: [Qemu-devel] [PATCH 2/3] Pass optional destination version hint to migrate
Date: Wed, 28 May 2014 12:20:33 +0100

From: "Dr. David Alan Gilbert" <address@hidden>

Allow a VersionInfo to be passed as an option to migrate
to indicate the destination QEMU version.

It's intended to help those having to provide compatibility between minor
versions (irrespective of what might have happened in a previous minor)
and for those having to think about backwards migration compatibility.

e.g. using the output of query-version:
{'execute': 'migrate', 'arguments': {'dest-version': { 'qemu': { 'micro': 50, 
'major': 2, 'minor': 0}, 'package': ''}, 'uri': 'exec:/bin/true'}}

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
 hmp.c                         |  5 ++++-
 include/migration/migration.h |  1 +
 migration.c                   | 17 +++++++++++++++++
 qapi-schema.json              |  5 ++++-
 qmp-commands.hx               |  3 ++-
 5 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/hmp.c b/hmp.c
index ccc35d4..411e4bc 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1280,7 +1280,10 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
     const char *uri = qdict_get_str(qdict, "uri");
     Error *err = NULL;
 
-    qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err);
+    qmp_migrate(uri, !!blk, blk, !!inc, inc,
+                false, false,  /* detach */
+                false, NULL, /* dest_version */
+                &err);
     if (err) {
         monitor_printf(mon, "migrate: %s\n", error_get_pretty(err));
         error_free(err);
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 3cb5ba8..8e67e66 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -37,6 +37,7 @@
 struct MigrationParams {
     bool blk;
     bool shared;
+    VersionInfo *dest_version;
 };
 
 typedef struct MigrationState MigrationState;
diff --git a/migration.c b/migration.c
index 3fc03d6..4954f84 100644
--- a/migration.c
+++ b/migration.c
@@ -315,6 +315,10 @@ static void migrate_fd_cleanup(void *opaque)
             migrate_set_state(s, MIG_STATE_CANCELLING, MIG_STATE_CANCELLED);
         }
     }
+    if (s->params.dest_version) {
+        qapi_free_VersionInfo(s->params.dest_version);
+        s->params.dest_version = NULL;
+    }
 
     notifier_list_notify(&migration_state_notifiers, s);
 }
@@ -406,6 +410,7 @@ void migrate_del_blocker(Error *reason)
 
 void qmp_migrate(const char *uri, bool has_blk, bool blk,
                  bool has_inc, bool inc, bool has_detach, bool detach,
+                 bool has_dest_version, VersionInfo *dest_version,
                  Error **errp)
 {
     Error *local_err = NULL;
@@ -415,6 +420,18 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 
     params.blk = has_blk && blk;
     params.shared = has_inc && inc;
+    if (has_dest_version) {
+        params.dest_version = g_malloc(sizeof(VersionInfo));
+        *params.dest_version = *dest_version;
+        params.dest_version->package = g_strdup(dest_version->package);
+        fprintf(stderr, "Migration to version %d.%d.%d (%s)\n",
+                        (int)dest_version->qemu.major,
+                        (int)dest_version->qemu.minor,
+                        (int)dest_version->qemu.micro,
+                        dest_version->package);
+    } else {
+        params.dest_version = NULL;
+    }
 
     if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
         s->state == MIG_STATE_CANCELLING) {
diff --git a/qapi-schema.json b/qapi-schema.json
index 7bc33ea..520498c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2772,6 +2772,8 @@
 #
 # @inc: #optional incremental disk copy migration
 #
+# @dest-version: #optional destination QEMU version
+#
 # @detach: this argument exists only for compatibility reasons and
 #          is ignored by QEMU
 #
@@ -2780,7 +2782,8 @@
 # Since: 0.14.0
 ##
 { 'command': 'migrate',
-  'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } }
+  'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool',
+           '*dest-version': 'VersionInfo' } }
 
 # @xen-save-devices-state:
 #
diff --git a/qmp-commands.hx b/qmp-commands.hx
index d8aa4ed..b33143e 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -611,7 +611,7 @@ EQMP
 
     {
         .name       = "migrate",
-        .args_type  = "detach:-d,blk:-b,inc:-i,uri:s",
+        .args_type  = "detach:-d,blk:-b,inc:-i,dest-version:O?,uri:s",
         .mhandler.cmd_new = qmp_marshal_input_migrate,
     },
 
@@ -625,6 +625,7 @@ Arguments:
 
 - "blk": block migration, full disk copy (json-bool, optional)
 - "inc": incremental disk copy (json-bool, optional)
+- "dest-version": Destination QEMU Version (VersionInfo, optional)
 - "uri": Destination URI (json-string)
 
 Example:
-- 
1.9.3




reply via email to

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