[PATCH 2/5] conf: expose APIs to let drivers load individual config / status files

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

 



Currently drivers can only do a bulk load of config / status files for
their guests. This exposes some helper methods to allow individual
guests to be loaded.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/conf/virdomainobjlist.c | 98 ++++++++++++++++++++++++++++++++-------------
 src/conf/virdomainobjlist.h | 17 ++++++++
 src/libvirt_private.syms    |  2 +
 3 files changed, 89 insertions(+), 28 deletions(-)

diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 87a742b1ea..37f795fe6d 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -443,16 +443,15 @@ void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
     virObjectUnlock(dom);
 }
 
-
 static virDomainObjPtr
-virDomainObjListLoadConfig(virDomainObjListPtr doms,
-                           virCapsPtr caps,
-                           virDomainXMLOptionPtr xmlopt,
-                           const char *configDir,
-                           const char *autostartDir,
-                           const char *name,
-                           virDomainLoadConfigNotify notify,
-                           void *opaque)
+virDomainObjListLoadConfigLocked(virDomainObjListPtr doms,
+                                 virCapsPtr caps,
+                                 virDomainXMLOptionPtr xmlopt,
+                                 const char *configDir,
+                                 const char *autostartDir,
+                                 const char *name,
+                                 virDomainLoadConfigNotify notify,
+                                 void *opaque)
 {
     char *configFile = NULL, *autostartLink = NULL;
     virDomainDefPtr def = NULL;
@@ -496,14 +495,36 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms,
 }
 
 
-static virDomainObjPtr
-virDomainObjListLoadStatus(virDomainObjListPtr doms,
-                           const char *statusDir,
-                           const char *name,
+virDomainObjPtr
+virDomainObjListLoadConfig(virDomainObjListPtr doms,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
+                           const char *configDir,
+                           const char *autostartDir,
+                           const char *name,
                            virDomainLoadConfigNotify notify,
                            void *opaque)
+{
+    virDomainObjPtr vm = NULL;
+    virObjectRWLockWrite(doms);
+
+    vm = virDomainObjListLoadConfigLocked(doms, caps, xmlopt, configDir,
+                                          autostartDir, name, notify, opaque);
+    virObjectRef(vm);
+
+    virObjectRWUnlock(doms);
+    return vm;
+}
+
+
+static virDomainObjPtr
+virDomainObjListLoadStatusLocked(virDomainObjListPtr doms,
+                                 const char *statusDir,
+                                 const char *name,
+                                 virCapsPtr caps,
+                                 virDomainXMLOptionPtr xmlopt,
+                                 virDomainLoadConfigNotify notify,
+                                 void *opaque)
 {
     char *statusFile = NULL;
     virDomainObjPtr obj = NULL;
@@ -555,6 +576,27 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms,
 }
 
 
+virDomainObjPtr
+virDomainObjListLoadStatus(virDomainObjListPtr doms,
+                           const char *statusDir,
+                           const char *name,
+                           virCapsPtr caps,
+                           virDomainXMLOptionPtr xmlopt,
+                           virDomainLoadConfigNotify notify,
+                           void *opaque)
+{
+    virDomainObjPtr vm = NULL;
+    virObjectRWLockWrite(doms);
+
+    vm = virDomainObjListLoadStatusLocked(doms, statusDir, name, caps, xmlopt,
+                                          notify, opaque);
+    virObjectRef(vm);
+
+    virObjectRWUnlock(doms);
+    return vm;
+}
+
+
 int
 virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
                                const char *configDir,
@@ -587,22 +629,22 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
            kill the whole process */
         VIR_INFO("Loading config file '%s.xml'", entry->d_name);
         if (liveStatus)
-            dom = virDomainObjListLoadStatus(doms,
-                                             configDir,
-                                             entry->d_name,
-                                             caps,
-                                             xmlopt,
-                                             notify,
-                                             opaque);
+            dom = virDomainObjListLoadStatusLocked(doms,
+                                                   configDir,
+                                                   entry->d_name,
+                                                   caps,
+                                                   xmlopt,
+                                                   notify,
+                                                   opaque);
         else
-            dom = virDomainObjListLoadConfig(doms,
-                                             caps,
-                                             xmlopt,
-                                             configDir,
-                                             autostartDir,
-                                             entry->d_name,
-                                             notify,
-                                             opaque);
+            dom = virDomainObjListLoadConfigLocked(doms,
+                                                   caps,
+                                                   xmlopt,
+                                                   configDir,
+                                                   autostartDir,
+                                                   entry->d_name,
+                                                   notify,
+                                                   opaque);
         if (dom) {
             if (!liveStatus)
                 dom->persistent = 1;
diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h
index bb186bde30..4aee8fae13 100644
--- a/src/conf/virdomainobjlist.h
+++ b/src/conf/virdomainobjlist.h
@@ -77,6 +77,23 @@ int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
                                    virDomainXMLOptionPtr xmlopt,
                                    virDomainLoadConfigNotify notify,
                                    void *opaque);
+virDomainObjPtr
+virDomainObjListLoadConfig(virDomainObjListPtr doms,
+                           virCapsPtr caps,
+                           virDomainXMLOptionPtr xmlopt,
+                           const char *configDir,
+                           const char *autostartDir,
+                           const char *name,
+                           virDomainLoadConfigNotify notify,
+                           void *opaque);
+virDomainObjPtr
+virDomainObjListLoadStatus(virDomainObjListPtr doms,
+                           const char *statusDir,
+                           const char *name,
+                           virCapsPtr caps,
+                           virDomainXMLOptionPtr xmlopt,
+                           virDomainLoadConfigNotify notify,
+                           void *opaque);
 
 int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                  bool active,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a0fde65dba..be631e3dd7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -938,6 +938,8 @@ virDomainObjListForEach;
 virDomainObjListGetActiveIDs;
 virDomainObjListGetInactiveNames;
 virDomainObjListLoadAllConfigs;
+virDomainObjListLoadConfig;
+virDomainObjListLoadStatus;
 virDomainObjListNew;
 virDomainObjListNumOfDomains;
 virDomainObjListRemove;
-- 
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