This will be used later when a save cookie will become part of the
snapshot XML using new driver specific parser/formatter functions.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
Reviewed-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Notes:
I know the line in vbox_common.c is too long, but I don't really want
to touch that horrible piece of code more than making it compile.
Version 2:
- enhanced commit message
src/conf/snapshot_conf.c | 1 +
src/conf/snapshot_conf.h | 1 +
src/esx/esx_driver.c | 2 +-
src/qemu/qemu_domain.c | 4 +++-
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 16 ++++++++++++----
src/test/test_driver.c | 1 +
src/vbox/vbox_common.c | 4 ++--
src/vz/vz_driver.c | 1 +
tests/domainsnapshotxml2xmltest.c | 1 +
10 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 7daa9b22a..e3bba985d 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -691,6 +691,7 @@ char *
virDomainSnapshotDefFormat(const char *domain_uuid,
virDomainSnapshotDefPtr def,
virCapsPtr caps,
+ virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
unsigned int flags,
int internal)
{
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index da904f946..2ce526fa6 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -114,6 +114,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
char *virDomainSnapshotDefFormat(const char *domain_uuid,
virDomainSnapshotDefPtr def,
virCapsPtr caps,
+ virDomainXMLOptionPtr xmlopt,
unsigned int flags,
int internal);
int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 6333855c7..1f4f2c7a7 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4265,7 +4265,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
virUUIDFormat(snapshot->domain->uuid, uuid_string);
- xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
+ xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
priv->xmlopt,
virDomainDefFormatConvertXMLFlags(flags),
0);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 698632489..814232164 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4820,6 +4820,7 @@ int
qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virDomainSnapshotObjPtr snapshot,
virCapsPtr caps,
+ virDomainXMLOptionPtr xmlopt,
char *snapshotDir)
{
char *newxml = NULL;
@@ -4830,7 +4831,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virUUIDFormat(vm->def->uuid, uuidstr);
newxml = virDomainSnapshotDefFormat(
- uuidstr, snapshot->def, caps,
+ uuidstr, snapshot->def, caps, xmlopt,
virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS),
1);
if (newxml == NULL)
@@ -4991,6 +4992,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
} else {
parentsnap->def->current = true;
if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps,
+ driver->xmlopt,
cfg->snapshotDir) < 0) {
VIR_WARN("failed to set parent snapshot '%s' as
current",
snap->def->parent);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 829f7746e..d0e2e0628 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -555,6 +555,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virDomainSnapshotObjPtr snapshot,
virCapsPtr caps,
+ virDomainXMLOptionPtr xmlopt,
char *snapshotDir);
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f0cdea659..f97d41030 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14649,7 +14649,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
if (update_current) {
vm->current_snapshot->def->current = false;
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
- driver->caps,
+ driver->caps, driver->xmlopt,
cfg->snapshotDir) < 0)
goto endjob;
vm->current_snapshot = NULL;
@@ -14699,6 +14699,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
endjob:
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
+ driver->xmlopt,
cfg->snapshotDir) < 0) {
/* if writing of metadata fails, error out rather than trying
* to silently carry on without completing the snapshot */
@@ -15036,7 +15037,8 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
virUUIDFormat(snapshot->domain->uuid, uuidstr);
- xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps,
+ xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
+ driver->caps, driver->xmlopt,
virDomainDefFormatConvertXMLFlags(flags),
0);
@@ -15218,7 +15220,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (vm->current_snapshot) {
vm->current_snapshot->def->current = false;
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
- driver->caps, cfg->snapshotDir) <
0)
+ driver->caps, driver->xmlopt,
+ cfg->snapshotDir) < 0)
goto endjob;
vm->current_snapshot = NULL;
/* XXX Should we restore vm->current_snapshot after this point
@@ -15458,6 +15461,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
cleanup:
if (ret == 0) {
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
+ driver->xmlopt,
cfg->snapshotDir) < 0)
ret = -1;
else
@@ -15494,6 +15498,7 @@ struct _virQEMUSnapReparent {
virDomainSnapshotObjPtr parent;
virDomainObjPtr vm;
virCapsPtr caps;
+ virDomainXMLOptionPtr xmlopt;
int err;
virDomainSnapshotObjPtr last;
};
@@ -15522,7 +15527,8 @@ qemuDomainSnapshotReparentChildren(void *payload,
if (!snap->sibling)
rep->last = snap;
- rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps,
+ rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
+ rep->caps, rep->xmlopt,
rep->cfg->snapshotDir);
return 0;
}
@@ -15593,6 +15599,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
snap->def->current = true;
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
+ driver->xmlopt,
cfg->snapshotDir) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to set snapshot '%s' as
current"),
@@ -15610,6 +15617,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
rep.err = 0;
rep.last = NULL;
rep.caps = driver->caps;
+ rep.xmlopt = driver->xmlopt;
virDomainSnapshotForEachChild(snap,
qemuDomainSnapshotReparentChildren,
&rep);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 338b7d35d..8cecc6add 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6235,6 +6235,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
virUUIDFormat(snapshot->domain->uuid, uuidstr);
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
+ privconn->xmlopt,
virDomainDefFormatConvertXMLFlags(flags),
0);
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index c66939e01..1a90d00aa 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -5105,7 +5105,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
VIR_FREE(currentSnapshotXmlFilePath);
if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml",
machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
goto cleanup;
- char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps,
VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
+ char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps,
data->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
if (snapshotContent == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to get snapshot content"));
@@ -6027,7 +6027,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
virUUIDFormat(dom->uuid, uuidstr);
memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
- ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps,
+ ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xmlopt,
virDomainDefFormatConvertXMLFlags(flags),
0);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 2c021884f..e6bb20182 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2303,6 +2303,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned
int flags)
virUUIDFormat(snapshot->domain->uuid, uuidstr);
xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
privconn->driver->caps,
+ privconn->driver->xmlopt,
virDomainDefFormatConvertXMLFlags(flags),
0);
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index bb4d60f7d..3a6f86b4a 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -101,6 +101,7 @@ testCompareXMLToXMLFiles(const char *inxml,
goto cleanup;
if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps,
+ driver.xmlopt,
VIR_DOMAIN_DEF_FORMAT_SECURE,
internal)))
goto cleanup;
--
2.13.0