|
|
3e5111 |
From 49f9421cddc176e39cbb062f26e80ec93341ef0d Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <49f9421cddc176e39cbb062f26e80ec93341ef0d@dist-git>
|
|
|
3e5111 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Date: Fri, 2 Jun 2017 00:27:33 +0200
|
|
|
3e5111 |
Subject: [PATCH] conf: Pass xmlopt to virDomainSnapshotDefFormat
|
|
|
3e5111 |
|
|
|
3e5111 |
This will be used later when a save cookie will become part of the
|
|
|
3e5111 |
snapshot XML using new driver specific parser/formatter functions.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 957cd268a98043fe061227a8e829c622a6fb4b86)
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1441662
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/conf/snapshot_conf.c | 1 +
|
|
|
3e5111 |
src/conf/snapshot_conf.h | 1 +
|
|
|
3e5111 |
src/esx/esx_driver.c | 2 +-
|
|
|
3e5111 |
src/qemu/qemu_domain.c | 4 +++-
|
|
|
3e5111 |
src/qemu/qemu_domain.h | 1 +
|
|
|
3e5111 |
src/qemu/qemu_driver.c | 16 ++++++++++++----
|
|
|
3e5111 |
src/test/test_driver.c | 1 +
|
|
|
3e5111 |
src/vbox/vbox_common.c | 4 ++--
|
|
|
3e5111 |
src/vz/vz_driver.c | 1 +
|
|
|
3e5111 |
tests/domainsnapshotxml2xmltest.c | 1 +
|
|
|
3e5111 |
10 files changed, 24 insertions(+), 8 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
|
|
|
3e5111 |
index 7daa9b22ad..e3bba985d7 100644
|
|
|
3e5111 |
--- a/src/conf/snapshot_conf.c
|
|
|
3e5111 |
+++ b/src/conf/snapshot_conf.c
|
|
|
3e5111 |
@@ -691,6 +691,7 @@ char *
|
|
|
3e5111 |
virDomainSnapshotDefFormat(const char *domain_uuid,
|
|
|
3e5111 |
virDomainSnapshotDefPtr def,
|
|
|
3e5111 |
virCapsPtr caps,
|
|
|
3e5111 |
+ virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
unsigned int flags,
|
|
|
3e5111 |
int internal)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
|
|
|
3e5111 |
index da904f9460..2ce526fa6b 100644
|
|
|
3e5111 |
--- a/src/conf/snapshot_conf.h
|
|
|
3e5111 |
+++ b/src/conf/snapshot_conf.h
|
|
|
3e5111 |
@@ -114,6 +114,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
|
|
|
3e5111 |
char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
|
|
3e5111 |
virDomainSnapshotDefPtr def,
|
|
|
3e5111 |
virCapsPtr caps,
|
|
|
3e5111 |
+ virDomainXMLOptionPtr xmlopt,
|
|
|
3e5111 |
unsigned int flags,
|
|
|
3e5111 |
int internal);
|
|
|
3e5111 |
int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
|
|
|
3e5111 |
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
|
|
|
3e5111 |
index 166d4bcfcc..c4e1f58a0b 100644
|
|
|
3e5111 |
--- a/src/esx/esx_driver.c
|
|
|
3e5111 |
+++ b/src/esx/esx_driver.c
|
|
|
3e5111 |
@@ -4282,7 +4282,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
|
|
|
3e5111 |
virUUIDFormat(snapshot->domain->uuid, uuid_string);
|
|
|
3e5111 |
|
|
|
3e5111 |
- xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
|
|
|
3e5111 |
+ xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps, priv->xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
3e5111 |
0);
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
index 11be085801..09903bdd5f 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
@@ -4794,6 +4794,7 @@ int
|
|
|
3e5111 |
qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainSnapshotObjPtr snapshot,
|
|
|
3e5111 |
virCapsPtr caps,
|
|
|
3e5111 |
+ virDomainXMLOptionPtr xmlopt,
|
|
|
3e5111 |
char *snapshotDir)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
char *newxml = NULL;
|
|
|
3e5111 |
@@ -4804,7 +4805,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
|
|
3e5111 |
|
|
|
3e5111 |
virUUIDFormat(vm->def->uuid, uuidstr);
|
|
|
3e5111 |
newxml = virDomainSnapshotDefFormat(
|
|
|
3e5111 |
- uuidstr, snapshot->def, caps,
|
|
|
3e5111 |
+ uuidstr, snapshot->def, caps, xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS),
|
|
|
3e5111 |
1);
|
|
|
3e5111 |
if (newxml == NULL)
|
|
|
3e5111 |
@@ -4965,6 +4966,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
|
|
|
3e5111 |
} else {
|
|
|
3e5111 |
parentsnap->def->current = true;
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps,
|
|
|
3e5111 |
+ driver->xmlopt,
|
|
|
3e5111 |
cfg->snapshotDir) < 0) {
|
|
|
3e5111 |
VIR_WARN("failed to set parent snapshot '%s' as current",
|
|
|
3e5111 |
snap->def->parent);
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
index 2994398a9e..4db92fac8a 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.h
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
@@ -557,6 +557,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
|
|
|
3e5111 |
int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainSnapshotObjPtr snapshot,
|
|
|
3e5111 |
virCapsPtr caps,
|
|
|
3e5111 |
+ virDomainXMLOptionPtr xmlopt,
|
|
|
3e5111 |
char *snapshotDir);
|
|
|
3e5111 |
|
|
|
3e5111 |
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
index 354329fe64..2688c3eec7 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_driver.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
@@ -14650,7 +14650,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
3e5111 |
if (update_current) {
|
|
|
3e5111 |
vm->current_snapshot->def->current = false;
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
|
|
3e5111 |
- driver->caps,
|
|
|
3e5111 |
+ driver->caps, driver->xmlopt,
|
|
|
3e5111 |
cfg->snapshotDir) < 0)
|
|
|
3e5111 |
goto endjob;
|
|
|
3e5111 |
vm->current_snapshot = NULL;
|
|
|
3e5111 |
@@ -14700,6 +14700,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
3e5111 |
endjob:
|
|
|
3e5111 |
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
|
|
3e5111 |
+ driver->xmlopt,
|
|
|
3e5111 |
cfg->snapshotDir) < 0) {
|
|
|
3e5111 |
/* if writing of metadata fails, error out rather than trying
|
|
|
3e5111 |
* to silently carry on without completing the snapshot */
|
|
|
3e5111 |
@@ -15037,7 +15038,8 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
|
|
|
3e5111 |
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
|
|
3e5111 |
|
|
|
3e5111 |
- xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps,
|
|
|
3e5111 |
+ xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
|
|
|
3e5111 |
+ driver->caps, driver->xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
3e5111 |
0);
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -15219,7 +15221,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
if (vm->current_snapshot) {
|
|
|
3e5111 |
vm->current_snapshot->def->current = false;
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
|
|
3e5111 |
- driver->caps, cfg->snapshotDir) < 0)
|
|
|
3e5111 |
+ driver->caps, driver->xmlopt,
|
|
|
3e5111 |
+ cfg->snapshotDir) < 0)
|
|
|
3e5111 |
goto endjob;
|
|
|
3e5111 |
vm->current_snapshot = NULL;
|
|
|
3e5111 |
/* XXX Should we restore vm->current_snapshot after this point
|
|
|
3e5111 |
@@ -15459,6 +15462,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
if (ret == 0) {
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
|
|
3e5111 |
+ driver->xmlopt,
|
|
|
3e5111 |
cfg->snapshotDir) < 0)
|
|
|
3e5111 |
ret = -1;
|
|
|
3e5111 |
else
|
|
|
3e5111 |
@@ -15495,6 +15499,7 @@ struct _virQEMUSnapReparent {
|
|
|
3e5111 |
virDomainSnapshotObjPtr parent;
|
|
|
3e5111 |
virDomainObjPtr vm;
|
|
|
3e5111 |
virCapsPtr caps;
|
|
|
3e5111 |
+ virDomainXMLOptionPtr xmlopt;
|
|
|
3e5111 |
int err;
|
|
|
3e5111 |
virDomainSnapshotObjPtr last;
|
|
|
3e5111 |
};
|
|
|
3e5111 |
@@ -15523,7 +15528,8 @@ qemuDomainSnapshotReparentChildren(void *payload,
|
|
|
3e5111 |
if (!snap->sibling)
|
|
|
3e5111 |
rep->last = snap;
|
|
|
3e5111 |
|
|
|
3e5111 |
- rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps,
|
|
|
3e5111 |
+ rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
|
|
|
3e5111 |
+ rep->caps, rep->xmlopt,
|
|
|
3e5111 |
rep->cfg->snapshotDir);
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
@@ -15594,6 +15600,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
|
|
|
3e5111 |
snap->def->current = true;
|
|
|
3e5111 |
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
|
|
3e5111 |
+ driver->xmlopt,
|
|
|
3e5111 |
cfg->snapshotDir) < 0) {
|
|
|
3e5111 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
3e5111 |
_("failed to set snapshot '%s' as current"),
|
|
|
3e5111 |
@@ -15611,6 +15618,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
rep.err = 0;
|
|
|
3e5111 |
rep.last = NULL;
|
|
|
3e5111 |
rep.caps = driver->caps;
|
|
|
3e5111 |
+ rep.xmlopt = driver->xmlopt;
|
|
|
3e5111 |
virDomainSnapshotForEachChild(snap,
|
|
|
3e5111 |
qemuDomainSnapshotReparentChildren,
|
|
|
3e5111 |
&rep;;
|
|
|
3e5111 |
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
|
|
|
3e5111 |
index 39df646260..c8085dd797 100644
|
|
|
3e5111 |
--- a/src/test/test_driver.c
|
|
|
3e5111 |
+++ b/src/test/test_driver.c
|
|
|
3e5111 |
@@ -6348,6 +6348,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
|
|
3e5111 |
|
|
|
3e5111 |
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
|
|
|
3e5111 |
+ privconn->xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
3e5111 |
0);
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
|
|
|
3e5111 |
index dcc64b579c..c739031660 100644
|
|
|
3e5111 |
--- a/src/vbox/vbox_common.c
|
|
|
3e5111 |
+++ b/src/vbox/vbox_common.c
|
|
|
3e5111 |
@@ -5115,7 +5115,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|
|
3e5111 |
VIR_FREE(currentSnapshotXmlFilePath);
|
|
|
3e5111 |
if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
- char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
|
|
|
3e5111 |
+ char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, data->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
|
|
|
3e5111 |
if (snapshotContent == NULL) {
|
|
|
3e5111 |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
3e5111 |
_("Unable to get snapshot content"));
|
|
|
3e5111 |
@@ -6037,7 +6037,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
|
|
|
3e5111 |
virUUIDFormat(dom->uuid, uuidstr);
|
|
|
3e5111 |
memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
|
|
|
3e5111 |
- ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps,
|
|
|
3e5111 |
+ ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
3e5111 |
0);
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
|
|
|
3e5111 |
index 26c4f48459..f0b6722a6e 100644
|
|
|
3e5111 |
--- a/src/vz/vz_driver.c
|
|
|
3e5111 |
+++ b/src/vz/vz_driver.c
|
|
|
3e5111 |
@@ -2309,6 +2309,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|
|
3e5111 |
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
|
|
3e5111 |
|
|
|
3e5111 |
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->driver->caps,
|
|
|
3e5111 |
+ privconn->driver->xmlopt,
|
|
|
3e5111 |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
3e5111 |
0);
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
|
|
|
3e5111 |
index f5fec47520..df204f9f16 100644
|
|
|
3e5111 |
--- a/tests/domainsnapshotxml2xmltest.c
|
|
|
3e5111 |
+++ b/tests/domainsnapshotxml2xmltest.c
|
|
|
3e5111 |
@@ -101,6 +101,7 @@ testCompareXMLToXMLFiles(const char *inxml,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps,
|
|
|
3e5111 |
+ driver.xmlopt,
|
|
|
3e5111 |
VIR_DOMAIN_DEF_FORMAT_SECURE,
|
|
|
3e5111 |
internal)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.1
|
|
|
3e5111 |
|