[lxc-devel] RFC: aliases

Serge Hallyn serge.hallyn at ubuntu.com
Wed Aug 21 12:59:11 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
> Hi Serge,
> 
> > I'm thinking symbolic link may be the simplest thing to support -
> > lxc_container_new() could immediately readlink() to get the real
> > container name.
> 
> Yes, I agree, I'd find such a thing very useful. However, it should not
> only be lxc_container_new but also the utilities not using the API,
> such as lxc-start etc.

Heh, lxc-start should be using the API.  Egads, several commands which
I thought I had converted have NOT in fact been converted.  That should
be done before we do this.

> So the desireable behavior would be, in my eyes:
> 
> - _Everywhere_, when resolving a container name, see if the
>    configuration directory is a symlink. If it is:
>      - relativ symlink without a /:
>          use destination as effective container name
>      - contains / (relative or absolute):
>          completely resolve path and see if it starts with
>          the configuration directory
>             if not -> don't assume anything about the name
>                       (i.e. use the supplied one), but do
>                       follow symlink if possible (as is
>                       currently done)
>             if so  -> strip configuration directory from
>                       path and use the rest as effective
>                       container name

Hm, I was thinking just:

	Anything but lxc-destroy: readlink if $lxcpath/$lxcname
	is a symlink

	lxc-destroy: specifically don't dereference symlink.

To implement that, we would rename lxc_container_new() to
lxc_container_new_ln() which takes an extra boolean and dereferences the
symlink if the boolean is true, have lxc_container_new() call that, and
have lxc-destroy call lxc_container_new_ln() with the boolean false.

> - When showing names (mostly lxc-ls), always show the
>    real name by default, never the alias. So if /var/lib/lxc
>    contains the following contents
>            foo/
>            bar/
>            baz -> bar
>    then lxc-ls should only show foo and bar. An additional
>    option for also showing aliases (or only showing aliases)
>    may be useful here.

Yes, that might require a trivial tweak to the listing logic
to ignore symlinks.




More information about the lxc-devel mailing list