From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Laurent Vivier <lvivier@redhat.com>, Peter Xu <peterx@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH v3 06/10] migration: check global params for validity
Date: Tue, 18 Jul 2017 11:39:06 +0800 [thread overview]
Message-ID: <1500349150-13240-7-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1500349150-13240-1-git-send-email-peterx@redhat.com>
Adding validity check for the migration parameters passed in via global
properties.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 8c65054..a4a8ed8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -102,14 +102,22 @@ enum mig_rp_message_type {
static MigrationState *current_migration;
+static bool migration_object_check(MigrationState *ms, Error **errp);
+
void migration_object_init(void)
{
MachineState *ms = MACHINE(qdev_get_machine());
+ Error *err = NULL;
/* This can only be called once. */
assert(!current_migration);
current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION));
+ if (!migration_object_check(current_migration, &err)) {
+ error_report_err(err);
+ exit(1);
+ }
+
/*
* We cannot really do this in migration_instance_init() since at
* that time global properties are not yet applied, then this
@@ -2101,12 +2109,38 @@ static void migration_class_init(ObjectClass *klass, void *data)
static void migration_instance_init(Object *obj)
{
MigrationState *ms = MIGRATION_OBJ(obj);
+ MigrationParameters *params = &ms->parameters;
ms->state = MIGRATION_STATUS_NONE;
ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
ms->mbps = -1;
- ms->parameters.tls_creds = g_strdup("");
- ms->parameters.tls_hostname = g_strdup("");
+
+ params->tls_hostname = g_strdup("");
+ params->tls_creds = g_strdup("");
+
+ /* Set has_* up only for parameter checks */
+ params->has_compress_level = true;
+ params->has_compress_threads = true;
+ params->has_decompress_threads = true;
+ params->has_cpu_throttle_initial = true;
+ params->has_cpu_throttle_increment = true;
+ params->has_max_bandwidth = true;
+ params->has_downtime_limit = true;
+ params->has_x_checkpoint_delay = true;
+ params->has_block_incremental = true;
+}
+
+/*
+ * Return true if check pass, false otherwise. Error will be put
+ * inside errp if provided.
+ */
+static bool migration_object_check(MigrationState *ms, Error **errp)
+{
+ if (!migrate_params_check(&ms->parameters, errp)) {
+ return false;
+ }
+
+ return true;
}
static const TypeInfo migration_type = {
--
2.7.4
next prev parent reply other threads:[~2017-07-18 3:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 3:39 [Qemu-devel] [PATCH v3 00/10] migration: export cap/params to qdev props Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 01/10] qdev: provide DEFINE_PROP_INT64() Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 02/10] migration: export parameters to props Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 03/10] migration: export capabilities " Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 04/10] migration: introduce migrate_params_check() Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 05/10] migration: provide migrate_params_apply() Peter Xu
2017-07-18 3:39 ` Peter Xu [this message]
2017-07-18 8:20 ` [Qemu-devel] [PATCH v3 06/10] migration: check global params for validity Juan Quintela
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 07/10] migration: remove check against colo support Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 08/10] migration: provide migrate_caps_check() Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 09/10] migration: provide migrate_cap_add() Peter Xu
2017-07-18 3:39 ` [Qemu-devel] [PATCH v3 10/10] migration: check global caps for validity Peter Xu
2017-07-18 8:21 ` Juan Quintela
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=1500349150-13240-7-git-send-email-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=lvivier@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).