mirror of https://gitee.com/openkylin/libvirt.git
conf: Pass xmlopt to virDomainSnapshotDefFormat
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@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
00968dca96
commit
957cd268a9
|
@ -691,6 +691,7 @@ char *
|
|||
virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virDomainSnapshotDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
|
||||
unsigned int flags,
|
||||
int internal)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6235,6 +6235,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
||||
|
||||
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
|
||||
privconn->xmlopt,
|
||||
virDomainDefFormatConvertXMLFlags(flags),
|
||||
0);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue