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