]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add 'basic' post parse callback
authorPeter Krempa <pkrempa@redhat.com>
Tue, 15 Aug 2017 13:11:45 +0000 (15:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 18 Aug 2017 13:07:44 +0000 (15:07 +0200)
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
src/conf/domain_conf.h

index 3db56ffb7aec4615051adf5847dca953aea628f8..b7519c8b34e4a2ab7120315126bba8ee7bf2eba5 100644 (file)
@@ -4828,6 +4828,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
      */
index f857f509e474a7f21b9cf21c51d2b95299788b7c..bb5faa8b8eb687a14b7245b81a635d339fb7c0f1 100644 (file)
@@ -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. 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;