only INFO rcfile if asprintf successfully allocates it

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
lxc-alpine: autodetect standard bridges and set hwaddress

Check for lxcbr0, virbr0 and br0 and use one of those if they exist.

Set mac address if network type is veth.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
legacy ls: only output appropriate directories/containers

For lxc-ls without --active, only output a directory in lxc_path if it
contains a file named config. This avoids extra directories that may
exist in lxc_path, for example .snapshot if lxc_path is an nfs mount.

For lxc-ls with --active, don't output . if there are no active
containers.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
configure: replace deprecated AM_CONFIG_HEADER

Replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS.

This is needed for automake-1.13.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Introduce --lxcpath cmdline option, and make default_lxc_path() return const char *

For the lxc-* C binaries, introduce a -P|--lxcpath command line option
to override the system default.

With this, I can

    lxc-create -t ubuntu -n r1
    lxc-create -t ubuntu -n r1 -P /home/ubuntu/lxcbase
    lxc-start -n r1 -d
    lxc-start -n r1 -d -P /home/ubuntu/lxcbase
    lxc-console -n r1 -d -P /home/ubuntu/lxcbase
    lxc-stop -n r1

all working with the right containers (module cgroup stuff).

To do:
    * lxc monitor needs to be made to handle cgroups.
      This is another very invasive one.  I started doing this as
      a part of this set, but that gets hairy, so I'm sending this
      separately.  Note that lxc-wait and lxc-monitor don't work
      without this, and there may be niggles in what I said works
      above - since start.c is doing lxc_monitor_send_state etc
      to the shared abstract unix domain socket.
    * Need to handle the cgroup conflicts.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Use AC_SEARCH_LIBS instead of hardcoded lists

Use AC_SEARCH_LIBS to detect what library provides sem_*.
This allows us to stop hardcoding the ld arguments in the various MakeFiles.

Suggested-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Fix typos identified by lintian

Lintian spotted those two typos.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
lxc_monitor_open: prepend lxcpath

This is needed for lxc_wait and lxc_monitor to handle lxcpath.  However,
the full path name is limited to 108 bytes.  Should we use a md5sum of
the lxcpath instead of the path itself?

In any case, with this patch, lxc-wait and lxc-monitor work right with
respect to multiple lxcpaths.

The lxcpath is added to the lxc_handler to make it available most of the
places we need it.

I also remove function prototypes in monitor.h for two functions which
are not defined or used anywhere.

TODO: make cgroups tolerate multiple same-named containers.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-ubuntu{-cloud}: Config layout tweaking

This commit tweaks the layout of the config file for the Ubuntu templates.

With this, we now get a clear network config group, then a path related group,
then a bunch of random config options and the end of the config is apparmor,
capabilities and cgroups.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
remove redundant, too-early call to clearenv in api_start call.

Ok, took a look, what happened was the clearenv calls used to be
in lxc_start and lxccontainer and lxc_execute (do lxc_start() callers)
themselves.  I moved those into do_start(), but the calls in
lxccontainer.c were never removed.

They should simply be removed altogether.  Trivial patch follows.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Add example hooks from Ubuntu package

We've been shipping those two hooks for a while in Ubuntu.
Yesterday I reworked them to use the new environment variables and
avoid hardcoding any path that we have available as a variable.

I tested both to work on Ubuntu 13.04 but they should work just as well
on any distro shipping with the cgroup hierarchy in /sys/fs/cgroup and
with ecryptfs available.

Those are intended as example and distros are free to drop them, they
should however be working without any change required, at least on Ubuntu.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
python: Update the python scripts for lxcpath

This adds -P/--lxcpath to the various python scripts.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
include hook files in make dist

this makes "make rpm" work again

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
A new option '--host' for lxc-ps

Allow for an additional --host parameter to lxc-ps hiding all processes running
in containers.

Signed-off-by: Guido Jäkel <G.Jaekel@dnb.de>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
ensure clock_gettime symbol is found

got link error liblxc.so: undefined reference to `clock_gettime'
clock_gettime is used by lxclock.c and is in librt, or bionic libc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
various fixes for openSUSE template for lxc-clone usage

- create /etc/hostname as symlink to /etc/HOSTNAME
- fix inadequate space in lxc.mount config, preventing lxc-clone to work

Jiri Slaby: some cleanups

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
shutdown fixes for openSUSE container

- mount /run on tmpfs outside container
- replace /var/run bind mount on /run by a symlink

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
give a hint if old cgroup can't be moved

When cgroup can't be moved, it might be a hint container is already
running.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
lxc-opensuse: update for 12.2

This adaptation of systemd. We also add network configuration support.

Jiri Slaby: cleanups, rebase

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
lxc-opensuse: extend base

Base no longer provides bash, sed and tar, but we need those. So add them.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>