diff mbox

[v2,2/2] migration: always report tls-creds & tls-hostname migrate parameters

Message ID 20170302123746.9694-3-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé March 2, 2017, 12:37 p.m. UTC
Currently the query-migrate-parameters command will omit reporting
of the tls-creds & tls-hostname parameters if their value is NULL.
This makes it impossible for an app to detect if these parameters
are supported by QEMU, without trying to actually set them and
catching the error. Since the code is treating "" and NULL as
equivalent, we can simply always report these values and give them
a value of "". This allows apps like libvirt to detect the fact
that these parameters are supported by QEMU.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 migration/migration.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

John Ferlan March 2, 2017, 1:19 p.m. UTC | #1
On 03/02/2017 07:37 AM, Daniel P. Berrange wrote:
> Currently the query-migrate-parameters command will omit reporting
> of the tls-creds & tls-hostname parameters if their value is NULL.
> This makes it impossible for an app to detect if these parameters
> are supported by QEMU, without trying to actually set them and
> catching the error. Since the code is treating "" and NULL as
> equivalent, we can simply always report these values and give them
> a value of "". This allows apps like libvirt to detect the fact
> that these parameters are supported by QEMU.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  migration/migration.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 

Should the query-migrate-parameters description in qapi-schema.json also
be updated?  Anywhere else I haven't found yet either...

Naively asking - would the plan be to also get these changes accepted
for previous releases w/ tls-creds/hostname support? (2.7, 2.8). Mostly
curious - not that it matters since the query will tell me the answer.

John

> diff --git a/migration/migration.c b/migration/migration.c
> index a8cb56e..760f104 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -581,10 +581,12 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
>      params->cpu_throttle_initial = s->parameters.cpu_throttle_initial;
>      params->has_cpu_throttle_increment = true;
>      params->cpu_throttle_increment = s->parameters.cpu_throttle_increment;
> -    params->has_tls_creds = !!s->parameters.tls_creds;
> -    params->tls_creds = g_strdup(s->parameters.tls_creds);
> -    params->has_tls_hostname = !!s->parameters.tls_hostname;
> -    params->tls_hostname = g_strdup(s->parameters.tls_hostname);
> +    params->has_tls_creds = true;
> +    params->tls_creds = g_strdup(s->parameters.tls_creds ?
> +                                 s->parameters.tls_creds : "");
> +    params->has_tls_hostname = true;
> +    params->tls_hostname = g_strdup(s->parameters.tls_hostname ?
> +                                    s->parameters.tls_hostname : "");
>      params->has_max_bandwidth = true;
>      params->max_bandwidth = s->parameters.max_bandwidth;
>      params->has_downtime_limit = true;
>
Daniel P. Berrangé March 2, 2017, 1:23 p.m. UTC | #2
On Thu, Mar 02, 2017 at 08:19:29AM -0500, John Ferlan wrote:
> 
> 
> On 03/02/2017 07:37 AM, Daniel P. Berrange wrote:
> > Currently the query-migrate-parameters command will omit reporting
> > of the tls-creds & tls-hostname parameters if their value is NULL.
> > This makes it impossible for an app to detect if these parameters
> > are supported by QEMU, without trying to actually set them and
> > catching the error. Since the code is treating "" and NULL as
> > equivalent, we can simply always report these values and give them
> > a value of "". This allows apps like libvirt to detect the fact
> > that these parameters are supported by QEMU.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> >  migration/migration.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> 
> Should the query-migrate-parameters description in qapi-schema.json also
> be updated?  Anywhere else I haven't found yet either...

That's just a code example, the actual parameters are documented against
the MigrationParameters struct definition. That said, we might as well
update the example too.

> Naively asking - would the plan be to also get these changes accepted
> for previous releases w/ tls-creds/hostname support? (2.7, 2.8). Mostly
> curious - not that it matters since the query will tell me the answer.

QEMU only maintains one stable branch, but I think we could add these
to 2.8

Regards,
Daniel
Eric Blake March 2, 2017, 4:08 p.m. UTC | #3
On 03/02/2017 06:37 AM, Daniel P. Berrange wrote:
> Currently the query-migrate-parameters command will omit reporting
> of the tls-creds & tls-hostname parameters if their value is NULL.
> This makes it impossible for an app to detect if these parameters
> are supported by QEMU, without trying to actually set them and
> catching the error. Since the code is treating "" and NULL as
> equivalent, we can simply always report these values and give them
> a value of "". This allows apps like libvirt to detect the fact
> that these parameters are supported by QEMU.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  migration/migration.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

The .c changes look fine, but I agree that we want to document the
special-case of "" in the .json file.  Looking forward to v3.
diff mbox

Patch

diff --git a/migration/migration.c b/migration/migration.c
index a8cb56e..760f104 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -581,10 +581,12 @@  MigrationParameters *qmp_query_migrate_parameters(Error **errp)
     params->cpu_throttle_initial = s->parameters.cpu_throttle_initial;
     params->has_cpu_throttle_increment = true;
     params->cpu_throttle_increment = s->parameters.cpu_throttle_increment;
-    params->has_tls_creds = !!s->parameters.tls_creds;
-    params->tls_creds = g_strdup(s->parameters.tls_creds);
-    params->has_tls_hostname = !!s->parameters.tls_hostname;
-    params->tls_hostname = g_strdup(s->parameters.tls_hostname);
+    params->has_tls_creds = true;
+    params->tls_creds = g_strdup(s->parameters.tls_creds ?
+                                 s->parameters.tls_creds : "");
+    params->has_tls_hostname = true;
+    params->tls_hostname = g_strdup(s->parameters.tls_hostname ?
+                                    s->parameters.tls_hostname : "");
     params->has_max_bandwidth = true;
     params->max_bandwidth = s->parameters.max_bandwidth;
     params->has_downtime_limit = true;