1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-11 09:17:52 +03:00

qemu: domain: Set up disk TLS alias when preparing TLS setup

Move the TLS object alias setup earlier. Also make sure that the alias
is not overwritten on hotplug.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-05-29 17:42:23 +02:00
parent da49ff2c01
commit 9083586b21
3 changed files with 13 additions and 12 deletions

View File

@ -791,9 +791,6 @@ qemuBuildDiskSrcTLSx509CommandLine(virCommandPtr cmd,
/* other protocols may be added later */
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_VXHS &&
src->haveTLS == VIR_TRISTATE_BOOL_YES) {
if (!(src->tlsAlias = qemuAliasTLSObjFromSrcAlias(srcalias)))
return -1;
return qemuBuildTLSx509CommandLine(cmd, src->tlsCertdir,
false, src->tlsVerify,
false, srcalias, qemuCaps);

View File

@ -9957,6 +9957,7 @@ qemuProcessPrepareStorageSourceTLSVxhs(virStorageSourcePtr src,
/* qemuProcessPrepareStorageSourceTLS:
* @source: source for a disk
* @cfg: driver configuration
* @parentAlias: alias of the parent device
*
* Updates host interface TLS encryption setting based on qemu.conf
* for disk devices. This will be presented as "tls='yes|no'" in
@ -9966,7 +9967,8 @@ qemuProcessPrepareStorageSourceTLSVxhs(virStorageSourcePtr src,
*/
static int
qemuDomainPrepareStorageSourceTLS(virStorageSourcePtr src,
virQEMUDriverConfigPtr cfg)
virQEMUDriverConfigPtr cfg,
const char *parentAlias)
{
if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK)
return 0;
@ -10003,6 +10005,10 @@ qemuDomainPrepareStorageSourceTLS(virStorageSourcePtr src,
return -1;
}
if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
!(src->tlsAlias = qemuAliasTLSObjFromSrcAlias(parentAlias)))
return -1;
return 0;
}
@ -12516,6 +12522,9 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefPtr disk,
if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias) < 0)
return -1;
if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg, disk->info.alias) < 0)
return -1;
return 0;
}
@ -12530,9 +12539,6 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
if (qemuDomainPrepareDiskSourceLegacy(disk, priv, cfg) < 0)
return -1;
if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg) < 0)
return -1;
return 0;
}

View File

@ -156,8 +156,7 @@ qemuHotplugPrepareDiskAccess(virQEMUDriverPtr driver,
static int
qemuDomainAddDiskSrcTLSObject(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr src,
const char *srcalias)
virStorageSourcePtr src)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
@ -167,7 +166,7 @@ qemuDomainAddDiskSrcTLSObject(virQEMUDriverPtr driver,
src->tlsCertdir,
false,
src->tlsVerify,
srcalias, &tlsProps, &src->tlsAlias,
NULL, &tlsProps, NULL,
NULL, NULL) < 0)
goto cleanup;
@ -471,8 +470,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
prdStarted = true;
if (disk->src->haveTLS &&
qemuDomainAddDiskSrcTLSObject(driver, vm, disk->src,
disk->info.alias) < 0)
qemuDomainAddDiskSrcTLSObject(driver, vm, disk->src) < 0)
goto error;
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))