From: Eric Blake Date: Tue, 16 Apr 2019 02:59:44 +0000 (-0500) Subject: snapshot: Allow for post-parse override X-Git-Tag: v5.3.0-rc1~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df2ae0d0429049c52b8f693c84a1e9ac99e06f0a;p=thirdparty%2Flibvirt.git snapshot: Allow for post-parse override 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 Reviewed-by: Cole Robinson --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 980642cee8..51aa48f421 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -82,6 +82,9 @@ struct _virDomainXMLOption { /* Private data for save image stored in snapshot XML */ virSaveCookieCallbacks saveCookie; + + /* Snapshot postparse callbacks */ + virDomainMomentPostParseCallback momentPostParse; }; #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ @@ -1476,6 +1479,24 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt) } +void +virDomainXMLOptionSetMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentPostParseCallback cb) +{ + xmlopt->momentPostParse = cb; +} + + +int +virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentDefPtr def) +{ + if (!xmlopt->momentPostParse) + return virDomainMomentDefPostParse(def); + return xmlopt->momentPostParse(def); +} + + void virBlkioDeviceArrayClear(virBlkioDevicePtr devices, int ndevices) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2755c74924..5910ed0beb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2728,6 +2728,13 @@ virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, virSaveCookieCallbacksPtr virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt); +typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def); + +void virDomainXMLOptionSetMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentPostParseCallback cb); +int virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt, + virDomainMomentDefPtr def); + void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac); virDomainXMLNamespacePtr 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 673e98bf60..a3d480d846 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -608,6 +608,7 @@ virDomainWatchdogModelTypeToString; virDomainXMLOptionGetNamespace; virDomainXMLOptionGetSaveCookie; virDomainXMLOptionNew; +virDomainXMLOptionSetMomentPostParse; # conf/domain_event.h