Skip to contentSkip to conversation

migration: Provide a test for migratability

PATCH In review Dr. David Alan Gilbert (git) 3 participants 6 messages Jan 21, 2021 – Feb 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: Provide a test for migratability

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---
 hmp-commands-info.hx  | 14 ++++++++++++++
 include/monitor/hmp.h |  1 +
 migration/migration.c |  5 +++++
 monitor/hmp-cmds.c    | 13 +++++++++++++
 qapi/migration.json   | 14 ++++++++++++++
 5 files changed, 47 insertions(+)
hmp-commands-info.hx +14 -0
index 117ba25f91..c2d7ac2f11 100644
@@ -541,6 +541,20 @@ SRST
     Show migration status.
 ERST
 
+    {
+        .name       = "migratable",
+        .args_type  = "",
+        .params     = "",
+        .help       = "tests if VM is migratable",
+        .cmd        = hmp_info_migratable,
+    },
+
+SRST
+  ''info migratable''
+    Tests whether the VM is currently migratable.
+ERST
+
+
     {
         .name       = "migrate_capabilities",
         .args_type  = "",
include/monitor/hmp.h +1 -0
index ed2913fd18..0dd7941daf 100644
@@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
 void hmp_info_uuid(Monitor *mon, const QDict *qdict);
 void hmp_info_chardev(Monitor *mon, const QDict *qdict);
 void hmp_info_mice(Monitor *mon, const QDict *qdict);
+void hmp_info_migratable(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
migration/migration.c +5 -0
index 5e330cc6eb..8745a5b9f9 100644
@@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp)
     return migrate_xbzrle_cache_size();
 }
 
+void qmp_query_migratable(Error **errp)
+{
+    migration_is_blocked(errp);
+}
+
 void qmp_migrate_set_speed(int64_t value, Error **errp)
 {
     MigrateSetParameters p = {
monitor/hmp-cmds.c +13 -0
index ef569035f8..a7f48b3512 100644
@@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr)
     }
 }
 
+void hmp_info_migratable(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    /* It's migratable if this succeeds */
+    qmp_query_migratable(&err);
+    if (err) {
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    monitor_printf(mon, "Migratable\n");
+}
+
 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
 {
     MigrationInfo *info;
qapi/migration.json +14 -0
index d1d9632c2a..07aee9907c 100644
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)
+#
+# Since: 6.0
+# Example:
+#
+# -> { "execute": "query-migratable" }
+# <- { "return": {} }
+##
+{ 'command': 'query-migratable' }
+
 ##
 # @MigrationCapability:
 #
Signature · 1 line
2.29.2
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Thu, 21 Jan 2021 18:51:13 +0000 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

FWIW, a vfio device gets:

(qemu) info migratable
Error: VFIO device doesn't support migration

I think your example is getting the device string because you're testing something with unmigratable = 1 in the vmsd and the iterator prints a generic string plus the device, we'd need to make our error message include the device info. But even without that it seems more useful than we have currently. Thanks

Quoted 116 lines
$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---
 hmp-commands-info.hx  | 14 ++++++++++++++
 include/monitor/hmp.h |  1 +
 migration/migration.c |  5 +++++
 monitor/hmp-cmds.c    | 13 +++++++++++++
 qapi/migration.json   | 14 ++++++++++++++
 5 files changed, 47 insertions(+)
hmp-commands-info.hx +14 -0
index 117ba25f91..c2d7ac2f11 100644
@@ -541,6 +541,20 @@ SRST
     Show migration status.
 ERST
 
+    {
+        .name       = "migratable",
+        .args_type  = "",
+        .params     = "",
+        .help       = "tests if VM is migratable",
+        .cmd        = hmp_info_migratable,
+    },
+
+SRST
+  ''info migratable''
+    Tests whether the VM is currently migratable.
+ERST
+
+
     {
         .name       = "migrate_capabilities",
         .args_type  = "",
include/monitor/hmp.h +1 -0
index ed2913fd18..0dd7941daf 100644
@@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
 void hmp_info_uuid(Monitor *mon, const QDict *qdict);
 void hmp_info_chardev(Monitor *mon, const QDict *qdict);
 void hmp_info_mice(Monitor *mon, const QDict *qdict);
+void hmp_info_migratable(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
migration/migration.c +5 -0
index 5e330cc6eb..8745a5b9f9 100644
@@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp)
     return migrate_xbzrle_cache_size();
 }
 
+void qmp_query_migratable(Error **errp)
+{
+    migration_is_blocked(errp);
+}
+
 void qmp_migrate_set_speed(int64_t value, Error **errp)
 {
     MigrateSetParameters p = {
monitor/hmp-cmds.c +13 -0
index ef569035f8..a7f48b3512 100644
@@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr)
     }
 }
 
+void hmp_info_migratable(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    /* It's migratable if this succeeds */
+    qmp_query_migratable(&err);
+    if (err) {
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    monitor_printf(mon, "Migratable\n");
+}
+
 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
 {
     MigrationInfo *info;
qapi/migration.json +14 -0
index d1d9632c2a..07aee9907c 100644
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)
+#
+# Since: 6.0
+# Example:
+#
+# -> { "execute": "query-migratable" }
+# <- { "return": {} }
+##
+{ 'command': 'query-migratable' }
+
 ##
 # @MigrationCapability:
 #
#2 lore raw
Quoted 15 lines · * Alex Williamson ([email protected]) wrote:
Quoted 9 lines · On Thu, 21 Jan 2021 18:51:13 +0000 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

FWIW, a vfio device gets:

Quoted 8 lines

(qemu) info migratable
Error: VFIO device doesn't support migration

I think your example is getting the device string because you're testing something with unmigratable = 1 in the vmsd and the iterator prints a generic string plus the device, we'd need to make our error message include the device info. But even without that it seems more useful than we have currently. Thanks

The 'migrate_add_blocker' function just takes the error you give it; it would be nice to add something like a device_add_migrate_blocker that filled in the name.

Quoted 1 line

Thanks.

Dave

Quoted 118 lines
Quoted 117 lines
$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---
 hmp-commands-info.hx  | 14 ++++++++++++++
 include/monitor/hmp.h |  1 +
 migration/migration.c |  5 +++++
 monitor/hmp-cmds.c    | 13 +++++++++++++
 qapi/migration.json   | 14 ++++++++++++++
 5 files changed, 47 insertions(+)
hmp-commands-info.hx +14 -0
index 117ba25f91..c2d7ac2f11 100644
@@ -541,6 +541,20 @@ SRST
     Show migration status.
 ERST
 
+    {
+        .name       = "migratable",
+        .args_type  = "",
+        .params     = "",
+        .help       = "tests if VM is migratable",
+        .cmd        = hmp_info_migratable,
+    },
+
+SRST
+  ''info migratable''
+    Tests whether the VM is currently migratable.
+ERST
+
+
     {
         .name       = "migrate_capabilities",
         .args_type  = "",
include/monitor/hmp.h +1 -0
index ed2913fd18..0dd7941daf 100644
@@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
 void hmp_info_uuid(Monitor *mon, const QDict *qdict);
 void hmp_info_chardev(Monitor *mon, const QDict *qdict);
 void hmp_info_mice(Monitor *mon, const QDict *qdict);
+void hmp_info_migratable(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
migration/migration.c +5 -0
index 5e330cc6eb..8745a5b9f9 100644
@@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp)
     return migrate_xbzrle_cache_size();
 }
 
+void qmp_query_migratable(Error **errp)
+{
+    migration_is_blocked(errp);
+}
+
 void qmp_migrate_set_speed(int64_t value, Error **errp)
 {
     MigrateSetParameters p = {
monitor/hmp-cmds.c +13 -0
index ef569035f8..a7f48b3512 100644
@@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr)
     }
 }
 
+void hmp_info_migratable(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    /* It's migratable if this succeeds */
+    qmp_query_migratable(&err);
+    if (err) {
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    monitor_printf(mon, "Migratable\n");
+}
+
 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
 {
     MigrationInfo *info;
qapi/migration.json +14 -0
index d1d9632c2a..07aee9907c 100644
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)
+#
+# Since: 6.0
+# Example:
+#
+# -> { "execute": "query-migratable" }
+# <- { "return": {} }
+##
+{ 'command': 'query-migratable' }
+
 ##
 # @MigrationCapability:
 #
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#3 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 21 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---

+++ b/qapi/migration.json

qapi/migration.json line 373

Quoted 8 lines
qapi/migration.json +5 -0
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)

Do we really need a new command? Or can we get away with enhancing the existing 'query-migrate' to add another bool field to 'MigrationInfo'?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 25 lines · * Eric Blake ([email protected]) wrote:
Quoted 24 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---

+++ b/qapi/migration.json

qapi/migration.json +0 -0
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
Quoted 8 lines

qapi/migration.json line 373

Quoted 5 lines
qapi/migration.json +5 -0
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)

Do we really need a new command? Or can we get away with enhancing the existing 'query-migrate' to add another bool field to 'MigrationInfo'?

In the case where the VM is not migratable this command errors with the message set in a migration-blocker (Our migration blocker mechanism always takes an Error* as the reason).

It didn't seem right to make that change for the existing commands; so how would you like the existing MigrationInfo to change; a boolean to say yes/no, and an error/list of errors for the reason?

Dave

Quoted 4 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#5 lore raw
In reply to Eric Blake
Quoted 25 lines · * Eric Blake ([email protected]) wrote:
Quoted 24 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a simple way to see if there's currently a migration blocker in operation:

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n

(qemu) info migratable
Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial'

$ ./x86_64-softmmu/qemu-system-x86_64 -nographic

(qemu) info migratable
Migratable

---

+++ b/qapi/migration.json

qapi/migration.json +0 -0
@@ -366,6 +366,20 @@
 ##
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
Quoted 8 lines

qapi/migration.json line 373

Quoted 5 lines
qapi/migration.json +5 -0
+##
+# @query-migratable:
+# Tests whether it will be possible to migrate the VM in the current state.
+#
+# Returns: nothing on success (i.e. if the VM is migratable)

Do we really need a new command? Or can we get away with enhancing the existing 'query-migrate' to add another bool field to 'MigrationInfo'?

OK, new version of this coming up, glued into query-migrate.

Dave

Quoted 4 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK