mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
snapshot_conf: introduce <revertDisks> metadata element
This new element will hold the new disk overlay created when reverting to non-leaf snapshot in order to remember the files libvirt created. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
a0853c89fe
commit
206ff69832
@ -60,6 +60,13 @@
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="revertDisks">
|
||||
<zeroOrMore>
|
||||
<ref name="disksnapshot"/>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="active">
|
||||
<choice>
|
||||
|
@ -112,6 +112,9 @@ virDomainSnapshotDefDispose(void *obj)
|
||||
for (i = 0; i < def->ndisks; i++)
|
||||
virDomainSnapshotDiskDefClear(&def->disks[i]);
|
||||
g_free(def->disks);
|
||||
for (i = 0; i < def->nrevertdisks; i++)
|
||||
virDomainSnapshotDiskDefClear(&def->revertdisks[i]);
|
||||
g_free(def->revertdisks);
|
||||
virObjectUnref(def->cookie);
|
||||
}
|
||||
|
||||
@ -376,6 +379,22 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
|
||||
g_autofree xmlNodePtr *revertDiskNodes = NULL;
|
||||
|
||||
if ((n = virXPathNodeSet("./revertDisks/*", ctxt, &revertDiskNodes)) < 0)
|
||||
return NULL;
|
||||
if (n)
|
||||
def->revertdisks = g_new0(virDomainSnapshotDiskDef, n);
|
||||
def->nrevertdisks = n;
|
||||
for (i = 0; i < def->nrevertdisks; i++) {
|
||||
if (virDomainSnapshotDiskDefParseXML(revertDiskNodes[i], ctxt,
|
||||
&def->revertdisks[i],
|
||||
flags, xmlopt) < 0)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) {
|
||||
int active;
|
||||
|
||||
@ -834,6 +853,17 @@ virDomainSnapshotDefFormatInternal(virBuffer *buf,
|
||||
virBufferAddLit(buf, "</disks>\n");
|
||||
}
|
||||
|
||||
if (def->nrevertdisks > 0) {
|
||||
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||
|
||||
for (i = 0; i < def->nrevertdisks; i++) {
|
||||
if (virDomainSnapshotDiskDefFormat(&childBuf, &def->revertdisks[i], xmlopt) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
virXMLFormatElement(buf, "revertDisks", NULL, &childBuf);
|
||||
}
|
||||
|
||||
if (def->parent.dom) {
|
||||
if (virDomainDefFormatInternal(def->parent.dom, xmlopt,
|
||||
buf, domainflags) < 0)
|
||||
|
@ -80,6 +80,11 @@ struct _virDomainSnapshotDef {
|
||||
size_t ndisks; /* should not exceed dom->ndisks */
|
||||
virDomainSnapshotDiskDef *disks;
|
||||
|
||||
/* When we revert to non-leaf snapshot we need to
|
||||
* store the new overlay disks. */
|
||||
size_t nrevertdisks;
|
||||
virDomainSnapshotDiskDef *revertdisks;
|
||||
|
||||
virObject *cookie;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user