[PATCH 3/4] qemu: domain: Don't allocate storage source private data if not needed

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

 



---
 src/qemu/qemu_domain.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 61d28337b..db5af1019 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1402,13 +1402,18 @@ qemuDomainSecretStorageSourcePrepare(virConnectPtr conn,
                                      const char *encalias)
 {
     qemuDomainStorageSourcePrivatePtr srcPriv;
+    bool hasAuth = qemuDomainSecretDiskCapable(src);
+    bool hasEnc = qemuDomainDiskHasEncryptionSecret(src);
+
+    if (!hasAuth && !hasEnc)
+        return 0;

     if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
         return -1;

     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);

-    if (qemuDomainSecretDiskCapable(src)) {
+    if (hasAuth) {
         virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;

         if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
@@ -1421,7 +1426,7 @@ qemuDomainSecretStorageSourcePrepare(virConnectPtr conn,
               return -1;
     }

-    if (qemuDomainDiskHasEncryptionSecret(src)) {
+    if (hasEnc) {
         if (!(srcPriv->encinfo =
               qemuDomainSecretInfoNew(conn, priv, encalias,
                                       VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
-- 
2.14.3

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