virDomainXMLOption gains driver specific callbacks for parsing and
formatting save cookies.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/bhyve/bhyve_domain.c | 2 +-
src/conf/domain_conf.c | 16 +++++++++++++++-
src/conf/domain_conf.h | 7 ++++++-
src/conf/snapshot_conf.c | 11 ++++++++++-
src/conf/snapshot_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/libxl/libxl_conf.c | 2 +-
src/lxc/lxc_conf.c | 2 +-
src/openvz/openvz_driver.c | 2 +-
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_conf.c | 3 ++-
src/security/virt-aa-helper.c | 2 +-
src/test/test_driver.c | 2 +-
src/uml/uml_driver.c | 2 +-
src/vbox/vbox_common.c | 2 +-
src/vmware/vmware_driver.c | 3 ++-
src/vmx/vmx.c | 2 +-
src/vz/vz_driver.c | 2 +-
src/xen/xen_driver.c | 2 +-
src/xenapi/xenapi_driver.c | 2 +-
tests/bhyveargv2xmltest.c | 2 +-
tests/testutils.c | 2 +-
23 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 0a99550af..20c82937b 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -144,7 +144,7 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
virBhyveDriverDomainDefParserConfig.priv = driver;
return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
&virBhyveDriverPrivateDataCallbacks,
- NULL, NULL);
+ NULL, NULL, NULL);
}
virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7144914cf..d3bc3655e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -79,6 +79,9 @@ struct _virDomainXMLOption {
/* ABI stability callbacks */
virDomainABIStability abi;
+
+ /* Private data for save image stored in snapshot XML */
+ virSaveCookieCallbacks saveCookie;
};
#define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \
@@ -1054,7 +1057,8 @@ virDomainXMLOptionPtr
virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
virDomainXMLPrivateDataCallbacksPtr priv,
virDomainXMLNamespacePtr xmlns,
- virDomainABIStabilityPtr abi)
+ virDomainABIStabilityPtr abi,
+ virSaveCookieCallbacksPtr saveCookie)
{
virDomainXMLOptionPtr xmlopt;
@@ -1076,6 +1080,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
if (abi)
xmlopt->abi = *abi;
+ if (saveCookie)
+ xmlopt->saveCookie = *saveCookie;
+
/* Technically this forbids to use one of Xerox's MAC address prefixes in
* our hypervisor drivers. This shouldn't ever be a problem.
*
@@ -1106,6 +1113,13 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
}
+virSaveCookieCallbacksPtr
+virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
+{
+ return &xmlopt->saveCookie;
+}
+
+
void
virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
int ndevices)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 446b117b7..1231aeac6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -55,6 +55,7 @@
# include "virgic.h"
# include "virperf.h"
# include "virtypedparam.h"
+# include "virsavecookie.h"
/* forward declarations of all device types, required by
* virDomainDeviceDef
@@ -2549,7 +2550,11 @@ struct _virDomainABIStability {
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
virDomainXMLPrivateDataCallbacksPtr priv,
virDomainXMLNamespacePtr xmlns,
- virDomainABIStabilityPtr abi);
+ virDomainABIStabilityPtr abi,
+ virSaveCookieCallbacksPtr saveCookie);
+
+virSaveCookieCallbacksPtr
+virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index e3bba985d..6330f7d1f 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -102,6 +102,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
virDomainSnapshotDiskDefClear(&def->disks[i]);
VIR_FREE(def->disks);
virDomainDefFree(def->dom);
+ virObjectUnref(def->cookie);
VIR_FREE(def);
}
@@ -214,6 +215,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
char *memorySnapshot = NULL;
char *memoryFile = NULL;
bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
+ virSaveCookieCallbacksPtr saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt);
if (VIR_ALLOC(def) < 0)
goto cleanup;
@@ -365,6 +367,9 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
def->current = active != 0;
}
+ if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie)
< 0)
+ goto cleanup;
+
ret = def;
cleanup:
@@ -691,7 +696,7 @@ char *
virDomainSnapshotDefFormat(const char *domain_uuid,
virDomainSnapshotDefPtr def,
virCapsPtr caps,
- virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
+ virDomainXMLOptionPtr xmlopt,
unsigned int flags,
int internal)
{
@@ -751,6 +756,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
virBufferAddLit(&buf, "</domain>\n");
}
+ if (virSaveCookieFormatBuf(&buf, def->cookie,
+ virDomainXMLOptionGetSaveCookie(xmlopt)) < 0)
+ goto error;
+
if (internal)
virBufferAsprintf(&buf, "<active>%d</active>\n",
def->current);
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 2ce526fa6..1d663c77b 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -76,6 +76,8 @@ struct _virDomainSnapshotDef {
virDomainDefPtr dom;
+ virObjectPtr cookie;
+
/* Internal use. */
bool current; /* At most one snapshot in the list should have this set */
};
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 863c71cf3..fad31b475 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -535,6 +535,7 @@ virDomainWatchdogActionTypeToString;
virDomainWatchdogModelTypeFromString;
virDomainWatchdogModelTypeToString;
virDomainXMLOptionGetNamespace;
+virDomainXMLOptionGetSaveCookie;
virDomainXMLOptionNew;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 886dc629f..04d9dd1bd 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -2255,5 +2255,5 @@ libxlCreateXMLConf(void)
{
return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
&libxlDomainXMLPrivateDataCallbacks,
- NULL, NULL);
+ NULL, NULL, NULL);
}
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index ff975decc..92a82a476 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -216,7 +216,7 @@ lxcDomainXMLConfInit(void)
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
&virLXCDriverPrivateDataCallbacks,
&virLXCDriverDomainXMLNamespace,
- NULL);
+ NULL, NULL);
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 8e305a85c..a1485fc88 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1483,7 +1483,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
goto cleanup;
if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig,
- NULL, NULL, NULL)))
+ NULL, NULL, NULL, NULL)))
goto cleanup;
if (openvzLoadDomains(driver) < 0)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4465ac862..9121581fe 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1202,7 +1202,7 @@ phypConnectOpen(virConnectPtr conn,
goto failure;
if (!(phyp_driver->xmlopt =
virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig,
- NULL, NULL, NULL)))
+ NULL, NULL, NULL, NULL)))
goto failure;
conn->privateData = phyp_driver;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 03c55853f..7f2249259 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5026,7 +5026,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
goto ignore;
}
- if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) ||
+ if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
!(cmd->vm = virDomainObjNew(xmlopt)))
goto cleanup;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index d8b88386d..d02e776b0 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -910,7 +910,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
&virQEMUDriverPrivateDataCallbacks,
&virQEMUDriverDomainXMLNamespace,
- &virQEMUDriverDomainABIStability);
+ &virQEMUDriverDomainABIStability,
+ NULL);
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 48201d5b8..97436e5dc 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -667,7 +667,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
goto exit;
}
- if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL))) {
+ if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL))) {
vah_error(ctl, 0, _("Failed to create XML config object"));
goto exit;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 521c12c11..2cfaf70b2 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -414,7 +414,7 @@ testDriverNew(void)
goto error;
}
- if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) ||
+ if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) ||
!(ret->eventState = virObjectEventStateNew()) ||
!(ret->ifaces = virInterfaceObjListNew()) ||
!(ret->domains = virDomainObjListNew()) ||
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 58ab033c8..080fea47d 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -533,7 +533,7 @@ umlStateInitialize(bool privileged,
goto out_of_memory;
if (!(uml_driver->xmlopt =
virDomainXMLOptionNew(¨DriverDomainDefParserConfig,
- &privcb, NULL, NULL)))
+ &privcb, NULL, NULL, NULL)))
goto error;
if ((uml_driver->inotifyFD = inotify_init()) < 0) {
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 1a90d00aa..c46e71bcf 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -142,7 +142,7 @@ vboxDriverObjNew(void)
if (!(driver->caps = vboxCapsInit()) ||
!(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
- NULL, NULL, NULL)))
+ NULL, NULL, NULL, NULL)))
goto cleanup;
return driver;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 9e369e67b..0ee1c5bb9 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -114,7 +114,8 @@ vmwareDomainXMLConfigInit(void)
virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
.free = vmwareDataFreeFunc };
- return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL,
NULL);
+ return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
+ NULL, NULL, NULL);
}
static virDrvOpenStatus
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 3289a2002..96507f10f 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -591,7 +591,7 @@ virDomainXMLOptionPtr
virVMXDomainXMLConfInit(void)
{
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
- &virVMXDomainXMLNamespace, NULL);
+ &virVMXDomainXMLNamespace, NULL, NULL);
}
char *
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index e6bb20182..7aa0c4c48 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -328,7 +328,7 @@ vzDriverObjNew(void)
if (!(driver->caps = vzBuildCapabilities()) ||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
&vzDomainXMLPrivateDataCallbacksPtr,
- NULL, NULL)) ||
+ NULL, NULL, NULL)) ||
!(driver->domains = virDomainObjListNew()) ||
!(driver->domainEventState = virObjectEventStateNew()) ||
(vzInitVersion(driver) < 0) ||
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index f81ee20ad..8e7bc350c 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -401,7 +401,7 @@ virDomainXMLOptionPtr
xenDomainXMLConfInit(void)
{
return virDomainXMLOptionNew(&xenDomainDefParserConfig,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
}
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 380c3a1de..fb462cd3a 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
}
if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
- NULL, NULL, NULL))) {
+ NULL, NULL, NULL, NULL))) {
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to create XML conf object"));
goto error;
diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c
index bde7d0e05..e1c0294cb 100644
--- a/tests/bhyveargv2xmltest.c
+++ b/tests/bhyveargv2xmltest.c
@@ -131,7 +131,7 @@ mymain(void)
return EXIT_FAILURE;
if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL,
- NULL, NULL)) == NULL)
+ NULL, NULL, NULL)) == NULL)
return EXIT_FAILURE;
# define DO_TEST_FULL(name, flags) \
diff --git a/tests/testutils.c b/tests/testutils.c
index 4b8cf79ef..f45596997 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
{
return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
&virTestGenericPrivateDataCallbacks,
- NULL, NULL);
+ NULL, NULL, NULL);
}
--
2.13.0