qemu: Split out initialization of secrets for 'iscsi' hostdevs

Currently we don't have infrastructure to remember the secret aliases
for hostdevs. Since an upcoming patch is going to change aliases for
the disks, initialize the iscsi hostdevs separately so that we can keep
the alias. At the same time let's use qemuAliasForSecret instead of
qemuDomainGetSecretAESAlias when unplugging the iscsi hostdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-03-09 07:31:53 +01:00
parent 95a8c4332d
commit 740dd1a4e5
2 changed files with 24 additions and 3 deletions

View File

@ -1840,8 +1840,29 @@ qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
src->auth) {
if (qemuDomainSecretStorageSourcePrepare(priv, src,
hostdev->info->alias, NULL) < 0)
bool iscsiHasPS = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET);
virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
qemuDomainStorageSourcePrivatePtr srcPriv;
if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
return -1;
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
if (!qemuDomainSupportsEncryptedSecret(priv) || !iscsiHasPS) {
srcPriv->secinfo = qemuDomainSecretInfoNewPlain(usageType,
src->auth->username,
&src->auth->seclookupdef);
} else {
srcPriv->secinfo = qemuDomainSecretAESSetupFromSecret(priv,
hostdev->info->alias,
usageType,
src->auth->username,
&src->auth->seclookupdef,
false);
}
if (!srcPriv->secinfo)
return -1;
}
}

View File

@ -4471,7 +4471,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET) &&
qemuDomainStorageSourceHasAuth(iscsisrc->src)) {
if (!(objAlias = qemuDomainGetSecretAESAlias(hostdev->info->alias, false)))
if (!(objAlias = qemuAliasForSecret(hostdev->info->alias, NULL)))
return -1;
}