[lxc-devel] [PATCH] python: Update the python scripts for lxcpath
This adds -P/--lxcpath to the various python scripts. Signed-off-by: Stéphane Graber --- src/lxc/lxc-device| 6 +- src/lxc/lxc-ls| 7 +-- src/lxc/lxc-start-ephemeral.in| 14 +++--- src/python-lxc/lxc/__init__.py.in | 6 -- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc-device b/src/lxc/lxc-device index db9399d..b194b05 100644 --- a/src/lxc/lxc-device +++ b/src/lxc/lxc-device @@ -47,6 +47,9 @@ parser.add_argument("-n", dest="container", metavar="CONTAINER", help=_("Name of the container to add the device to"), required=True) +parser.add_argument("-P", "--lxcpath", dest="lxcpath", metavar="PATH", +help=_("Use specified container path"), default=None) + # Commands subparsers = parser.add_subparsers() subparser_add = subparsers.add_parser('add', help=_('Add a device')) @@ -76,7 +79,8 @@ if not args.name: args.name = args.device ## Check that the container is ready -container = lxc.Container(args.container) +container = lxc.Container(args.container, args.lxcpath) + if not container.running: parser.error("The container must be running.") diff --git a/src/lxc/lxc-ls b/src/lxc/lxc-ls index 98b7861..92a4e53 100644 --- a/src/lxc/lxc-ls +++ b/src/lxc/lxc-ls @@ -92,6 +92,9 @@ parser = argparse.ArgumentParser(description=_("LXC: List containers"), parser.add_argument("-1", dest="one", action="store_true", help=_("list one container per line (default when piped)")) +parser.add_argument("-P", "--lxcpath", dest="lxcpath", metavar="PATH", +help=_("Use specified container path"), default=None) + parser.add_argument("--active", action="store_true", help=_("list only active containers " "(same as --running --frozen)")) @@ -138,7 +141,7 @@ if not os.geteuid() == 0 and (args.fancy or args.state): # List of containers, stored as dictionaries containers = [] -for container_name in lxc.list_containers(): +for container_name in lxc.list_containers(config_path=args.lxcpath): entry = {} entry['name'] = container_name @@ -151,7 +154,7 @@ for container_name in lxc.list_containers(): containers.append(entry) continue -container = lxc.Container(container_name) +container = lxc.Container(container_name, args.lxcpath) # Filter by status if args.state and container.state not in args.state: diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in index e11919f..3e2a5d3 100644 --- a/src/lxc/lxc-start-ephemeral.in +++ b/src/lxc/lxc-start-ephemeral.in @@ -64,6 +64,9 @@ container when exiting (with ctrl-a-q). If no COMMAND is given and -d is used, the name and IP addresses of the container will be printed to the console.""")) +parser.add_argument("--lxcpath", "-P", dest="lxcpath", metavar="PATH", +help=_("Use specified container path"), default=None) + parser.add_argument("--orig", "-o", type=str, required=True, help=_("name of the original container")) @@ -104,16 +107,21 @@ if not os.geteuid() == 0: % (sys.argv[0]))) # Load the orig container -orig = lxc.Container(args.orig) +orig = lxc.Container(args.orig, args.lxcpath) if not orig.defined: parser.error(_("Source container '%s' doesn't exist." % args.orig)) # Create the new container paths -dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir="@LXCPATH@") +if not args.lxcpath: +lxc_path = lxc.default_config_path +else: +lxc_path = args.lxcpath + +dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir=lxc_path) os.mkdir(os.path.join(dest_path, "rootfs")) # Setup the new container's configuration -dest = lxc.Container(os.path.basename(dest_path)) +dest = lxc.Container(os.path.basename(dest_path), args.lxcpath) dest.load_config(orig.config_file_name) dest.set_config_item("lxc.utsname", dest.name) dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs")) diff --git a/src/python-lxc/lxc/__init__.py.in b/src/python-lxc/lxc/__init__.py.in index 151a505..e262c23 100644 --- a/src/python-lxc/lxc/__init__.py.in +++ b/src/python-lxc/lxc/__init__.py.in @@ -238,7 +238,8 @@ class Container(_lxc.Container): if not self.running: return False -attach = ["lxc-attach", "-n", self.name] +attach = ["lxc-attach", "-n", self.name, + "-P", self.get_config_path()] if namespace != "ALL": attach += ["-s", namespace] @@ -299,7 +300,8 @@ class Container(_lxc.Container): if not self.running: return False -if subprocess.call(["lxc-console", "-n", self.name, "-t", "%s" % tty], +if subprocess.call(["lxc-console", "-n", self.name, "-t", "%s" % tty, +"-P", self.get_config_path()], universal_newli
Re: [lxc-devel] [PATCH] python: Update the python scripts for lxcpath
Quoting Stéphane Graber (stgra...@ubuntu.com): > This adds -P/--lxcpath to the various python scripts. > > Signed-off-by: Stéphane Graber thanks. Acked-by: Serge E. Hallyn > --- > src/lxc/lxc-device| 6 +- > src/lxc/lxc-ls| 7 +-- > src/lxc/lxc-start-ephemeral.in| 14 +++--- > src/python-lxc/lxc/__init__.py.in | 6 -- > 4 files changed, 25 insertions(+), 8 deletions(-) > > diff --git a/src/lxc/lxc-device b/src/lxc/lxc-device > index db9399d..b194b05 100644 > --- a/src/lxc/lxc-device > +++ b/src/lxc/lxc-device > @@ -47,6 +47,9 @@ parser.add_argument("-n", dest="container", > metavar="CONTAINER", > help=_("Name of the container to add the device to"), > required=True) > > +parser.add_argument("-P", "--lxcpath", dest="lxcpath", metavar="PATH", > +help=_("Use specified container path"), default=None) > + > # Commands > subparsers = parser.add_subparsers() > subparser_add = subparsers.add_parser('add', help=_('Add a device')) > @@ -76,7 +79,8 @@ if not args.name: > args.name = args.device > > ## Check that the container is ready > -container = lxc.Container(args.container) > +container = lxc.Container(args.container, args.lxcpath) > + > if not container.running: > parser.error("The container must be running.") > > diff --git a/src/lxc/lxc-ls b/src/lxc/lxc-ls > index 98b7861..92a4e53 100644 > --- a/src/lxc/lxc-ls > +++ b/src/lxc/lxc-ls > @@ -92,6 +92,9 @@ parser = argparse.ArgumentParser(description=_("LXC: List > containers"), > parser.add_argument("-1", dest="one", action="store_true", > help=_("list one container per line (default when > piped)")) > > +parser.add_argument("-P", "--lxcpath", dest="lxcpath", metavar="PATH", > +help=_("Use specified container path"), default=None) > + > parser.add_argument("--active", action="store_true", > help=_("list only active containers " > "(same as --running --frozen)")) > @@ -138,7 +141,7 @@ if not os.geteuid() == 0 and (args.fancy or args.state): > > # List of containers, stored as dictionaries > containers = [] > -for container_name in lxc.list_containers(): > +for container_name in lxc.list_containers(config_path=args.lxcpath): > entry = {} > entry['name'] = container_name > > @@ -151,7 +154,7 @@ for container_name in lxc.list_containers(): > containers.append(entry) > continue > > -container = lxc.Container(container_name) > +container = lxc.Container(container_name, args.lxcpath) > > # Filter by status > if args.state and container.state not in args.state: > diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in > index e11919f..3e2a5d3 100644 > --- a/src/lxc/lxc-start-ephemeral.in > +++ b/src/lxc/lxc-start-ephemeral.in > @@ -64,6 +64,9 @@ container when exiting (with ctrl-a-q). > If no COMMAND is given and -d is used, the name and IP addresses of the > container will be printed to the console.""")) > > +parser.add_argument("--lxcpath", "-P", dest="lxcpath", metavar="PATH", > +help=_("Use specified container path"), default=None) > + > parser.add_argument("--orig", "-o", type=str, required=True, > help=_("name of the original container")) > > @@ -104,16 +107,21 @@ if not os.geteuid() == 0: > % (sys.argv[0]))) > > # Load the orig container > -orig = lxc.Container(args.orig) > +orig = lxc.Container(args.orig, args.lxcpath) > if not orig.defined: > parser.error(_("Source container '%s' doesn't exist." % args.orig)) > > # Create the new container paths > -dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir="@LXCPATH@") > +if not args.lxcpath: > +lxc_path = lxc.default_config_path > +else: > +lxc_path = args.lxcpath > + > +dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir=lxc_path) > os.mkdir(os.path.join(dest_path, "rootfs")) > > # Setup the new container's configuration > -dest = lxc.Container(os.path.basename(dest_path)) > +dest = lxc.Container(os.path.basename(dest_path), args.lxcpath) > dest.load_config(orig.config_file_name) > dest.set_config_item("lxc.utsname", dest.name) > dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs")) > diff --git a/src/python-lxc/lxc/__init__.py.in > b/src/python-lxc/lxc/__init__.py.in > index 151a505..e262c23 100644 > --- a/src/python-lxc/lxc/__init__.py.in > +++ b/src/python-lxc/lxc/__init__.py.in > @@ -238,7 +238,8 @@ class Container(_lxc.Container): > if not self.running: > return False > > -attach = ["lxc-attach", "-n", self.name] > +attach = ["lxc-attach", "-n", self.name, > + "-P", self.get_config_path()] > if namespace != "ALL": > attach += ["-s", namespace] > > @@ -299,7 +300,8 @@ class Container(_lx
[lxc-devel] [PATCH] A new option '--host' for lxc-ps
From: Jäkel, Guido Allow for an additional --host parameter to lxc-ps hiding all processes running in containers. Signed-off-by: Guido Jäkel Signed-off-by: Stéphane Graber --- doc/lxc-ps.sgml.in | 13 + src/lxc/lxc-ps.in | 15 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/lxc-ps.sgml.in b/doc/lxc-ps.sgml.in index e266ba8..b9d8e42 100644 --- a/doc/lxc-ps.sgml.in +++ b/doc/lxc-ps.sgml.in @@ -51,6 +51,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA lxc-ps --name name --lxc + --host -- ps option @@ -106,6 +107,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + --host + + + + limit the output to the processes belonging + to the host. + + + + + + ps options diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in index 5f7cf4d..57c4041 100644 --- a/src/lxc/lxc-ps.in +++ b/src/lxc/lxc-ps.in @@ -19,7 +19,7 @@ usage() { -echo "usage: $(basename $0) [--lxc | --name NAME] [--] [PS_OPTIONS...]" >&2 +echo "usage: $(basename $0) [--lxc | --host | --name NAME] [--] [PS_OPTIONS...]" >&2 } help() { @@ -28,6 +28,7 @@ help() { echo "List current processes with container names." >&2 echo >&2 echo " --lxc show processes in all containers" >&2 +echo " --hostshow processes not related to any container, i.e. to the host" >&2 echo " --name NAME show processes in the specified container" >&2 echo " (multiple containers can be separated by commas)" >&2 echo " PS_OPTIONSps command options (see \`ps --help')" >&2 @@ -79,7 +80,9 @@ while true; do -n|--name) containers=$2; list_container_processes=1; shift 2;; --lxc) -list_container_processes=1; shift;; +list_container_processes=1; shift;; +--host) +list_container_processes=-1; shift;; --) shift; break;; *) @@ -118,6 +121,7 @@ ps "$@" | awk -v container_field_width="$container_field_width" \ -v list_container_processes="$list_container_processes" ' # first line is PS header NR == 1 { +header = $0 # find pid field index for (i = 1; i<=NF; i++) if ($i == "PID") { @@ -126,9 +130,9 @@ NR == 1 { } if (pididx == "") { print("No PID field found") > "/dev/stderr" +header = "" # to signal error condition to the END rule exit 1 } -header = $0 next } @@ -152,10 +156,11 @@ FNR == 1 { } END { +if (!header) exit 1 # quit due to internal error printf("%-" container_field_width "s %s\n", "CONTAINER", header) for (i in ps_line) { - container = container_of_pid[pid_of_line[i]] -if (list_container_processes == 0 || container != "") +container = container_of_pid[pid_of_line[i]] +if (list_container_processes == 0 || (container != "") == (list_container_processes > 0) ) printf("%-" container_field_width "s %s\n", container, ps_line[i]) } } -- 1.8.1.2 -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH] add -lrt back for liblxc.so link
got link error liblxc.so: undefined reference to `clock_gettime' clock_gettime is used by lxclock.c and is indeed in librt. Signed-off-by: Dwight Engen --- src/lxc/Makefile.am | 4 1 file changed, 4 insertions(+) diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index aba2e67..5497fab 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -168,6 +168,10 @@ AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir) endif LDADD=liblxc.so @CAP_LIBS@ @APPARMOR_LIBS@ @SECCOMP_LIBS@ +if !IS_BIONIC +LDADD += -lrt +endif + lxc_attach_SOURCES = lxc_attach.c lxc_cgroup_SOURCES = lxc_cgroup.c lxc_checkpoint_SOURCES = lxc_checkpoint.c -- 1.7.12.3 -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH] include hook files in make dist
this makes "make rpm" work again Signed-off-by: Dwight Engen --- hooks/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hooks/Makefile.am b/hooks/Makefile.am index 4fc20ac..196e632 100644 --- a/hooks/Makefile.am +++ b/hooks/Makefile.am @@ -3,3 +3,5 @@ hooksdir=@LXCHOOKDIR@ hooks_SCRIPTS = \ mountcgroups \ mountecryptfsroot + +EXTRA_DIST=$(hooks_SCRIPTS) -- 1.7.12.3 -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] add -lrt back for liblxc.so link
On 02/21/2013 04:37 PM, Dwight Engen wrote: > got link error liblxc.so: undefined reference to `clock_gettime' > clock_gettime is used by lxclock.c and is indeed in librt. > > Signed-off-by: Dwight Engen > --- > src/lxc/Makefile.am | 4 > 1 file changed, 4 insertions(+) > > diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am > index aba2e67..5497fab 100644 > --- a/src/lxc/Makefile.am > +++ b/src/lxc/Makefile.am > @@ -168,6 +168,10 @@ AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir) > endif > LDADD=liblxc.so @CAP_LIBS@ @APPARMOR_LIBS@ @SECCOMP_LIBS@ > > +if !IS_BIONIC > +LDADD += -lrt > +endif > + > lxc_attach_SOURCES = lxc_attach.c > lxc_cgroup_SOURCES = lxc_cgroup.c > lxc_checkpoint_SOURCES = lxc_checkpoint.c > Can we do that with a statement in configure.ac similar to that for sem_open instead of using !IS_BIONIC? -- Stéphane Graber Ubuntu developer http://www.ubuntu.com signature.asc Description: OpenPGP digital signature -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] add -lrt back for liblxc.so link
On Thu, 21 Feb 2013 16:58:36 -0500 Stéphane Graber wrote: > On 02/21/2013 04:37 PM, Dwight Engen wrote: > > got link error liblxc.so: undefined reference to `clock_gettime' > > clock_gettime is used by lxclock.c and is indeed in librt. > > > > Signed-off-by: Dwight Engen > > --- > > src/lxc/Makefile.am | 4 > > 1 file changed, 4 insertions(+) > > > > diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am > > index aba2e67..5497fab 100644 > > --- a/src/lxc/Makefile.am > > +++ b/src/lxc/Makefile.am > > @@ -168,6 +168,10 @@ AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir) > > endif > > LDADD=liblxc.so @CAP_LIBS@ @APPARMOR_LIBS@ @SECCOMP_LIBS@ > > > > +if !IS_BIONIC > > +LDADD += -lrt > > +endif > > + > > lxc_attach_SOURCES = lxc_attach.c > > lxc_cgroup_SOURCES = lxc_cgroup.c > > lxc_checkpoint_SOURCES = lxc_checkpoint.c > > > > Can we do that with a statement in configure.ac similar to that for > sem_open instead of using !IS_BIONIC? Yeah, I looked at that, but I wasn't sure what other library to put in the search with rt? On bionic does clock_gettime come from libc? ... and would we just put AC_SEARCH_LIBS(sem_open, [rt c]) ? I don't have bionic to try it out :) -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] add -lrt back for liblxc.so link
On 02/21/2013 05:26 PM, Dwight Engen wrote: > On Thu, 21 Feb 2013 16:58:36 -0500 > Stéphane Graber wrote: > >> On 02/21/2013 04:37 PM, Dwight Engen wrote: >>> got link error liblxc.so: undefined reference to `clock_gettime' >>> clock_gettime is used by lxclock.c and is indeed in librt. >>> >>> Signed-off-by: Dwight Engen >>> --- >>> src/lxc/Makefile.am | 4 >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am >>> index aba2e67..5497fab 100644 >>> --- a/src/lxc/Makefile.am >>> +++ b/src/lxc/Makefile.am >>> @@ -168,6 +168,10 @@ AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir) >>> endif >>> LDADD=liblxc.so @CAP_LIBS@ @APPARMOR_LIBS@ @SECCOMP_LIBS@ >>> >>> +if !IS_BIONIC >>> +LDADD += -lrt >>> +endif >>> + >>> lxc_attach_SOURCES = lxc_attach.c >>> lxc_cgroup_SOURCES = lxc_cgroup.c >>> lxc_checkpoint_SOURCES = lxc_checkpoint.c >>> >> >> Can we do that with a statement in configure.ac similar to that for >> sem_open instead of using !IS_BIONIC? > > Yeah, I looked at that, but I wasn't sure what other library to put in > the search with rt? On bionic does clock_gettime come from libc? ... > and would we just put AC_SEARCH_LIBS(sem_open, [rt c]) ? I don't have > bionic to try it out :) clock_gettime is part of libc on bionic, so adding something like: AC_SEARCH_LIBS(clock_gettime, [rt]) Should do it. I confirmed that lxc still builds on android with that. -- Stéphane Graber Ubuntu developer http://www.ubuntu.com signature.asc Description: OpenPGP digital signature -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] [PATCH] include hook files in make dist
On 02/21/2013 04:57 PM, Dwight Engen wrote: > this makes "make rpm" work again > > Signed-off-by: Dwight Engen Acked-by: Stéphane Graber And pushed to staging. Thanks > --- > hooks/Makefile.am | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/hooks/Makefile.am b/hooks/Makefile.am > index 4fc20ac..196e632 100644 > --- a/hooks/Makefile.am > +++ b/hooks/Makefile.am > @@ -3,3 +3,5 @@ hooksdir=@LXCHOOKDIR@ > hooks_SCRIPTS = \ > mountcgroups \ > mountecryptfsroot > + > +EXTRA_DIST=$(hooks_SCRIPTS) > -- Stéphane Graber Ubuntu developer http://www.ubuntu.com signature.asc Description: OpenPGP digital signature -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel