Move the TLS object alias setup earlier. Also make sure that the alias
is not overwritten on hotplug.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 3 ---
src/qemu/qemu_domain.c | 14 ++++++++++----
src/qemu/qemu_hotplug.c | 8 +++-----
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0b5ec4f2ba..9ec1d30c80 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 55e47a482d..e329cdf958 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9940,6 +9940,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
@@ -9949,7 +9950,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;
@@ -9986,6 +9988,10 @@ qemuDomainPrepareStorageSourceTLS(virStorageSourcePtr src,
return -1;
}
+ if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
+ !(src->tlsAlias = qemuAliasTLSObjFromSrcAlias(parentAlias)))
+ return -1;
+
return 0;
}
@@ -12499,6 +12505,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;
}
@@ -12513,9 +12522,6 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
if (qemuDomainPrepareDiskSourceLegacy(disk, priv, cfg) < 0)
return -1;
- if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg) < 0)
- return -1;
-
return 0;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f52e0c773d..996063b117 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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)))
--
2.16.2