obmc-console: Introduce console-id, deprecate socket-id
The name `socket-id` exposes too much detail about the implementation.
Really the tag identifies the console, so name it as such.
Maintain backwards compatibility until we've converted all the in-tree
OpenBMC users over to `console-id`. Once that's done we can drop support
for `socket-id`.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I5aa2ba84835d64901e459b42bfe7be59043466c7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e1537d..78cd16e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,3 +26,10 @@
1. The `xyz.openbmc_project.console` interface is only published if the
underlying TTY device is a UART and not a VUART nor PTY (where baud is not
applicable)
+
+### Deprecated
+
+1. obmc-console: Introduce console-id, deprecate socket-id
+
+ Deprecate the `socket-id` key in the configuration schema. Uses of
+ `socket-id` should be directly replaced with `console-id`.
diff --git a/README.md b/README.md
index 90fe9fe..76fd158 100644
--- a/README.md
+++ b/README.md
@@ -38,25 +38,25 @@
domain socket.
```
- +--------------------------------------------------------------------------------------------+
- | |
- | obmc-console-client unix domain socket obmc-console-server |
- | |
- | +---------------------+ +------------------------+ |
- | | client.2200.conf | +---------------------+ | server.ttyVUART0.conf | |
- +---+--+ +---------------------+ | | +------------------------+ +--------+-------+
-Network | 2200 +--> +->+ @obmc-console.host0 +<-+ <--+ /dev/ttyVUART0 | UARTs
- +---+--+ | socket-id = "host0" | | | | socket-id = "host0" | +--------+-------+
- | | | +---------------------+ | | |
- | +---------------------+ +------------------------+ |
- | |
- | |
- | |
- +--------------------------------------------------------------------------------------------+
+ +---------------------------------------------------------------------------------------------+
+ | |
+ | obmc-console-client unix domain socket obmc-console-server |
+ | |
+ | +----------------------+ +------------------------+ |
+ | | client.2200.conf | +---------------------+ | server.ttyVUART0.conf | |
+ +---+--+ +----------------------+ | | +------------------------+ +--------+-------+
+Network | 2200 +--> +->+ @obmc-console.host0 +<-+ <--+ /dev/ttyVUART0 | UARTs
+ +---+--+ | console-id = "host0" | | | | console-id = "host0" | +--------+-------+
+ | | | +---------------------+ | | |
+ | +----------------------+ +------------------------+ |
+ | |
+ | |
+ | |
+ +---------------------------------------------------------------------------------------------+
```
-This supports multiple independent consoles. The socket-id is a unique portion
-for the unix domain socket created by the obmc-console-server instance. The
-server needs to know this because it needs to know what to name the pipe; the
-client needs to know it as it needs to form the abstract socket name to which to
-connect.
+This supports multiple independent consoles. The `console-id` is a unique
+portion for the unix domain socket created by the obmc-console-server instance.
+The server needs to know this because it needs to know what to name the pipe;
+the client needs to know it as it needs to form the abstract socket name to
+which to connect.
diff --git a/conf/client.2200.conf.in b/conf/client.2200.conf.in
index 538cb55..fe8a905 100644
--- a/conf/client.2200.conf.in
+++ b/conf/client.2200.conf.in
@@ -1 +1 @@
-socket-id = host
+console-id = host
diff --git a/conf/server.ttyVUART0.conf.in b/conf/server.ttyVUART0.conf.in
index 7d3f758..5d6b019 100644
--- a/conf/server.ttyVUART0.conf.in
+++ b/conf/server.ttyVUART0.conf.in
@@ -3,4 +3,4 @@
upstream-tty = ttyVUART0
local-tty = ttyS0
local-tty-baud = 115200
-socket-id = host
+console-id = host
diff --git a/console-client.c b/console-client.c
index ea66b22..de2b1e3 100644
--- a/console-client.c
+++ b/console-client.c
@@ -212,7 +212,7 @@
return 0;
}
-static int client_init(struct console_client *client, const char *socket_id)
+static int client_init(struct console_client *client, const char *console_id)
{
struct sockaddr_un addr;
socket_path_t path;
@@ -227,7 +227,7 @@
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- len = console_socket_path(addr.sun_path, socket_id);
+ len = console_socket_path(addr.sun_path, console_id);
if (len < 0) {
if (errno) {
warn("Failed to configure socket: %s", strerror(errno));
@@ -266,7 +266,7 @@
enum process_rc prc = PROCESS_OK;
const char *config_path = NULL;
struct config *config = NULL;
- const char *socket_id = NULL;
+ const char *console_id = NULL;
const uint8_t *esc = NULL;
int rc;
@@ -301,13 +301,13 @@
"Socket ID str cannot be empty\n");
return EXIT_FAILURE;
}
- socket_id = optarg;
+ console_id = optarg;
break;
default:
fprintf(stderr,
"Usage: %s "
"[-e <escape sequence>]"
- "[-i <socket ID>]"
+ "[-i <console ID>]"
"[-c <config>]\n",
argv[0]);
return EXIT_FAILURE;
@@ -326,8 +326,13 @@
config, "escape-sequence");
}
- if (!socket_id) {
- socket_id = config_get_value(config, "socket-id");
+ if (!console_id) {
+ console_id = config_get_value(config, "console-id");
+ }
+
+ /* socket-id is deprecated */
+ if (!console_id) {
+ console_id = config_get_value(config, "socket-id");
}
}
@@ -336,7 +341,7 @@
client->esc_state.str.str = esc;
}
- rc = client_init(client, socket_id);
+ rc = client_init(client, console_id);
if (rc) {
goto out_config_fini;
}
diff --git a/console-server.c b/console-server.c
index fd97a6f..3440fb2 100644
--- a/console-server.c
+++ b/console-server.c
@@ -395,9 +395,15 @@
{
ssize_t len;
- console->console_id = config_get_value(config, "socket-id");
+ console->console_id = config_get_value(config, "console-id");
+
+ /* socket-id is deprecated */
if (!console->console_id) {
- warnx("Error: The socket-id is not set in the config file");
+ console->console_id = config_get_value(config, "socket-id");
+ }
+
+ if (!console->console_id) {
+ warnx("Error: The console-id is not set in the config file");
return EXIT_FAILURE;
}
diff --git a/socket-handler.c b/socket-handler.c
index 1932b86..16aed33 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -357,7 +357,7 @@
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
len = console_socket_path(addr.sun_path,
- config_get_value(config, "socket-id"));
+ config_get_value(config, "console-id"));
if (len < 0) {
if (errno) {
warn("Failed to configure socket: %s", strerror(errno));