提交 be2bff3d 编写于 作者: N Nikolay Shirokovskiy

vz: fix for tracking current snapshot

f1056279 removed virDomainSnapshotDef.current and leaved
using vm->current_snapshot only. Later 4819f54b moved current snapshot
tracking to virDomainSnapshotObjList. As vz driver never used
vm->current_snaphot this patch includes fixes after both commits.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
ACKed-by: NMaxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 c64152b6
......@@ -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, &current);
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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册