Add yet another post parse callback, which is executed prior the real
one without @parseOpaque. This is meant to set basics before
@parseOpaque (in case of the qemu driver qemuCaps) can be allocated.
This callback will allow to optimize passing of custom parseOpaque
through the callbacks.
---
src/conf/domain_conf.c | 9 +++++++++
src/conf/domain_conf.h | 10 ++++++++++
2 files changed, 19 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 281dc68f0..7c5e6b95a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4825,6 +4825,15 @@ virDomainDefPostParse(virDomainDefPtr def,
.parseOpaque = parseOpaque,
};
+ /* call the basic post parse callback */
+ if (xmlopt->config.domainPostParseBasicCallback) {
+ ret = xmlopt->config.domainPostParseBasicCallback(def, caps,
+ xmlopt->config.priv);
+
+ if (ret < 0)
+ return ret;
+ }
+
/* this must be done before the hypervisor-specific callback,
* in case presence of a controller at a specific index is checked
*/
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f857f509e..4daf024ea 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2497,6 +2497,15 @@ typedef enum {
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
+
+/* Called after everything else has been parsed, for adjusting basics.
+ * This has similar semantics to virDomainDefPostParseCallback, but no
+ * parseOpaque is used used. This callback is run prior to
+ * virDomainDefPostParseCallback. */
+typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def,
+ virCapsPtr caps,
+ void *opaque);
+
/* Called once after everything else has been parsed, for adjusting
* overall domain defaults.
* @parseOpaque is opaque data passed by virDomainDefParse* caller,
@@ -2546,6 +2555,7 @@ typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
/* driver domain definition callbacks */
+ virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
virDomainDefPostParseCallback domainPostParseCallback;
virDomainDeviceDefPostParseCallback devicesPostParseCallback;
virDomainDefAssignAddressesCallback assignAddressesCallback;
--
2.14.0