]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
snapshot: Allow for post-parse override
authorEric Blake <eblake@redhat.com>
Tue, 16 Apr 2019 02:59:44 +0000 (21:59 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 17 Apr 2019 02:55:59 +0000 (21:55 -0500)
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 <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/snapshot_conf.c
src/libvirt_private.syms

index 980642cee87d5d531e8365f04f3327230a01af71..51aa48f4211b2359e783b0b888435df62ec33576 100644 (file)
@@ -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)
index 2755c74924892d8b42f0dbcfbb0915849c091ddf..5910ed0beb72c79833e03dffc8bad169070ca838 100644 (file)
@@ -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
index ef6eae3a51d217b53a5b06b410f89343d7e553a9..36c328f6926f3f44538158b7d8169feade32eb6f 100644 (file)
@@ -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;
     }
 
index 673e98bf609b1c231dfc43db09a6a43fee55f75a..a3d480d84629ec665d532d1a0db48f2eeacbedc9 100644 (file)
@@ -608,6 +608,7 @@ virDomainWatchdogModelTypeToString;
 virDomainXMLOptionGetNamespace;
 virDomainXMLOptionGetSaveCookie;
 virDomainXMLOptionNew;
+virDomainXMLOptionSetMomentPostParse;
 
 
 # conf/domain_event.h