cr: tty/pty
PATCH 29/30 cr: tty/pty
FIXME: opened tty won't passed ->checkpoint check.
currently in desperate need on how to test it.
Signed-off-by Alexey Dobriyan <[email protected]>
---
include/linux/cr.h | 37 ++++++++++++ kernel/cr/Kconfig | 1 kernel/cr/Makefile | 1 kernel/cr/cpt-sys.c | 6 + kernel/cr/cr-pid.c | 14 ++++ kernel/cr/cr-tty.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/cr/cr.h | 4 + 7 files changed, 223 insertions(+)
include/linux/cr.h +37 -0
@@ -51,6 +51,7 @@ struct cr_object_header {#define CR_OBJ_MNT_NS 20#define CR_OBJ_NET_NS 21#define CR_OBJ_SOCK 22 +#define CR_OBJ_TTY 23__u32 cr_type;/* object type */ __u32 cr_len;/* object length in bytes including header */ } __packed;
@@ -381,4 +382,40 @@ struct cr_image_sock {cr_pos_t cr_pos_sk_net; __u16 cr_sk_family; } __packed; + +struct cr_image_tty { +struct cr_object_header cr_hdr; + +__u16 cr_driver_type; +__u16 cr_driver_subtype; +__u32 cr_driver_flags; +__u32 cr_index; +__u32 cr_link_index; +struct { +__u32 cr_c_iflag; +__u32 cr_c_oflag; +__u32 cr_c_cflag; +__u32 cr_c_lflag; +__u8 cr_c_line; +__u8 cr_c_cc[23 ]; +__u32 cr_c_ispeed; +__u32 cr_c_ospeed; + } cr_termios; +__u8 cr_name[64 ]; +cr_pos_t cr_pos_pgrp;/* CR_POS_UNDEF if tty->pgrp == NULL */ +cr_pos_t cr_pos_session;/* CR_POS_UNDEF if tty->session == NULL */ +__u64 cr_flags; +struct { +__u16 cr_ws_row; +__u16 cr_ws_col; +__u16 cr_ws_xpixel; +__u16 cr_ws_ypixel; + } cr_winsize; +__u8 cr_stopped; +__u8 cr_hw_stopped; +__u8 cr_flow_stopped; +__u8 cr_packet; +__u8 cr_low_latency; +__u8 cr_ctrl_status; +} __packed;#endif
kernel/cr/Kconfig +1 -0
@@ -1,5 +1,6 @@ config CR bool "Container checkpoint/restart" + depends on DEVPTS_MULTIPLE_INSTANCES depends on NET_NS || (NET = n) depends on PID_NS depends on USER_NS
kernel/cr/Makefile +1 -0
@@ -12,6 +12,7 @@ cr-y += cr-pid.o cr-y += cr-signal.o cr-$(CONFIG_NET) += cr-socket.o cr-y += cr-task.o +cr-y += cr-tty.o cr-y += cr-uts.o cr-$(CONFIG_X86_32) += cr-x86_32.o cr-$(CONFIG_X86_64) += cr-x86_64.o
kernel/cr/cpt-sys.c +6 -0
@@ -101,6 +101,9 @@ static int cr_collect(struct cr_context *ctx) rv =cr_collect_all_sighand_struct (ctx);if (rv <0 )return rv; + rv =cr_collect_all_tty_struct (ctx); +if (rv <0 ) +return rv; rv =cr_collect_all_cred (ctx);if (rv <0 )return rv;
@@ -179,6 +182,9 @@ static int cr_dump(struct cr_context *ctx) rv =cr_dump_all_fs_struct (ctx);if (rv <0 )return rv; + rv =cr_dump_all_tty (ctx); +if (rv <0 ) +return rv; rv =cr_dump_all_uts_ns (ctx);if (rv <0 )return rv;
kernel/cr/cr-pid.c +14 -0
@@ -226,6 +226,20 @@ int cr_collect_all_pid(struct cr_context *ctx)return rv; } } +for_each_cr_object (ctx, obj,CR_CTX_TTY ) { +struct tty_struct *tty = obj->o_obj; + +if (tty->pgrp) { + rv =cr_collect_pid (ctx, tty->pgrp); +if (rv <0 ) +return rv; + } +if (tty->session) { + rv =cr_collect_pid (ctx, tty->session); +if (rv <0 ) +return rv; + } + }/* FIXME pid refcount check should account references from proc inodes */ return 0 ; }
new file mode 100644
kernel/cr/cr-tty.c new file +160 -0
160 lines not on this page · raw message
kernel/cr/cr.h +4 -0
@@ -3,6 +3,7 @@#define __KERNEL_CR_CR_H#include <linux/list.h> #include <linux/slab.h> +#include <asm/signal.h> #include <linux/cr.h>
@@ -41,6 +42,7 @@ enum cr_context_obj_type {CR_CTX_SOCK , #endifCR_CTX_TASK_STRUCT , +CR_CTX_TTY ,CR_CTX_USER_NS ,CR_CTX_USER_STRUCT , CR_CTX_UTS_NS,
@@ -125,6 +127,7 @@ static inline int cr_collect_all_sock(struct cr_context *ctx) }#endif int cr_collect_all_task_struct (struct cr_context *ctx); +int cr_collect_all_tty_struct (struct cr_context *ctx);int cr_collect_all_user_ns (struct cr_context *ctx);int cr_collect_all_user_struct (struct cr_context *ctx);int cr_collect_all_uts_ns (struct cr_context *ctx);
@@ -158,6 +161,7 @@ static inline int cr_dump_all_sock(struct cr_context *ctx) }#endif int cr_dump_all_task_struct (struct cr_context *ctx); +int cr_dump_all_tty (struct cr_context *ctx);int cr_dump_all_user_ns (struct cr_context *ctx);int cr_dump_all_user_struct (struct cr_context *ctx);int cr_dump_all_uts_ns (struct cr_context *ctx);