]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: introduce enqueue-marked-jobs verb, stop lumping it with distinct verbs
authorMike Yuan <me@yhndnzj.com>
Tue, 24 Feb 2026 14:41:20 +0000 (15:41 +0100)
committerMike Yuan <me@yhndnzj.com>
Tue, 24 Feb 2026 15:00:05 +0000 (16:00 +0100)
man/systemctl.xml
src/systemctl/systemctl-main.c
src/systemctl/systemctl-start-unit.c
src/systemctl/systemctl.c

index 63454505dcb78d1dec10f1195a566ad8ea0a49c5..e771275ac0f8b941ffd15aec9eb29f3f5aac8253 100644 (file)
@@ -499,6 +499,20 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
                  do not document that. -->
           </listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><command>enqueue-marked-jobs</command></term>
+
+          <listitem><para>Enqueue start/stop/restart/reload jobs for all units that have the respective
+          <literal>needs-*</literal> markers set. When a unit marked for reload does not support reload,
+          restart will be queued. Those properties can be set using <command>set-property Markers=…</command>.</para>
+
+          <para>Unless <option>--no-block</option> is used, <command>systemctl</command> will wait for the
+          queued jobs to finish.</para>
+
+          <xi:include href="version-info.xml" xpointer="v260"/></listitem>
+        </varlistentry>
+
         <varlistentry>
           <term><command>reload-or-restart <replaceable>PATTERN</replaceable>…</command></term>
 
index c0596cfb861d3f30fdef5695837daad7e645c720..3b8a5e9088e4a38e8088338f6c94788bda13bd55 100644 (file)
@@ -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                   },
index a6fb12d1c001d4ac99e59f57f00c186fb452b3b0..2e203c65ecb08df417ba42d3525f1af42a9665b1 100644 (file)
@@ -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 <unit1> <unit2> …", "systemctl stop <unit1> <unit2> …" 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)
index 382a50e312322cd08d9c222caece3693f3475d1b..0c9dd3b0afb012ff772f6e3b4a11cd8fc254b00b 100644 (file)
@@ -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)