History log of /lxc/src/tests/cgpath.c
Revision Date Author Comments Expand
5a21336025eec5b4228994d0efece129257411bd 11-Aug-2016 Christian Brauner <cbrauner@suse.de>

tools, tests: reorganize repo - tools: move lxc commands to common subfolder - tests: adapt include search path Signed-off-by: Christian Brauner <cbrauner@suse.de>

/lxc/configure.ac /lxc/src/lxc/Makefile.am /lxc/src/lxc/tools/lxc-checkconfig.in /lxc/src/lxc/tools/lxc-start-ephemeral.in /lxc/src/lxc/tools/lxc-top.lua /lxc/src/lxc/tools/lxc_attach.c /lxc/src/lxc/tools/lxc_autostart.c /lxc/src/lxc/tools/lxc_cgroup.c /lxc/src/lxc/tools/lxc_checkpoint.c /lxc/src/lxc/tools/lxc_clone.c /lxc/src/lxc/tools/lxc_config.c /lxc/src/lxc/tools/lxc_console.c /lxc/src/lxc/tools/lxc_copy.c /lxc/src/lxc/tools/lxc_create.c /lxc/src/lxc/tools/lxc_destroy.c /lxc/src/lxc/tools/lxc_device.c /lxc/src/lxc/tools/lxc_execute.c /lxc/src/lxc/tools/lxc_freeze.c /lxc/src/lxc/tools/lxc_info.c /lxc/src/lxc/tools/lxc_init.c /lxc/src/lxc/tools/lxc_ls.c /lxc/src/lxc/tools/lxc_monitor.c /lxc/src/lxc/tools/lxc_snapshot.c /lxc/src/lxc/tools/lxc_start.c /lxc/src/lxc/tools/lxc_stop.c /lxc/src/lxc/tools/lxc_top.c /lxc/src/lxc/tools/lxc_unfreeze.c /lxc/src/lxc/tools/lxc_unshare.c /lxc/src/lxc/tools/lxc_usernsexec.c /lxc/src/lxc/tools/lxc_wait.c Makefile.am cgpath.c
4fb3cba5bc6b256b774e780f2bbf47b1dbcc0ce9 06-Feb-2014 Dwight Engen <dwight.engen@oracle.com>

split cgroup handling into discrete backends - refactor cgroup into two backends, the classic cgfs driver and the new cgmanager. Instead of lxc_handler knowing about the internals of each, have it just store an opaque pointer to a struct that is private to each backend. - rename a couple of cgroup functions for consistency: those that are considered an API (ie. exported by lxc.h) begin with lxc_ and those that are not are just cgroup_* - made as many backend routines static as possible, only cg*_ops_init is exported - made a nrtasks op which is needed by the utmp code for monitoring container shutdown, currently only implemented for the cgfs backend Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

f2363e38d07db2ad4796b5580b95e3665ed34a88 01-Jan-2014 S.Çağlar Onur < <caglar@10ur.org>

adjust include statements (v2) Use "#include <somefile.h>" style for external or exported headers only. changes since v1: - adjusted formatting as Stéphane suggested Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

/lxc/src/lua-lxc/core.c /lxc/src/lxc/attach.h /lxc/src/lxc/bdev.c /lxc/src/lxc/cgroup.c /lxc/src/lxc/checkpoint.c /lxc/src/lxc/commands.c /lxc/src/lxc/conf.h /lxc/src/lxc/confile.c /lxc/src/lxc/confile.h /lxc/src/lxc/console.c /lxc/src/lxc/error.c /lxc/src/lxc/freezer.c /lxc/src/lxc/lsm/apparmor.c /lxc/src/lxc/lsm/selinux.c /lxc/src/lxc/lxc.h /lxc/src/lxc/lxc_cgroup.c /lxc/src/lxc/lxc_checkpoint.c /lxc/src/lxc/lxc_clone.c /lxc/src/lxc/lxc_config.c /lxc/src/lxc/lxc_console.c /lxc/src/lxc/lxc_create.c /lxc/src/lxc/lxc_destroy.c /lxc/src/lxc/lxc_freeze.c /lxc/src/lxc/lxc_info.c /lxc/src/lxc/lxc_kill.c /lxc/src/lxc/lxc_monitor.c /lxc/src/lxc/lxc_monitord.c /lxc/src/lxc/lxc_snapshot.c /lxc/src/lxc/lxc_start.c /lxc/src/lxc/lxc_stop.c /lxc/src/lxc/lxc_unfreeze.c /lxc/src/lxc/lxc_user_nic.c /lxc/src/lxc/lxc_usernsexec.c /lxc/src/lxc/lxc_wait.c /lxc/src/lxc/lxccontainer.c /lxc/src/lxc/lxccontainer.h /lxc/src/lxc/lxclock.c /lxc/src/lxc/monitor.c /lxc/src/lxc/monitor.h /lxc/src/lxc/parse.c /lxc/src/lxc/restart.c /lxc/src/lxc/seccomp.c /lxc/src/lxc/start.h /lxc/src/lxc/state.c /lxc/src/lxc/utils.h /lxc/src/python-lxc/lxc.c attach.c cgpath.c containertests.c get_item.c getkeys.c locktests.c reboot.c snapshot.c
95ee490bbdb97ab2b4f1dfa63a0a26e0dd1c2f17 03-Dec-2013 Stéphane Graber <stgraber@ubuntu.com>

Reduce public API (V2) This removes all but the following headers from our includes: - attach_options.h - lxccontainer.h - version.h This also removes the duplicate lxc_version function (lxc_get_version has been preferred for a while). lxclock.h is now considered private. As a result quite a lot of files needed addition of extra includes previously inherited from lxclock.h. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

540f932aeb28274e8e7ea1e8f3a8e5889b88e1d6 29-Nov-2013 Stéphane Graber <stgraber@ubuntu.com>

Allow unsetting daemonize and close_fds As mentioned in a previous commit, this does two changes: - Make want_daemonize return a bool (false on failure, true on success) - Make both want_daemonize and want_close_all_fds take a "state" argument so the user can choose to unset those flags. This commit also updates all occurences of those two functions and turns the daemonize attribute from an int to a bool. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>

8cd80b50efe2107ac351bfd0285050dd183398e7 25-Nov-2013 Stéphane Graber <stgraber@ubuntu.com>

Convert all files to utf-8 Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>

f25f058d5d9da06305fdb3f4af6f48dcddd56467 30-Oct-2013 Dwight Engen <dwight.engen@oracle.com>

remove left over debug getchar() I goofed and left in a getchar() that I was using to pause the test program in a case that was failing for me. Remove it. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

1f845c396fc102951cc250d75f6f2bbfcb321aa0 30-Oct-2013 Dwight Engen <dwight.engen@oracle.com>

fix cgpath test Commit 1ea59ad28 sets memory.use_hierarchy, which means that this test cannot use memory.swappiness as its dummy cgroup item to set/unset since writing to it with use_hierarchy set gets -EINVAL. Change test to use memory.soft_limit_in_bytes instead. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

948955a2d6f8e4e28bceada9666c5831de4a6bb8 23-Sep-2013 Stéphane Graber <stgraber@ubuntu.com>

Consistently use <lxc/lxccontainer.h> for the API The API header was included in a variety of ways before, standardize those to "include <lxc/lxccontainer.h>" as this will always work both in tree and on a system with the headers installed. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

33ad9f1ab13de51d28aecbcbdac086ea009a1740 11-Sep-2013 Christian Seiler <christian@iwakd.de>

cgroup: Major rewrite of cgroup logic This patch rewrites most of the cgroup logic. It creates a set of data structures to store the kernel state of the cgroup hierarchies and their mountpoints. Mainly, everything is now grouped with respect to the hierarchies of the system. Multiple controllers may be mounted together or separately to different hierarchies, the data structures reflect this. Each hierarchy may have multiple mount points (that were created previously using the bind mount method) and each of these mount points may point to a different prefix inside the cgroup tree. The current code does not make any assumptions regarding the mount points, it just parses /proc/self/mountinfo to acquire the relevant information. The only requirement is that the current cgroup of either init (if cgroup.pattern starts with '/' and the tools are executed as root) or the current process (otherwise) are accessible. The root cgroup need not be accessible. The configuration option cgroup.pattern is introduced. For root-executed containers, it specifies which format the cgroups should be in. Example values may include '/lxc/%n', 'lxc/%n', '%n' or '/machine/%n.lxc'. Any occurrence of '%n' is replaced with the name of the container (and if clashes occur in any hierarchy, -1, -2, etc. are appended globally). If the pattern starts with /, new containers' cgroups will be located relative to init's cgroup; if it doesn't, they will be located relative to the current process's cgroup. Some changes to the cgroup.h API have been done to make it more consistent, both with respect to naming and with respect to the parameters. This causes some changes in other parts of the code that are included in the patch. There has been some testing of this functionality, but there are probably still quite a few bugs in there, especially for people with different configurations. Signed-off-by: Christian Seiler <christian@iwakd.de> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

b98f7d6ed1b89b6452af4a2b5e27d445e4b3a138 14-Aug-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

cgroups: rework to handle nested containers with multiple and partial mounts Currently, if you create a container and use the mountcgruop hook, you get the /lxc/c1/c1.real cgroup mounted to /. If you then try to start containers inside that container, lxc can get confused. This patch addresses that, by accepting that the cgroup as found in /proc/self/cgroup can be partially hidden by bind mounts. In this patch: Add optional 'lxc.cgroup.use' to /etc/lxc/lxc.conf to specify which mounted cgroup filesystems lxc should use. So far only the cgroup creation respects this. Keep separate cgroup information for each cgroup mountpoint. So if the caller is in devices cgroup /a but cpuset cgroup /b that should now be ok. Change how we decide whether to ignore failure to set devices cgroup settings. Actually look to see if our current cgroup already has the settings. If not, add them. Finally, the real reason for this patch: in a nested container, /proc/self/cgroup says nothing about where under /sys/fs/cgroup you might find yourself. Handle this by searching for our pid in tasks files, and keep that info in the cgroup handler. Also remove all strdupa from cgroup.c (not android-friendly). Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

dc23c1c817da5c13529432270e51d0f7f3b1e95e 12-Jul-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

create: add a quiet flag If set, then fds 0,1,2 will be redirected while the creation template is executed. Note, as Dwight has pointed out, if fd 0 is redirected, then if templates ask for input there will be a problem. We could simply not redirect fd 0, or we could require that templates work without interaction. I'm assuming here that we want to do the latter, but I'm open to changing that. Reported-by: "S.Çağlar Onur" <caglar@10ur.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

1897e3bcd36af9f3fe6d3649910a9adb93e5e988 26-May-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

Move container creation fully into the api 1. implement bdev->create: python and lua: send NULL for bdevtype and bdevspecs. They'll want to be updated to pass those in in a way that makes sense, but I can't think about that right now. 2. templates: pass --rootfs If the container is backed by a device which must be mounted (i.e. lvm) then pass the actual rootfs mount destination to the templates. Note that the lxc.rootfs can be a mounted block device. The template should actually be installing the rootfs under the path where the lxc.rootfs is *mounted*. Still, some people like to run templates by hand and assume purely directory backed containers, so continue to support that use case (i.e. if no --rootfs is listed). Make sure the templates don't re-write lxc.rootfs if it is already in the config. (Most were already checking for that) 3. Replace lxc-create script with lxc_create.c program. Changelog: May 24: when creating a container, create $lxcpath/$name/partial, and flock it. When done, close that file and unlink it. In lxc_container_new() and lxcapi_start(), check for this file. If it is locked, create is ongoing. If it exists but is not locked, create() was killed - remove the container. May 24: dont disk-lock during lxcapi_create. The partial lock is sufficient. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

2acf77955239ec0046451fa16812d2884e6bd19b 25-May-2013 Dwight Engen <dwight.engen@oracle.com>

fix memory leaks in cgroup functions There were several memory leaks in the cgroup functions, notably in the success cases. The cgpath test program was refactored and additional tests added to it. It was used in various modes under valgrind to test that the leaks were fixed. Simplify lxc_cgroup_path_get() and cgroup_path_get by having them return a char * instead of an int and an output char * argument. The only return values ever used were -1 and 0, which are now handled with NULL and non-NULL returns respectively. Use consistent variable names of cgabspath when refering to an absolute path to a cgroup subsystem or file, and cgrelpath when refering to a container "group/name" within the cgroup heirarchy. Remove unused subsystem argument to lxc_cmd_get_cgroup_path(). Remove unused #define MAXPRIOLEN Make template arg to lxcapi_create() const Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

481624b37b37ffa98b735cf3f94e35d1fbd729e0 22-May-2013 Dwight Engen <dwight.engen@oracle.com>

fix build with --enable-tests Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

ef6e34eec8d5a9f1447462d6080facb674b3ccdb 21-May-2013 Dwight Engen <dwight.engen@oracle.com>

extend command processor to handle generic data Motivation for this change is to have the ability to get the run-time configuration items from a container, which may differ from its current on disk configuration, or might not be available any other way (for example lxc.network.0.veth.pair). In adding this ability it seemed there was room for refactoring improvements. Genericize the command infrastructure so that both command requests and responses can have arbitrary data. Consolidate all commands into command.c and name them consistently. This allows all the callback routines to be made static, reducing exposure. Return the actual allocated tty for the console command. Don't print the init pid in lxc_info if the container isn't actually running. Command processing was made more thread safe by removing the static buffer from receive_answer(). Refactored command response code to a common routine. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

a9bafa108521ac785e846f2ace105c327371c106 03-May-2013 Dwight Engen <dwight.engen@oracle.com>

coverity: fix dereference before NULL check also fixed some error strings while here Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

7e1667d76e76eb3d571be5e4b545e8ace6e92187 22-Apr-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

cgpath test: don't check path len before checking if it is null Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

ae5c8b8ed5feb9a47c5007c986ce01ea39b5075f 04-Mar-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

cgroup: improve support for multiple lxcpaths (v3) Add a monitor command to get the cgroup for a running container. This allows container r1 started from /var/lib/lxc and container r1 started from /home/ubuntu/lxcbase to pick unique cgroup directories (which will be /sys/fs/cgroup/$subsys/lxc/r1 and .../r1-1), and all the lxc-* tools to get that path over the monitor at lxcpath. Rework the cgroup code. Before, if /sys/fs/cgroup/$subsys/lxc/r1 already existed, it would be moved to 'deadXXXXX', and a new r1 created. Instead, if r1 exists, use r1-1, r1-2, etc. I ended up removing both the use of cgroup.clone_children and support for ns cgroup. Presumably we'll want to put support for ns cgroup back in for older kernels. Instead of guessing whether or not we have clone_children support, just always explicitly do the only thing that feature buys us - set cpuset.{cpus,mems} for newly created cgroups. Note that upstream kernel is working toward strict hierarchical limit enforcements, which will be good for us. NOTE - I am changing the lxc_answer struct size. This means that upgrades to this version while containers are running will result in lxc_* commands on pre-running containers will fail. Changelog: (v3) implement cgroup attach fix a subtle bug arising when we lxc_get_cgpath() returned STOPPED rather than -1 (STOPPED is 0, and 0 meant success). Rename some functions and add detailed comments above most. Drop all my lxc_attach changes in favor of those by Christian Seiler (which are mostly the same, but improved). Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>