21255d
From 7155c010ef8c620295d230c284849636c07b40c0 Mon Sep 17 00:00:00 2001
21255d
From: Lennart Poettering <lennart@poettering.net>
21255d
Date: Fri, 22 Mar 2019 20:57:30 +0100
21255d
Subject: [PATCH] core: add new API for enqueing a job with returning the
21255d
 transaction data
21255d
21255d
(cherry picked from commit 50cbaba4fe5a32850998682699322d012e597e4a)
21255d
21255d
Related: #846319
21255d
---
21255d
 src/analyze/analyze-verify.c |   2 +-
21255d
 src/core/automount.c         |   4 +-
21255d
 src/core/dbus-manager.c      |  23 +++++-
21255d
 src/core/dbus-unit.c         | 153 +++++++++++++++++++++++++++++++----
21255d
 src/core/dbus-unit.h         |   8 +-
21255d
 src/core/dbus.c              |   2 +-
21255d
 src/core/device.c            |   2 +-
21255d
 src/core/emergency-action.c  |   5 +-
21255d
 src/core/main.c              |   4 +-
21255d
 src/core/manager.c           |  38 +++++----
21255d
 src/core/manager.h           |   6 +-
21255d
 src/core/path.c              |   2 +-
21255d
 src/core/service.c           |   2 +-
21255d
 src/core/socket.c            |   4 +-
21255d
 src/core/timer.c             |   2 +-
21255d
 src/core/transaction.c       |  22 ++++-
21255d
 src/core/transaction.h       |   2 +-
21255d
 src/core/unit.c              |  16 ++--
21255d
 src/test/test-engine.c       |  20 ++---
21255d
 19 files changed, 244 insertions(+), 73 deletions(-)
21255d
21255d
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
21255d
index ed369532d4..1e143511b2 100644
21255d
--- a/src/analyze/analyze-verify.c
21255d
+++ b/src/analyze/analyze-verify.c
21255d
@@ -205,7 +205,7 @@ static int verify_unit(Unit *u, bool check_man) {
21255d
                 unit_dump(u, stdout, "\t");
21255d
 
21255d
         log_unit_debug(u, "Creating %s/start job", u->id);
21255d
-        r = manager_add_job(u->manager, JOB_START, u, JOB_REPLACE, &err, NULL);
21255d
+        r = manager_add_job(u->manager, JOB_START, u, JOB_REPLACE, NULL, &err, NULL);
21255d
         if (r < 0)
21255d
                 log_unit_error_errno(u, r, "Failed to create %s/start: %s", u->id, bus_error_message(&err, r));
21255d
 
21255d
diff --git a/src/core/automount.c b/src/core/automount.c
21255d
index b1a155d8d4..76e70f4dac 100644
21255d
--- a/src/core/automount.c
21255d
+++ b/src/core/automount.c
21255d
@@ -776,7 +776,7 @@ static void automount_enter_running(Automount *a) {
21255d
                 goto fail;
21255d
         }
21255d
 
21255d
-        r = manager_add_job(UNIT(a)->manager, JOB_START, trigger, JOB_REPLACE, &error, NULL);
21255d
+        r = manager_add_job(UNIT(a)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
21255d
         if (r < 0) {
21255d
                 log_unit_warning(UNIT(a), "Failed to queue mount startup job: %s", bus_error_message(&error, r));
21255d
                 goto fail;
21255d
@@ -1032,7 +1032,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
21255d
                         goto fail;
21255d
                 }
21255d
 
21255d
-                r = manager_add_job(UNIT(a)->manager, JOB_STOP, trigger, JOB_REPLACE, &error, NULL);
21255d
+                r = manager_add_job(UNIT(a)->manager, JOB_STOP, trigger, JOB_REPLACE, NULL, &error, NULL);
21255d
                 if (r < 0) {
21255d
                         log_unit_warning(UNIT(a), "Failed to queue umount startup job: %s", bus_error_message(&error, r));
21255d
                         goto fail;
21255d
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
21255d
index a0777f63d5..0a1d3df42f 100644
21255d
--- a/src/core/dbus-manager.c
21255d
+++ b/src/core/dbus-manager.c
21255d
@@ -549,6 +549,26 @@ static int method_reload_or_try_restart_unit(sd_bus_message *message, void *user
21255d
         return method_start_unit_generic(message, userdata, JOB_TRY_RESTART, true, error);
21255d
 }
21255d
 
21255d
+static int method_enqueue_unit_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
+        Manager *m = userdata;
21255d
+        const char *name;
21255d
+        Unit *u;
21255d
+        int r;
21255d
+
21255d
+        assert(message);
21255d
+        assert(m);
21255d
+
21255d
+        r = sd_bus_message_read(message, "s", &name);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        r = manager_load_unit(m, name, NULL, error, &u);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        return bus_unit_method_enqueue_job(message, u, error);
21255d
+}
21255d
+
21255d
 static int method_start_unit_replace(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
         Manager *m = userdata;
21255d
         const char *old_name;
21255d
@@ -978,7 +998,7 @@ static int method_start_transient_unit(sd_bus_message *message, void *userdata,
21255d
                 return r;
21255d
 
21255d
         /* Finally, start it */
21255d
-        return bus_unit_queue_job(message, u, JOB_START, mode, false, error);
21255d
+        return bus_unit_queue_job(message, u, JOB_START, mode, 0, error);
21255d
 }
21255d
 
21255d
 static int method_get_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
@@ -2547,6 +2567,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
21255d
         SD_BUS_METHOD("TryRestartUnit", "ss", "o", method_try_restart_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ReloadOrRestartUnit", "ss", "o", method_reload_or_restart_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ReloadOrTryRestartUnit", "ss", "o", method_reload_or_try_restart_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
+        SD_BUS_METHOD("EnqueueUnitJob", "sss", "uososa(uosos)", method_enqueue_unit_job, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("KillUnit", "ssi", NULL, method_kill_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("FreezeUnit", "s", NULL, method_freeze_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ThawUnit", "s", NULL, method_thaw_unit, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
21255d
index ce81103e92..549a166abc 100644
21255d
--- a/src/core/dbus-unit.c
21255d
+++ b/src/core/dbus-unit.c
21255d
@@ -314,6 +314,14 @@ static int bus_verify_manage_units_async_full(
21255d
                         error);
21255d
 }
21255d
 
21255d
+static const char *const polkit_message_for_job[_JOB_TYPE_MAX] = {
21255d
+        [JOB_START]       = N_("Authentication is required to start '$(unit)'."),
21255d
+        [JOB_STOP]        = N_("Authentication is required to stop '$(unit)'."),
21255d
+        [JOB_RELOAD]      = N_("Authentication is required to reload '$(unit)'."),
21255d
+        [JOB_RESTART]     = N_("Authentication is required to restart '$(unit)'."),
21255d
+        [JOB_TRY_RESTART] = N_("Authentication is required to restart '$(unit)'."),
21255d
+};
21255d
+
21255d
 int bus_unit_method_start_generic(
21255d
                 sd_bus_message *message,
21255d
                 Unit *u,
21255d
@@ -324,13 +332,6 @@ int bus_unit_method_start_generic(
21255d
         const char *smode;
21255d
         JobMode mode;
21255d
         _cleanup_free_ char *verb = NULL;
21255d
-        static const char *const polkit_message_for_job[_JOB_TYPE_MAX] = {
21255d
-                [JOB_START]       = N_("Authentication is required to start '$(unit)'."),
21255d
-                [JOB_STOP]        = N_("Authentication is required to stop '$(unit)'."),
21255d
-                [JOB_RELOAD]      = N_("Authentication is required to reload '$(unit)'."),
21255d
-                [JOB_RESTART]     = N_("Authentication is required to restart '$(unit)'."),
21255d
-                [JOB_TRY_RESTART] = N_("Authentication is required to restart '$(unit)'."),
21255d
-        };
21255d
         int r;
21255d
 
21255d
         assert(message);
21255d
@@ -372,7 +373,8 @@ int bus_unit_method_start_generic(
21255d
         if (r == 0)
21255d
                 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
21255d
 
21255d
-        return bus_unit_queue_job(message, u, job_type, mode, reload_if_possible, error);
21255d
+        return bus_unit_queue_job(message, u, job_type, mode,
21255d
+                                  reload_if_possible ? BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE : 0, error);
21255d
 }
21255d
 
21255d
 static int method_start(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
@@ -403,6 +405,62 @@ static int method_reload_or_try_restart(sd_bus_message *message, void *userdata,
21255d
         return bus_unit_method_start_generic(message, userdata, JOB_TRY_RESTART, true, error);
21255d
 }
21255d
 
21255d
+int bus_unit_method_enqueue_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
+        BusUnitQueueFlags flags = BUS_UNIT_QUEUE_VERBOSE_REPLY;
21255d
+        const char *jtype, *smode;
21255d
+        Unit *u = userdata;
21255d
+        JobType type;
21255d
+        JobMode mode;
21255d
+        int r;
21255d
+
21255d
+        assert(message);
21255d
+        assert(u);
21255d
+
21255d
+        r = sd_bus_message_read(message, "ss", &jtype, &smode);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        /* Parse the two magic reload types "reload-or-…" manually */
21255d
+        if (streq(jtype, "reload-or-restart")) {
21255d
+                type = JOB_RESTART;
21255d
+                flags |= BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE;
21255d
+        } else if (streq(jtype, "reload-or-try-restart")) {
21255d
+                type = JOB_TRY_RESTART;
21255d
+                flags |= BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE;
21255d
+        } else {
21255d
+                /* And the rest generically */
21255d
+                type = job_type_from_string(jtype);
21255d
+                if (type < 0)
21255d
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job type %s invalid", jtype);
21255d
+        }
21255d
+
21255d
+        mode = job_mode_from_string(smode);
21255d
+        if (mode < 0)
21255d
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s invalid", smode);
21255d
+
21255d
+        r = mac_selinux_unit_access_check(
21255d
+                        u, message,
21255d
+                        job_type_to_access_method(type),
21255d
+                        error);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        r = bus_verify_manage_units_async_full(
21255d
+                        u,
21255d
+                        jtype,
21255d
+                        CAP_SYS_ADMIN,
21255d
+                        polkit_message_for_job[type],
21255d
+                        true,
21255d
+                        message,
21255d
+                        error);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+        if (r == 0)
21255d
+                return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
21255d
+
21255d
+        return bus_unit_queue_job(message, u, type, mode, flags, error);
21255d
+}
21255d
+
21255d
 int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) {
21255d
         Unit *u = userdata;
21255d
         const char *swho;
21255d
@@ -722,6 +780,7 @@ const sd_bus_vtable bus_unit_vtable[] = {
21255d
         SD_BUS_METHOD("TryRestart", "s", "o", method_try_restart, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ReloadOrRestart", "s", "o", method_reload_or_restart, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ReloadOrTryRestart", "s", "o", method_reload_or_try_restart, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
+        SD_BUS_METHOD("EnqueueJob", "ss", "uososa(uosos)", bus_unit_method_enqueue_job, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("Kill", "si", NULL, bus_unit_method_kill, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("ResetFailed", NULL, NULL, bus_unit_method_reset_failed, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
         SD_BUS_METHOD("SetProperties", "ba(sv)", NULL, bus_unit_method_set_properties, SD_BUS_VTABLE_UNPRIVILEGED),
21255d
@@ -1354,11 +1413,14 @@ int bus_unit_queue_job(
21255d
                 Unit *u,
21255d
                 JobType type,
21255d
                 JobMode mode,
21255d
-                bool reload_if_possible,
21255d
+                BusUnitQueueFlags flags,
21255d
                 sd_bus_error *error) {
21255d
 
21255d
-        _cleanup_free_ char *path = NULL;
21255d
-        Job *j;
21255d
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
21255d
+        _cleanup_free_ char *job_path = NULL, *unit_path = NULL;
21255d
+        _cleanup_(set_freep) Set *affected = NULL;
21255d
+        Iterator i;
21255d
+        Job *j, *a;
21255d
         int r;
21255d
 
21255d
         assert(message);
21255d
@@ -1373,7 +1435,7 @@ int bus_unit_queue_job(
21255d
         if (r < 0)
21255d
                 return r;
21255d
 
21255d
-        if (reload_if_possible && unit_can_reload(u)) {
21255d
+        if (FLAGS_SET(flags, BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE) && unit_can_reload(u)) {
21255d
                 if (type == JOB_RESTART)
21255d
                         type = JOB_RELOAD_OR_START;
21255d
                 else if (type == JOB_TRY_RESTART)
21255d
@@ -1391,7 +1453,13 @@ int bus_unit_queue_job(
21255d
             (type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start))
21255d
                 return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id);
21255d
 
21255d
-        r = manager_add_job(u->manager, type, u, mode, error, &j);
21255d
+        if (FLAGS_SET(flags, BUS_UNIT_QUEUE_VERBOSE_REPLY)) {
21255d
+                affected = set_new(NULL);
21255d
+                if (!affected)
21255d
+                        return -ENOMEM;
21255d
+        }
21255d
+
21255d
+        r = manager_add_job(u->manager, type, u, mode, affected, error, &j);
21255d
         if (r < 0)
21255d
                 return r;
21255d
 
21255d
@@ -1399,11 +1467,64 @@ int bus_unit_queue_job(
21255d
         if (r < 0)
21255d
                 return r;
21255d
 
21255d
-        path = job_dbus_path(j);
21255d
-        if (!path)
21255d
+        job_path = job_dbus_path(j);
21255d
+        if (!job_path)
21255d
                 return -ENOMEM;
21255d
 
21255d
-        return sd_bus_reply_method_return(message, "o", path);
21255d
+        /* The classic response is just a job object path */
21255d
+        if (!FLAGS_SET(flags, BUS_UNIT_QUEUE_VERBOSE_REPLY))
21255d
+                return sd_bus_reply_method_return(message, "o", job_path);
21255d
+
21255d
+        /* In verbose mode respond with the anchor job plus everything that has been affected */
21255d
+        r = sd_bus_message_new_method_return(message, &reply);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        unit_path = unit_dbus_path(j->unit);
21255d
+        if (!unit_path)
21255d
+                return -ENOMEM;
21255d
+
21255d
+        r = sd_bus_message_append(reply, "uosos",
21255d
+                                  j->id, job_path,
21255d
+                                  j->unit->id, unit_path,
21255d
+                                  job_type_to_string(j->type));
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        r = sd_bus_message_open_container(reply, 'a', "(uosos)");
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        SET_FOREACH(a, affected, i) {
21255d
+
21255d
+                if (a->id == j->id)
21255d
+                        continue;
21255d
+
21255d
+                /* Free paths from previous iteration */
21255d
+                job_path = mfree(job_path);
21255d
+                unit_path = mfree(unit_path);
21255d
+
21255d
+                job_path = job_dbus_path(a);
21255d
+                if (!job_path)
21255d
+                        return -ENOMEM;
21255d
+
21255d
+                unit_path = unit_dbus_path(a->unit);
21255d
+                if (!unit_path)
21255d
+                        return -ENOMEM;
21255d
+
21255d
+                r = sd_bus_message_append(reply, "(uosos)",
21255d
+                                          a->id, job_path,
21255d
+                                          a->unit->id, unit_path,
21255d
+                                          job_type_to_string(a->type));
21255d
+                if (r < 0)
21255d
+                        return r;
21255d
+        }
21255d
+
21255d
+        r = sd_bus_message_close_container(reply);
21255d
+        if (r < 0)
21255d
+                return r;
21255d
+
21255d
+        return sd_bus_send(NULL, reply, NULL);
21255d
 }
21255d
 
21255d
 static int bus_unit_set_live_property(
21255d
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
21255d
index 39aa1bb53c..d298fcc99e 100644
21255d
--- a/src/core/dbus-unit.h
21255d
+++ b/src/core/dbus-unit.h
21255d
@@ -15,6 +15,7 @@ int bus_unit_send_pending_freezer_message(Unit *u);
21255d
 void bus_unit_send_removed_signal(Unit *u);
21255d
 
21255d
 int bus_unit_method_start_generic(sd_bus_message *message, Unit *u, JobType job_type, bool reload_if_possible, sd_bus_error *error);
21255d
+int bus_unit_method_enqueue_job(sd_bus_message *message, void *userdata, sd_bus_error *error);
21255d
 int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);
21255d
 int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error);
21255d
 
21255d
@@ -27,7 +28,12 @@ int bus_unit_method_unref(sd_bus_message *message, void *userdata, sd_bus_error
21255d
 int bus_unit_method_freeze(sd_bus_message *message, void *userdata, sd_bus_error *error);
21255d
 int bus_unit_method_thaw(sd_bus_message *message, void *userdata, sd_bus_error *error);
21255d
 
21255d
-int bus_unit_queue_job(sd_bus_message *message, Unit *u, JobType type, JobMode mode, bool reload_if_possible, sd_bus_error *error);
21255d
+typedef enum BusUnitQueueFlags {
21255d
+        BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE = 1 << 0,
21255d
+        BUS_UNIT_QUEUE_VERBOSE_REPLY      = 1 << 1,
21255d
+} BusUnitQueueFlags;
21255d
+
21255d
+int bus_unit_queue_job(sd_bus_message *message, Unit *u, JobType type, JobMode mode, BusUnitQueueFlags flags, sd_bus_error *error);
21255d
 int bus_unit_validate_load_state(Unit *u, sd_bus_error *error);
21255d
 
21255d
 int bus_unit_track_add_name(Unit *u, const char *name);
21255d
diff --git a/src/core/dbus.c b/src/core/dbus.c
21255d
index b69c11c519..584a8a1b01 100644
21255d
--- a/src/core/dbus.c
21255d
+++ b/src/core/dbus.c
21255d
@@ -176,7 +176,7 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd
21255d
                 goto failed;
21255d
         }
21255d
 
21255d
-        r = manager_add_job(m, JOB_START, u, JOB_REPLACE, &error, NULL);
21255d
+        r = manager_add_job(m, JOB_START, u, JOB_REPLACE, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 goto failed;
21255d
 
21255d
diff --git a/src/core/device.c b/src/core/device.c
21255d
index 021c28dfbd..cb8b66dfc5 100644
21255d
--- a/src/core/device.c
21255d
+++ b/src/core/device.c
21255d
@@ -419,7 +419,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
21255d
                         if (strv_contains(d->wants_property, *i)) /* Was this unit already listed before? */
21255d
                                 continue;
21255d
 
21255d
-                        r = manager_add_job_by_name(u->manager, JOB_START, *i, JOB_FAIL, &error, NULL);
21255d
+                        r = manager_add_job_by_name(u->manager, JOB_START, *i, JOB_FAIL, NULL, &error, NULL);
21255d
                         if (r < 0)
21255d
                                 log_unit_warning_errno(u, r, "Failed to enqueue SYSTEMD_WANTS= job, ignoring: %s", bus_error_message(&error, r));
21255d
                 }
21255d
diff --git a/src/core/emergency-action.c b/src/core/emergency-action.c
21255d
index 76e1124cff..766a3b4d2b 100644
21255d
--- a/src/core/emergency-action.c
21255d
+++ b/src/core/emergency-action.c
21255d
@@ -54,8 +54,7 @@ int emergency_action(
21255d
                 log_and_status(m, "Rebooting", reason);
21255d
 
21255d
                 (void) update_reboot_parameter_and_warn(reboot_arg);
21255d
-                (void) manager_add_job_by_name_and_warn(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE_IRREVERSIBLY, NULL);
21255d
-
21255d
+                (void) manager_add_job_by_name_and_warn(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE_IRREVERSIBLY, NULL, NULL);
21255d
                 break;
21255d
 
21255d
         case EMERGENCY_ACTION_REBOOT_FORCE:
21255d
@@ -83,7 +82,7 @@ int emergency_action(
21255d
 
21255d
         case EMERGENCY_ACTION_POWEROFF:
21255d
                 log_and_status(m, "Powering off", reason);
21255d
-                (void) manager_add_job_by_name_and_warn(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE_IRREVERSIBLY, NULL);
21255d
+                (void) manager_add_job_by_name_and_warn(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE_IRREVERSIBLY, NULL, NULL);
21255d
                 break;
21255d
 
21255d
         case EMERGENCY_ACTION_POWEROFF_FORCE:
21255d
diff --git a/src/core/main.c b/src/core/main.c
21255d
index 25536054b3..d897155644 100644
21255d
--- a/src/core/main.c
21255d
+++ b/src/core/main.c
21255d
@@ -1952,13 +1952,13 @@ static int do_queue_default_job(
21255d
 
21255d
         assert(target->load_state == UNIT_LOADED);
21255d
 
21255d
-        r = manager_add_job(m, JOB_START, target, JOB_ISOLATE, &error, &default_unit_job);
21255d
+        r = manager_add_job(m, JOB_START, target, JOB_ISOLATE, NULL, &error, &default_unit_job);
21255d
         if (r == -EPERM) {
21255d
                 log_debug_errno(r, "Default target could not be isolated, starting instead: %s", bus_error_message(&error, r));
21255d
 
21255d
                 sd_bus_error_free(&error);
21255d
 
21255d
-                r = manager_add_job(m, JOB_START, target, JOB_REPLACE, &error, &default_unit_job);
21255d
+                r = manager_add_job(m, JOB_START, target, JOB_REPLACE, NULL, &error, &default_unit_job);
21255d
                 if (r < 0) {
21255d
                         *ret_error_message = "Failed to start default target";
21255d
                         return log_emergency_errno(r, "Failed to start default target: %s", bus_error_message(&error, r));
21255d
diff --git a/src/core/manager.c b/src/core/manager.c
21255d
index 4c04896aaa..012615e537 100644
21255d
--- a/src/core/manager.c
21255d
+++ b/src/core/manager.c
21255d
@@ -1242,7 +1242,7 @@ static unsigned manager_dispatch_stop_when_unneeded_queue(Manager *m) {
21255d
                 }
21255d
 
21255d
                 /* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
21255d
-                r = manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, &error, NULL);
21255d
+                r = manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, NULL, &error, NULL);
21255d
                 if (r < 0)
21255d
                         log_unit_warning_errno(u, r, "Failed to enqueue stop job, ignoring: %s", bus_error_message(&error, r));
21255d
         }
21255d
@@ -1685,9 +1685,17 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
21255d
         return 0;
21255d
 }
21255d
 
21255d
-int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_error *e, Job **_ret) {
21255d
-        int r;
21255d
+int manager_add_job(
21255d
+                Manager *m,
21255d
+                JobType type,
21255d
+                Unit *unit,
21255d
+                JobMode mode,
21255d
+                Set *affected_jobs,
21255d
+                sd_bus_error *error,
21255d
+                Job **ret) {
21255d
+
21255d
         Transaction *tr;
21255d
+        int r;
21255d
 
21255d
         assert(m);
21255d
         assert(type < _JOB_TYPE_MAX);
21255d
@@ -1695,10 +1703,10 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
21255d
         assert(mode < _JOB_MODE_MAX);
21255d
 
21255d
         if (mode == JOB_ISOLATE && type != JOB_START)
21255d
-                return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Isolate is only valid for start.");
21255d
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Isolate is only valid for start.");
21255d
 
21255d
         if (mode == JOB_ISOLATE && !unit->allow_isolate)
21255d
-                return sd_bus_error_setf(e, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
21255d
+                return sd_bus_error_setf(error, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
21255d
 
21255d
         log_unit_debug(unit, "Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode));
21255d
 
21255d
@@ -1710,7 +1718,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
21255d
 
21255d
         r = transaction_add_job_and_dependencies(tr, type, unit, NULL, true, false,
21255d
                                                  IN_SET(mode, JOB_IGNORE_DEPENDENCIES, JOB_IGNORE_REQUIREMENTS),
21255d
-                                                 mode == JOB_IGNORE_DEPENDENCIES, e);
21255d
+                                                 mode == JOB_IGNORE_DEPENDENCIES, error);
21255d
         if (r < 0)
21255d
                 goto tr_abort;
21255d
 
21255d
@@ -1720,7 +1728,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
21255d
                         goto tr_abort;
21255d
         }
21255d
 
21255d
-        r = transaction_activate(tr, m, mode, e);
21255d
+        r = transaction_activate(tr, m, mode, affected_jobs, error);
21255d
         if (r < 0)
21255d
                 goto tr_abort;
21255d
 
21255d
@@ -1728,8 +1736,8 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
21255d
                        "Enqueued job %s/%s as %u", unit->id,
21255d
                        job_type_to_string(type), (unsigned) tr->anchor_job->id);
21255d
 
21255d
-        if (_ret)
21255d
-                *_ret = tr->anchor_job;
21255d
+        if (ret)
21255d
+                *ret = tr->anchor_job;
21255d
 
21255d
         transaction_free(tr);
21255d
         return 0;
21255d
@@ -1740,7 +1748,7 @@ tr_abort:
21255d
         return r;
21255d
 }
21255d
 
21255d
-int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, sd_bus_error *e, Job **ret) {
21255d
+int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, sd_bus_error *e, Job **ret) {
21255d
         Unit *unit = NULL;  /* just to appease gcc, initialization is not really necessary */
21255d
         int r;
21255d
 
21255d
@@ -1754,10 +1762,10 @@ int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode
21255d
                 return r;
21255d
         assert(unit);
21255d
 
21255d
-        return manager_add_job(m, type, unit, mode, e, ret);
21255d
+        return manager_add_job(m, type, unit, mode, affected_jobs, e, ret);
21255d
 }
21255d
 
21255d
-int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Job **ret) {
21255d
+int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, Job **ret) {
21255d
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
21255d
         int r;
21255d
 
21255d
@@ -1766,7 +1774,7 @@ int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name,
21255d
         assert(name);
21255d
         assert(mode < _JOB_MODE_MAX);
21255d
 
21255d
-        r = manager_add_job_by_name(m, type, name, mode, &error, ret);
21255d
+        r = manager_add_job_by_name(m, type, name, mode, affected_jobs, &error, ret);
21255d
         if (r < 0)
21255d
                 return log_warning_errno(r, "Failed to enqueue %s job for %s: %s", job_mode_to_string(mode), name, bus_error_message(&error, r));
21255d
 
21255d
@@ -1794,7 +1802,7 @@ int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error
21255d
         /* Failure in adding individual dependencies is ignored, so this always succeeds. */
21255d
         transaction_add_propagate_reload_jobs(tr, unit, tr->anchor_job, mode == JOB_IGNORE_DEPENDENCIES, e);
21255d
 
21255d
-        r = transaction_activate(tr, m, mode, e);
21255d
+        r = transaction_activate(tr, m, mode, NULL, e);
21255d
         if (r < 0)
21255d
                 goto tr_abort;
21255d
 
21255d
@@ -2512,7 +2520,7 @@ static void manager_start_target(Manager *m, const char *name, JobMode mode) {
21255d
 
21255d
         log_debug("Activating special unit %s", name);
21255d
 
21255d
-        r = manager_add_job_by_name(m, JOB_START, name, mode, &error, NULL);
21255d
+        r = manager_add_job_by_name(m, JOB_START, name, mode, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 log_error("Failed to enqueue %s job: %s", name, bus_error_message(&error, r));
21255d
 }
21255d
diff --git a/src/core/manager.h b/src/core/manager.h
21255d
index 40568d3c8b..c4b8e80093 100644
21255d
--- a/src/core/manager.h
21255d
+++ b/src/core/manager.h
21255d
@@ -397,9 +397,9 @@ int manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_err
21255d
 int manager_load_startable_unit_or_warn(Manager *m, const char *name, const char *path, Unit **ret);
21255d
 int manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, Unit **_u);
21255d
 
21255d
-int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_error *e, Job **_ret);
21255d
-int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, sd_bus_error *e, Job **_ret);
21255d
-int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Job **ret);
21255d
+int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, Set *affected_jobs, sd_bus_error *e, Job **_ret);
21255d
+int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, sd_bus_error *e, Job **_ret);
21255d
+int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs,  Job **ret);
21255d
 int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error *e);
21255d
 
21255d
 void manager_dump_units(Manager *s, FILE *f, const char *prefix);
21255d
diff --git a/src/core/path.c b/src/core/path.c
21255d
index dda4a3036b..ed40bc6c19 100644
21255d
--- a/src/core/path.c
21255d
+++ b/src/core/path.c
21255d
@@ -474,7 +474,7 @@ static void path_enter_running(Path *p) {
21255d
                 return;
21255d
         }
21255d
 
21255d
-        r = manager_add_job(UNIT(p)->manager, JOB_START, trigger, JOB_REPLACE, &error, NULL);
21255d
+        r = manager_add_job(UNIT(p)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 goto fail;
21255d
 
21255d
diff --git a/src/core/service.c b/src/core/service.c
21255d
index 7cff419e4e..5e3e75b5ae 100644
21255d
--- a/src/core/service.c
21255d
+++ b/src/core/service.c
21255d
@@ -2176,7 +2176,7 @@ static void service_enter_restart(Service *s) {
21255d
          * restarted. We use JOB_RESTART (instead of the more obvious
21255d
          * JOB_START) here so that those dependency jobs will be added
21255d
          * as well. */
21255d
-        r = manager_add_job(UNIT(s)->manager, JOB_RESTART, UNIT(s), JOB_REPLACE, &error, NULL);
21255d
+        r = manager_add_job(UNIT(s)->manager, JOB_RESTART, UNIT(s), JOB_REPLACE, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 goto fail;
21255d
 
21255d
diff --git a/src/core/socket.c b/src/core/socket.c
21255d
index 7c6d3dfad1..fe061eb73b 100644
21255d
--- a/src/core/socket.c
21255d
+++ b/src/core/socket.c
21255d
@@ -2274,7 +2274,7 @@ static void socket_enter_running(Socket *s, int cfd) {
21255d
                                 goto fail;
21255d
                         }
21255d
 
21255d
-                        r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, &error, NULL);
21255d
+                        r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, NULL, &error, NULL);
21255d
                         if (r < 0)
21255d
                                 goto fail;
21255d
                 }
21255d
@@ -2349,7 +2349,7 @@ static void socket_enter_running(Socket *s, int cfd) {
21255d
 
21255d
                 service->peer = TAKE_PTR(p); /* Pass ownership of the peer reference */
21255d
 
21255d
-                r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(service), JOB_REPLACE, &error, NULL);
21255d
+                r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(service), JOB_REPLACE, NULL, &error, NULL);
21255d
                 if (r < 0) {
21255d
                         /* We failed to activate the new service, but it still exists. Let's make sure the service
21255d
                          * closes and forgets the connection fd again, immediately. */
21255d
diff --git a/src/core/timer.c b/src/core/timer.c
21255d
index 2876d54a59..281ac7f97f 100644
21255d
--- a/src/core/timer.c
21255d
+++ b/src/core/timer.c
21255d
@@ -566,7 +566,7 @@ static void timer_enter_running(Timer *t) {
21255d
                 return;
21255d
         }
21255d
 
21255d
-        r = manager_add_job(UNIT(t)->manager, JOB_START, trigger, JOB_REPLACE, &error, NULL);
21255d
+        r = manager_add_job(UNIT(t)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 goto fail;
21255d
 
21255d
diff --git a/src/core/transaction.c b/src/core/transaction.c
21255d
index 045930838b..cdaaff4f55 100644
21255d
--- a/src/core/transaction.c
21255d
+++ b/src/core/transaction.c
21255d
@@ -585,7 +585,12 @@ rescan:
21255d
         }
21255d
 }
21255d
 
21255d
-static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
21255d
+static int transaction_apply(
21255d
+                Transaction *tr,
21255d
+                Manager *m,
21255d
+                JobMode mode,
21255d
+                Set *affected_jobs) {
21255d
+
21255d
         Iterator i;
21255d
         Job *j;
21255d
         int r;
21255d
@@ -642,6 +647,11 @@ static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
21255d
                 job_add_to_dbus_queue(j);
21255d
                 job_start_timer(j, false);
21255d
                 job_shutdown_magic(j);
21255d
+
21255d
+                /* When 'affected' is specified, let's track all in it all jobs that were touched because of
21255d
+                 * this transaction. */
21255d
+                if (affected_jobs)
21255d
+                        (void) set_put(affected_jobs, j);
21255d
         }
21255d
 
21255d
         return 0;
21255d
@@ -654,7 +664,13 @@ rollback:
21255d
         return r;
21255d
 }
21255d
 
21255d
-int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error *e) {
21255d
+int transaction_activate(
21255d
+                Transaction *tr,
21255d
+                Manager *m,
21255d
+                JobMode mode,
21255d
+                Set *affected_jobs,
21255d
+                sd_bus_error *e) {
21255d
+
21255d
         Iterator i;
21255d
         Job *j;
21255d
         int r;
21255d
@@ -731,7 +747,7 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
21255d
                 return log_notice_errno(r, "Requested transaction contradicts existing jobs: %s", bus_error_message(e, r));
21255d
 
21255d
         /* Tenth step: apply changes */
21255d
-        r = transaction_apply(tr, m, mode);
21255d
+        r = transaction_apply(tr, m, mode, affected_jobs);
21255d
         if (r < 0)
21255d
                 return log_warning_errno(r, "Failed to apply transaction: %m");
21255d
 
21255d
diff --git a/src/core/transaction.h b/src/core/transaction.h
21255d
index 70d74a4ccb..4b5620f5c8 100644
21255d
--- a/src/core/transaction.h
21255d
+++ b/src/core/transaction.h
21255d
@@ -29,6 +29,6 @@ int transaction_add_job_and_dependencies(
21255d
                 bool ignore_requirements,
21255d
                 bool ignore_order,
21255d
                 sd_bus_error *e);
21255d
-int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error *e);
21255d
+int transaction_activate(Transaction *tr, Manager *m, JobMode mode, Set *affected, sd_bus_error *e);
21255d
 int transaction_add_isolate_jobs(Transaction *tr, Manager *m);
21255d
 void transaction_abort(Transaction *tr);
21255d
diff --git a/src/core/unit.c b/src/core/unit.c
21255d
index 29ce6c1fb7..ffbf3cfd48 100644
21255d
--- a/src/core/unit.c
21255d
+++ b/src/core/unit.c
21255d
@@ -2033,7 +2033,7 @@ static void unit_check_binds_to(Unit *u) {
21255d
         log_unit_info(u, "Unit is bound to inactive unit %s. Stopping, too.", other->id);
21255d
 
21255d
         /* A unit we need to run is gone. Sniff. Let's stop this. */
21255d
-        r = manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, &error, NULL);
21255d
+        r = manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, NULL, &error, NULL);
21255d
         if (r < 0)
21255d
                 log_unit_warning_errno(u, r, "Failed to enqueue stop job, ignoring: %s", bus_error_message(&error, r));
21255d
 }
21255d
@@ -2049,25 +2049,25 @@ static void retroactively_start_dependencies(Unit *u) {
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_REQUIRES], i)
21255d
                 if (!hashmap_get(u->dependencies[UNIT_AFTER], other) &&
21255d
                     !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL, NULL);
21255d
 
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BINDS_TO], i)
21255d
                 if (!hashmap_get(u->dependencies[UNIT_AFTER], other) &&
21255d
                     !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, NULL, NULL, NULL);
21255d
 
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_WANTS], i)
21255d
                 if (!hashmap_get(u->dependencies[UNIT_AFTER], other) &&
21255d
                     !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_START, other, JOB_FAIL, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_START, other, JOB_FAIL, NULL, NULL, NULL);
21255d
 
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTS], i)
21255d
                 if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL);
21255d
 
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_CONFLICTED_BY], i)
21255d
                 if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL);
21255d
 }
21255d
 
21255d
 static void retroactively_stop_dependencies(Unit *u) {
21255d
@@ -2081,7 +2081,7 @@ static void retroactively_stop_dependencies(Unit *u) {
21255d
         /* Pull down units which are bound to us recursively if enabled */
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_BOUND_BY], i)
21255d
                 if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
21255d
-                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL);
21255d
+                        manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, NULL, NULL, NULL);
21255d
 }
21255d
 
21255d
 void unit_start_on_failure(Unit *u) {
21255d
@@ -2100,7 +2100,7 @@ void unit_start_on_failure(Unit *u) {
21255d
         HASHMAP_FOREACH_KEY(v, other, u->dependencies[UNIT_ON_FAILURE], i) {
21255d
                 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
21255d
 
21255d
-                r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, &error, NULL);
21255d
+                r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, NULL, &error, NULL);
21255d
                 if (r < 0)
21255d
                         log_unit_warning_errno(u, r, "Failed to enqueue OnFailure= job, ignoring: %s", bus_error_message(&error, r));
21255d
         }
21255d
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
21255d
index 0f3e244dc1..f2e327b3f5 100644
21255d
--- a/src/test/test-engine.c
21255d
+++ b/src/test/test-engine.c
21255d
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
21255d
         manager_dump_units(m, stdout, "\t");
21255d
 
21255d
         printf("Test1: (Trivial)\n");
21255d
-        r = manager_add_job(m, JOB_START, c, JOB_REPLACE, &err, &j);
21255d
+        r = manager_add_job(m, JOB_START, c, JOB_REPLACE, NULL, &err, &j);
21255d
         if (sd_bus_error_is_set(&err))
21255d
                 log_error("error: %s: %s", err.name, err.message);
21255d
         assert_se(r == 0);
21255d
@@ -59,15 +59,15 @@ int main(int argc, char *argv[]) {
21255d
         manager_dump_units(m, stdout, "\t");
21255d
 
21255d
         printf("Test2: (Cyclic Order, Unfixable)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, NULL, &j) == -EDEADLK);
21255d
+        assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, NULL, NULL, &j) == -EDEADLK);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Test3: (Cyclic Order, Fixable, Garbage Collector)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Test4: (Identical transaction)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, e, JOB_FAIL, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_START, e, JOB_FAIL, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Load3:\n");
21255d
@@ -75,21 +75,21 @@ int main(int argc, char *argv[]) {
21255d
         manager_dump_units(m, stdout, "\t");
21255d
 
21255d
         printf("Test5: (Colliding transaction, fail)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, g, JOB_FAIL, NULL, &j) == -EDEADLK);
21255d
+        assert_se(manager_add_job(m, JOB_START, g, JOB_FAIL, NULL, NULL, &j) == -EDEADLK);
21255d
 
21255d
         printf("Test6: (Colliding transaction, replace)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, g, JOB_REPLACE, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_START, g, JOB_REPLACE, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Test7: (Unmergeable job type, fail)\n");
21255d
-        assert_se(manager_add_job(m, JOB_STOP, g, JOB_FAIL, NULL, &j) == -EDEADLK);
21255d
+        assert_se(manager_add_job(m, JOB_STOP, g, JOB_FAIL, NULL, NULL, &j) == -EDEADLK);
21255d
 
21255d
         printf("Test8: (Mergeable job type, fail)\n");
21255d
-        assert_se(manager_add_job(m, JOB_RESTART, g, JOB_FAIL, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_RESTART, g, JOB_FAIL, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Test9: (Unmergeable job type, replace)\n");
21255d
-        assert_se(manager_add_job(m, JOB_STOP, g, JOB_REPLACE, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_STOP, g, JOB_REPLACE, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         printf("Load4:\n");
21255d
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
21255d
         manager_dump_units(m, stdout, "\t");
21255d
 
21255d
         printf("Test10: (Unmergeable job type of auxiliary job, fail)\n");
21255d
-        assert_se(manager_add_job(m, JOB_START, h, JOB_FAIL, NULL, &j) == 0);
21255d
+        assert_se(manager_add_job(m, JOB_START, h, JOB_FAIL, NULL, NULL, &j) == 0);
21255d
         manager_dump_jobs(m, stdout, "\t");
21255d
 
21255d
         assert_se(!hashmap_get(a->dependencies[UNIT_PROPAGATES_RELOAD_TO], b));