[PATCH v5 06/16] qemu: Relocate qemuDomainSecretInfoPtr from disk private

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Relocate into disk source private (qemuDomainDiskSrcPrivatePtr)

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@xxxxxxxxxx>
---
 src/qemu/qemu_command.c |  6 ++++--
 src/qemu/qemu_domain.c  |  9 +++++----
 src/qemu/qemu_domain.h  |  4 ----
 src/qemu/qemu_hotplug.c | 11 ++++++++---
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9c8bde49a8..76725e2d4e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1378,7 +1378,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 {
     int actualType = virStorageSourceGetActualType(disk->src);
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
+    qemuDomainSecretInfoPtr secinfo = diskSrcPriv->secinfo;
     qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
     virJSONValuePtr srcprops = NULL;
     char *source = NULL;
@@ -2255,7 +2256,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
         bool driveBoot = false;
         virDomainDiskDefPtr disk = def->disks[i];
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-        qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
+        qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
+        qemuDomainSecretInfoPtr secinfo = diskSrcPriv->secinfo;
         qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
 
         if (disk->info.bootIndex) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4b5929b251..72433ed36a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -954,7 +954,6 @@ qemuDomainDiskPrivateDispose(void *obj)
 {
     qemuDomainDiskPrivatePtr priv = obj;
 
-    qemuDomainSecretInfoFree(&priv->secinfo);
     qemuDomainSecretInfoFree(&priv->encinfo);
 }
 
@@ -1399,9 +1398,10 @@ void
 qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 {
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
 
-    if (diskPriv && diskPriv->secinfo)
-        qemuDomainSecretInfoFree(&diskPriv->secinfo);
+    if (diskSrcPriv && diskSrcPriv->secinfo)
+        qemuDomainSecretInfoFree(&diskSrcPriv->secinfo);
 
     if (diskPriv && diskPriv->encinfo)
         qemuDomainSecretInfoFree(&diskPriv->encinfo);
@@ -1450,6 +1450,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
 {
     virStorageSourcePtr src = disk->src;
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
 
     if (qemuDomainSecretDiskCapable(src)) {
         virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
@@ -1457,7 +1458,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
         if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
             usageType = VIR_SECRET_USAGE_TYPE_CEPH;
 
-        if (!(diskPriv->secinfo =
+        if (!(diskSrcPriv->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 a7a590c950..fc4f5bc6d8 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -345,10 +345,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 0288986d83..544a592fb7 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);
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv = QEMU_DOMAIN_DISK_SRC_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, diskSrcPriv->secinfo, &sourcestr) < 0)
             goto error;
 
         if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
@@ -369,6 +370,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
     virJSONValuePtr secobjProps = NULL;
     virJSONValuePtr encobjProps = NULL;
     qemuDomainDiskPrivatePtr diskPriv;
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv;
     qemuDomainSecretInfoPtr secinfo;
     qemuDomainSecretInfoPtr encinfo;
 
@@ -406,7 +408,8 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
         goto error;
 
     diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    secinfo = diskPriv->secinfo;
+    diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
+    secinfo = diskSrcPriv->secinfo;
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
         if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
             goto error;
@@ -671,6 +674,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
     virJSONValuePtr encobjProps = NULL;
     virJSONValuePtr secobjProps = NULL;
     qemuDomainDiskPrivatePtr diskPriv;
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv;
     qemuDomainSecretInfoPtr encinfo;
     qemuDomainSecretInfoPtr secinfo;
 
@@ -704,7 +708,8 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
         goto error;
 
     diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    secinfo = diskPriv->secinfo;
+    diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(disk->src);
+    secinfo = diskSrcPriv->secinfo;
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
         if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
             goto error;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux