Compare commits

..

No commits in common. "df46dbca92f7197cd3c6c8ae6e67560683b6dc0d" and "161bc525bbd7e3707cc71f0258f663bed9a354dd" have entirely different histories.

11 changed files with 49 additions and 68 deletions

3
TODO
View File

@ -677,6 +677,9 @@ Features:
* merge ~/.local/share and ~/.local/lib into one similar /usr/lib and /usr/share.... * merge ~/.local/share and ~/.local/lib into one similar /usr/lib and /usr/share....
* systemd.show_status= should probably have a mode where only failed
units are shown.
* add systemd.abort_on_kill or some other such flag to send SIGABRT instead of SIGKILL * add systemd.abort_on_kill or some other such flag to send SIGABRT instead of SIGKILL
(throughout the codebase, not only PID1) (throughout the codebase, not only PID1)

View File

@ -798,14 +798,15 @@
<varlistentry> <varlistentry>
<term><varname>systemd.show_status</varname></term> <term><varname>systemd.show_status</varname></term>
<listitem><para>Takes a boolean argument or the constants <constant>error</constant> and <listitem><para>Takes a boolean argument or the constant
<constant>auto</constant>. Can be also specified without an argument, with the same effect as a <constant>auto</constant>. Can be also specified without an argument, with
positive boolean. If enabled, the systemd manager (PID 1) shows terse service status updates on the the same effect as a positive boolean. If enabled, the systemd manager (PID
console during bootup. With <constant>error</constant>, only messages about failures are shown, but 1) shows terse service status updates on the console during bootup.
boot is otherwise quiet. <constant>auto</constant> behaves like <option>false</option> until there is <constant>auto</constant> behaves like <option>false</option> until a unit
a significant delay in boot. Defaults to enabled, unless <option>quiet</option> is passed as kernel fails or there is a significant delay in boot. Defaults to enabled, unless
command line option, in which case it defaults to <constant>error</constant>. If specified overrides <option>quiet</option> is passed as kernel command line option, in which case
the system manager configuration file option <option>ShowStatus=</option>, see it defaults to <constant>auto</constant>. If specified overrides the system
manager configuration file option <option>ShowStatus=</option>, see
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>. <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>

View File

@ -572,7 +572,7 @@ static void job_print_begin_status_message(Unit *u, JobType t) {
format = job_get_begin_status_message_format(u, t); format = job_get_begin_status_message_format(u, t);
DISABLE_WARNING_FORMAT_NONLITERAL; DISABLE_WARNING_FORMAT_NONLITERAL;
unit_status_printf(u, STATUS_TYPE_NORMAL, "", format); unit_status_printf(u, "", format);
REENABLE_WARNING; REENABLE_WARNING;
} }
@ -861,10 +861,11 @@ static void job_print_done_status_message(Unit *u, JobType t, JobResult result)
else else
status = job_print_done_status_messages[result].word; status = job_print_done_status_messages[result].word;
if (result != JOB_DONE)
manager_flip_auto_status(u->manager, true);
DISABLE_WARNING_FORMAT_NONLITERAL; DISABLE_WARNING_FORMAT_NONLITERAL;
unit_status_printf(u, unit_status_printf(u, status, format);
result == JOB_DONE ? STATUS_TYPE_NORMAL : STATUS_TYPE_NOTICE,
status, format);
REENABLE_WARNING; REENABLE_WARNING;
if (t == JOB_START && result == JOB_FAILED) { if (t == JOB_START && result == JOB_FAILED) {

View File

@ -494,7 +494,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
} else if (streq(key, "quiet") && !value) { } else if (streq(key, "quiet") && !value) {
if (arg_show_status == _SHOW_STATUS_INVALID) if (arg_show_status == _SHOW_STATUS_INVALID)
arg_show_status = SHOW_STATUS_ERROR; arg_show_status = SHOW_STATUS_AUTO;
} else if (streq(key, "debug") && !value) { } else if (streq(key, "debug") && !value) {
@ -711,7 +711,7 @@ static void set_manager_settings(Manager *m) {
m->kexec_watchdog = arg_kexec_watchdog; m->kexec_watchdog = arg_kexec_watchdog;
m->cad_burst_action = arg_cad_burst_action; m->cad_burst_action = arg_cad_burst_action;
manager_set_show_status(m, arg_show_status, "commandline"); manager_set_show_status(m, arg_show_status);
m->status_unit_format = arg_status_unit_format; m->status_unit_format = arg_status_unit_format;
} }
@ -1254,7 +1254,7 @@ static int status_welcome(void) {
_cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL; _cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
int r; int r;
if (!show_status_on(arg_show_status)) if (IN_SET(arg_show_status, SHOW_STATUS_NO, SHOW_STATUS_AUTO))
return 0; return 0;
r = parse_os_release(NULL, r = parse_os_release(NULL,

View File

@ -85,8 +85,7 @@
#define CGROUPS_AGENT_RCVBUF_SIZE (8*1024*1024) #define CGROUPS_AGENT_RCVBUF_SIZE (8*1024*1024)
/* Initial delay and the interval for printing status messages about running jobs */ /* Initial delay and the interval for printing status messages about running jobs */
#define JOBS_IN_PROGRESS_WAIT_USEC (2*USEC_PER_SEC) #define JOBS_IN_PROGRESS_WAIT_USEC (5*USEC_PER_SEC)
#define JOBS_IN_PROGRESS_QUIET_WAIT_USEC (25*USEC_PER_SEC)
#define JOBS_IN_PROGRESS_PERIOD_USEC (USEC_PER_SEC / 3) #define JOBS_IN_PROGRESS_PERIOD_USEC (USEC_PER_SEC / 3)
#define JOBS_IN_PROGRESS_PERIOD_DIVISOR 3 #define JOBS_IN_PROGRESS_PERIOD_DIVISOR 3
@ -110,12 +109,6 @@ static int manager_dispatch_timezone_change(sd_event_source *source, const struc
static int manager_run_environment_generators(Manager *m); static int manager_run_environment_generators(Manager *m);
static int manager_run_generators(Manager *m); static int manager_run_generators(Manager *m);
static usec_t manager_watch_jobs_next_time(Manager *m) {
return usec_add(now(CLOCK_MONOTONIC),
show_status_on(m->show_status) ? JOBS_IN_PROGRESS_WAIT_USEC :
JOBS_IN_PROGRESS_QUIET_WAIT_USEC);
}
static void manager_watch_jobs_in_progress(Manager *m) { static void manager_watch_jobs_in_progress(Manager *m) {
usec_t next; usec_t next;
int r; int r;
@ -131,7 +124,7 @@ static void manager_watch_jobs_in_progress(Manager *m) {
if (m->jobs_in_progress_event_source) if (m->jobs_in_progress_event_source)
return; return;
next = manager_watch_jobs_next_time(m); next = now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC;
r = sd_event_add_time( r = sd_event_add_time(
m->event, m->event,
&m->jobs_in_progress_event_source, &m->jobs_in_progress_event_source,
@ -180,15 +173,15 @@ static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned po
} }
} }
void manager_flip_auto_status(Manager *m, bool enable, const char *reason) { void manager_flip_auto_status(Manager *m, bool enable) {
assert(m); assert(m);
if (enable) { if (enable) {
if (m->show_status == SHOW_STATUS_AUTO) if (m->show_status == SHOW_STATUS_AUTO)
manager_set_show_status(m, SHOW_STATUS_TEMPORARY, reason); manager_set_show_status(m, SHOW_STATUS_TEMPORARY);
} else { } else {
if (m->show_status == SHOW_STATUS_TEMPORARY) if (m->show_status == SHOW_STATUS_TEMPORARY)
manager_set_show_status(m, SHOW_STATUS_AUTO, reason); manager_set_show_status(m, SHOW_STATUS_AUTO);
} }
} }
@ -205,7 +198,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
assert(m); assert(m);
assert(m->n_running_jobs > 0); assert(m->n_running_jobs > 0);
manager_flip_auto_status(m, true, "delay"); manager_flip_auto_status(m, true);
print_nr = (m->jobs_in_progress_iteration / JOBS_IN_PROGRESS_PERIOD_DIVISOR) % m->n_running_jobs; print_nr = (m->jobs_in_progress_iteration / JOBS_IN_PROGRESS_PERIOD_DIVISOR) % m->n_running_jobs;
@ -2743,11 +2736,11 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
switch (sfsi.ssi_signo - SIGRTMIN) { switch (sfsi.ssi_signo - SIGRTMIN) {
case 20: case 20:
manager_set_show_status(m, SHOW_STATUS_YES, "signal"); manager_set_show_status(m, SHOW_STATUS_YES);
break; break;
case 21: case 21:
manager_set_show_status(m, SHOW_STATUS_NO, "signal"); manager_set_show_status(m, SHOW_STATUS_NO);
break; break;
case 22: case 22:
@ -3409,7 +3402,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
if (s < 0) if (s < 0)
log_notice("Failed to parse show-status flag '%s', ignoring.", val); log_notice("Failed to parse show-status flag '%s', ignoring.", val);
else else
manager_set_show_status(m, s, "deserialization"); manager_set_show_status(m, s);
} else if ((val = startswith(l, "log-level-override="))) { } else if ((val = startswith(l, "log-level-override="))) {
int level; int level;
@ -3780,12 +3773,12 @@ void manager_check_finished(Manager *m) {
if (hashmap_size(m->jobs) > 0) { if (hashmap_size(m->jobs) > 0) {
if (m->jobs_in_progress_event_source) if (m->jobs_in_progress_event_source)
/* Ignore any failure, this is only for feedback */ /* Ignore any failure, this is only for feedback */
(void) sd_event_source_set_time(m->jobs_in_progress_event_source, (void) sd_event_source_set_time(m->jobs_in_progress_event_source, now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC);
manager_watch_jobs_next_time(m));
return; return;
} }
manager_flip_auto_status(m, false, "boot finished"); manager_flip_auto_status(m, false);
/* Notify Type=idle units that we are done now */ /* Notify Type=idle units that we are done now */
manager_close_idle_pipe(m); manager_close_idle_pipe(m);
@ -4083,24 +4076,19 @@ void manager_recheck_journal(Manager *m) {
log_open(); log_open();
} }
void manager_set_show_status(Manager *m, ShowStatus mode, const char *reason) { void manager_set_show_status(Manager *m, ShowStatus mode) {
assert(m); assert(m);
assert(mode >= 0 && mode < _SHOW_STATUS_MAX); assert(IN_SET(mode, SHOW_STATUS_AUTO, SHOW_STATUS_NO, SHOW_STATUS_YES, SHOW_STATUS_TEMPORARY));
if (!MANAGER_IS_SYSTEM(m)) if (!MANAGER_IS_SYSTEM(m))
return; return;
if (mode == m->show_status) if (m->show_status != mode)
return; log_debug("%s showing of status.",
mode == SHOW_STATUS_NO ? "Disabling" : "Enabling");
bool enabled = IN_SET(mode, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
log_debug("%s (%s) showing of status (%s).",
enabled ? "Enabling" : "Disabling",
strna(show_status_to_string(mode)),
reason);
m->show_status = mode; m->show_status = mode;
if (enabled) if (IN_SET(mode, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES))
(void) touch("/run/systemd/show-status"); (void) touch("/run/systemd/show-status");
else else
(void) unlink("/run/systemd/show-status"); (void) unlink("/run/systemd/show-status");
@ -4122,10 +4110,7 @@ static bool manager_get_show_status(Manager *m, StatusType type) {
if (type != STATUS_TYPE_EMERGENCY && manager_check_ask_password(m) > 0) if (type != STATUS_TYPE_EMERGENCY && manager_check_ask_password(m) > 0)
return false; return false;
if (type == STATUS_TYPE_NOTICE && m->show_status != SHOW_STATUS_NO) return IN_SET(m->show_status, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
return true;
return show_status_on(m->show_status);
} }
const char *manager_get_confirm_spawn(Manager *m) { const char *manager_get_confirm_spawn(Manager *m) {

View File

@ -56,7 +56,6 @@ typedef enum ManagerObjective {
typedef enum StatusType { typedef enum StatusType {
STATUS_TYPE_EPHEMERAL, STATUS_TYPE_EPHEMERAL,
STATUS_TYPE_NORMAL, STATUS_TYPE_NORMAL,
STATUS_TYPE_NOTICE,
STATUS_TYPE_EMERGENCY, STATUS_TYPE_EMERGENCY,
} StatusType; } StatusType;
@ -506,11 +505,11 @@ void disable_printk_ratelimit(void);
void manager_recheck_dbus(Manager *m); void manager_recheck_dbus(Manager *m);
void manager_recheck_journal(Manager *m); void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, ShowStatus mode, const char *reason); void manager_set_show_status(Manager *m, ShowStatus mode);
void manager_set_first_boot(Manager *m, bool b); void manager_set_first_boot(Manager *m, bool b);
void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5); void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5);
void manager_flip_auto_status(Manager *m, bool enable, const char *reason); void manager_flip_auto_status(Manager *m, bool enable);
Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path); Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path);

View File

@ -16,7 +16,6 @@
static const char* const show_status_table[_SHOW_STATUS_MAX] = { static const char* const show_status_table[_SHOW_STATUS_MAX] = {
[SHOW_STATUS_NO] = "no", [SHOW_STATUS_NO] = "no",
[SHOW_STATUS_ERROR] = "error",
[SHOW_STATUS_AUTO] = "auto", [SHOW_STATUS_AUTO] = "auto",
[SHOW_STATUS_TEMPORARY] = "temporary", [SHOW_STATUS_TEMPORARY] = "temporary",
[SHOW_STATUS_YES] = "yes", [SHOW_STATUS_YES] = "yes",

View File

@ -8,11 +8,10 @@
/* Manager status */ /* Manager status */
typedef enum ShowStatus { typedef enum ShowStatus {
SHOW_STATUS_NO, /* printing of status is disabled */ SHOW_STATUS_NO,
SHOW_STATUS_ERROR, /* only print errors */ SHOW_STATUS_AUTO,
SHOW_STATUS_AUTO, /* disabled but may flip to _TEMPORARY */ SHOW_STATUS_TEMPORARY,
SHOW_STATUS_TEMPORARY, /* enabled temporarily, may flip back to _AUTO */ SHOW_STATUS_YES,
SHOW_STATUS_YES, /* printing of status is enabled */
_SHOW_STATUS_MAX, _SHOW_STATUS_MAX,
_SHOW_STATUS_INVALID = -1, _SHOW_STATUS_INVALID = -1,
} ShowStatus; } ShowStatus;
@ -29,9 +28,6 @@ typedef enum StatusUnitFormat {
_STATUS_UNIT_FORMAT_INVALID = -1, _STATUS_UNIT_FORMAT_INVALID = -1,
} StatusUnitFormat; } StatusUnitFormat;
static inline bool show_status_on(ShowStatus s) {
return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
}
ShowStatus show_status_from_string(const char *v) _const_; ShowStatus show_status_from_string(const char *v) _const_;
const char* show_status_to_string(ShowStatus s) _pure_; const char* show_status_to_string(ShowStatus s) _pure_;
int parse_show_status(const char *v, ShowStatus *ret); int parse_show_status(const char *v, ShowStatus *ret);

View File

@ -425,9 +425,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
else else
status = " SKIP "; status = " SKIP ";
unit_status_printf(delete->unit, unit_status_printf(delete->unit, status,
STATUS_TYPE_NOTICE,
status,
"Ordering cycle found, skipping %s"); "Ordering cycle found, skipping %s");
transaction_delete_unit(tr, delete->unit); transaction_delete_unit(tr, delete->unit);
return -EAGAIN; return -EAGAIN;

View File

@ -1659,7 +1659,7 @@ static bool unit_test_assert(Unit *u) {
return u->assert_result; return u->assert_result;
} }
void unit_status_printf(Unit *u, StatusType status_type, const char *status, const char *unit_status_msg_format) { void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) {
const char *d; const char *d;
d = unit_status_string(u); d = unit_status_string(u);
@ -1667,7 +1667,7 @@ void unit_status_printf(Unit *u, StatusType status_type, const char *status, con
d = strjoina(ANSI_HIGHLIGHT, d, ANSI_NORMAL); d = strjoina(ANSI_HIGHLIGHT, d, ANSI_NORMAL);
DISABLE_WARNING_FORMAT_NONLITERAL; DISABLE_WARNING_FORMAT_NONLITERAL;
manager_status_printf(u->manager, status_type, status, unit_status_msg_format, d); manager_status_printf(u->manager, STATUS_TYPE_NORMAL, status, unit_status_msg_format, d);
REENABLE_WARNING; REENABLE_WARNING;
} }

View File

@ -9,7 +9,6 @@
#include "condition.h" #include "condition.h"
#include "emergency-action.h" #include "emergency-action.h"
#include "list.h" #include "list.h"
#include "show-status.h"
#include "set.h" #include "set.h"
#include "unit-file.h" #include "unit-file.h"
#include "cgroup.h" #include "cgroup.h"
@ -749,7 +748,7 @@ int unit_add_blockdev_dependency(Unit *u, const char *what, UnitDependencyMask m
int unit_coldplug(Unit *u); int unit_coldplug(Unit *u);
void unit_catchup(Unit *u); void unit_catchup(Unit *u);
void unit_status_printf(Unit *u, StatusType status_type, const char *status, const char *unit_status_msg_format) _printf_(4, 0); void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) _printf_(3, 0);
bool unit_need_daemon_reload(Unit *u); bool unit_need_daemon_reload(Unit *u);