diff options
-rw-r--r-- | hmp.c | 8 | ||||
-rw-r--r-- | migration/migration.c | 27 | ||||
-rw-r--r-- | qapi-schema.json | 20 |
3 files changed, 47 insertions, 8 deletions
@@ -1586,11 +1586,15 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) break; case MIGRATION_PARAMETER_TLS_CREDS: p->has_tls_creds = true; - visit_type_str(v, param, &p->tls_creds, &err); + p->tls_creds = g_new0(StrOrNull, 1); + p->tls_creds->type = QTYPE_QSTRING; + visit_type_str(v, param, &p->tls_creds->u.s, &err); break; case MIGRATION_PARAMETER_TLS_HOSTNAME: p->has_tls_hostname = true; - visit_type_str(v, param, &p->tls_hostname, &err); + p->tls_hostname = g_new0(StrOrNull, 1); + p->tls_hostname->type = QTYPE_QSTRING; + visit_type_str(v, param, &p->tls_hostname->u.s, &err); break; case MIGRATION_PARAMETER_MAX_BANDWIDTH: p->has_max_bandwidth = true; diff --git a/migration/migration.c b/migration/migration.c index 205b801..085c32c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -770,11 +770,13 @@ static void migrate_params_test_apply(MigrateSetParameters *params, } if (params->has_tls_creds) { - dest->tls_creds = g_strdup(params->tls_creds); + assert(params->tls_creds->type == QTYPE_QSTRING); + dest->tls_creds = g_strdup(params->tls_creds->u.s); } if (params->has_tls_hostname) { - dest->tls_hostname = g_strdup(params->tls_hostname); + assert(params->tls_hostname->type == QTYPE_QSTRING); + dest->tls_hostname = g_strdup(params->tls_hostname->u.s); } if (params->has_max_bandwidth) { @@ -822,12 +824,14 @@ static void migrate_params_apply(MigrateSetParameters *params) if (params->has_tls_creds) { g_free(s->parameters.tls_creds); - s->parameters.tls_creds = g_strdup(params->tls_creds); + assert(params->tls_creds->type == QTYPE_QSTRING); + s->parameters.tls_creds = g_strdup(params->tls_creds->u.s); } if (params->has_tls_hostname) { g_free(s->parameters.tls_hostname); - s->parameters.tls_hostname = g_strdup(params->tls_hostname); + assert(params->tls_hostname->type == QTYPE_QSTRING); + s->parameters.tls_hostname = g_strdup(params->tls_hostname->u.s); } if (params->has_max_bandwidth) { @@ -858,6 +862,21 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) { MigrationParameters tmp; + /* TODO Rewrite "" to null instead */ + if (params->has_tls_creds + && params->tls_creds->type == QTYPE_QNULL) { + QDECREF(params->tls_creds->u.n); + params->tls_creds->type = QTYPE_QSTRING; + params->tls_creds->u.s = strdup(""); + } + /* TODO Rewrite "" to null instead */ + if (params->has_tls_hostname + && params->tls_hostname->type == QTYPE_QNULL) { + QDECREF(params->tls_hostname->u.n); + params->tls_hostname->type = QTYPE_QSTRING; + params->tls_hostname->u.s = strdup(""); + } + migrate_params_test_apply(params, &tmp); if (!migrate_params_check(&tmp, errp)) { diff --git a/qapi-schema.json b/qapi-schema.json index 70c3541..9c6c3e1 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -116,6 +116,22 @@ { 'command': 'qmp_capabilities' } ## +# @StrOrNull: +# +# This is a string value or the explicit lack of a string (null +# pointer in C). Intended for cases when 'optional absent' already +# has a different meaning. +# +# @s: the string value +# @n: no string value +# +# Since: 2.10 +## +{ 'alternate': 'StrOrNull', + 'data': { 's': 'str', + 'n': 'null' } } + +## # @LostTickPolicy: # # Policy for handling lost ticks in timer devices. @@ -1098,8 +1114,8 @@ '*decompress-threads': 'int', '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', - '*tls-creds': 'str', - '*tls-hostname': 'str', + '*tls-creds': 'StrOrNull', + '*tls-hostname': 'StrOrNull', '*max-bandwidth': 'int', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', |