Re: [PATCH 4/4] snapshot: drop dead parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 07, 2011 at 06:05:57PM -0600, Eric Blake wrote:
> 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.
> ---
>  src/conf/domain_conf.c |   20 ++++++++------------
>  src/conf/domain_conf.h |   11 ++---------
>  src/qemu/qemu_driver.c |   12 +++++-------
>  3 files changed, 15 insertions(+), 28 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index e77257a..d52a79f 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -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)
>  {
> @@ -12331,15 +12328,14 @@ virDomainSnapshotActOnDescendant(void *payload,
> 
>      curr->number++;
>      (curr->iter)(payload, name, curr->data);
> -    virDomainSnapshotForEachDescendant(NULL, obj, curr->iter, curr->data);
> +    virDomainSnapshotForEachDescendant(obj, curr->iter, curr->data);
>  }
> 
>  /* Run iter(data) on all descendants of snapshot, while ignoring all
>   * 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)
>  {
> @@ -12348,7 +12344,7 @@ virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots ATTRIBU
>      act.number = 0;
>      act.iter = iter;
>      act.data = data;
> -    virDomainSnapshotForEachChild(NULL, snapshot,
> +    virDomainSnapshotForEachChild(snapshot,
>                                    virDomainSnapshotActOnDescendant, &act);
> 
>      return act.number;
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 9b3870a..ce93215 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -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);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 501a3fc..7a134e3 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -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)

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]