qemu: Use private storage source for iscsi instead of private hostdev

Rather than placing/using privateData about secinfo in the hostdev,
let's use the virStorageSource private data instead.
This commit is contained in:
John Ferlan 2017-09-23 07:03:10 -04:00
parent 626ea2d596
commit 16eef5c2b4
2 changed files with 20 additions and 11 deletions

View File

@ -4959,13 +4959,14 @@ static char *
qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
{
char *source = NULL;
qemuDomainHostdevPrivatePtr hostdevPriv = QEMU_DOMAIN_HOSTDEV_PRIVATE(dev);
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
qemuDomainStorageSourcePrivatePtr srcPriv =
QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
/* Rather than pull what we think we want - use the network disk code */
source = qemuBuildNetworkDriveStr(iscsisrc->src, hostdevPriv->secinfo);
source = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ?
srcPriv->secinfo : NULL);
return source;
}

View File

@ -1469,13 +1469,18 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
void
qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr hostdev)
{
qemuDomainHostdevPrivatePtr hostdevPriv =
QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
qemuDomainStorageSourcePrivatePtr srcPriv;
if (!hostdevPriv || !hostdevPriv->secinfo)
return;
if (virHostdevIsSCSIDevice(hostdev)) {
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
qemuDomainSecretInfoFree(&hostdevPriv->secinfo);
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
if (srcPriv && srcPriv->secinfo)
qemuDomainSecretInfoFree(&srcPriv->secinfo);
}
}
}
@ -1497,14 +1502,17 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
virStorageSourcePtr src = iscsisrc->src;
qemuDomainStorageSourcePrivatePtr srcPriv;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
src->auth) {
qemuDomainHostdevPrivatePtr hostdevPriv =
QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
return -1;
if (!(hostdevPriv->secinfo =
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
if (!(srcPriv->secinfo =
qemuDomainSecretInfoNew(conn, priv, hostdev->info->alias,
VIR_SECRET_USAGE_TYPE_ISCSI,
src->auth->username,