qemu: Relocate qemuDomainSecretInfoPtr to qemuDomainStorageSourcePrivate

Since the secret information is really virStorageSource specific
piece of data, let's manage the privateData from there instead of
at the Disk level.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
John Ferlan 2017-10-05 09:22:13 -04:00 committed by Peter Krempa
parent 3ff3eb70c7
commit ab0e32fbdf
4 changed files with 19 additions and 12 deletions

View File

@ -1362,7 +1362,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
{
int actualType = virStorageSourceGetActualType(disk->src);
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = srcpriv->secinfo;
qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
virJSONValuePtr srcprops = NULL;
char *source = NULL;
@ -2239,7 +2240,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
bool driveBoot = false;
virDomainDiskDefPtr disk = def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = srcPriv->secinfo;
qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
if (disk->info.bootIndex) {

View File

@ -927,7 +927,6 @@ qemuDomainDiskPrivateDispose(void *obj)
{
qemuDomainDiskPrivatePtr priv = obj;
qemuDomainSecretInfoFree(&priv->secinfo);
qemuDomainSecretInfoFree(&priv->encinfo);
}
@ -1344,9 +1343,10 @@ void
qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
if (diskPriv && diskPriv->secinfo)
qemuDomainSecretInfoFree(&diskPriv->secinfo);
if (srcPriv && srcPriv->secinfo)
qemuDomainSecretInfoFree(&srcPriv->secinfo);
if (diskPriv && diskPriv->encinfo)
qemuDomainSecretInfoFree(&diskPriv->encinfo);
@ -1395,6 +1395,12 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
{
virStorageSourcePtr src = disk->src;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv;
if (!(disk->src->privateData = qemuDomainStorageSourcePrivateNew()))
return -1;
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
if (qemuDomainSecretDiskCapable(src)) {
virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
@ -1402,7 +1408,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
usageType = VIR_SECRET_USAGE_TYPE_CEPH;
if (!(diskPriv->secinfo =
if (!(srcPriv->secinfo =
qemuDomainSecretInfoNew(conn, priv, disk->info.alias,
usageType, src->auth->username,
&src->auth->seclookupdef, false)))

View File

@ -349,10 +349,6 @@ struct _qemuDomainDiskPrivate {
bool migrating; /* the disk is being migrated */
/* for storage devices using auth/secret
* NB: *not* to be written to qemu domain object XML */
qemuDomainSecretInfoPtr secinfo;
/* for storage devices using encryption/secret
* Can have both <auth> and <encryption> for some disks
* NB:*not* to be written to qemu domain object XML */

View File

@ -258,6 +258,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
char *driveAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
const char *format = NULL;
char *sourcestr = NULL;
@ -299,7 +300,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
}
if (!virStorageSourceIsEmpty(newsrc)) {
if (qemuGetDriveSourceString(newsrc, diskPriv->secinfo, &sourcestr) < 0)
if (qemuGetDriveSourceString(newsrc, srcPriv->secinfo, &sourcestr) < 0)
goto error;
if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
@ -370,6 +371,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
virJSONValuePtr secobjProps = NULL;
virJSONValuePtr encobjProps = NULL;
qemuDomainDiskPrivatePtr diskPriv;
qemuDomainStorageSourcePrivatePtr srcPriv;
qemuDomainSecretInfoPtr secinfo;
qemuDomainSecretInfoPtr encinfo;
@ -383,7 +385,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
goto error;
diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
secinfo = diskPriv->secinfo;
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
secinfo = srcPriv->secinfo;
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
goto error;