snapshot: drop dead parameters

The previous optimizations lead to some follow-on cleanups.

* src/conf/domain_conf.c (virDomainSnapshotForEachChild)
(virDomainSnapshotForEachDescendant): Drop dead parameter.
(virDomainSnapshotActOnDescendant)
(virDomainSnapshotObjListNumFrom)
(virDomainSnapshotObjListGetNamesFrom): Update callers.
* src/qemu/qemu_driver.c (qemuDomainSnapshotNumChildren)
(qemuDomainSnapshotListChildrenNames, qemuDomainSnapshotDelete):
Likewise.
* src/conf/domain_conf.h: Update prototypes.
This commit is contained in:
Eric Blake 2011-10-11 17:34:19 -06:00
parent 35abced2a8
commit ebec21eee0
3 changed files with 15 additions and 28 deletions

View File

@ -12192,7 +12192,6 @@ cleanup:
} }
int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot, int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjListPtr snapshots,
char **const names, int maxnames, char **const names, int maxnames,
unsigned int flags) unsigned int flags)
{ {
@ -12202,11 +12201,11 @@ int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS; data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS)
virDomainSnapshotForEachDescendant(snapshots, snapshot, virDomainSnapshotForEachDescendant(snapshot,
virDomainSnapshotObjListCopyNames, virDomainSnapshotObjListCopyNames,
&data); &data);
else else
virDomainSnapshotForEachChild(snapshots, snapshot, virDomainSnapshotForEachChild(snapshot,
virDomainSnapshotObjListCopyNames, &data); virDomainSnapshotObjListCopyNames, &data);
if (data.oom) { if (data.oom) {
@ -12263,7 +12262,6 @@ int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
int int
virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot, virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjListPtr snapshots,
unsigned int flags) unsigned int flags)
{ {
struct virDomainSnapshotNumData data = { 0, 0 }; struct virDomainSnapshotNumData data = { 0, 0 };
@ -12271,11 +12269,11 @@ virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS; data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS)
virDomainSnapshotForEachDescendant(snapshots, snapshot, virDomainSnapshotForEachDescendant(snapshot,
virDomainSnapshotObjListCount, virDomainSnapshotObjListCount,
&data); &data);
else if (data.flags) else if (data.flags)
virDomainSnapshotForEachChild(snapshots, snapshot, virDomainSnapshotForEachChild(snapshot,
virDomainSnapshotObjListCount, &data); virDomainSnapshotObjListCount, &data);
else else
data.count = snapshot->nchildren; data.count = snapshot->nchildren;
@ -12300,8 +12298,7 @@ void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
* other entries in snapshots. Return the number of children * other entries in snapshots. Return the number of children
* visited. No particular ordering is guaranteed. */ * visited. No particular ordering is guaranteed. */
int int
virDomainSnapshotForEachChild(virDomainSnapshotObjListPtr snapshots ATTRIBUTE_UNUSED, virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjPtr snapshot,
virHashIterator iter, virHashIterator iter,
void *data) void *data)
{ {
@ -12330,7 +12327,7 @@ virDomainSnapshotActOnDescendant(void *payload,
struct snapshot_act_on_descendant *curr = data; struct snapshot_act_on_descendant *curr = data;
(curr->iter)(payload, name, curr->data); (curr->iter)(payload, name, curr->data);
curr->number += 1 + virDomainSnapshotForEachDescendant(NULL, obj, curr->number += 1 + virDomainSnapshotForEachDescendant(obj,
curr->iter, curr->iter,
curr->data); curr->data);
} }
@ -12339,8 +12336,7 @@ virDomainSnapshotActOnDescendant(void *payload,
* other entries in snapshots. Return the number of descendants * other entries in snapshots. Return the number of descendants
* visited. No particular ordering is guaranteed. */ * visited. No particular ordering is guaranteed. */
int int
virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots ATTRIBUTE_UNUSED, virDomainSnapshotForEachDescendant(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjPtr snapshot,
virHashIterator iter, virHashIterator iter,
void *data) void *data)
{ {
@ -12349,7 +12345,7 @@ virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots ATTRIBU
act.number = 0; act.number = 0;
act.iter = iter; act.iter = iter;
act.data = data; act.data = data;
virDomainSnapshotForEachChild(NULL, snapshot, virDomainSnapshotForEachChild(snapshot,
virDomainSnapshotActOnDescendant, &act); virDomainSnapshotActOnDescendant, &act);
return act.number; return act.number;

View File

@ -1464,9 +1464,6 @@ struct _virDomainSnapshotObj {
virDomainSnapshotObjPtr sibling; /* NULL if last child of parent */ virDomainSnapshotObjPtr sibling; /* NULL if last child of parent */
size_t nchildren; size_t nchildren;
virDomainSnapshotObjPtr first_child; /* NULL if no children */ virDomainSnapshotObjPtr first_child; /* NULL if no children */
/* Internal use only */
int mark; /* Used in identifying descendents. */
}; };
typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList; typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
@ -1508,22 +1505,18 @@ int virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots, int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
unsigned int flags); unsigned int flags);
int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot, int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjListPtr snapshots,
char **const names, int maxnames, char **const names, int maxnames,
unsigned int flags); unsigned int flags);
int virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot, int virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjListPtr snapshots,
unsigned int flags); unsigned int flags);
virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots, virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots,
const char *name); const char *name);
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots, void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotObjPtr snapshot); virDomainSnapshotObjPtr snapshot);
int virDomainSnapshotForEachChild(virDomainSnapshotObjListPtr snapshots, int virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjPtr snapshot,
virHashIterator iter, virHashIterator iter,
void *data); void *data);
int virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots, int virDomainSnapshotForEachDescendant(virDomainSnapshotObjPtr snapshot,
virDomainSnapshotObjPtr snapshot,
virHashIterator iter, virHashIterator iter,
void *data); void *data);
int virDomainSnapshotUpdateRelations(virDomainSnapshotObjListPtr snapshots); int virDomainSnapshotUpdateRelations(virDomainSnapshotObjListPtr snapshots);

View File

@ -9502,8 +9502,7 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
goto cleanup; goto cleanup;
} }
n = virDomainSnapshotObjListGetNamesFrom(snap, &vm->snapshots, n = virDomainSnapshotObjListGetNamesFrom(snap, names, nameslen, flags);
names, nameslen, flags);
cleanup: cleanup:
if (vm) if (vm)
@ -9546,7 +9545,7 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
* VIR_DOMAIN_SNAPSHOT_LIST_METADATA makes no difference to our * VIR_DOMAIN_SNAPSHOT_LIST_METADATA makes no difference to our
* answer. */ * answer. */
n = virDomainSnapshotObjListNumFrom(snap, &vm->snapshots, flags); n = virDomainSnapshotObjListNumFrom(snap, flags);
cleanup: cleanup:
if (vm) if (vm)
@ -10163,7 +10162,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT) snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT)
external++; external++;
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
virDomainSnapshotForEachDescendant(&vm->snapshots, snap, virDomainSnapshotForEachDescendant(snap,
qemuDomainSnapshotCountExternal, qemuDomainSnapshotCountExternal,
&external); &external);
if (external) { if (external) {
@ -10184,8 +10183,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
rem.metadata_only = metadata_only; rem.metadata_only = metadata_only;
rem.err = 0; rem.err = 0;
rem.current = false; rem.current = false;
virDomainSnapshotForEachDescendant(&vm->snapshots, virDomainSnapshotForEachDescendant(snap,
snap,
qemuDomainSnapshotDiscardAll, qemuDomainSnapshotDiscardAll,
&rem); &rem);
if (rem.err < 0) if (rem.err < 0)
@ -10210,7 +10208,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
rep.vm = vm; rep.vm = vm;
rep.err = 0; rep.err = 0;
rep.last = NULL; rep.last = NULL;
virDomainSnapshotForEachChild(&vm->snapshots, snap, virDomainSnapshotForEachChild(snap,
qemuDomainSnapshotReparentChildren, qemuDomainSnapshotReparentChildren,
&rep); &rep);
if (rep.err < 0) if (rep.err < 0)