Wire up the accessor functions necessary for the testsuite to install an alternative post-parse handler from normal drivers. I could have modified the signature for virDomainXMLOptionNew() to take another parameter, but thought it was easier to add a new set function rather than chase down all existing callers. Until code actually sets the override, there is no change in behavior.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- src/conf/domain_conf.h | 9 +++++++++ src/conf/domain_conf.c | 24 ++++++++++++++++++++++++ src/conf/snapshot_conf.c | 2 +- src/libvirt_private.syms | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 988ef90f11..be3b8bedf2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2693,6 +2693,15 @@ virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, virSaveCookieCallbacksPtr virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt); +typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def, + void *opaque); + +void virDomainXMLOptionSetMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentPostParseCallback cb, + void *opaque); +int virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentDefPtr def); + void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac); virDomainXMLNamespacePtr diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 17e8975be3..32d4539f69 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -82,6 +82,10 @@ struct _virDomainXMLOption { /* Private data for save image stored in snapshot XML */ virSaveCookieCallbacks saveCookie; + + /* Snapshot postparse callbacks */ + virDomainMomentPostParseCallback moment; + void *moment_opaque; }; #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ @@ -1451,6 +1455,26 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt) } +void +virDomainXMLOptionSetMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentPostParseCallback cb, + void *opaque) +{ + xmlopt->moment = cb; + xmlopt->moment_opaque = opaque; +} + + +int +virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentDefPtr def) +{ + if (!xmlopt->moment) + return virDomainMomentDefPostParse(def); + return xmlopt->moment(def, xmlopt->moment_opaque); +} + + void virBlkioDeviceArrayClear(virBlkioDevicePtr devices, int ndevices) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index ef6eae3a51..36c328f692 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -270,7 +270,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } else { VIR_WARN("parsing older snapshot that lacks domain"); } - } else if (virDomainMomentDefPostParse(&def->common) < 0) { + } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->common) < 0) { goto cleanup; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2be2d0fb9..8cd82c4416 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -604,6 +604,7 @@ virDomainWatchdogModelTypeToString; virDomainXMLOptionGetNamespace; virDomainXMLOptionGetSaveCookie; virDomainXMLOptionNew; +virDomainXMLOptionSetMomentPostParse; # conf/domain_event.h -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list