Rather than placing/using privateData about secinfo in the hostdev,
let's use the virStorageSource (e.g. disksrc) instead.

Signed-off-by: John Ferlan <jfer...@redhat.com>
---
 src/qemu/qemu_command.c |  5 ++---
 src/qemu/qemu_domain.c  | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0dd5d08c1..5f5277e63 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4881,13 +4881,12 @@ 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;
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv = 
QEMU_DOMAIN_DISK_SRC_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, diskSrcPriv->secinfo);
 
     return source;
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b10b36d1d..21fdfd9ee 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1479,13 +1479,18 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
 void
 qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr hostdev)
 {
-    qemuDomainHostdevPrivatePtr hostdevPriv =
-        QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
+    qemuDomainDiskSrcPrivatePtr diskSrcPriv;
 
-    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) {
+            diskSrcPriv = QEMU_DOMAIN_DISK_SRC_PRIVATE(iscsisrc->src);
+            if (diskSrcPriv && diskSrcPriv->secinfo)
+                qemuDomainSecretInfoFree(&diskSrcPriv->secinfo);
+        }
+    }
 }
 
 
@@ -1510,10 +1515,10 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
         if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
             iscsisrc->src->auth) {
 
-            qemuDomainHostdevPrivatePtr hostdevPriv =
-                QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
+            qemuDomainDiskSrcPrivatePtr diskSrcPriv =
+                QEMU_DOMAIN_DISK_SRC_PRIVATE(iscsisrc->src);
 
-            if (!(hostdevPriv->secinfo =
+            if (!(diskSrcPriv->secinfo =
                   qemuDomainSecretInfoNew(conn, priv, hostdev->info->alias,
                                           VIR_SECRET_USAGE_TYPE_ISCSI,
                                           iscsisrc->src->auth->username,
-- 
2.13.5

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

Reply via email to