[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] migration: Provide a test for migratability
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH] migration: Provide a test for migratability |
Date: |
Thu, 21 Jan 2021 18:51:13 +0000 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
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
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
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(+)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 117ba25f91..c2d7ac2f11 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -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 = "",
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index ed2913fd18..0dd7941daf 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -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);
diff --git a/migration/migration.c b/migration/migration.c
index 5e330cc6eb..8745a5b9f9 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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 = {
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index ef569035f8..a7f48b3512 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -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;
diff --git a/qapi/migration.json b/qapi/migration.json
index d1d9632c2a..07aee9907c 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -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.29.2
- [PATCH] migration: Provide a test for migratability,
Dr. David Alan Gilbert (git) <=