mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
vz: fix for tracking current snapshot
f1056279 removed virDomainSnapshotDef.current and leaved using vm->current_snapshot only. Later 4819f54bd moved current snapshot tracking to virDomainSnapshotObjList. As vz driver never used vm->current_snaphot this patch includes fixes after both commits. Reviewed-by: Cole Robinson <crobinso@redhat.com> ACKed-by: Maxim Nestratov <mnestratov@virtuozzo.com> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
c64152b67c
commit
be2bff3d0a
@ -2150,29 +2150,6 @@ vzSnapObjFromSnapshot(virDomainSnapshotObjListPtr snapshots,
|
||||
return vzSnapObjFromName(snapshots, snapshot->name);
|
||||
}
|
||||
|
||||
static int
|
||||
vzCurrentSnapshotIterator(void *payload,
|
||||
const void *name ATTRIBUTE_UNUSED,
|
||||
void *data)
|
||||
{
|
||||
virDomainMomentObjPtr snapshot = payload;
|
||||
virDomainMomentObjPtr *current = data;
|
||||
|
||||
if (snapshot->def->current)
|
||||
*current = snapshot;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static virDomainMomentObjPtr
|
||||
vzFindCurrentSnapshot(virDomainSnapshotObjListPtr snapshots)
|
||||
{
|
||||
virDomainMomentObjPtr current = NULL;
|
||||
|
||||
virDomainSnapshotForEach(snapshots, vzCurrentSnapshotIterator, ¤t);
|
||||
return current;
|
||||
}
|
||||
|
||||
static int
|
||||
vzDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
@ -2451,7 +2428,7 @@ vzDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
|
||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||
goto cleanup;
|
||||
|
||||
ret = vzFindCurrentSnapshot(snapshots) != NULL;
|
||||
ret = virDomainSnapshotGetCurrent(snapshots) != NULL;
|
||||
|
||||
cleanup:
|
||||
virDomainSnapshotObjListFree(snapshots);
|
||||
@ -2517,7 +2494,7 @@ vzDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
|
||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(current = vzFindCurrentSnapshot(snapshots))) {
|
||||
if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
|
||||
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, "%s",
|
||||
_("the domain does not have a current snapshot"));
|
||||
goto cleanup;
|
||||
@ -2551,7 +2528,7 @@ vzDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags)
|
||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||
goto cleanup;
|
||||
|
||||
current = vzFindCurrentSnapshot(snapshots);
|
||||
current = virDomainSnapshotGetCurrent(snapshots);
|
||||
ret = current && STREQ(snapshot->name, current->def->name);
|
||||
|
||||
cleanup:
|
||||
@ -2647,7 +2624,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(current = vzFindCurrentSnapshot(snapshots))) {
|
||||
if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("can't find created snapshot"));
|
||||
goto cleanup;
|
||||
|
@ -4653,7 +4653,6 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
xmlNodePtr *nodes = NULL;
|
||||
virDomainSnapshotDefPtr def = NULL;
|
||||
virDomainMomentObjPtr snapshot;
|
||||
virDomainMomentObjPtr current = NULL;
|
||||
virDomainSnapshotObjListPtr snapshots = NULL;
|
||||
char *xmlstr = NULL;
|
||||
int n;
|
||||
@ -4740,22 +4739,21 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
}
|
||||
VIR_FREE(xmlstr);
|
||||
|
||||
xmlstr = virXPathString("string(./@current)", ctxt);
|
||||
def->current = xmlstr && STREQ("yes", xmlstr);
|
||||
VIR_FREE(xmlstr);
|
||||
|
||||
if (!(snapshot = virDomainSnapshotAssignDef(snapshots, def)))
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
|
||||
if (snapshot->def->current) {
|
||||
if (current) {
|
||||
xmlstr = virXPathString("string(./@current)", ctxt);
|
||||
if (xmlstr && STREQ("yes", xmlstr)) {
|
||||
if (virDomainSnapshotGetCurrent(snapshots)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("too many current snapshots"));
|
||||
VIR_FREE(xmlstr);
|
||||
goto cleanup;
|
||||
}
|
||||
current = snapshot;
|
||||
virDomainSnapshotSetCurrent(snapshots, snapshot);
|
||||
}
|
||||
VIR_FREE(xmlstr);
|
||||
}
|
||||
|
||||
if (virDomainSnapshotUpdateRelations(snapshots) < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user