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