提交 0beaadfa 编写于 作者: J Jiri Denemark

qemu: Hide cfg inside qemuMigrationParamsEnableTLS

There's no real reason for qemuMigrationParamsEnableTLS to require the
callers to pass a valid virQEMUDriverConfigPtr, it can just call
virQEMUDriverGetConfig.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 312fe9cc
...@@ -2228,7 +2228,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, ...@@ -2228,7 +2228,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
{ {
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virQEMUDriverConfigPtr cfg = NULL;
int ret = -1; int ret = -1;
int dataFD[2] = { -1, -1 }; int dataFD[2] = { -1, -1 };
qemuDomainObjPrivatePtr priv = NULL; qemuDomainObjPrivatePtr priv = NULL;
...@@ -2451,8 +2450,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, ...@@ -2451,8 +2450,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
/* Migrations using TLS need to add the "tls-creds-x509" object and /* Migrations using TLS need to add the "tls-creds-x509" object and
* set the migration TLS parameters */ * set the migration TLS parameters */
if (flags & VIR_MIGRATE_TLS) { if (flags & VIR_MIGRATE_TLS) {
cfg = virQEMUDriverGetConfig(driver); if (qemuMigrationParamsEnableTLS(driver, vm, true,
if (qemuMigrationParamsEnableTLS(driver, vm, cfg, true,
QEMU_ASYNC_JOB_MIGRATION_IN, QEMU_ASYNC_JOB_MIGRATION_IN,
&tlsAlias, &secAlias, NULL, &tlsAlias, &secAlias, NULL,
migParams) < 0) migParams) < 0)
...@@ -2549,7 +2547,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, ...@@ -2549,7 +2547,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
cleanup: cleanup:
VIR_FREE(tlsAlias); VIR_FREE(tlsAlias);
VIR_FREE(secAlias); VIR_FREE(secAlias);
virObjectUnref(cfg);
qemuProcessIncomingDefFree(incoming); qemuProcessIncomingDefFree(incoming);
VIR_FREE(xmlout); VIR_FREE(xmlout);
VIR_FORCE_CLOSE(dataFD[0]); VIR_FORCE_CLOSE(dataFD[0]);
...@@ -3330,7 +3327,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, ...@@ -3330,7 +3327,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
{ {
int ret = -1; int ret = -1;
unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND; unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
virQEMUDriverConfigPtr cfg = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
char *tlsAlias = NULL; char *tlsAlias = NULL;
...@@ -3410,8 +3406,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, ...@@ -3410,8 +3406,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
spec->destType == MIGRATION_DEST_FD) spec->destType == MIGRATION_DEST_FD)
hostname = spec->dest.host.name; hostname = spec->dest.host.name;
cfg = virQEMUDriverGetConfig(driver); if (qemuMigrationParamsEnableTLS(driver, vm, false,
if (qemuMigrationParamsEnableTLS(driver, vm, cfg, false,
QEMU_ASYNC_JOB_MIGRATION_OUT, QEMU_ASYNC_JOB_MIGRATION_OUT,
&tlsAlias, &secAlias, hostname, &tlsAlias, &secAlias, hostname,
migParams) < 0) migParams) < 0)
...@@ -3649,7 +3644,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, ...@@ -3649,7 +3644,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
cleanup: cleanup:
VIR_FREE(tlsAlias); VIR_FREE(tlsAlias);
VIR_FREE(secAlias); VIR_FREE(secAlias);
virObjectUnref(cfg);
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
virDomainDefFree(persistDef); virDomainDefFree(persistDef);
qemuMigrationCookieFree(mig); qemuMigrationCookieFree(mig);
......
...@@ -136,7 +136,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver, ...@@ -136,7 +136,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver,
/* qemuMigrationParamsEnableTLS /* qemuMigrationParamsEnableTLS
* @driver: pointer to qemu driver * @driver: pointer to qemu driver
* @vm: domain object * @vm: domain object
* @cfg: configuration pointer
* @tlsListen: server or client * @tlsListen: server or client
* @asyncJob: Migration job to join * @asyncJob: Migration job to join
* @tlsAlias: alias to be generated for TLS object * @tlsAlias: alias to be generated for TLS object
...@@ -153,7 +152,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver, ...@@ -153,7 +152,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver,
int int
qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virQEMUDriverConfigPtr cfg,
bool tlsListen, bool tlsListen,
int asyncJob, int asyncJob,
char **tlsAlias, char **tlsAlias,
...@@ -164,6 +162,8 @@ qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, ...@@ -164,6 +162,8 @@ qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virJSONValuePtr tlsProps = NULL; virJSONValuePtr tlsProps = NULL;
virJSONValuePtr secProps = NULL; virJSONValuePtr secProps = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
if (!cfg->migrateTLSx509certdir) { if (!cfg->migrateTLSx509certdir) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
...@@ -206,12 +206,16 @@ qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, ...@@ -206,12 +206,16 @@ qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver,
VIR_STRDUP(migParams->params.tlsHostname, hostname ? hostname : "") < 0) VIR_STRDUP(migParams->params.tlsHostname, hostname ? hostname : "") < 0)
goto error; goto error;
return 0; ret = 0;
cleanup:
virObjectUnref(cfg);
return ret;
error: error:
virJSONValueFree(tlsProps); virJSONValueFree(tlsProps);
virJSONValueFree(secProps); virJSONValueFree(secProps);
return -1; goto cleanup;
} }
......
...@@ -74,7 +74,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver, ...@@ -74,7 +74,6 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver,
int int
qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virQEMUDriverConfigPtr cfg,
bool tlsListen, bool tlsListen,
int asyncJob, int asyncJob,
char **tlsAlias, char **tlsAlias,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册