mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
conf: add caps to virDomainSnapshotDefFormat
The virDomainSnapshotDefFormat calls into virDomainDefFormat, so should be providing a non-NULL virCapsPtr instance. On the qemu driver we change qemuDomainSnapshotWriteMetadata to also include caps since it calls virDomainSnapshotDefFormat. Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
This commit is contained in:
parent
1036ddadb2
commit
b8b03f64e1
@ -659,6 +659,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
|
||||
|
||||
char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virDomainSnapshotDefPtr def,
|
||||
virCapsPtr caps,
|
||||
unsigned int flags,
|
||||
int internal)
|
||||
{
|
||||
@ -702,7 +703,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virBufferAddLit(&buf, "</disks>\n");
|
||||
}
|
||||
if (def->dom) {
|
||||
if (virDomainDefFormatInternal(def->dom, NULL, flags, &buf) < 0) {
|
||||
if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) {
|
||||
virBufferFreeAndReset(&buf);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
||||
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
|
||||
char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virDomainSnapshotDefPtr def,
|
||||
virCapsPtr caps,
|
||||
unsigned int flags,
|
||||
int internal);
|
||||
int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
|
||||
|
@ -4292,7 +4292,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
|
||||
virUUIDFormat(snapshot->domain->uuid, uuid_string);
|
||||
|
||||
xml = virDomainSnapshotDefFormat(uuid_string, &def,
|
||||
xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
|
||||
virDomainDefFormatConvertXMLFlags(flags),
|
||||
0);
|
||||
|
||||
|
@ -2605,6 +2605,7 @@ qemuFindQemuImgBinary(virQEMUDriverPtr driver)
|
||||
int
|
||||
qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
virCapsPtr caps,
|
||||
char *snapshotDir)
|
||||
{
|
||||
char *newxml = NULL;
|
||||
@ -2615,7 +2616,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
||||
|
||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||
newxml = virDomainSnapshotDefFormat(
|
||||
uuidstr, snapshot->def,
|
||||
uuidstr, snapshot->def, caps,
|
||||
virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS),
|
||||
1);
|
||||
if (newxml == NULL)
|
||||
@ -2775,7 +2776,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
|
||||
snap->def->parent);
|
||||
} else {
|
||||
parentsnap->def->current = true;
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, parentsnap,
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps,
|
||||
cfg->snapshotDir) < 0) {
|
||||
VIR_WARN("failed to set parent snapshot '%s' as current",
|
||||
snap->def->parent);
|
||||
|
@ -375,6 +375,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
|
||||
|
||||
int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
virCapsPtr caps,
|
||||
char *snapshotDir);
|
||||
|
||||
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
|
||||
|
@ -14908,6 +14908,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
if (update_current) {
|
||||
vm->current_snapshot->def->current = false;
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
||||
driver->caps,
|
||||
cfg->snapshotDir) < 0)
|
||||
goto endjob;
|
||||
vm->current_snapshot = NULL;
|
||||
@ -14956,7 +14957,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
|
||||
endjob:
|
||||
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
||||
cfg->snapshotDir) < 0) {
|
||||
/* if writing of metadata fails, error out rather than trying
|
||||
* to silently carry on without completing the snapshot */
|
||||
@ -15275,6 +15276,7 @@ static char *
|
||||
qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
unsigned int flags)
|
||||
{
|
||||
virQEMUDriverPtr driver = snapshot->domain->conn->privateData;
|
||||
virDomainObjPtr vm = NULL;
|
||||
char *xml = NULL;
|
||||
virDomainSnapshotObjPtr snap = NULL;
|
||||
@ -15293,7 +15295,7 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
|
||||
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
||||
|
||||
xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
|
||||
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps,
|
||||
virDomainDefFormatConvertXMLFlags(flags),
|
||||
0);
|
||||
|
||||
@ -15474,7 +15476,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
||||
if (vm->current_snapshot) {
|
||||
vm->current_snapshot->def->current = false;
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
||||
cfg->snapshotDir) < 0)
|
||||
driver->caps, cfg->snapshotDir) < 0)
|
||||
goto endjob;
|
||||
vm->current_snapshot = NULL;
|
||||
/* XXX Should we restore vm->current_snapshot after this point
|
||||
@ -15709,7 +15711,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
||||
|
||||
cleanup:
|
||||
if (ret == 0) {
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
||||
cfg->snapshotDir) < 0)
|
||||
ret = -1;
|
||||
else
|
||||
@ -15736,6 +15738,7 @@ struct _virQEMUSnapReparent {
|
||||
virQEMUDriverConfigPtr cfg;
|
||||
virDomainSnapshotObjPtr parent;
|
||||
virDomainObjPtr vm;
|
||||
virCapsPtr caps;
|
||||
int err;
|
||||
virDomainSnapshotObjPtr last;
|
||||
};
|
||||
@ -15764,7 +15767,7 @@ qemuDomainSnapshotReparentChildren(void *payload,
|
||||
if (!snap->sibling)
|
||||
rep->last = snap;
|
||||
|
||||
rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
|
||||
rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps,
|
||||
rep->cfg->snapshotDir);
|
||||
}
|
||||
|
||||
@ -15833,7 +15836,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
||||
if (rem.current) {
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
|
||||
snap->def->current = true;
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
||||
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
|
||||
cfg->snapshotDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to set snapshot '%s' as current"),
|
||||
@ -15850,6 +15853,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
||||
rep.vm = vm;
|
||||
rep.err = 0;
|
||||
rep.last = NULL;
|
||||
rep.caps = driver->caps;
|
||||
virDomainSnapshotForEachChild(snap,
|
||||
qemuDomainSnapshotReparentChildren,
|
||||
&rep);
|
||||
|
@ -6087,6 +6087,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
char *xml = NULL;
|
||||
virDomainSnapshotObjPtr snap = NULL;
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
testDriverPtr privconn = snapshot->domain->conn->privateData;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
||||
|
||||
@ -6098,7 +6099,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
|
||||
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
||||
|
||||
xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
|
||||
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
|
||||
virDomainDefFormatConvertXMLFlags(flags),
|
||||
0);
|
||||
|
||||
|
@ -5221,7 +5221,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
VIR_FREE(currentSnapshotXmlFilePath);
|
||||
if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
|
||||
goto cleanup;
|
||||
char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
|
||||
char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
|
||||
if (snapshotContent == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to get snapshot content"));
|
||||
@ -6146,7 +6146,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
|
||||
ret = virDomainSnapshotDefFormat(uuidstr, def,
|
||||
ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps,
|
||||
virDomainDefFormatConvertXMLFlags(flags),
|
||||
0);
|
||||
|
||||
|
@ -100,7 +100,7 @@ testCompareXMLToXMLFiles(const char *inxml,
|
||||
flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(actual = virDomainSnapshotDefFormat(uuid, def,
|
||||
if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps,
|
||||
VIR_DOMAIN_DEF_FORMAT_SECURE,
|
||||
internal)))
|
||||
goto cleanup;
|
||||
|
Loading…
x
Reference in New Issue
Block a user