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;
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;