conf: Add 'basic' post parse callback

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.
This commit is contained in:
Peter Krempa 2017-08-15 15:11:45 +02:00
parent 7a5f68a1f2
commit 2f19c9325e
2 changed files with 19 additions and 0 deletions

View 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
*/

View 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;