[PATCH 5/5] qemu: Move encinfo from private disk to private disk src

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

 



From: John Ferlan <jferlan@xxxxxxxxxx>

Since the encryption information can also be disk source specific
move it from qemuDomainDiskPrivate to qemuDomainStorageSourcePrivate

Since the last allocated element from qemuDomainDiskPrivate is
removed, that means we no longer need qemuDomainDiskPrivateDispose.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c |  6 ++----
 src/qemu/qemu_domain.c  | 20 ++++----------------
 src/qemu/qemu_domain.h  |  5 -----
 src/qemu/qemu_hotplug.c |  4 +---
 4 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7c511263b..b1cfafa79 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1361,10 +1361,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
                         virQEMUCapsPtr qemuCaps)
 {
     int actualType = virStorageSourceGetActualType(disk->src);
-    qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
     qemuDomainSecretInfoPtr secinfo = srcpriv->secinfo;
-    qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
+    qemuDomainSecretInfoPtr encinfo = srcpriv->encinfo;
     virJSONValuePtr srcprops = NULL;
     char *source = NULL;
     int ret = -1;
@@ -2239,10 +2238,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
         unsigned int bootindex = 0;
         bool driveBoot = false;
         virDomainDiskDefPtr disk = def->disks[i];
-        qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
         qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
         qemuDomainSecretInfoPtr secinfo = srcPriv->secinfo;
-        qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
+        qemuDomainSecretInfoPtr encinfo = srcPriv->encinfo;

         if (disk->info.bootIndex) {
             bootindex = disk->info.bootIndex;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index aa8370866..2bd3dcb49 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -890,7 +890,6 @@ qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)


 static virClassPtr qemuDomainDiskPrivateClass;
-static void qemuDomainDiskPrivateDispose(void *obj);

 static int
 qemuDomainDiskPrivateOnceInit(void)
@@ -898,7 +897,7 @@ qemuDomainDiskPrivateOnceInit(void)
     qemuDomainDiskPrivateClass = virClassNew(virClassForObject(),
                                              "qemuDomainDiskPrivate",
                                              sizeof(qemuDomainDiskPrivate),
-                                             qemuDomainDiskPrivateDispose);
+                                             NULL);
     if (!qemuDomainDiskPrivateClass)
         return -1;
     else
@@ -922,15 +921,6 @@ qemuDomainDiskPrivateNew(void)
 }


-static void
-qemuDomainDiskPrivateDispose(void *obj)
-{
-    qemuDomainDiskPrivatePtr priv = obj;
-
-    qemuDomainSecretInfoFree(&priv->encinfo);
-}
-
-
 static virClassPtr qemuDomainStorageSourcePrivateClass;
 static void qemuDomainStorageSourcePrivateDispose(void *obj);

@@ -1342,14 +1332,13 @@ qemuDomainSecretInfoTLSNew(virConnectPtr conn,
 void
 qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
 {
-    qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);

     if (srcPriv && srcPriv->secinfo)
         qemuDomainSecretInfoFree(&srcPriv->secinfo);

-    if (diskPriv && diskPriv->encinfo)
-        qemuDomainSecretInfoFree(&diskPriv->encinfo);
+    if (srcPriv && srcPriv->encinfo)
+        qemuDomainSecretInfoFree(&srcPriv->encinfo);
 }


@@ -1394,7 +1383,6 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
                             virDomainDiskDefPtr disk)
 {
     virStorageSourcePtr src = disk->src;
-    qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     qemuDomainStorageSourcePrivatePtr srcPriv;

     if (!(disk->src->privateData = qemuDomainStorageSourcePrivateNew()))
@@ -1416,7 +1404,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
     }

     if (qemuDomainDiskHasEncryptionSecret(src)) {
-        if (!(diskPriv->encinfo =
+        if (!(srcPriv->encinfo =
               qemuDomainSecretInfoNew(conn, priv, disk->info.alias,
                                       VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
                                       &src->encryption->secrets[0]->seclookupdef,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 30e0a5d8d..39cb68b3c 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -349,11 +349,6 @@ struct _qemuDomainDiskPrivate {

     bool migrating; /* the disk is being migrated */

-    /* 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 */
-    qemuDomainSecretInfoPtr encinfo;
-
     /* information about the device */
     bool tray; /* device has tray */
     bool removable; /* device media can be removed/changed */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d65aa3a72..ab07ba25f 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -370,7 +370,6 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     virJSONValuePtr secobjProps = NULL;
     virJSONValuePtr encobjProps = NULL;
-    qemuDomainDiskPrivatePtr diskPriv;
     qemuDomainStorageSourcePrivatePtr srcPriv;
     qemuDomainSecretInfoPtr secinfo;
     qemuDomainSecretInfoPtr encinfo;
@@ -384,7 +383,6 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
     if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
         goto error;

-    diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
     secinfo = srcPriv->secinfo;
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
@@ -392,7 +390,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
             goto error;
     }

-    encinfo = diskPriv->encinfo;
+    encinfo = srcPriv->encinfo;
     if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
         goto error;

-- 
2.14.1

--
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