[lxc-devel] [PATCH] Eliminate duplicate entries from list_active_containers

Serge Hallyn serge.hallyn at ubuntu.com
Tue Oct 22 16:44:34 UTC 2013


Quoting S.Çağlar Onur (caglar at 10ur.org):
> Hi,
> 
> 
> On Mon, Oct 21, 2013 at 8:22 PM, Serge Hallyn <serge.hallyn at ubuntu.com>wrote:
> 
> > Quoting S.Çağlar Onur (caglar at 10ur.org):
> > > list_active_containers parses /proc/net/unix which can contain multiple
> > entries for the same container;
> > >
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273672
> > @/var/lib/lxc/6/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 274395
> > @/var/lib/lxc/5/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273890
> > @/var/lib/lxc/4/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273141
> > @/var/lib/lxc/3/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273915
> > @/var/lib/lxc/2/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273683
> > @/var/lib/lxc/1/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273074
> > @/var/lib/lxc/0/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273931
> > @/var/lib/lxc/9/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273110
> > @/var/lib/lxc/8/command
> > > 0000000000000000: 00000002 00000000 00010000 0001 01 273390
> > @/var/lib/lxc/7/command
> > > 0000000000000000: 00000003 00000000 00000000 0001 03 275903
> > @/var/lib/lxc/8/command
> > > 0000000000000000: 00000003 00000000 00000000 0001 03 276043
> > @/var/lib/lxc/1/command
> > > 0000000000000000: 00000003 00000000 00000000 0001 03 273301
> > @/var/lib/lxc/0/command
> > > 0000000000000000: 00000003 00000000 00000000 0001 03 275650
> > @/var/lib/lxc/4/command
> > >
> > > On this system list_active_containers returns 14 containers while only
> > 10 containers are running.
> > >
> > > Following patch;
> > >
> > > * Introduces array_contains function to do a binary search on given
> > array,
> > > * Starts to sort arrays inside the add_to_clist and add_to_names
> > functions,
> > > * Consumes array_contains in list_active_containers to eliminate
> > duplicates,
> > > * Replaces the linear search code in lxcapi_get_interfaces with the new
> > function.
> >
> > Thanks - that patch on the whole is good, except that you move the
> > adding to *names in list_active_containers() to after the attempt to
> > load the container.  Not loading the container if a container list is
> > not passed in is deliberately done to avoid a potentially large
> > amount of work.  (The very low potential for differing results when
> > passing in *cret and not is deemed worthwhile)
> 
> 
> OK, I was just trying to make sure both cases return same result :) I'll
> iterate one more time with that change.

Thanks - everything else looked good.




More information about the lxc-devel mailing list