Merge pull request #30005 from poettering/storagetm-plymout
storagetm: plymouth hookup
This commit is contained in:
@@ -182,7 +182,6 @@ Features:
|
||||
as mass storage devices on systems that have a USB controller that can
|
||||
operate in device mode
|
||||
- add NVMe authentication
|
||||
- show login details also via plymouth
|
||||
|
||||
* add support for activating nvme-oF devices at boot automatically via kernel
|
||||
cmdline, and maybe even support a syntax such as
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "main-func.h"
|
||||
#include "parse-argument.h"
|
||||
#include "path-util.h"
|
||||
#include "plymouth-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "random-util.h"
|
||||
@@ -568,7 +569,41 @@ static int nvme_subsystem_report(NvmeSubsystem *subsystem, NvmePort *ipv4, NvmeP
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nvme_port_report(NvmePort *port) {
|
||||
static int plymouth_send_text(const char *text) {
|
||||
_cleanup_free_ char *plymouth_message = NULL;
|
||||
int c, r;
|
||||
|
||||
assert(text);
|
||||
|
||||
c = asprintf(&plymouth_message,
|
||||
"M\x02%c%s%c"
|
||||
"A%c", /* pause spinner */
|
||||
(int) strlen(text) + 1, text, '\x00',
|
||||
'\x00');
|
||||
if (c < 0)
|
||||
return log_oom();
|
||||
|
||||
r = plymouth_send_raw(plymouth_message, c, SOCK_NONBLOCK);
|
||||
if (r < 0)
|
||||
return log_full_errno(ERRNO_IS_NO_PLYMOUTH(r) ? LOG_DEBUG : LOG_WARNING, r,
|
||||
"Failed to communicate with plymouth, ignoring: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int plymouth_notify_port(NvmePort *port, struct local_address *a) {
|
||||
_cleanup_free_ char *m = NULL;
|
||||
|
||||
if (!port || !a)
|
||||
return 0;
|
||||
|
||||
if (asprintf(&m, "nvme connect-all -t tcp -a %s -s %" PRIu16, IN_ADDR_TO_STRING(a->family, &a->address), port->portnr) < 0)
|
||||
return log_oom();
|
||||
|
||||
return plymouth_send_text(m);
|
||||
}
|
||||
|
||||
static int nvme_port_report(NvmePort *port, bool *plymouth_done) {
|
||||
if (!port)
|
||||
return 0;
|
||||
|
||||
@@ -590,6 +625,11 @@ static int nvme_port_report(NvmePort *port) {
|
||||
IN_ADDR_TO_STRING(a->family, &a->address),
|
||||
port->portnr);
|
||||
|
||||
if (plymouth_done && !*plymouth_done) {
|
||||
(void) plymouth_notify_port(port, n_addresses > 0 ? addresses : NULL);
|
||||
*plymouth_done = n_addresses > 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -861,8 +901,15 @@ static int on_display_refresh(sd_event_source *s, uint64_t usec, void *userdata)
|
||||
if (isatty(STDERR_FILENO) > 0)
|
||||
fputs(ANSI_HOME_CLEAR, stderr);
|
||||
|
||||
(void) nvme_port_report(c->ipv4_port);
|
||||
(void) nvme_port_report(c->ipv6_port);
|
||||
/* If we have both IPv4 and IPv6, we display IPv4 info via Plymouth, since it doesn't have much
|
||||
* space, and IPv4 is simply shorter (and easy to type off screen) */
|
||||
|
||||
bool plymouth_done = false;
|
||||
(void) nvme_port_report(c->ipv4_port, &plymouth_done);
|
||||
(void) nvme_port_report(c->ipv6_port, &plymouth_done);
|
||||
|
||||
if (!plymouth_done)
|
||||
(void) plymouth_send_text("Network disconnected.");
|
||||
|
||||
NvmeSubsystem *i;
|
||||
HASHMAP_FOREACH(i, c->subsystems)
|
||||
@@ -946,16 +993,20 @@ static int run(int argc, char* argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
nvme_port_report(context.ipv4_port);
|
||||
bool plymouth_done = false;
|
||||
nvme_port_report(context.ipv4_port, &plymouth_done);
|
||||
|
||||
if (socket_ipv6_is_enabled()) {
|
||||
r = nvme_port_add(arg_nqn, AF_INET6, &context.ipv6_port);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
nvme_port_report(context.ipv6_port);
|
||||
nvme_port_report(context.ipv6_port, &plymouth_done);
|
||||
}
|
||||
|
||||
if (!plymouth_done)
|
||||
(void) plymouth_send_text("Network disconnected.");
|
||||
|
||||
NvmeSubsystem *i;
|
||||
HASHMAP_FOREACH(i, context.subsystems) {
|
||||
if (context.ipv4_port) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[Unit]
|
||||
Description=Storage Target Mode
|
||||
Documentation=man:systemd.special(7)
|
||||
Wants=systemd-storagetm.service systemd-udevd.service systemd-udev-trigger.service systemd-networkd.service systemd-network-generator.service systemd-journald.socket systemd-journald-dev-log.socket
|
||||
Wants=systemd-storagetm.service systemd-udevd.service systemd-udev-trigger.service systemd-networkd.service systemd-network-generator.service systemd-journald.socket systemd-journald-dev-log.socket plymouth-start.service
|
||||
Conflicts=rescue.service rescue.target
|
||||
After=systemd-storagetm.service systemd-udevd.service systemd-udev-trigger.service systemd-networkd.service systemd-network-generator.service systemd-journald.socket systemd-journald-dev-log.socket rescue.service rescue.target
|
||||
After=systemd-storagetm.service systemd-udevd.service systemd-udev-trigger.service systemd-networkd.service systemd-network-generator.service systemd-journald.socket systemd-journald-dev-log.socket plymouth-start.service rescue.service rescue.target
|
||||
AllowIsolate=yes
|
||||
|
||||
@@ -13,7 +13,7 @@ Documentation=man:systemd-storagetm.service(8)
|
||||
ConditionVirtualization=!container
|
||||
DefaultDependencies=no
|
||||
Wants=modprobe@nvmet_tcp.service modprobe@thunderbolt_net.service sys-kernel-config.mount
|
||||
After=modprobe@nvmet_tcp.service modprobe@thunderbolt_net.service sys-kernel-config.mount
|
||||
After=modprobe@nvmet_tcp.service modprobe@thunderbolt_net.service sys-kernel-config.mount plymouth-start.service
|
||||
Conflicts=shutdown.target
|
||||
Before=shutdown.target
|
||||
FailureAction=reboot
|
||||
|
||||
Reference in New Issue
Block a user