Supply Serial port as an optional argument to obmc-console-server
obmc-console-server is a serial console server that currently uses
ttyS5 on the BMC and this is configured in obmc-console.conf.
This patch introduced a new parameter so that tty port can be specified
while starting the server. When this parameter is passed, it overrides
the TTY that has been given in the configuration file.
This feature is being added to support systemd template unit files.
We would write a 'obmc-console@.service' file and then start
'obmc-console@ttyS5' and the part after the @ becomes a parameter to the unit
that can be passed along. This is only "useful" if we have somewhere to pass it
to.
One aspect of the template unit, which is appropriate to this issue, is that the
template parameter can be used as a dependency, so we can ensure the service
obmc-console@%s will not start unless /dev/%s is present.
Below are the advantages of this approach:
1. We can use systemd template unit files as intended without hard-coding the
dev-entry.
2. It gets us very close to being able to handle multiple host consoles for a
blade-chassis style system.
3. It allows us to easily map a [virtual] physical UART in QEMU to the
obmc-console application for test purposes.
Change-Id: I6599a2572e2db996fba9a19a3d65ff502d550114
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/console-server.c b/console-server.c
index 45dd07a..9a0d60e 100644
--- a/console-server.c
+++ b/console-server.c
@@ -71,7 +71,7 @@
static void usage(const char *progname)
{
fprintf(stderr,
-"usage: %s [options]\n"
+"usage: %s [options] <DEVICE>\n"
"\n"
"Options:\n"
" --config <FILE> Use FILE for configuration\n"
@@ -216,8 +216,6 @@
char *endp;
int rc;
- console->tty_kname = config_get_value(config, "device");
-
val = config_get_value(config, "lpc-address");
if (val) {
console->tty_lpc_addr = strtoul(val, &endp, 0);
@@ -504,6 +502,7 @@
int main(int argc, char **argv)
{
const char *config_filename = NULL;
+ const char *config_tty_kname = NULL;
struct console *console;
struct config *config;
int rc;
@@ -528,6 +527,14 @@
}
}
+ if (optind >= argc) {
+ warnx("Required argument <DEVICE> missing");
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ config_tty_kname = argv[optind];
+
console = malloc(sizeof(struct console));
memset(console, 0, sizeof(*console));
console->pollfds = calloc(n_internal_pollfds,
@@ -539,6 +546,8 @@
goto out_free;
}
+ console->tty_kname = config_tty_kname;
+
rc = tty_init(console, config);
if (rc)
goto out_config_fini;
diff --git a/obmc-console.conf.sample b/obmc-console.conf.sample
index d473af2..647e3c7 100644
--- a/obmc-console.conf.sample
+++ b/obmc-console.conf.sample
@@ -1,6 +1,3 @@
-# Device to use for our UART console
-device = ttyUSB0
-
# For VUART devices, we can specify the LPC address and SIRQ parameters
lpc-address = 0x3f8
sirq = 4