mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
qemu: Add TLS params to _qemuMonitorMigrationParams
Add the fields to support setting tls-creds and tls-hostname during a migration (either source or target). Modify the query migration function to check for the presence and set the field for future consumers to determine which of 3 conditions is being met (NULL, present and set to "", or present and sent to something). These correspond to qemu commit id '4af245dc3' which added support to default the value to "" and allow setting (or resetting) to "" in order to disable. This reset option allows libvirt to properly use the tls-creds and tls-hostname parameters. Modify code paths that either allocate or use stack space in order to call qemuMigrationParamsClear or qemuMigrationParamsFree for cleanup. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
6a8d898de6
commit
3d06cb96fb
@ -11845,6 +11845,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
|
|||||||
flags, dname, resource, false);
|
flags, dname, resource, false);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
qemuMigrationParamsClear(&migParams);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -12253,6 +12254,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
|
|||||||
flags, dname, resource, true);
|
flags, dname, resource, true);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
qemuMigrationParamsClear(&migParams);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -12343,7 +12345,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
|
|||||||
flags, dname, bandwidth, true);
|
flags, dname, bandwidth, true);
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
VIR_FREE(migParams);
|
qemuMigrationParamsFree(&migParams);
|
||||||
VIR_FREE(migrate_disks);
|
VIR_FREE(migrate_disks);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3508,6 +3508,28 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuMigrationParamsClear(qemuMonitorMigrationParamsPtr migParams)
|
||||||
|
{
|
||||||
|
if (!migParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VIR_FREE(migParams->migrateTLSAlias);
|
||||||
|
VIR_FREE(migParams->migrateTLSHostname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuMigrationParamsFree(qemuMonitorMigrationParamsPtr *migParams)
|
||||||
|
{
|
||||||
|
if (!*migParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
qemuMigrationParamsClear(*migParams);
|
||||||
|
VIR_FREE(*migParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
qemuMonitorMigrationParamsPtr
|
qemuMonitorMigrationParamsPtr
|
||||||
qemuMigrationParams(virTypedParameterPtr params,
|
qemuMigrationParams(virTypedParameterPtr params,
|
||||||
int nparams,
|
int nparams,
|
||||||
@ -3549,7 +3571,7 @@ qemuMigrationParams(virTypedParameterPtr params,
|
|||||||
return migParams;
|
return migParams;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(migParams);
|
qemuMigrationParamsFree(&migParams);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3909,6 +3931,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|||||||
virDomainObjRemoveTransientDef(vm);
|
virDomainObjRemoveTransientDef(vm);
|
||||||
qemuDomainRemoveInactive(driver, vm);
|
qemuDomainRemoveInactive(driver, vm);
|
||||||
}
|
}
|
||||||
|
qemuMigrationParamsClear(&migParams);
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
qemuDomainEventQueue(driver, event);
|
qemuDomainEventQueue(driver, event);
|
||||||
qemuMigrationCookieFree(mig);
|
qemuMigrationCookieFree(mig);
|
||||||
@ -5244,6 +5267,7 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver,
|
|||||||
virSetError(orig_err);
|
virSetError(orig_err);
|
||||||
virFreeError(orig_err);
|
virFreeError(orig_err);
|
||||||
}
|
}
|
||||||
|
qemuMigrationParamsClear(&migParams);
|
||||||
VIR_FREE(uri_out);
|
VIR_FREE(uri_out);
|
||||||
VIR_FREE(cookie);
|
VIR_FREE(cookie);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
|
@ -121,6 +121,12 @@ int qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression,
|
|||||||
int *maxparams,
|
int *maxparams,
|
||||||
unsigned long *flags);
|
unsigned long *flags);
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuMigrationParamsClear(qemuMonitorMigrationParamsPtr migParams);
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuMigrationParamsFree(qemuMonitorMigrationParamsPtr *migParams);
|
||||||
|
|
||||||
qemuMonitorMigrationParamsPtr
|
qemuMonitorMigrationParamsPtr
|
||||||
qemuMigrationParams(virTypedParameterPtr params,
|
qemuMigrationParams(virTypedParameterPtr params,
|
||||||
int nparams,
|
int nparams,
|
||||||
|
@ -2529,12 +2529,15 @@ qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
|
|||||||
{
|
{
|
||||||
VIR_DEBUG("compressLevel=%d:%d compressThreads=%d:%d "
|
VIR_DEBUG("compressLevel=%d:%d compressThreads=%d:%d "
|
||||||
"decompressThreads=%d:%d cpuThrottleInitial=%d:%d "
|
"decompressThreads=%d:%d cpuThrottleInitial=%d:%d "
|
||||||
"cpuThrottleIncrement=%d:%d",
|
"cpuThrottleIncrement=%d:%d tlsAlias=%s "
|
||||||
|
"tlsHostname=%s",
|
||||||
params->compressLevel_set, params->compressLevel,
|
params->compressLevel_set, params->compressLevel,
|
||||||
params->compressThreads_set, params->compressThreads,
|
params->compressThreads_set, params->compressThreads,
|
||||||
params->decompressThreads_set, params->decompressThreads,
|
params->decompressThreads_set, params->decompressThreads,
|
||||||
params->cpuThrottleInitial_set, params->cpuThrottleInitial,
|
params->cpuThrottleInitial_set, params->cpuThrottleInitial,
|
||||||
params->cpuThrottleIncrement_set, params->cpuThrottleIncrement);
|
params->cpuThrottleIncrement_set, params->cpuThrottleIncrement,
|
||||||
|
NULLSTR(params->migrateTLSAlias),
|
||||||
|
NULLSTR(params->migrateTLSHostname));
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR_JSON(mon);
|
QEMU_CHECK_MONITOR_JSON(mon);
|
||||||
|
|
||||||
@ -2542,7 +2545,9 @@ qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
|
|||||||
!params->compressThreads_set &&
|
!params->compressThreads_set &&
|
||||||
!params->decompressThreads_set &&
|
!params->decompressThreads_set &&
|
||||||
!params->cpuThrottleInitial_set &&
|
!params->cpuThrottleInitial_set &&
|
||||||
!params->cpuThrottleIncrement_set)
|
!params->cpuThrottleIncrement_set &&
|
||||||
|
!params->migrateTLSAlias &&
|
||||||
|
!params->migrateTLSHostname)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return qemuMonitorJSONSetMigrationParams(mon, params);
|
return qemuMonitorJSONSetMigrationParams(mon, params);
|
||||||
|
@ -571,6 +571,11 @@ struct _qemuMonitorMigrationParams {
|
|||||||
|
|
||||||
bool cpuThrottleIncrement_set;
|
bool cpuThrottleIncrement_set;
|
||||||
int cpuThrottleIncrement;
|
int cpuThrottleIncrement;
|
||||||
|
|
||||||
|
/* Value is either NULL, "", or some string. NULL indicates no support;
|
||||||
|
* whereas, some string value indicates we can support setting/clearing */
|
||||||
|
char *migrateTLSAlias;
|
||||||
|
char *migrateTLSHostname;
|
||||||
};
|
};
|
||||||
|
|
||||||
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
|
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
|
||||||
|
@ -2566,6 +2566,7 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr result;
|
virJSONValuePtr result;
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
|
const char *tlsStr = NULL;
|
||||||
|
|
||||||
memset(params, 0, sizeof(*params));
|
memset(params, 0, sizeof(*params));
|
||||||
|
|
||||||
@ -2595,6 +2596,16 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
#undef PARSE
|
#undef PARSE
|
||||||
|
|
||||||
|
if ((tlsStr = virJSONValueObjectGetString(result, "tls-creds"))) {
|
||||||
|
if (VIR_STRDUP(params->migrateTLSAlias, tlsStr) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tlsStr = virJSONValueObjectGetString(result, "tls-hostname"))) {
|
||||||
|
if (VIR_STRDUP(params->migrateTLSHostname, tlsStr) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
@ -2637,6 +2648,16 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
#undef APPEND
|
#undef APPEND
|
||||||
|
|
||||||
|
if (params->migrateTLSAlias &&
|
||||||
|
virJSONValueObjectAppendString(args, "tls-creds",
|
||||||
|
params->migrateTLSAlias) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (params->migrateTLSHostname &&
|
||||||
|
virJSONValueObjectAppendString(args, "tls-hostname",
|
||||||
|
params->migrateTLSHostname) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virJSONValueObjectAppend(cmd, "arguments", args) < 0)
|
if (virJSONValueObjectAppend(cmd, "arguments", args) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
args = NULL;
|
args = NULL;
|
||||||
|
@ -1789,7 +1789,9 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationParams(const void *data)
|
|||||||
" \"cpu-throttle-increment\": 10,"
|
" \"cpu-throttle-increment\": 10,"
|
||||||
" \"compress-threads\": 8,"
|
" \"compress-threads\": 8,"
|
||||||
" \"compress-level\": 1,"
|
" \"compress-level\": 1,"
|
||||||
" \"cpu-throttle-initial\": 20"
|
" \"cpu-throttle-initial\": 20,"
|
||||||
|
" \"tls-creds\": \"tls0\","
|
||||||
|
" \"tls-hostname\": \"\""
|
||||||
" }"
|
" }"
|
||||||
"}") < 0) {
|
"}") < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1819,11 +1821,32 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationParams(const void *data)
|
|||||||
CHECK(cpuThrottleInitial, "cpu-throttle-initial", 20);
|
CHECK(cpuThrottleInitial, "cpu-throttle-initial", 20);
|
||||||
CHECK(cpuThrottleIncrement, "cpu-throttle-increment", 10);
|
CHECK(cpuThrottleIncrement, "cpu-throttle-increment", 10);
|
||||||
|
|
||||||
|
#undef CHECK
|
||||||
|
|
||||||
|
#define CHECK(VAR, FIELD, VALUE) \
|
||||||
|
do { \
|
||||||
|
if (!params.VAR) { \
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s is not set", FIELD); \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
if (STRNEQ(params.VAR, VALUE)) { \
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||||
|
"Invalid %s:'%s', expected '%s'", \
|
||||||
|
FIELD, params.VAR, VALUE); \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
CHECK(migrateTLSAlias, "tls-creds", "tls0");
|
||||||
|
CHECK(migrateTLSHostname, "tls-hostname", "");
|
||||||
|
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(params.migrateTLSAlias);
|
||||||
|
VIR_FREE(params.migrateTLSHostname);
|
||||||
qemuMonitorTestFree(test);
|
qemuMonitorTestFree(test);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user