[CRIU] [RFC 2/2] tty: add serial driver & popular serial majors
Dmitry Safonov
dsafonov at virtuozzo.com
Wed Apr 27 10:10:54 PDT 2016
Fixes restoring on AMBA serial line. That is /dev/ttyAMA0,
which is the default serial port to use on qemu-system-aarch64.
(at least in those articles, which I meet it's in boot cmdline)
Also should add support for C/R /dev/ttyUSB*
One may check major numbers on
https://www.kernel.org/doc/Documentation/devices.txt
Also by grepping on kernel repository.
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/include/tty.h | 4 ++++
criu/tty.c | 12 ++++++++++++
images/tty.proto | 1 +
3 files changed, 17 insertions(+)
diff --git a/criu/include/tty.h b/criu/include/tty.h
index 48f743eb293b..24841d055b87 100644
--- a/criu/include/tty.h
+++ b/criu/include/tty.h
@@ -9,6 +9,10 @@
/* Kernel's limit */
#define TERMIOS_NCC 19
+/* Popular serial console's majors, which not defined in <linux/major.h> */
+#define USB_SERIAL_MAJOR 188
+#define LOW_DENSE_SERIAL_MAJOR 204
+
extern const struct fdtype_ops tty_dump_ops;
struct tty_driver;
diff --git a/criu/tty.c b/criu/tty.c
index 7c634e19ebc0..c6e8e32b7013 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -210,6 +210,12 @@ static struct tty_driver ext_driver = {
.open = open_ext_tty,
};
+static struct tty_driver serial_driver = {
+ .type = TTY_TYPE__SERIAL,
+ .name = "serial",
+ .open = open_simple_tty,
+};
+
static int pts_fd_get_index(int fd, const struct fd_parms *p)
{
int index;
@@ -268,6 +274,10 @@ struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
* of kernel).
*/
return &vt_driver;
+ /* Other minors points to UART serial ports */
+ case USB_SERIAL_MAJOR:
+ case LOW_DENSE_SERIAL_MAJOR:
+ return &serial_driver;
case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
return &ptm_driver;
case UNIX98_PTY_SLAVE_MAJOR:
@@ -668,6 +678,7 @@ static bool tty_is_master(struct tty_info *info)
case TTY_TYPE__CONSOLE:
case TTY_TYPE__CTTY:
return true;
+ case TTY_TYPE__SERIAL:
case TTY_TYPE__VT:
if (!opts.shell_job)
return true;
@@ -1368,6 +1379,7 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg, struct c
break;
case TTY_TYPE__CTTY:
case TTY_TYPE__CONSOLE:
+ case TTY_TYPE__SERIAL:
case TTY_TYPE__VT:
case TTY_TYPE__EXT_TTY:
if (info->tie->pty) {
diff --git a/images/tty.proto b/images/tty.proto
index 4b5a70c20a88..0b444b2439e8 100644
--- a/images/tty.proto
+++ b/images/tty.proto
@@ -31,6 +31,7 @@ enum TtyType {
VT = 3;
CTTY = 4;
EXT_TTY = 5;
+ SERIAL = 6;
}
message tty_info_entry {
--
2.8.0
More information about the CRIU
mailing list