This will be called at the end of virDomainDefPostParse to
allow hypervisor drivers to fill in device aliases.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 7 +++++++
src/conf/domain_conf.h | 13 +++++++++++++
2 files changed, 20 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e3e9fc748..653357531 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5011,6 +5011,13 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
goto cleanup;
}
+ if (xmlopt->config.assignAliasesCallback) {
+ ret = xmlopt->config.assignAliasesCallback(def, caps, parseFlags,
+ xmlopt->config.priv,
+ data.parseOpaque);
+ if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0)
+ goto cleanup;
+ }
if ((ret = virDomainDefPostParseCheckFeatures(def, xmlopt)) < 0)
goto cleanup;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e11ae5247..764360ccb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2559,6 +2559,18 @@ typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef
*def,
void *opaque,
void *parseOpaque);
+/* Driver callback for assigning device aliases, called at the
+ * end of parsing, after all defaults and implicit devices have
+ * been added and all addresses were assigned. @parseOpaque is
+ * opaque data passed by virDomainDefParse *caller, @opaque is
+ * opaque data set by driver (usually pointer to driver private
+ * data). */
+typedef int (*virDomainDefAssignAliasesCallback)(virDomainDefPtr def,
+ virCapsPtr caps,
+ unsigned int parseFlags,
+ void *opaque,
+ void *parseOpaque);
+
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
virCapsPtr caps,
unsigned int parseFlags,
@@ -2588,6 +2600,7 @@ struct _virDomainDefParserConfig {
virDomainDefPostParseCallback domainPostParseCallback;
virDomainDeviceDefPostParseCallback devicesPostParseCallback;
virDomainDefAssignAddressesCallback assignAddressesCallback;
+ virDomainDefAssignAliasesCallback assignAliasesCallback;
virDomainDefPostParseDataFree domainPostParseDataFree;
/* validation callbacks */
--
2.13.5