mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vz: fix for tracking current snapshot
f1056279
removed virDomainSnapshotDef.current and leaved using vm->current_snapshot only. Later4819f54bd
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);
|
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
|
static int
|
||||||
vzDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
vzDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -2451,7 +2428,7 @@ vzDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
|
|||||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = vzFindCurrentSnapshot(snapshots) != NULL;
|
ret = virDomainSnapshotGetCurrent(snapshots) != NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainSnapshotObjListFree(snapshots);
|
virDomainSnapshotObjListFree(snapshots);
|
||||||
@ -2517,7 +2494,7 @@ vzDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
|
|||||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(current = vzFindCurrentSnapshot(snapshots))) {
|
if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, "%s",
|
||||||
_("the domain does not have a current snapshot"));
|
_("the domain does not have a current snapshot"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2551,7 +2528,7 @@ vzDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
current = vzFindCurrentSnapshot(snapshots);
|
current = virDomainSnapshotGetCurrent(snapshots);
|
||||||
ret = current && STREQ(snapshot->name, current->def->name);
|
ret = current && STREQ(snapshot->name, current->def->name);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2647,7 +2624,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
if (!(snapshots = prlsdkLoadSnapshots(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(current = vzFindCurrentSnapshot(snapshots))) {
|
if (!(current = virDomainSnapshotGetCurrent(snapshots))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("can't find created snapshot"));
|
_("can't find created snapshot"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -4653,7 +4653,6 @@ prlsdkParseSnapshotTree(const char *treexml)
|
|||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
virDomainSnapshotDefPtr def = NULL;
|
virDomainSnapshotDefPtr def = NULL;
|
||||||
virDomainMomentObjPtr snapshot;
|
virDomainMomentObjPtr snapshot;
|
||||||
virDomainMomentObjPtr current = NULL;
|
|
||||||
virDomainSnapshotObjListPtr snapshots = NULL;
|
virDomainSnapshotObjListPtr snapshots = NULL;
|
||||||
char *xmlstr = NULL;
|
char *xmlstr = NULL;
|
||||||
int n;
|
int n;
|
||||||
@ -4740,22 +4739,21 @@ prlsdkParseSnapshotTree(const char *treexml)
|
|||||||
}
|
}
|
||||||
VIR_FREE(xmlstr);
|
VIR_FREE(xmlstr);
|
||||||
|
|
||||||
xmlstr = virXPathString("string(./@current)", ctxt);
|
|
||||||
def->current = xmlstr && STREQ("yes", xmlstr);
|
|
||||||
VIR_FREE(xmlstr);
|
|
||||||
|
|
||||||
if (!(snapshot = virDomainSnapshotAssignDef(snapshots, def)))
|
if (!(snapshot = virDomainSnapshotAssignDef(snapshots, def)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
if (snapshot->def->current) {
|
xmlstr = virXPathString("string(./@current)", ctxt);
|
||||||
if (current) {
|
if (xmlstr && STREQ("yes", xmlstr)) {
|
||||||
|
if (virDomainSnapshotGetCurrent(snapshots)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("too many current snapshots"));
|
_("too many current snapshots"));
|
||||||
|
VIR_FREE(xmlstr);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
current = snapshot;
|
virDomainSnapshotSetCurrent(snapshots, snapshot);
|
||||||
}
|
}
|
||||||
|
VIR_FREE(xmlstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainSnapshotUpdateRelations(snapshots) < 0) {
|
if (virDomainSnapshotUpdateRelations(snapshots) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user