[lxc-devel] [PATCH] c/r: use freezer to seize tasks
Stéphane Graber
stgraber at ubuntu.com
Sat Nov 7 04:24:02 UTC 2015
On Fri, Nov 06, 2015 at 05:26:43PM -0700, Tycho Andersen wrote:
> Instead of relying on the old ptrace loop, we should instead put all the
> tasks in the container into the freezer. This will stop them all at the
> same time, preventing fork bombs from causing criu to infinite loop (and is
> also simply a lot faster).
>
> Note that this uses --freeze-cgroup which isn't in criu 1.7, so it should
> only go into master.
>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
> src/lxc/criu.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/src/lxc/criu.c b/src/lxc/criu.c
> index 7ee6cbe..695a763 100644
> --- a/src/lxc/criu.c
> +++ b/src/lxc/criu.c
> @@ -37,6 +37,7 @@
> #include "bdev.h"
> #include "cgroup.h"
> #include "conf.h"
> +#include "commands.h"
> #include "criu.h"
> #include "log.h"
> #include "lxc.h"
> @@ -64,8 +65,8 @@ void exec_criu(struct criu_opts *opts)
> * +1 for final NULL */
>
> if (strcmp(opts->action, "dump") == 0) {
> - /* -t pid */
> - static_args += 2;
> + /* -t pid --freeze-cgroup /lxc/ct */
> + static_args += 4;
>
> /* --leave-running */
> if (!opts->stop)
> @@ -133,13 +134,30 @@ void exec_criu(struct criu_opts *opts)
> DECLARE_ARG("-vvvvvv");
>
> if (strcmp(opts->action, "dump") == 0) {
> - char pid[32];
> + char pid[32], *freezer_relative;
>
> if (sprintf(pid, "%d", opts->c->init_pid(opts->c)) < 0)
> goto err;
>
> +
> DECLARE_ARG("-t");
> DECLARE_ARG(pid);
> +
> + freezer_relative = lxc_cmd_get_cgroup_path(opts->c->name,
> + opts->c->config_path,
> + "freezer");
> + if (!freezer_relative) {
> + ERROR("failed getting freezer path");
> + goto err;
> + }
> +
> + ret = snprintf(log, sizeof(log), "/sys/fs/cgroup/freezer/%s", freezer_relative);
> + if (ret < 0 || ret >= sizeof(log))
> + goto err;
> +
> + DECLARE_ARG("--freeze-cgroup");
> + DECLARE_ARG(log);
> +
> if (!opts->stop)
> DECLARE_ARG("--leave-running");
> } else if (strcmp(opts->action, "restore") == 0) {
> --
> 2.6.2
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20151106/8b6a0edd/attachment.sig>
More information about the lxc-devel
mailing list