[lxc-devel] [lxc/lxc] b1ca43: commands: don't traverse whole list

GitHub noreply at github.com
Wed Dec 6 22:31:51 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: b1ca434ae52c6b1ac9f73030d022e2a2e537cb3f
      https://github.com/lxc/lxc/commit/b1ca434ae52c6b1ac9f73030d022e2a2e537cb3f
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c

  Log Message:
  -----------
  commands: don't traverse whole list

When we remove a state client fd there's not reason to walk the whole list. We
can simply break once we found and removed the fd.

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


  Commit: e533be71c8a397ebc6d72c867ff8627d0a87260e
      https://github.com/lxc/lxc/commit/e533be71c8a397ebc6d72c867ff8627d0a87260e
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c

  Log Message:
  -----------
  commands: don't lock atomic operations

We're dealing with an integer (lxc_state_t which is an enum). Any POSIX
implementation makes those operations atomic so there's not need in locking
this.

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


  Commit: f3a2945e8852a50550d00fc3510f669629c28702
      https://github.com/lxc/lxc/commit/f3a2945e8852a50550d00fc3510f669629c28702
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c
    M src/lxc/commands_utils.c

  Log Message:
  -----------
  commands: don't lock the whole command

There are multiple reasons why this is not required:
- every command is transactional
- we only care about the list being modified not the memory allocation and
  other costly operations

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


  Commit: 20144819c4207911ac08654943e4273d7b97f353
      https://github.com/lxc/lxc/commit/20144819c4207911ac08654943e4273d7b97f353
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/start.c

  Log Message:
  -----------
  start: don't lock setting the state

- setting the handler->state value is atomic on any POSIX implementation since
  we're dealing with an integer (enum/lxc_state_t)
- while the state clients are served it is not possible for lxc_set_state() to
  transition to the next state anyway so there's no danger in moving to the
  next state with clients missing it
- we only care about the list being modified

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


  Commit: 24b0bd9a80a1a83b292afa61b1970730d01d4963
      https://github.com/lxc/lxc/commit/24b0bd9a80a1a83b292afa61b1970730d01d4963
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c

  Log Message:
  -----------
  commands: allow waiting for all states

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


  Commit: d39b10eba1837e3638925e653eb7121d1563cbe3
      https://github.com/lxc/lxc/commit/d39b10eba1837e3638925e653eb7121d1563cbe3
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c
    M src/lxc/commands_utils.c
    M src/lxc/conf.c
    M src/lxc/conf.h
    M src/lxc/lxccontainer.c
    M src/lxc/lxccontainer.h
    M src/lxc/start.c
    M src/lxc/start.h
    M src/lxc/state.c
    M src/lxc/tools/lxc_stop.c

  Log Message:
  -----------
  lxccontainer: add reboot2() API extension

This adds reboot2() as a new API extension. This function properly wait until a
reboot succeeded. It takes a timeout argument. When set to > 0 reboot2() will
block until the timeout is reached, if timeout is set to zero reboot2() will
not block, if set to -1 reboot2() will block indefinitly.

The struct state_client gets rename to lxc_state_client since it's more in line
with other declarations. It also gets moved from the lxc_handler to the
lxc_conf struct so that the state clients waiting for reboots don't get
deallocated on reboot since the handler is deallocated on reboot.

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


  Commit: c02c49ee3d01dec5c0cd558fe56725bb1a7df83d
      https://github.com/lxc/lxc/commit/c02c49ee3d01dec5c0cd558fe56725bb1a7df83d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/tests/Makefile.am
    A src/tests/api_reboot.c
    M src/tests/livepatch.c

  Log Message:
  -----------
  test: add test for reboot2() API extension

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


  Commit: fc788340f7b336aba2b8cf6a06ba5ff0a8a43b67
      https://github.com/lxc/lxc/commit/fc788340f7b336aba2b8cf6a06ba5ff0a8a43b67
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/tests/Makefile.am
    A src/tests/state_server.c

  Log Message:
  -----------
  test: add state server tests

This checks whether multiple concurrent waiters all get notified by the state
server.

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


  Commit: bc631984fcc1c8b69cafbcce448f98961bca1e55
      https://github.com/lxc/lxc/commit/bc631984fcc1c8b69cafbcce448f98961bca1e55
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c
    M src/lxc/commands_utils.c
    M src/lxc/start.c

  Log Message:
  -----------
  commands: tweak locking

Take the lock on the list after we've done all necessary work and check state.
If we are in requested state, do cleanup and return without adding the state
client to the state client list.

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


  Commit: f8bdb6dcc4d85d1b25a5926917cd6f882a9170e0
      https://github.com/lxc/lxc/commit/f8bdb6dcc4d85d1b25a5926917cd6f882a9170e0
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/lxccontainer.c

  Log Message:
  -----------
  lxccontainer: restore non-blocking shutdown

If timeout is set to 0 don't block.

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


  Commit: 44552fb2b794573334136209dc44a4270f3acf45
      https://github.com/lxc/lxc/commit/44552fb2b794573334136209dc44a4270f3acf45
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c
    M src/lxc/commands_utils.c

  Log Message:
  -----------
  commands: tell mainloop to reap client fd on error

This is the proper way to handle errors.

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


  Commit: 6b7f85cbcdce8bd5d6b1c4c719ae776d6b3ffb06
      https://github.com/lxc/lxc/commit/6b7f85cbcdce8bd5d6b1c4c719ae776d6b3ffb06
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c

  Log Message:
  -----------
  commands: return -ECONNRESET to caller

Callers can then make a decision whether they want to consider the peer closing
the connection an error or not. For example, a c->wait(c, "STOPPED", -1) call
can then consider a ECONNRESET not an error but rather see it - correctly - as
a container exiting before being able to register a state client.

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


  Commit: 8f98ac7b0f3f25e42f6de50c4d43ec74bcb90c8d
      https://github.com/lxc/lxc/commit/8f98ac7b0f3f25e42f6de50c4d43ec74bcb90c8d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/execute.c

  Log Message:
  -----------
  execute: pass logfile to lxc-init

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


  Commit: fa30091bb5bef1c1267357d876e5de51f3d990f5
      https://github.com/lxc/lxc/commit/fa30091bb5bef1c1267357d876e5de51f3d990f5
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/lxccontainer.c

  Log Message:
  -----------
  lxccontainer: handle execute containers correctly

It doesn't make sense to error out when an app container doesn't pass explicit
arguments through c->start{l}(). This is especially true since we implemented
lxc.execute.cmd. However, even before we could have always relied on
lxc.init.cmd and errored out after that.

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


  Commit: 77f76f316a9478e64654fe11ca233d485b1abe9f
      https://github.com/lxc/lxc/commit/77f76f316a9478e64654fe11ca233d485b1abe9f
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/tests/shortlived.c

  Log Message:
  -----------
  tests: expand tests for shortlived init processes

This adds additional test for app containers.

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


  Commit: 49be8a144ac900d3be848e5d10db1bbb424e5b35
      https://github.com/lxc/lxc/commit/49be8a144ac900d3be848e5d10db1bbb424e5b35
  Author: Serge Hallyn <serge at hallyn.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/lxc/commands.c
    M src/lxc/commands_utils.c
    M src/lxc/conf.c
    M src/lxc/conf.h
    M src/lxc/execute.c
    M src/lxc/lxccontainer.c
    M src/lxc/lxccontainer.h
    M src/lxc/start.c
    M src/lxc/start.h
    M src/lxc/state.c
    M src/lxc/tools/lxc_stop.c
    M src/tests/Makefile.am
    A src/tests/api_reboot.c
    M src/tests/livepatch.c
    M src/tests/shortlived.c
    A src/tests/state_server.c

  Log Message:
  -----------
  Merge pull request #1934 from brauner/2017-11-21/implement_do_lxc_reboot_correctly

commands: improve and simplify locking + lxccontainer: add reboot2() API extension


Compare: https://github.com/lxc/lxc/compare/6dcd0821c8f8...49be8a144ac9


More information about the lxc-devel mailing list