提交 a69e266d 编写于 作者: J John Ferlan

qemu: Set up the migration TLS objects for source

https://bugzilla.redhat.com/show_bug.cgi?id=1300769

If the migration flags indicate this migration will be using TLS,
then while we have connection in the Begin phase check and setup the
TLS environment that will be used by virMigrationRun during the Perform
phase for the source to configure TLS.

Processing adds an "-object tls-creds-x509,endpoint=client,..." and
possibly an "-object secret,..." to handle the passphrase response.

Then it sets the 'tls-creds' and possibly 'tls-hostname' migration
parameters.

The qemuMigrateCancel will clean up and reset the environment as it
was originally found.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 1a6b6d9a
...@@ -3442,6 +3442,7 @@ qemuMigrationBegin(virConnectPtr conn, ...@@ -3442,6 +3442,7 @@ qemuMigrationBegin(virConnectPtr conn,
unsigned long flags) unsigned long flags)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
virQEMUDriverConfigPtr cfg = NULL;
char *xml = NULL; char *xml = NULL;
qemuDomainAsyncJob asyncJob; qemuDomainAsyncJob asyncJob;
...@@ -3475,6 +3476,12 @@ qemuMigrationBegin(virConnectPtr conn, ...@@ -3475,6 +3476,12 @@ qemuMigrationBegin(virConnectPtr conn,
nmigrate_disks, migrate_disks, flags))) nmigrate_disks, migrate_disks, flags)))
goto endjob; goto endjob;
if (flags & VIR_MIGRATE_TLS) {
cfg = virQEMUDriverGetConfig(driver);
if (qemuMigrationCheckSetupTLS(conn, driver, cfg, vm, asyncJob) < 0)
goto endjob;
}
if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) { if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
/* We keep the job active across API calls until the confirm() call. /* We keep the job active across API calls until the confirm() call.
* This prevents any other APIs being invoked while migration is taking * This prevents any other APIs being invoked while migration is taking
...@@ -3491,6 +3498,7 @@ qemuMigrationBegin(virConnectPtr conn, ...@@ -3491,6 +3498,7 @@ qemuMigrationBegin(virConnectPtr conn,
} }
cleanup: cleanup:
virObjectUnref(cfg);
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
return xml; return xml;
...@@ -4951,8 +4959,11 @@ qemuMigrationRun(virQEMUDriverPtr driver, ...@@ -4951,8 +4959,11 @@ qemuMigrationRun(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 *secAlias = NULL;
qemuMigrationIOThreadPtr iothread = NULL; qemuMigrationIOThreadPtr iothread = NULL;
int fd = -1; int fd = -1;
unsigned long migrate_speed = resource ? resource : priv->migMaxBandwidth; unsigned long migrate_speed = resource ? resource : priv->migMaxBandwidth;
...@@ -5016,6 +5027,35 @@ qemuMigrationRun(virQEMUDriverPtr driver, ...@@ -5016,6 +5027,35 @@ qemuMigrationRun(virQEMUDriverPtr driver,
if (qemuDomainMigrateGraphicsRelocate(driver, vm, mig, graphicsuri) < 0) if (qemuDomainMigrateGraphicsRelocate(driver, vm, mig, graphicsuri) < 0)
VIR_WARN("unable to provide data for graphics client relocation"); VIR_WARN("unable to provide data for graphics client relocation");
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 (qemuMigrationAddTLSObjects(driver, vm, cfg, false,
QEMU_ASYNC_JOB_MIGRATION_OUT,
&tlsAlias, &secAlias, migParams) < 0)
goto cleanup;
/* We need to add tls-hostname whenever QEMU itself does not
* connect directly to the destination. */
if (spec->destType == MIGRATION_DEST_CONNECT_HOST ||
spec->destType == MIGRATION_DEST_FD) {
if (VIR_STRDUP(migParams->migrateTLSHostname,
spec->dest.host.name) < 0)
goto cleanup;
} else {
/* Be sure there's nothing from a previous migration */
if (VIR_STRDUP(migParams->migrateTLSHostname, "") < 0)
goto cleanup;
}
} else {
if (qemuMigrationSetEmptyTLSParams(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT,
migParams) < 0)
goto cleanup;
}
if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
QEMU_MONITOR_MIGRATE_NON_SHARED_INC)) { QEMU_MONITOR_MIGRATE_NON_SHARED_INC)) {
if (mig->nbd) { if (mig->nbd) {
...@@ -5196,6 +5236,14 @@ qemuMigrationRun(virQEMUDriverPtr driver, ...@@ -5196,6 +5236,14 @@ qemuMigrationRun(virQEMUDriverPtr driver,
ret = -1; ret = -1;
} }
if (qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
tlsAlias, secAlias) < 0)
ret = -1;
VIR_FREE(tlsAlias);
VIR_FREE(secAlias);
virObjectUnref(cfg);
if (spec->fwdType != MIGRATION_FWD_DIRECT) { if (spec->fwdType != MIGRATION_FWD_DIRECT) {
if (iothread && qemuMigrationStopTunnel(iothread, ret < 0) < 0) if (iothread && qemuMigrationStopTunnel(iothread, ret < 0) < 0)
ret = -1; ret = -1;
...@@ -6900,6 +6948,9 @@ qemuMigrationCancel(virQEMUDriverPtr driver, ...@@ -6900,6 +6948,9 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
if (qemuDomainObjExitMonitor(driver, vm) < 0 || (storage && !blockJobs)) if (qemuDomainObjExitMonitor(driver, vm) < 0 || (storage && !blockJobs))
goto endsyncjob; goto endsyncjob;
ignore_value(qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE,
NULL, NULL));
if (!storage) { if (!storage) {
ret = 0; ret = 0;
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册