qemu-devel
[Top][All Lists]
Advanced

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

[PATCH RFC] migration: warn about non-migratable configurations unless '


From: Vitaly Kuznetsov
Subject: [PATCH RFC] migration: warn about non-migratable configurations unless '--no-migration' was specified
Date: Thu, 15 Apr 2021 17:44:02 +0200

When a migration blocker is added nothing is reported to the user,
inability to migrate such guest may come as a late surprise. As a bare
minimum, we can print a warning. To not pollute the output for those, who
have no intention to migrate their guests, introduce '--no-migration'
option which both block the migration and eliminates warning from

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 include/qapi/qmp/qerror.h |  3 +++
 include/sysemu/sysemu.h   |  1 +
 migration/migration.c     | 18 +++++++++++++++++-
 qemu-options.hx           |  7 +++++++
 softmmu/globals.c         |  1 +
 softmmu/vl.c              |  3 +++
 6 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 596fce0c54e7..2e1563c72f83 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -50,6 +50,9 @@
 #define QERR_MISSING_PARAMETER \
     "Parameter '%s' is missing"
 
+#define QERR_NO_MIGRATION \
+    "Guest is not migratable ('--no-migration' used)"
+
 #define QERR_PERMISSION_DENIED \
     "Insufficient permission to perform this operation"
 
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 8fae667172ac..c65cd5d5a336 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -9,6 +9,7 @@
 /* vl.c */
 
 extern int only_migratable;
+extern int no_migration;
 extern const char *qemu_name;
 extern QemuUUID qemu_uuid;
 extern bool qemu_uuid_set;
diff --git a/migration/migration.c b/migration/migration.c
index ca8b97baa5ac..29a8480ced54 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1077,7 +1077,9 @@ static void fill_source_migration_info(MigrationInfo 
*info)
     info->blocked = migration_is_blocked(NULL);
     info->has_blocked_reasons = info->blocked;
     info->blocked_reasons = NULL;
-    if (info->blocked) {
+    if (no_migration) {
+        QAPI_LIST_PREPEND(info->blocked_reasons, g_strdup(QERR_NO_MIGRATION));
+    } else if (info->blocked) {
         GSList *cur_blocker = migration_blockers;
 
         /*
@@ -2048,6 +2050,10 @@ void migrate_init(MigrationState *s)
 
 int migrate_add_blocker(Error *reason, Error **errp)
 {
+    if (!no_migration) {
+        warn_report("Guest won't be migratable: %s", error_get_pretty(reason));
+    }
+
     if (only_migratable) {
         error_propagate_prepend(errp, error_copy(reason),
                                 "disallowing migration blocker "
@@ -2155,6 +2161,11 @@ bool migration_is_blocked(Error **errp)
         return true;
     }
 
+    if (no_migration) {
+        error_setg(errp, QERR_NO_MIGRATION);
+        return true;
+    }
+
     if (migration_blockers) {
         error_propagate(errp, error_copy(migration_blockers->data));
         return true;
@@ -2198,6 +2209,11 @@ static bool migrate_prepare(MigrationState *s, bool blk, 
bool blk_inc,
         return true;
     }
 
+    if (no_migration) {
+        error_setg(errp, QERR_NO_MIGRATION);
+        return false;
+    }
+
     if (migration_is_running(s->state)) {
         error_setg(errp, QERR_MIGRATION_ACTIVE);
         return false;
diff --git a/qemu-options.hx b/qemu-options.hx
index fd21002bd61d..3443130273e9 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4234,6 +4234,13 @@ SRST
     an unmigratable state.
 ERST
 
+DEF("no-migration", 0, QEMU_OPTION_no_migration, \
+    "-no-migration     disallow migration\n", QEMU_ARCH_ALL)
+SRST
+``-no-migration``
+    Disallow migration. Don't warn about non-migratable configurations.
+ERST
+
 DEF("nodefaults", 0, QEMU_OPTION_nodefaults, \
     "-nodefaults     don't create default devices\n", QEMU_ARCH_ALL)
 SRST
diff --git a/softmmu/globals.c b/softmmu/globals.c
index 7d0fc811835a..bb0d892df307 100644
--- a/softmmu/globals.c
+++ b/softmmu/globals.c
@@ -59,6 +59,7 @@ int boot_menu;
 bool boot_strict;
 uint8_t *boot_splash_filedata;
 int only_migratable; /* turn it off unless user states otherwise */
+int no_migration;
 int icount_align_option;
 
 /* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in the
diff --git a/softmmu/vl.c b/softmmu/vl.c
index aadb52613888..9a6535e594c3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3339,6 +3339,9 @@ void qemu_init(int argc, char **argv, char **envp)
             case QEMU_OPTION_only_migratable:
                 only_migratable = 1;
                 break;
+            case QEMU_OPTION_no_migration:
+                no_migration = 1;
+                break;
             case QEMU_OPTION_nodefaults:
                 has_defaults = 0;
                 break;
-- 
2.30.2




reply via email to

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