qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] migration: warn about non-migratable configurations unless '--no-migration' was specified
@ 2021-04-15 15:44 Vitaly Kuznetsov
  2021-04-15 16:04 ` Daniel P. Berrangé
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Vitaly Kuznetsov @ 2021-04-15 15:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Juan Quintela, Eduardo Habkost, Markus Armbruster,
	Dr . David Alan Gilbert

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



^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2021-04-20 15:21 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 15:44 [PATCH RFC] migration: warn about non-migratable configurations unless '--no-migration' was specified Vitaly Kuznetsov
2021-04-15 16:04 ` Daniel P. Berrangé
2021-04-15 16:30   ` Eduardo Habkost
2021-04-15 16:40     ` Daniel P. Berrangé
2021-04-15 17:07       ` Daniel P. Berrangé
2021-04-15 17:28   ` Dr. David Alan Gilbert
2021-04-16  7:33     ` Vitaly Kuznetsov
2021-04-16 16:28       ` Eduardo Habkost
2021-04-17  9:33         ` Markus Armbruster
2021-04-19 16:42         ` Daniel P. Berrangé
2021-04-19 16:48           ` Eduardo Habkost
2021-04-19 17:11         ` Dr. David Alan Gilbert
2021-04-19 17:15           ` Daniel P. Berrangé
2021-04-19 17:17             ` Daniel P. Berrangé
2021-04-19 18:47               ` Dr. David Alan Gilbert
2021-04-19 19:32                 ` Eduardo Habkost
2021-04-20 11:51                   ` Dr. David Alan Gilbert
2021-04-20 13:48                     ` Eduardo Habkost
2021-04-20 14:10                       ` Dr. David Alan Gilbert
2021-04-20 14:15                         ` Daniel P. Berrangé
2021-04-20 15:20                         ` Eduardo Habkost
2021-04-17  9:35 ` Markus Armbruster
2021-04-19  7:26   ` Markus Armbruster
2021-04-19 15:46   ` Markus Armbruster
2021-04-18 15:53 ` Peter Maydell
2021-04-19 16:28   ` Eduardo Habkost
2021-04-19 16:37     ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).