Serge Hallyn | 16 Apr 21:04 2014

[PATCH 1/1] snapshots: move snapshot directory

Originally we kept snapshots under /var/lib/lxcsnaps.  If a
separate btrfs is mounted at /var/lib/lxc, then we can't
make btrfs snapshots under /var/lib/lxcsnaps.

This patch moves the default directory to /var/lib/lxc/lxcsnaps.
If /var/lib/lxcsnaps already exists, then use that.  Don't allow
any container to be used with the name 'lxcsnaps'.

Signed-off-by: Serge Hallyn <serge.hallyn <at>>
 src/lxc/lxccontainer.c | 49 +++++++++++++++++++++++++++++++++++++++----------
 src/lxc/lxccontainer.h |  4 ++--
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index c90b564..1059961 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
 <at>  <at>  -2823,16 +2823,42  <at>  <at>  static int get_next_index(const char *lxcpath, char *cname)

+static bool get_snappath_dir(struct lxc_container *c, char *snappath)
+	int ret;
+	/*
+	 * If the old style snapshot path exists, use it
+	 * /var/lib/lxc -> /var/lib/lxcsnaps
+	 */
+	ret = snprintf(snappath, MAXPATHLEN, "%ssnaps", c->config_path);
(Continue reading)

Serge Hallyn | 16 Apr 18:01 2014

[PATCH 1/1] lxc startup: manually mark every shared mount entry as slave

If you 'ip netns add x1', this creates /run/netns and /run/netns/x1
as shared mounts.  When a container starts, it umounts these after
pivot_root, and the umount is propagated to the host.

Worse, doing mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) does not
suffice to change those, even after binding /proc/mounts onto

So, I give up.  Do this manually, walking over /proc/self/mountinfo
and changing the mount propagation on everything marked as shared.

With this patch, lxc-start no longer unmounts /run/netns/* on the

Signed-off-by: Serge Hallyn <serge.hallyn <at>>
 src/lxc/conf.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 6 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 06235fb..4052c5f 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
 <at>  <at>  -3706,6 +3706,66  <at>  <at>  void tmp_proc_unmount(struct lxc_conf *lxc_conf)

+static void null_endofword(char *word)
+	while (*word && *word != ' ' && *word != '\t')
(Continue reading)

Serge Hallyn | 16 Apr 16:40 2014

snapshots location


Some time ago someone pointed out that the current lxc snapshot location
isn't ideal.  If you have a btrfs mounted at /var/lib/lxc, then the
snapshot locatoni /var/lib/lxcsnaps is not btrfs.

So I'm proposing that

1. we move the snapshot location to /var/lib/lxc/lxcsnaps
2. lxc_container_new() refuses 'lxcsnaps' as a container name
3. snapshot actions first check whether /var/lib/lxcsnaps exists; if so,
   and it is non-empty, then uses it.  Otherwise it uses the new

Any objections?  I didn't want to do this because I didn't want any
cruft under LXCPATH, but I think I'm ok with it, and I don't think
anyone should be bothering to ls /var/lib/lxc anymore, lxc-ls is so
much nicer.

lxc-devel mailing list
lxc-devel <at>
GitHub | 15 Apr 23:10 2014

[lxc/lxc] 5135b5: cppcheck: fix unchecked realloc in lxc_info.c

  Branch: refs/heads/master
  Commit: 5135b555bb3b406288cb24da8425daeaf3e38dde
  Author: Serge Hallyn <serge.hallyn@...>
  Date:   2014-04-15 (Tue, 15 Apr 2014)

  Changed paths:
    M src/lxc/lxc_info.c

  Log Message:
  cppcheck: fix unchecked realloc in lxc_info.c

Signed-off-by: Serge Hallyn <serge.hallyn@...>
Acked-by: Stéphane Graber <stgraber@...>

lxc-devel mailing list
lxc-devel <at>
Serge Hallyn | 15 Apr 22:53 2014

[PATCH 1/1] cppcheck: fix unchecked realloc in lxc_info.c

Signed-off-by: Serge Hallyn <serge.hallyn <at>>
 src/lxc/lxc_info.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
index 24d6f9b..e1e39c0 100644
--- a/src/lxc/lxc_info.c
+++ b/src/lxc/lxc_info.c
 <at>  <at>  -50,9 +50,13  <at>  <at>  static int filter_count = 0;

 static int my_parser(struct lxc_arguments* args, int c, char* arg)
+	char **newk;
 	switch (c) {
 	case 'c':
-		key = realloc(key, keys+1 * sizeof(key[0]));
+		newk = realloc(key, keys+1 * sizeof(key[0]));
+		if (!newk)
+			return -1;
+		key = newk;
 		key[keys] = arg;


lxc-devel mailing list
lxc-devel <at>
(Continue reading)

William Dauchy | 14 Apr 15:18 2014

call to setup_dev_symlinks with lxc.autodev


I'm looking for a way to not execute setup_dev_symlinks. In my case I'm
using lxc-start with a read only filesystem.
!lxc_conf->is_execute && setup_dev_symlinks(&lxc_conf->rootfs))
will probably fail

I saw there was:
               ret = symlink(d->oldpath, path);
               if (ret && errno != EEXIST) { }
but in my case I need to manually access the /dev directory in order to
make it return EEXIST.

I was wondering if we could avoid setup_dev_symlinks call in case of
autodev = 0 for example?


lxc-devel mailing list
lxc-devel <at>
Valentin LAB | 11 Apr 10:46 2014

lxc-create and template API issues


I'm having troubles migrating our lxc template from ubuntu 12.04 basic 
install to new 14.04 version. One of the major differences is that we 
can't lxc-attach or lxc-start the LXC being built. I need to do this to 
launch several startup scripts in the LXC to finish the set up.

This request seems quite normal to me, and other templates seems to 
struggle to do the same. Mostly using chroot.

For example, I see that lxc-fedora does some chroot... but this requires 
to make some mount (for /dev and /proc). And if anything goes wrong 
(Ctrl-C from the user, or the script does not finishing well for any 
reason (server unreachable), lxc-create will try to "rm -rf" the 
container rootfs (because the template script returned a non 0 
status)... leading to remove all in /dev or trying to remove things in 
/proc... And this will remove /dev/* on the host also. Yikes !

Ensuring having the template return 0 status in case of error just to 
avoid the big nasty deletion is perverse at best, or to umount properly 
these devices is cumbersome and error prone (and this even if all went 
right in the script you've launched on the LXC): Any "apt-get 
install..." could spawn services that get re-parented to PID 1 and 
they'll hook up to files in "/dev" and "/proc"... This means that umount 
will be refused unless you manage to pin and kill every process that 
were created in the chroot, and this is not trivial.

This means that the lxc-fedora could have a big nasty bug leading to 
deleting content of /dev/* on the host if you happen to Ctrl-C at the 
bad moment... (I didn't check this). Of course you can rebuild /dev on 
(Continue reading)

William Dauchy | 14 Apr 15:02 2014

lxc-start behavior in lxc1.0


With lxc0.9 I was used to do:
lxc-start -n XX -- /bin/bash
in order to debug my own init script.

now with lxc1.0, I can't get any shell but I need to use lxc-attach instead.
here is the last strace logs:
open("/proc/6951/ns/net", O_RDONLY)     = 16
epoll_create(2)                         = 17
fcntl(17, F_SETFD, FD_CLOEXEC)          = 0
epoll_ctl(17, EPOLL_CTL_ADD, 13, {EPOLLIN, {u32=13236672, u64=13236672}}) = 0
epoll_ctl(17, EPOLL_CTL_ADD, 14, {EPOLLIN, {u32=13236736, u64=13236736}}) = 0
epoll_ctl(17, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=13236800, u64=13236800}}) = 0
epoll_wait(17, {{EPOLLIN, {u32=13236672, u64=13236672}}}, 10, 4294967295) = 1
read(13, "\21\0\0\0\0\0\0\0\1\0\0\0\36\33\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
128) = 128
waitid(P_PID, 6951, {}, WNOHANG|WEXITED|WNOWAIT, NULL) = 0
epoll_wait(17, {{EPOLLIN, {u32=13236736, u64=13236736}}}, 10, 4294967295) = 1
read(14, "bash: cannot set terminal proces"..., 1024) = 114
epoll_wait(17, {{EPOLLIN, {u32=13236736, u64=13236736}}}, 10, 4294967295) = 1
read(14, "root <at> cgroups0:/# ", 1024)     = 17

I guess this new behavior is expected but I was wondering why since it
was really helpful for debug purpose (i.e check if the FS was ok and
start my init manually)


(Continue reading)

GitHub | 11 Apr 17:08 2014

[lxc/lxc] bb418c: change version to 1.0.3 in

  Branch: refs/heads/stable-1.0
  Commit: bb418ce25bb385437983ffc3ca9c8a86f2353648
  Author: Stéphane Graber <stgraber@...>
  Date:   2014-04-08 (Tue, 08 Apr 2014)

  Changed paths:

  Log Message:
  change version to 1.0.3 in

Signed-off-by: Stéphane Graber <stgraber@...>

  Commit: 944476e98e9f7aa2507f0e3257dc4a21424dc601
  Author: Dwight Engen <dwight.engen@...>
  Date:   2014-04-11 (Fri, 11 Apr 2014)

  Changed paths:
    M templates/

  Log Message:
  lxc-oracle: use db_load from container

This makes it so that the host doesn't need to have an old, compat
version of db43_load installed by using the db_load from the just
(Continue reading)

GitHub | 11 Apr 17:07 2014

[lxc/lxc] ccab6c: cgmanager: don't call nih_dbus_setup

  Branch: refs/heads/master
  Commit: ccab6c60290d2cc0592dbf380277f05f06617cdc
  Author: Serge Hallyn <serge.hallyn@...>
  Date:   2014-04-11 (Fri, 11 Apr 2014)

  Changed paths:
    M src/lxc/cgmanager.c

  Log Message:
  cgmanager: don't call nih_dbus_setup

it actually sets us up to run the nih_mainloop, but we will never run

Signed-off-by: Serge Hallyn <serge.hallyn@...>
Acked-by: Stéphane Graber <stgraber@...>

lxc-devel mailing list
Serge Hallyn | 11 Apr 17:01 2014

[PATCH 1/1] cgmanager: don't call nih_dbus_setup

it actually sets us up to run the nih_mainloop, but we will never run

Signed-off-by: Serge Hallyn <serge.hallyn@...>
 src/lxc/cgmanager.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
index 1dea824..fc959ec 100644
--- a/src/lxc/cgmanager.c
+++ b/src/lxc/cgmanager.c
 <at>  <at>  -147,17 +147,6  <at>  <at>  static bool cgm_dbus_connect(void)
 		return false;
-	if (nih_dbus_setup(connection, NULL) < 0) {
-		NihError *nerr;
-		nerr = nih_error_get();
-		DEBUG("Unable to open cgmanager connection at %s: %s", CGMANAGER_DBUS_SOCK,
-			nerr->message);
-		nih_free(nerr);
-		dbus_error_free(&dbus_error);
-		dbus_connection_unref(connection);
-		cgm_unlock();
-		return false;
-	}
 	dbus_connection_set_exit_on_disconnect(connection, FALSE);
 	cgroup_manager = nih_dbus_proxy_new(NULL, connection,
(Continue reading)