mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
qemu: Drop qemuMigrationParamsCheckSetupTLS
The code can be merged directly in qemuMigrationParamsAddTLSObjects. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
eb54cb473a
commit
02060be08e
@ -2042,7 +2042,6 @@ qemuMigrationSrcBegin(virConnectPtr conn,
|
||||
unsigned long flags)
|
||||
{
|
||||
virQEMUDriverPtr driver = conn->privateData;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
char *xml = NULL;
|
||||
qemuDomainAsyncJob asyncJob;
|
||||
|
||||
@ -2076,12 +2075,6 @@ qemuMigrationSrcBegin(virConnectPtr conn,
|
||||
nmigrate_disks, migrate_disks, flags)))
|
||||
goto endjob;
|
||||
|
||||
if (flags & VIR_MIGRATE_TLS) {
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuMigrationParamsCheckSetupTLS(driver, cfg, vm, asyncJob) < 0)
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
|
||||
/* We keep the job active across API calls until the confirm() call.
|
||||
* This prevents any other APIs being invoked while migration is taking
|
||||
@ -2098,7 +2091,6 @@ qemuMigrationSrcBegin(virConnectPtr conn,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(cfg);
|
||||
virDomainObjEndAPI(&vm);
|
||||
return xml;
|
||||
|
||||
@ -2460,10 +2452,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
||||
* set the migration TLS parameters */
|
||||
if (flags & VIR_MIGRATE_TLS) {
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuMigrationParamsCheckSetupTLS(driver, cfg, vm,
|
||||
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
|
||||
goto stopjob;
|
||||
|
||||
if (qemuMigrationParamsAddTLSObjects(driver, vm, cfg, true,
|
||||
QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||
&tlsAlias, &secAlias, migParams) < 0)
|
||||
@ -3421,9 +3409,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
|
||||
if (flags & VIR_MIGRATE_TLS) {
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
/* Begin/CheckSetupTLS already set up migTLSAlias, the following
|
||||
* assumes that and adds the TLS objects to the domain. */
|
||||
if (qemuMigrationParamsAddTLSObjects(driver, vm, cfg, false,
|
||||
QEMU_ASYNC_JOB_MIGRATION_OUT,
|
||||
&tlsAlias, &secAlias, migParams) < 0)
|
||||
|
@ -179,56 +179,6 @@ qemuMigrationParamsCheckTLSCreds(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
/* qemuMigrationParamsCheckSetupTLS
|
||||
* @driver: pointer to qemu driver
|
||||
* @vm: domain object
|
||||
* @cfg: configuration pointer
|
||||
* @asyncJob: migration job to join
|
||||
*
|
||||
* Check if TLS is possible and set up the environment. Assumes the caller
|
||||
* desires to use TLS (e.g. caller found VIR_MIGRATE_TLS flag).
|
||||
*
|
||||
* Ensure the qemu.conf has been properly configured to add an entry for
|
||||
* "migrate_tls_x509_cert_dir". Also check if the "tls-creds" parameter
|
||||
* was present from a query of migration parameters
|
||||
*
|
||||
* Returns 0 on success, -1 on error/failure
|
||||
*/
|
||||
int
|
||||
qemuMigrationParamsCheckSetupTLS(virQEMUDriverPtr driver,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
virDomainObjPtr vm,
|
||||
int asyncJob)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
|
||||
if (!cfg->migrateTLSx509certdir) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("host migration TLS directory not configured"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
|
||||
return -1;
|
||||
|
||||
if (!priv->migTLSAlias) {
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||
_("TLS migration is not supported with this "
|
||||
"QEMU binary"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If there's a secret, then grab/store it now using the connection */
|
||||
if (cfg->migrateTLSx509secretUUID &&
|
||||
!(priv->migSecinfo =
|
||||
qemuDomainSecretInfoTLSNew(priv, QEMU_MIGRATION_TLS_ALIAS_BASE,
|
||||
cfg->migrateTLSx509secretUUID)))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* qemuMigrationParamsAddTLSObjects
|
||||
* @driver: pointer to qemu driver
|
||||
* @vm: domain object
|
||||
@ -257,6 +207,29 @@ qemuMigrationParamsAddTLSObjects(virQEMUDriverPtr driver,
|
||||
virJSONValuePtr tlsProps = NULL;
|
||||
virJSONValuePtr secProps = NULL;
|
||||
|
||||
if (!cfg->migrateTLSx509certdir) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("host migration TLS directory not configured"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
|
||||
goto error;
|
||||
|
||||
if (!priv->migTLSAlias) {
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||
_("TLS migration is not supported with this "
|
||||
"QEMU binary"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* If there's a secret, then grab/store it now using the connection */
|
||||
if (cfg->migrateTLSx509secretUUID &&
|
||||
!(priv->migSecinfo =
|
||||
qemuDomainSecretInfoTLSNew(priv, QEMU_MIGRATION_TLS_ALIAS_BASE,
|
||||
cfg->migrateTLSx509secretUUID)))
|
||||
goto error;
|
||||
|
||||
if (qemuDomainGetTLSObjects(priv->qemuCaps, priv->migSecinfo,
|
||||
cfg->migrateTLSx509certdir, tlsListen,
|
||||
cfg->migrateTLSx509verify,
|
||||
|
@ -71,12 +71,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver,
|
||||
int asyncJob,
|
||||
qemuMigrationParamsPtr migParams);
|
||||
|
||||
int
|
||||
qemuMigrationParamsCheckSetupTLS(virQEMUDriverPtr driver,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
virDomainObjPtr vm,
|
||||
int asyncJob);
|
||||
|
||||
int
|
||||
qemuMigrationParamsAddTLSObjects(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
|
Loading…
x
Reference in New Issue
Block a user