[libvirt] [PATCH 3/4] conf: domain: Allow passing in 'parseOpaque' for post-parse of status XML

Peter Krempa pkrempa at redhat.com
Mon May 28 09:36:46 UTC 2018


The status XML parser function virDomainObjParseXML could not pass in
parseOpaque into the post parse callbacks. Add a callback which will
allow hypervisor drivers to fill it from the 'virDomainObj' data.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 6 +++++-
 src/conf/domain_conf.h | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 43ae5ad96a..cc38c441dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20518,6 +20518,7 @@ virDomainObjParseXML(xmlDocPtr xml,
     int n;
     int state;
     int reason = 0;
+    void *parseOpaque = NULL;

     if (!(obj = virDomainObjNew(xmlopt)))
         return NULL;
@@ -20589,8 +20590,11 @@ virDomainObjParseXML(xmlDocPtr xml,
         xmlopt->privateData.parse(ctxt, obj, &xmlopt->config) < 0)
         goto error;

+    if (xmlopt->privateData.getParseOpaque)
+        parseOpaque = xmlopt->privateData.getParseOpaque(obj);
+
     /* callback to fill driver specific domain aspects */
-    if (virDomainDefPostParse(obj->def, caps, flags, xmlopt, NULL) < 0)
+    if (virDomainDefPostParse(obj->def, caps, flags, xmlopt, parseOpaque) < 0)
         goto error;

     /* valdiate configuration */
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b7e52a1e03..651dcc445f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2662,6 +2662,8 @@ typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                 virDomainObjPtr,
                                                 virDomainDefParserConfigPtr);

+typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);
+
 typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                              virStorageSourcePtr src);
 typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
@@ -2680,6 +2682,9 @@ struct _virDomainXMLPrivateDataCallbacks {
     virDomainXMLPrivateDataNewFunc    chrSourceNew;
     virDomainXMLPrivateDataFormatFunc format;
     virDomainXMLPrivateDataParseFunc  parse;
+    /* following function shall return a pointer which will be used as the
+     * 'parseOpaque' argument for virDomainDefPostParse */
+    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
     virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
     virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
 };
-- 
2.16.2




More information about the libvir-list mailing list