On Fri, Apr 11, 2025 at 04:14:32PM -0300, Fabiano Rosas wrote: > The tls_creds, tls_authz and tls_hostname arguments are strings that > can be set by the user. They are allowed to be either a valid string, > an empty string or NULL. The values "" and NULL are effectively > treated the same by the code, but this is not entirely clear because > the handling is not uniform. > > Make the 3 variables be handled the same and at the same place in > options.c. Note that this affects only the internal usage of the > variables. > > (migrate_tls() had to be moved to be able to use migrate_tls_creds()) > > Signed-off-by: Fabiano Rosas <faro...@suse.de> > --- > migration/options.c | 81 ++++++++++++++++++++++++--------------------- > migration/tls.c | 2 +- > 2 files changed, 44 insertions(+), 39 deletions(-) > > diff --git a/migration/options.c b/migration/options.c > index cb8eec218f..7cd465ca94 100644 > --- a/migration/options.c > +++ b/migration/options.c
> @@ -1184,18 +1200,27 @@ static void > migrate_params_test_apply(MigrateSetParameters *params, > } > > if (params->tls_creds) { > - assert(params->tls_creds->type == QTYPE_QSTRING); > - dest->tls_creds = params->tls_creds->u.s; > + if (params->tls_creds->type == QTYPE_QNULL) { > + dest->tls_creds = NULL; > + } else { > + dest->tls_creds = params->tls_creds->u.s; > + } Feels like it is still worth having the assert(QTYPE_QSTRING) in the else branch before we blindly reference the string pointer > } > > if (params->tls_hostname) { > - assert(params->tls_hostname->type == QTYPE_QSTRING); > - dest->tls_hostname = params->tls_hostname->u.s; > + if (params->tls_hostname->type == QTYPE_QNULL) { > + dest->tls_hostname = NULL; > + } else { > + dest->tls_hostname = params->tls_hostname->u.s; > + } > } > > if (params->tls_authz) { > - assert(params->tls_authz->type == QTYPE_QSTRING); > - dest->tls_authz = params->tls_authz->u.s; > + if (params->tls_authz->type == QTYPE_QNULL) { > + dest->tls_authz = NULL; > + } else { > + dest->tls_authz = params->tls_authz->u.s; > + } > } > > if (params->has_max_bandwidth) { With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|