[PATCH 05/20] Allow caps to be NULL when creating virDomainObjPtr instances

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

If no private data needs to be maintained, it can be useful
to create virDomainObjPtr instances without having a virCapsPtr
instance around. Adapt the virDomainObjNew() function to allow
for a NULL caps

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8952b69..ef368f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1716,12 +1716,14 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps)
         return NULL;
     }
 
-    if (caps->privateDataAllocFunc &&
-        !(domain->privateData = (caps->privateDataAllocFunc)())) {
-        virReportOOMError();
-        goto error;
+    if (caps &&
+        caps->privateDataAllocFunc) {
+        if (!(domain->privateData = (caps->privateDataAllocFunc)())) {
+            virReportOOMError();
+            goto error;
+        }
+        domain->privateDataFreeFunc = caps->privateDataFreeFunc;
     }
-    domain->privateDataFreeFunc = caps->privateDataFreeFunc;
 
     if (!(domain->snapshots = virDomainSnapshotObjListNew()))
         goto error;
-- 
1.7.11.4

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