mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
virDomainSnapshotAssignDef: Clear second argument when it is consumed
Rather than callers second-guessing when the snapshot definition is assigned turn it into a double pointer and clear it on success. Fix callers to work with the new semantics. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
91df85e057
commit
d281c1323f
@ -42,9 +42,15 @@ struct _virDomainSnapshotObjList {
|
||||
|
||||
virDomainMomentObj *
|
||||
virDomainSnapshotAssignDef(virDomainSnapshotObjList *snapshots,
|
||||
virDomainSnapshotDef *def)
|
||||
virDomainSnapshotDef **snapdefptr)
|
||||
{
|
||||
return virDomainMomentAssignDef(snapshots->base, &def->parent);
|
||||
virDomainSnapshotDef *snapdef = *snapdefptr;
|
||||
virDomainMomentObj *ret = virDomainMomentAssignDef(snapshots->base, &snapdef->parent);
|
||||
|
||||
if (ret)
|
||||
*snapdefptr = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ virDomainSnapshotObjList *virDomainSnapshotObjListNew(void);
|
||||
void virDomainSnapshotObjListFree(virDomainSnapshotObjList *snapshots);
|
||||
|
||||
virDomainMomentObj *virDomainSnapshotAssignDef(virDomainSnapshotObjList *snapshots,
|
||||
virDomainSnapshotDef *def);
|
||||
virDomainSnapshotDef **snapdefptr);
|
||||
|
||||
int virDomainSnapshotObjListGetNames(virDomainSnapshotObjList *snapshots,
|
||||
virDomainMomentObj *from,
|
||||
|
@ -396,9 +396,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm,
|
||||
continue;
|
||||
}
|
||||
|
||||
snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef);
|
||||
if (snap)
|
||||
snapdef = NULL;
|
||||
snap = virDomainSnapshotAssignDef(vm->snapshots, &snapdef);
|
||||
if (cur && snap) {
|
||||
if (current)
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
|
@ -1721,9 +1721,8 @@ qemuSnapshotRedefine(virDomainObj *vm,
|
||||
return NULL;
|
||||
|
||||
if (!snap) {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, &snapdef)))
|
||||
return NULL;
|
||||
snapdef = NULL;
|
||||
}
|
||||
/* XXX Should we validate that the redefined snapshot even
|
||||
* makes sense, such as checking that qemu-img recognizes the
|
||||
@ -1772,9 +1771,8 @@ qemuSnapshotCreate(virDomainObj *vm,
|
||||
snap->def = &snapdef->parent;
|
||||
snapdef = NULL;
|
||||
} else {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, &snapdef)))
|
||||
return NULL;
|
||||
snapdef = NULL;
|
||||
|
||||
if ((current = virDomainSnapshotGetCurrent(vm->snapshots))) {
|
||||
snap->def->parent_name = g_strdup(current->def->name);
|
||||
|
@ -968,7 +968,7 @@ testParseDomainSnapshots(testDriver *privconn,
|
||||
|
||||
for (i = 0; i < nsdata->num_snap_nodes; i++) {
|
||||
virDomainMomentObj *snap;
|
||||
virDomainSnapshotDef *def;
|
||||
g_autoptr(virDomainSnapshotDef) def = NULL;
|
||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
||||
"domainsnapshot");
|
||||
if (!node)
|
||||
@ -984,10 +984,8 @@ testParseDomainSnapshots(testDriver *privconn,
|
||||
if (!def)
|
||||
return -1;
|
||||
|
||||
if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, def))) {
|
||||
virObjectUnref(def);
|
||||
if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, &def)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cur) {
|
||||
if (virDomainSnapshotGetCurrent(domobj->snapshots)) {
|
||||
@ -8755,9 +8753,8 @@ testDomainSnapshotRedefine(virDomainObj *vm,
|
||||
return NULL;
|
||||
|
||||
if (!snap) {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, &snapdef)))
|
||||
return NULL;
|
||||
snapdef = NULL;
|
||||
}
|
||||
|
||||
*snapout = snap;
|
||||
@ -8846,9 +8843,8 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
if (testDomainSnapshotAlignDisks(vm, def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, def)))
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, &def)))
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
|
||||
snap->def->parent_name = g_strdup(virDomainSnapshotGetCurrentName(vm->snapshots));
|
||||
|
||||
|
@ -4661,9 +4661,8 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
}
|
||||
VIR_FREE(xmlstr);
|
||||
|
||||
if (!(snapshot = virDomainSnapshotAssignDef(snapshots, def)))
|
||||
if (!(snapshot = virDomainSnapshotAssignDef(snapshots, &def)))
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
|
||||
xmlstr = virXPathString("string(./@current)", ctxt);
|
||||
if (xmlstr && STREQ("yes", xmlstr)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user