From a8ceed000003d0544b929be144f7e295db6a840c Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 24 Feb 2026 15:22:28 +0100 Subject: [PATCH 1/3] Revert "systemctl: allow --marker with start/stop too" This reverts commit 351b4dd123f89f7f8491239b2d3f77bef5d00797. I'm pretty sure we should not create more of these multiplexer interfaces, which in this specific also leads to a fair bit of confusion: start/stop/reload-or-restart --marked all enqueue all job types. Instead, a dedicated verb will be introduced in later commits. --- man/systemctl.xml | 8 ++++---- src/systemctl/systemctl-main.c | 4 ++-- src/systemctl/systemctl.c | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 619805891c..63454505dc 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -2855,10 +2855,10 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err - Only allowed with reload-or-restart, start, or - stop. Enqueues jobs for all units that are marked. When a unit marked for reload - does not support reload, restart will be queued. Those properties can be set using - set-property Markers=…. + Only allowed with reload-or-restart. Enqueues restart jobs for all + units that have the needs-restart mark, and reload jobs for units that have the + needs-reload mark. When a unit marked for reload does not support reload, restart + will be queued. Those properties can be set using set-property Markers=…. Unless is used, systemctl will wait for the queued jobs to finish. diff --git a/src/systemctl/systemctl-main.c b/src/systemctl/systemctl-main.c index b23bc4e6ff..c0596cfb86 100644 --- a/src/systemctl/systemctl-main.c +++ b/src/systemctl/systemctl-main.c @@ -59,8 +59,8 @@ static int systemctl_main(int argc, char *argv[]) { { "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_machines }, { "clear-jobs", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_trivial_method }, { "cancel", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_cancel }, - { "start", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, - { "stop", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, + { "start", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, + { "stop", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, { "condstop", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, /* For compatibility with ALTLinux */ { "reload", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, { "restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index fef1cb7a77..382a50e312 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1069,13 +1069,14 @@ static int systemctl_parse_argv(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--wait may not be combined with --no-block."); + bool do_reload_or_restart = streq_ptr(argv[optind], "reload-or-restart"); if (arg_marked) { - if (!STRPTR_IN_SET(argv[optind], "reload-or-restart", "start", "stop")) + if (!do_reload_or_restart) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "--marked may only be used with 'reload-or-restart', 'start', or 'stop'."); + "--marked may only be used with 'reload-or-restart'."); if (optind + 1 < argc) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "No additional arguments allowed with '%s --marked'.", strna(argv[optind])); + "No additional arguments allowed with 'reload-or-restart --marked'."); if (arg_wait) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--marked --wait is not supported."); @@ -1083,10 +1084,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--marked --show-transaction is not supported."); - } else if (STRPTR_IN_SET(argv[optind], "reload-or-restart", "start", "stop")) { + } else if (do_reload_or_restart) { if (optind + 1 >= argc) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "List of units to %s is required.", strna(argv[optind])); + "List of units to restart/reload is required."); } if (arg_image && arg_root) From c008f88dede789ce4572c21a2bca16ff7eede193 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 24 Feb 2026 15:41:20 +0100 Subject: [PATCH 2/3] systemctl: introduce enqueue-marked-jobs verb, stop lumping it with distinct verbs --- man/systemctl.xml | 14 ++++++++++++++ src/systemctl/systemctl-main.c | 1 + src/systemctl/systemctl-start-unit.c | 25 ++++++++++++++++++++----- src/systemctl/systemctl.c | 7 +------ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 63454505dc..e771275ac0 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -499,6 +499,20 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err do not document that. --> + + + enqueue-marked-jobs + + Enqueue start/stop/restart/reload jobs for all units that have the respective + needs-* markers set. When a unit marked for reload does not support reload, + restart will be queued. Those properties can be set using set-property Markers=…. + + Unless is used, systemctl will wait for the + queued jobs to finish. + + + + reload-or-restart PATTERN… diff --git a/src/systemctl/systemctl-main.c b/src/systemctl/systemctl-main.c index c0596cfb86..3b8a5e9088 100644 --- a/src/systemctl/systemctl-main.c +++ b/src/systemctl/systemctl-main.c @@ -65,6 +65,7 @@ static int systemctl_main(int argc, char *argv[]) { { "reload", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, { "restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, { "try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, + { "enqueue-marked-jobs", 1, 1, VERB_ONLINE_ONLY, verb_start }, { "reload-or-restart", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, { "reload-or-try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, /* For compatibility with old systemctl <= 228 */ { "try-reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, verb_start }, diff --git a/src/systemctl/systemctl-start-unit.c b/src/systemctl/systemctl-start-unit.c index a6fb12d1c0..2e203c65ec 100644 --- a/src/systemctl/systemctl-start-unit.c +++ b/src/systemctl/systemctl-start-unit.c @@ -295,6 +295,7 @@ int verb_start(int argc, char *argv[], void *userdata) { const char *method, *job_type, *mode, *one_name, *suffix = NULL; _cleanup_free_ char **stopped_units = NULL; /* Do not use _cleanup_strv_free_ */ _cleanup_strv_free_ char **names = NULL; + bool is_enqueue_marked_jobs = false; int r, ret = EXIT_SUCCESS; sd_bus *bus; @@ -331,13 +332,27 @@ int verb_start(int argc, char *argv[], void *userdata) { job_type = "start"; mode = "isolate"; suffix = ".target"; - } else if (!arg_marked) { + } else if (streq(argv[0], "enqueue-marked-jobs") || arg_marked) { + is_enqueue_marked_jobs = true; + method = job_type = mode = NULL; + + if (arg_wait) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "--wait is not supported for enqueue-marked-jobs."); + + if (arg_show_transaction) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "--show-transaction is not supported for enqueue-marked-jobs."); + + if (arg_marked) + log_warning("--marked is deprecated. Please use systemctl enqueue-marked-jobs instead."); + + } else { /* A command in style of "systemctl start …", "systemctl stop …" and so on */ method = verb_to_method(argv[0]); job_type = verb_to_job_type(argv[0]); mode = arg_job_mode(); - } else - method = job_type = mode = NULL; + } one_name = NULL; } @@ -357,7 +372,7 @@ int verb_start(int argc, char *argv[], void *userdata) { names = strv_new(one_name); if (!names) return log_oom(); - } else if (!arg_marked) { + } else if (!is_enqueue_marked_jobs) { bool expanded; r = expand_unit_names(bus, strv_skip(argv, 1), suffix, &names, &expanded); @@ -387,7 +402,7 @@ int verb_start(int argc, char *argv[], void *userdata) { } _cleanup_(fork_notify_terminate) PidRef journal_pid = PIDREF_NULL; - if (arg_marked) + if (is_enqueue_marked_jobs) ret = enqueue_marked_jobs(bus, w); else { if (arg_verbose) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 382a50e312..0c9dd3b0af 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -143,6 +143,7 @@ static int systemctl_help(void) { " reload UNIT... Reload one or more units\n" " restart UNIT... Start or restart one or more units\n" " try-restart UNIT... Restart one or more units if active\n" + " enqueue-marked-jobs Enqueue all marked unit jobs\n" " reload-or-restart UNIT... Reload one or more units if possible,\n" " otherwise start or restart\n" " try-reload-or-restart UNIT... If active, reload one or more units,\n" @@ -1077,12 +1078,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) { if (optind + 1 < argc) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No additional arguments allowed with 'reload-or-restart --marked'."); - if (arg_wait) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "--marked --wait is not supported."); - if (arg_show_transaction) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "--marked --show-transaction is not supported."); } else if (do_reload_or_restart) { if (optind + 1 >= argc) From 81f31dccb82059fa078f5236613e01f92b09ed1c Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 24 Feb 2026 15:43:21 +0100 Subject: [PATCH 3/3] man/systemctl: deprecate --marked --- man/systemctl.xml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index e771275ac0..c514c84926 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -520,8 +520,8 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err Reload one or more units if they support it. If not, stop and then start them instead. If the units are not running yet, they will be started. - This has a slightly differing functionality when used in combination with , - see below. + When used in combination with , it is a deprecated alias of + enqueue-marked-jobs. @@ -2866,20 +2866,6 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err - - - - Only allowed with reload-or-restart. Enqueues restart jobs for all - units that have the needs-restart mark, and reload jobs for units that have the - needs-reload mark. When a unit marked for reload does not support reload, restart - will be queued. Those properties can be set using set-property Markers=…. - - Unless is used, systemctl will wait for the - queued jobs to finish. - - - -