9fc0f6
From 39456b9f6e692a2385bf1288a53d02dd9abac8d5 Mon Sep 17 00:00:00 2001
9fc0f6
From: Hendrik Brueckner <brueckner@redhat.com>
9fc0f6
Date: Tue, 11 Mar 2014 18:41:09 +0100
9fc0f6
Subject: [PATCH] getty: Start getty on 3270 terminals available on Linux on
9fc0f6
 System z
9fc0f6
9fc0f6
Add the first 3270 terminal device that is associated with the Linux preferred
9fc0f6
console to the list of virtualization consoles.  This is required to
9fc0f6
automatically start a getty if the conmode=3270 kernel parameter is specified
9fc0f6
for Linux on z/VM instances.  Note that a queued upstream patch also enable
9fc0f6
the 3270 terminal device if it is associated with the Linux preferred console.
9fc0f6
How
9fc0f6
9fc0f6
To successfully start agetty on a 3270 terminal, a change in the agetty
9fc0f6
parameter order is required.  Previously, agetty would started like this:
9fc0f6
9fc0f6
    /sbin/agetty --keep-baud 3270/tty1 115200,38400,9600 TERM
9fc0f6
9fc0f6
The agetty program interprets the "3270/tty1" as baud rate and fails to start
9fc0f6
with the "bad speed: 3270/tty1" error message.  Fixing this in agetty is more
9fc0f6
complex rather than reordering the command line parameters like this:
9fc0f6
9fc0f6
    /sbin/agetty --keep-baud 115200,38400,9600 3270/tty1 TERM
9fc0f6
9fc0f6
According to agetty sources and "agetty --help", agetty accepts the "tty",
9fc0f6
"baudrate tty", and "tty baudrate" specifications.
9fc0f6
9fc0f6
P.S. The "tty: Set correct tty name in 'active' sysfs attribute" introduces
9fc0f6
     a change to display the terminal device which is associated with the
9fc0f6
     Linux preferred console.  This change helps to let systemd handle this
9fc0f6
     particular case only.  Without the changes of this commit, no additional
9fc0f6
     3270 terminal device can be managed by systemd.
9fc0f6
9fc0f6
     https://git.kernel.org/cgit/linux/kernel/git/gregkh/tty.git/commit/?id=723abd87f6e536f1353c8f64f621520bc29523a3
9fc0f6
9fc0f6
(cherry picked from commit fc6c7fe9becdd70ae6b671c396f2ad2db0b71cd7)
9fc0f6
9fc0f6
Resolves: #1075729
9fc0f6
---
9fc0f6
 rules/99-systemd.rules.in             | 2 +-
9fc0f6
 src/getty-generator/getty-generator.c | 3 ++-
9fc0f6
 units/serial-getty@.service.m4        | 2 +-
9fc0f6
 3 files changed, 4 insertions(+), 3 deletions(-)
9fc0f6
9fc0f6
diff --git a/rules/99-systemd.rules.in b/rules/99-systemd.rules.in
9fc0f6
index 0471719..308a074 100644
9fc0f6
--- a/rules/99-systemd.rules.in
9fc0f6
+++ b/rules/99-systemd.rules.in
9fc0f6
@@ -7,7 +7,7 @@
9fc0f6
 
9fc0f6
 ACTION=="remove", GOTO="systemd_end"
9fc0f6
 
9fc0f6
-SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*", TAG+="systemd"
9fc0f6
+SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*|3270/tty[0-9]*", TAG+="systemd"
9fc0f6
 
9fc0f6
 KERNEL=="vport*", TAG+="systemd"
9fc0f6
 
9fc0f6
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
9fc0f6
index 40374b5..5a1997f 100644
9fc0f6
--- a/src/getty-generator/getty-generator.c
9fc0f6
+++ b/src/getty-generator/getty-generator.c
9fc0f6
@@ -93,7 +93,8 @@ int main(int argc, char *argv[]) {
9fc0f6
                 "xvc0\0"
9fc0f6
                 "hvsi0\0"
9fc0f6
                 "sclp_line0\0"
9fc0f6
-                "ttysclp0\0";
9fc0f6
+                "ttysclp0\0"
9fc0f6
+                "3270!tty1\0";
9fc0f6
 
9fc0f6
         int r = EXIT_SUCCESS;
9fc0f6
         char *active;
9fc0f6
diff --git a/units/serial-getty@.service.m4 b/units/serial-getty@.service.m4
9fc0f6
index e94cdb4..4ac51e7 100644
9fc0f6
--- a/units/serial-getty@.service.m4
9fc0f6
+++ b/units/serial-getty@.service.m4
9fc0f6
@@ -22,7 +22,7 @@ Before=getty.target
9fc0f6
 IgnoreOnIsolate=yes
9fc0f6
 
9fc0f6
 [Service]
9fc0f6
-ExecStart=-/sbin/agetty --keep-baud %I 115200,38400,9600 $TERM
9fc0f6
+ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM
9fc0f6
 Type=idle
9fc0f6
 Restart=always
9fc0f6
 RestartSec=0