[lxc-devel] [lxc/lxc] 893b66: cgroups: refactor cgroup handling

GitHub noreply at github.com
Thu May 24 20:49:00 UTC 2018


  Branch: refs/heads/stable-3.0
  Home:   https://github.com/lxc/lxc
  Commit: 893b660cf6918f5ed1470a11ef108f939990e18d
      https://github.com/lxc/lxc/commit/893b660cf6918f5ed1470a11ef108f939990e18d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/attach.c
    M src/lxc/cgroups/cgfsng.c
    M src/lxc/cgroups/cgroup.c
    M src/lxc/cgroups/cgroup.h
    M src/lxc/commands.c
    M src/lxc/conf.c
    M src/lxc/criu.c
    M src/lxc/freezer.c
    M src/lxc/lxc.h
    M src/lxc/lxccontainer.c
    M src/lxc/start.c
    M src/lxc/start.h
    M src/tests/cgpath.c

  Log Message:
  -----------
  cgroups: refactor cgroup handling

This replaces the constructor implementation of cgroup handling with a simpler,
thread-safe on-demand model of cgroup driver initialization.
Making the cgroup initialization code run in a constructor means that each time
the shared library gets mapped the cgroup parsing code gets run. That's
unnecessary overhead.
It also feels to me that this is only accidently thread-safe because
constructors are only run once. But should threads actually end up manipulating
or freeing memory that is file-global to cgfsng.c we'd be screwed. Now, I might
be wrong here but the cleaner implementation is to allocate a cgroup driver on
demand whenever we need it.
Take the chance and rework the cgroup_ops interface to make the functions it
wants to have implemented a lot cleaner.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: c701a1d79143b17c350a288ae3276c04d513ea73
      https://github.com/lxc/lxc/commit/c701a1d79143b17c350a288ae3276c04d513ea73
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/freezer.c
    M src/lxc/state.c

  Log Message:
  -----------
  cgroups: remove freezer_state()

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: d78980250b3421e1ef4fe2ac0fbce0738f314adc
      https://github.com/lxc/lxc/commit/d78980250b3421e1ef4fe2ac0fbce0738f314adc
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/seccomp.c

  Log Message:
  -----------
  seccomp: #ifdef SCMP_ARCH_AARCH64

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 48c99954f794cc65d128e9a3b72f2d56b88900f7
      https://github.com/lxc/lxc/commit/48c99954f794cc65d128e9a3b72f2d56b88900f7
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  conf: simplify write_id_mapping()

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 56530d78a151702b605f725875841f8bc0e9770d
      https://github.com/lxc/lxc/commit/56530d78a151702b605f725875841f8bc0e9770d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/conf.h
    M src/lxc/log.c
    M src/lxc/lxccontainer.c

  Log Message:
  -----------
  log: enable per-thread container name prefix

When using the LXC API multi-thread and users initialize a log:

struct lxc_log log;
log.name = "my-log";
lxc_log_init(&log);

all threads will have the same "my-log" prefix even though thy might call
lxc_container_new() in separate threads. There is currently no easy way to
handle per-thread container name prefixes.
To handle this carry a reference to the name of the container in struct
lxc_conf and if no log.name was set, use it by default. This way each thread
will get the container it is currently working on as a log-prefix.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
Reported-by: duguhaotian <duguhaotian at gmail.com>


  Commit: 2a6be93564d20fa309a358f180df5220ce60f964
      https://github.com/lxc/lxc/commit/2a6be93564d20fa309a358f180df5220ce60f964
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/cmd/lxc_init.c

  Log Message:
  -----------
  lxc-init: skip signals that can't be caught

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 80370cecf653e6cd47824df1da1d3cad507aec93
      https://github.com/lxc/lxc/commit/80370cecf653e6cd47824df1da1d3cad507aec93
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/conf.c
    M src/lxc/execute.c
    M src/lxc/start.h

  Log Message:
  -----------
  execute: use execveat() syscall if supported

The execveat allows us to exec stuff via a fd so we don't have to bind mount
stuff in. See the comment about why we're using the syscall directly.

Closes #2339.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>
[christian.brauner at ubuntu.com: adapt error message and whitespace fixes]
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: d347dbaa4bd7c72f14e717682703c432e7ee0365
      https://github.com/lxc/lxc/commit/d347dbaa4bd7c72f14e717682703c432e7ee0365
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/tools/lxc_attach.c
    M src/lxc/tools/lxc_autostart.c
    M src/lxc/tools/lxc_cgroup.c
    M src/lxc/tools/lxc_checkpoint.c
    M src/lxc/tools/lxc_console.c
    M src/lxc/tools/lxc_copy.c
    M src/lxc/tools/lxc_create.c
    M src/lxc/tools/lxc_destroy.c
    M src/lxc/tools/lxc_device.c
    M src/lxc/tools/lxc_execute.c
    M src/lxc/tools/lxc_freeze.c
    M src/lxc/tools/lxc_info.c
    M src/lxc/tools/lxc_ls.c
    M src/lxc/tools/lxc_monitor.c
    M src/lxc/tools/lxc_snapshot.c
    M src/lxc/tools/lxc_start.c
    M src/lxc/tools/lxc_stop.c
    M src/lxc/tools/lxc_unfreeze.c
    M src/lxc/tools/lxc_wait.c

  Log Message:
  -----------
  tools: only create log file when requested

We used to initialize a log unconditionally before. This has led to scenarios
where users where left with container directories and an empty log file even
though they didn't request a log be created at all.
Switch all tools to only create a log file when the user explicitly requests
this.

Closes #1779.
Closes #2032.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 95cdca68669b2ef81e3f47dc625243d252b41db4
      https://github.com/lxc/lxc/commit/95cdca68669b2ef81e3f47dc625243d252b41db4
  Author: Felix Abecassis <fabecassis at nvidia.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/seccomp.c

  Log Message:
  -----------
  seccomp: fix off-by-one error in array allocation for sscanf

The maximum field width does not include the null terminator.

Signed-off-by: Felix Abecassis <fabecassis at nvidia.com>


  Commit: 88b95f3899f4e174227854a0a37553464aa0dcaa
      https://github.com/lxc/lxc/commit/88b95f3899f4e174227854a0a37553464aa0dcaa
  Author: Felix Abecassis <fabecassis at nvidia.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/seccomp.c

  Log Message:
  -----------
  seccomp: remove confusing comment line

Signed-off-by: Felix Abecassis <fabecassis at nvidia.com>


  Commit: 7cbf948f7d38affede7a2bfa62f1effd4199dba7
      https://github.com/lxc/lxc/commit/7cbf948f7d38affede7a2bfa62f1effd4199dba7
  Author: Felix Abecassis <fabecassis at nvidia.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/seccomp.c

  Log Message:
  -----------
  seccomp: remove unnecessary memset

Signed-off-by: Felix Abecassis <fabecassis at nvidia.com>


  Commit: 871746f2f21fa030fe6ee1ac43293eb31efbd58b
      https://github.com/lxc/lxc/commit/871746f2f21fa030fe6ee1ac43293eb31efbd58b
  Author: Felix Abecassis <fabecassis at nvidia.com>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M src/lxc/seccomp.c
    M src/lxc/utils.c
    M src/lxc/utils.h

  Log Message:
  -----------
  seccomp: fix type mismatch when parsing syscall arguments filters

Specifier %lli was insufficient for the type uint64_t, all values
between 2^63-1 and 2^64-1 were silently converted to 2^63-1.

We can't use %llu since it doesn't handle hexadecimal. Instead, we
parse the values as strings and then use strtoull(3).

Signed-off-by: Felix Abecassis <fabecassis at nvidia.com>


Compare: https://github.com/lxc/lxc/compare/e37266ab6f99...871746f2f21f
      **NOTE:** This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the lxc-devel mailing list