mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
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:
parent
35abced2a8
commit
ebec21eee0
@ -12192,7 +12192,6 @@ cleanup:
|
||||
}
|
||||
|
||||
int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotObjListPtr snapshots,
|
||||
char **const names, int maxnames,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -12202,11 +12201,11 @@ int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
|
||||
data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
|
||||
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS)
|
||||
virDomainSnapshotForEachDescendant(snapshots, snapshot,
|
||||
virDomainSnapshotForEachDescendant(snapshot,
|
||||
virDomainSnapshotObjListCopyNames,
|
||||
&data);
|
||||
else
|
||||
virDomainSnapshotForEachChild(snapshots, snapshot,
|
||||
virDomainSnapshotForEachChild(snapshot,
|
||||
virDomainSnapshotObjListCopyNames, &data);
|
||||
|
||||
if (data.oom) {
|
||||
@ -12263,7 +12262,6 @@ int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
|
||||
|
||||
int
|
||||
virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotObjListPtr snapshots,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct virDomainSnapshotNumData data = { 0, 0 };
|
||||
@ -12271,11 +12269,11 @@ virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
|
||||
data.flags = flags & ~VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
|
||||
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS)
|
||||
virDomainSnapshotForEachDescendant(snapshots, snapshot,
|
||||
virDomainSnapshotForEachDescendant(snapshot,
|
||||
virDomainSnapshotObjListCount,
|
||||
&data);
|
||||
else if (data.flags)
|
||||
virDomainSnapshotForEachChild(snapshots, snapshot,
|
||||
virDomainSnapshotForEachChild(snapshot,
|
||||
virDomainSnapshotObjListCount, &data);
|
||||
else
|
||||
data.count = snapshot->nchildren;
|
||||
@ -12300,8 +12298,7 @@ void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
|
||||
* other entries in snapshots. Return the number of children
|
||||
* visited. No particular ordering is guaranteed. */
|
||||
int
|
||||
virDomainSnapshotForEachChild(virDomainSnapshotObjListPtr snapshots ATTRIBUTE_UNUSED,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
|
||||
virHashIterator iter,
|
||||
void *data)
|
||||
{
|
||||
@ -12330,7 +12327,7 @@ virDomainSnapshotActOnDescendant(void *payload,
|
||||
struct snapshot_act_on_descendant *curr = data;
|
||||
|
||||
(curr->iter)(payload, name, curr->data);
|
||||
curr->number += 1 + virDomainSnapshotForEachDescendant(NULL, obj,
|
||||
curr->number += 1 + virDomainSnapshotForEachDescendant(obj,
|
||||
curr->iter,
|
||||
curr->data);
|
||||
}
|
||||
@ -12339,8 +12336,7 @@ virDomainSnapshotActOnDescendant(void *payload,
|
||||
* other entries in snapshots. Return the number of descendants
|
||||
* visited. No particular ordering is guaranteed. */
|
||||
int
|
||||
virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots ATTRIBUTE_UNUSED,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotForEachDescendant(virDomainSnapshotObjPtr snapshot,
|
||||
virHashIterator iter,
|
||||
void *data)
|
||||
{
|
||||
@ -12349,7 +12345,7 @@ virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots ATTRIBU
|
||||
act.number = 0;
|
||||
act.iter = iter;
|
||||
act.data = data;
|
||||
virDomainSnapshotForEachChild(NULL, snapshot,
|
||||
virDomainSnapshotForEachChild(snapshot,
|
||||
virDomainSnapshotActOnDescendant, &act);
|
||||
|
||||
return act.number;
|
||||
|
@ -1464,9 +1464,6 @@ struct _virDomainSnapshotObj {
|
||||
virDomainSnapshotObjPtr sibling; /* NULL if last child of parent */
|
||||
size_t nchildren;
|
||||
virDomainSnapshotObjPtr first_child; /* NULL if no children */
|
||||
|
||||
/* Internal use only */
|
||||
int mark; /* Used in identifying descendents. */
|
||||
};
|
||||
|
||||
typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
|
||||
@ -1508,22 +1505,18 @@ int virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
|
||||
int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
|
||||
unsigned int flags);
|
||||
int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotObjListPtr snapshots,
|
||||
char **const names, int maxnames,
|
||||
unsigned int flags);
|
||||
int virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
|
||||
virDomainSnapshotObjListPtr snapshots,
|
||||
unsigned int flags);
|
||||
virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots,
|
||||
const char *name);
|
||||
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr snapshot);
|
||||
int virDomainSnapshotForEachChild(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
int virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
|
||||
virHashIterator iter,
|
||||
void *data);
|
||||
int virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr snapshot,
|
||||
int virDomainSnapshotForEachDescendant(virDomainSnapshotObjPtr snapshot,
|
||||
virHashIterator iter,
|
||||
void *data);
|
||||
int virDomainSnapshotUpdateRelations(virDomainSnapshotObjListPtr snapshots);
|
||||
|
@ -9502,8 +9502,7 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
n = virDomainSnapshotObjListGetNamesFrom(snap, &vm->snapshots,
|
||||
names, nameslen, flags);
|
||||
n = virDomainSnapshotObjListGetNamesFrom(snap, names, nameslen, flags);
|
||||
|
||||
cleanup:
|
||||
if (vm)
|
||||
@ -9546,7 +9545,7 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
|
||||
* VIR_DOMAIN_SNAPSHOT_LIST_METADATA makes no difference to our
|
||||
* answer. */
|
||||
|
||||
n = virDomainSnapshotObjListNumFrom(snap, &vm->snapshots, flags);
|
||||
n = virDomainSnapshotObjListNumFrom(snap, flags);
|
||||
|
||||
cleanup:
|
||||
if (vm)
|
||||
@ -10163,7 +10162,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
||||
snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT)
|
||||
external++;
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
|
||||
virDomainSnapshotForEachDescendant(&vm->snapshots, snap,
|
||||
virDomainSnapshotForEachDescendant(snap,
|
||||
qemuDomainSnapshotCountExternal,
|
||||
&external);
|
||||
if (external) {
|
||||
@ -10184,8 +10183,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
||||
rem.metadata_only = metadata_only;
|
||||
rem.err = 0;
|
||||
rem.current = false;
|
||||
virDomainSnapshotForEachDescendant(&vm->snapshots,
|
||||
snap,
|
||||
virDomainSnapshotForEachDescendant(snap,
|
||||
qemuDomainSnapshotDiscardAll,
|
||||
&rem);
|
||||
if (rem.err < 0)
|
||||
@ -10210,7 +10208,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
|
||||
rep.vm = vm;
|
||||
rep.err = 0;
|
||||
rep.last = NULL;
|
||||
virDomainSnapshotForEachChild(&vm->snapshots, snap,
|
||||
virDomainSnapshotForEachChild(snap,
|
||||
qemuDomainSnapshotReparentChildren,
|
||||
&rep);
|
||||
if (rep.err < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user