[PATCH 2/9] conf: Introduce virDomainDefParseStringOpaque

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

 



This function allows callers to pass arbitrary pointer to domain
def parse callback.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 37 ++++++++++++++++++++++++++++++-------
 src/conf/domain_conf.h   | 11 +++++++++++
 src/libvirt_private.syms |  2 ++
 3 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e8c8465..91cd2ab 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15881,6 +15881,7 @@ virDomainDefParseXML(xmlDocPtr xml,
                      xmlXPathContextPtr ctxt,
                      virCapsPtr caps,
                      virDomainXMLOptionPtr xmlopt,
+                     void *parseOpaque,
                      unsigned int flags)
 {
     xmlNodePtr *nodes = NULL, node = NULL;
@@ -17532,7 +17533,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
 
     /* callback to fill driver specific domain aspects */
-    if (virDomainDefPostParse(def, caps, flags, xmlopt) < 0)
+    if (virDomainDefPostParseOpaque(def, caps, flags, xmlopt, parseOpaque) < 0)
         goto error;
 
     /* valdiate configuration */
@@ -17581,7 +17582,7 @@ virDomainObjParseXML(xmlDocPtr xml,
 
     oldnode = ctxt->node;
     ctxt->node = config;
-    obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, flags);
+    obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, NULL, flags);
     ctxt->node = oldnode;
     if (!obj->def)
         goto error;
@@ -17654,6 +17655,7 @@ virDomainDefParse(const char *xmlStr,
                   const char *filename,
                   virCapsPtr caps,
                   virDomainXMLOptionPtr xmlopt,
+                  void *parseOpaque,
                   unsigned int flags)
 {
     xmlDocPtr xml;
@@ -17661,8 +17663,8 @@ virDomainDefParse(const char *xmlStr,
     int keepBlanksDefault = xmlKeepBlanksDefault(0);
 
     if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) {
-        def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps,
-                                    xmlopt, flags);
+        def = virDomainDefParseNodeOpaque(xml, xmlDocGetRootElement(xml), caps,
+                                          xmlopt, parseOpaque, flags);
         xmlFreeDoc(xml);
     }
 
@@ -17676,7 +17678,17 @@ virDomainDefParseString(const char *xmlStr,
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
 {
-    return virDomainDefParse(xmlStr, NULL, caps, xmlopt, flags);
+    return virDomainDefParse(xmlStr, NULL, caps, xmlopt, NULL, flags);
+}
+
+virDomainDefPtr
+virDomainDefParseStringOpaque(const char *xmlStr,
+                              virCapsPtr caps,
+                              virDomainXMLOptionPtr xmlopt,
+                              void *parseOpaque,
+                              unsigned int flags)
+{
+    return virDomainDefParse(xmlStr, NULL, caps, xmlopt, parseOpaque, flags);
 }
 
 virDomainDefPtr
@@ -17685,7 +17697,7 @@ virDomainDefParseFile(const char *filename,
                       virDomainXMLOptionPtr xmlopt,
                       unsigned int flags)
 {
-    return virDomainDefParse(NULL, filename, caps, xmlopt, flags);
+    return virDomainDefParse(NULL, filename, caps, xmlopt, NULL, flags);
 }
 
 
@@ -17696,6 +17708,17 @@ virDomainDefParseNode(xmlDocPtr xml,
                       virDomainXMLOptionPtr xmlopt,
                       unsigned int flags)
 {
+    return virDomainDefParseNodeOpaque(xml, root, caps, xmlopt, NULL, flags);
+}
+
+virDomainDefPtr
+virDomainDefParseNodeOpaque(xmlDocPtr xml,
+                            xmlNodePtr root,
+                            virCapsPtr caps,
+                            virDomainXMLOptionPtr xmlopt,
+                            void *parseOpaque,
+                            unsigned int flags)
+{
     xmlXPathContextPtr ctxt = NULL;
     virDomainDefPtr def = NULL;
 
@@ -17714,7 +17737,7 @@ virDomainDefParseNode(xmlDocPtr xml,
     }
 
     ctxt->node = root;
-    def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, flags);
+    def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, parseOpaque, flags);
 
  cleanup:
     xmlXPathFreeContext(ctxt);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6056aa7..f132153 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2679,6 +2679,11 @@ virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                         virCapsPtr caps,
                                         virDomainXMLOptionPtr xmlopt,
                                         unsigned int flags);
+virDomainDefPtr virDomainDefParseStringOpaque(const char *xmlStr,
+                                              virCapsPtr caps,
+                                              virDomainXMLOptionPtr xmlopt,
+                                              void *parseOpaque,
+                                              unsigned int flags);
 virDomainDefPtr virDomainDefParseFile(const char *filename,
                                       virCapsPtr caps,
                                       virDomainXMLOptionPtr xmlopt,
@@ -2688,6 +2693,12 @@ virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
                                       virCapsPtr caps,
                                       virDomainXMLOptionPtr xmlopt,
                                       unsigned int flags);
+virDomainDefPtr virDomainDefParseNodeOpaque(xmlDocPtr xml,
+                                            xmlNodePtr root,
+                                            virCapsPtr caps,
+                                            virDomainXMLOptionPtr xmlopt,
+                                            void *parseOpaque,
+                                            unsigned int flags);
 virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                       xmlNodePtr root,
                                       virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5fd1178..d7cdfda 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -248,7 +248,9 @@ virDomainDefNew;
 virDomainDefNewFull;
 virDomainDefParseFile;
 virDomainDefParseNode;
+virDomainDefParseNodeOpaque;
 virDomainDefParseString;
+virDomainDefParseStringOpaque;
 virDomainDefPostParse;
 virDomainDefPostParseOpaque;
 virDomainDefSetMemoryTotal;
-- 
2.8.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]