From: John Ferlan <jferlan(a)redhat.com>
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(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 6 ++++--
src/qemu/qemu_domain.c | 14 ++++++++++----
src/qemu/qemu_domain.h | 4 ----
src/qemu/qemu_hotplug.c | 7 +++++--
4 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 40d9eeffd..7c511263b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f44e1436d..aa8370866 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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)))
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 2e1515fa1..30e0a5d8d 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -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 */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5efc60aea..d65aa3a72 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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;
--
2.14.1