mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-08 02:31:33 +00:00
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.andersen@canonical.com>
This commit is contained in:
parent
36d2096cf4
commit
97e4f1a91f
@ -290,6 +290,11 @@ static void exec_criu(struct criu_opts *opts)
|
|||||||
DECLARE_ARG(opts->cgroup_path);
|
DECLARE_ARG(opts->cgroup_path);
|
||||||
|
|
||||||
if (tty_info[0]) {
|
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);
|
ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, tty_info);
|
||||||
if (ret < 0 || ret >= sizeof(buf))
|
if (ret < 0 || ret >= sizeof(buf))
|
||||||
goto err;
|
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.cgroup_path = cgroup_canonical_path(handler);
|
||||||
os.console_fd = c->lxc_conf->console.slave;
|
os.console_fd = c->lxc_conf->console.slave;
|
||||||
|
|
||||||
/* Twiddle the FD_CLOEXEC bit. We want to pass this FD to criu
|
if (os.console_fd >= 0) {
|
||||||
* via --inherit-fd, so we don't want it to close.
|
/* 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) {
|
flags = fcntl(os.console_fd, F_GETFD);
|
||||||
SYSERROR("F_GETFD failed");
|
if (flags < 0) {
|
||||||
goto out_fini_handler;
|
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) {
|
if (fcntl(os.console_fd, F_SETFD, flags) < 0) {
|
||||||
SYSERROR("F_SETFD failed");
|
SYSERROR("F_SETFD failed");
|
||||||
goto out_fini_handler;
|
goto out_fini_handler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
os.console_name = c->lxc_conf->console.name;
|
os.console_name = c->lxc_conf->console.name;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user