From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
Eric Blake <eblake@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
John Ferlan <jferlan@redhat.com>,
Jiri Denemark <jdenemar@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/2] migration: allow clearing migration string parameters
Date: Thu, 2 Mar 2017 12:37:45 +0000 [thread overview]
Message-ID: <20170302123746.9694-2-berrange@redhat.com> (raw)
In-Reply-To: <20170302123746.9694-1-berrange@redhat.com>
Some of the migration parameters are strings, which default to NULL,
eg tls-hostname and tls-creds.
The mgmt app will set the tls-creds parameter on both source and target
QEMU instances, in order to trigger use of TLS for migration.
After performing a TLS encrypted migration though, migration might be
used for other reasons - for example, to save the QEMU state to a file.
We need TLS turned off when doing this, but the migrate-set-parameters
QAPI command does not provide any facility to clear/reset parameters
to their default state.
If you simply omit the tls_creds parameter in migrate-set-parameters,
then 'has_tls_creds' will be false and so no action will be taken. JSON
allows a parameter to have a nil value, but the QEMU JSON visitor will
reject that when deserializing into a QObject.
The migration code has no need to distinguish "" vs NULL for the TLS
hostname or TLS credentials object name, since "" is invalid in both
cases. This enables clearing of tls-hostname and tls-creds by
treating "" as equivalent to NULL.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
migration/migration.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index c6ae69d..a8cb56e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -872,11 +872,19 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
}
if (params->has_tls_creds) {
g_free(s->parameters.tls_creds);
- s->parameters.tls_creds = g_strdup(params->tls_creds);
+ if (*params->tls_creds == '\0') {
+ s->parameters.tls_creds = NULL;
+ } else {
+ s->parameters.tls_creds = g_strdup(params->tls_creds);
+ }
}
if (params->has_tls_hostname) {
g_free(s->parameters.tls_hostname);
- s->parameters.tls_hostname = g_strdup(params->tls_hostname);
+ if (*params->tls_hostname == '\0') {
+ s->parameters.tls_hostname = NULL;
+ } else {
+ s->parameters.tls_hostname = g_strdup(params->tls_hostname);
+ }
}
if (params->has_max_bandwidth) {
s->parameters.max_bandwidth = params->max_bandwidth;
--
2.9.3
next prev parent reply other threads:[~2017-03-02 12:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 12:37 [Qemu-devel] [PATCH v2 0/2] migration: fixes to handling tls-hostname/tls-creds Daniel P. Berrange
2017-03-02 12:37 ` Daniel P. Berrange [this message]
2017-03-02 16:09 ` [Qemu-devel] [PATCH v2 1/2] migration: allow clearing migration string parameters Eric Blake
2017-03-02 12:37 ` [Qemu-devel] [PATCH v2 2/2] migration: always report tls-creds & tls-hostname migrate parameters Daniel P. Berrange
2017-03-02 13:19 ` John Ferlan
2017-03-02 13:23 ` Daniel P. Berrange
2017-03-02 16:08 ` Eric Blake
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=20170302123746.9694-2-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=jdenemar@redhat.com \
--cc=jferlan@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).