From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [PATCH RFC] migration: warn about non-migratable configurations unless '--no-migration' was specified
Date: Thu, 15 Apr 2021 17:44:02 +0200 [thread overview]
Message-ID: <20210415154402.28424-1-vkuznets@redhat.com> (raw)
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
next reply other threads:[~2021-04-15 15:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 15:44 Vitaly Kuznetsov [this message]
2021-04-15 16:04 ` [PATCH RFC] migration: warn about non-migratable configurations unless '--no-migration' was specified 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é
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210415154402.28424-1-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).