The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/906
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 36d2096cf43340701150778d5547ec4f5a127338 Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Mon, 21 Mar 2016 16:50:39 -0600 Subject: [PATCH 1/2] c/r: don't pass --ext-mount-map flag when console=none We don't pass anything on the restore side since we didn't save anything, but the restore side will expect something if we pass this. Instead, let's not pass anything. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- src/lxc/criu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 7b72c6e..1b3c4ac 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -259,9 +259,10 @@ static void exec_criu(struct criu_opts *opts) DECLARE_ARG("--freeze-cgroup"); DECLARE_ARG(log); - DECLARE_ARG("--ext-mount-map"); - DECLARE_ARG("/dev/console:console"); if (opts->tty_id[0]) { + DECLARE_ARG("--ext-mount-map"); + DECLARE_ARG("/dev/console:console"); + DECLARE_ARG("--external"); DECLARE_ARG(opts->tty_id); } From 97e4f1a91f39fa3b4012eedf8f4e56f419dd2cca Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Mon, 21 Mar 2016 16:52:02 -0600 Subject: [PATCH 2/2] c/r: don't fail if there is no console_fd on restore If we set lxc.console=none, this fd won't exist, so let's not fail if it doesn't. We already partially handled this case correctly, so let's actually handle it correctly :) Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- src/lxc/criu.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 1b3c4ac..16449bc 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -290,6 +290,11 @@ static void exec_criu(struct criu_opts *opts) DECLARE_ARG(opts->cgroup_path); if (tty_info[0]) { + if (opts->console_fd < 0) { + ERROR("lxc.console configured on source host but not target"); + goto err; + } + ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, tty_info); if (ret < 0 || ret >= sizeof(buf)) goto err; @@ -624,20 +629,22 @@ void do_restore(struct lxc_container *c, int status_pipe, char *directory, bool os.cgroup_path = cgroup_canonical_path(handler); os.console_fd = c->lxc_conf->console.slave; - /* Twiddle the FD_CLOEXEC bit. We want to pass this FD to criu - * via --inherit-fd, so we don't want it to close. - */ - flags = fcntl(os.console_fd, F_GETFD); - if (flags < 0) { - SYSERROR("F_GETFD failed"); - goto out_fini_handler; - } + if (os.console_fd >= 0) { + /* Twiddle the FD_CLOEXEC bit. We want to pass this FD to criu + * via --inherit-fd, so we don't want it to close. + */ + flags = fcntl(os.console_fd, F_GETFD); + if (flags < 0) { + SYSERROR("F_GETFD failed: %d", os.console_fd); + goto out_fini_handler; + } - flags &= ~FD_CLOEXEC; + flags &= ~FD_CLOEXEC; - if (fcntl(os.console_fd, F_SETFD, flags) < 0) { - SYSERROR("F_SETFD failed"); - goto out_fini_handler; + if (fcntl(os.console_fd, F_SETFD, flags) < 0) { + SYSERROR("F_SETFD failed"); + goto out_fini_handler; + } } os.console_name = c->lxc_conf->console.name;
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel