1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include "bus-get-properties.h"
4 #include "dbus-cgroup.h"
5 #include "dbus-slice.h"
8 #include "string-util.h"
11 static int property_get_currently_active(
14 const char *interface
,
16 sd_bus_message
*reply
,
18 sd_bus_error
*error
) {
20 Slice
*s
= ASSERT_PTR(userdata
);
25 return sd_bus_message_append(
28 (uint32_t) slice_get_currently_active(s
, /* ignore= */ NULL
, /* with_pending= */ false));
31 const sd_bus_vtable bus_slice_vtable
[] = {
32 SD_BUS_VTABLE_START(0),
33 /* The following are currently constant, but we should change that eventually (i.e. open them up via
34 * systemctl set-property), hence they aren't marked as constant */
35 SD_BUS_PROPERTY("ConcurrencyHardMax", "u", bus_property_get_unsigned
, offsetof(Slice
, concurrency_hard_max
), 0),
36 SD_BUS_PROPERTY("ConcurrencySoftMax", "u", bus_property_get_unsigned
, offsetof(Slice
, concurrency_soft_max
), 0),
37 SD_BUS_PROPERTY("NCurrentlyActive", "u", property_get_currently_active
, 0, 0),
41 static int bus_slice_set_transient_property(
44 sd_bus_message
*message
,
46 sd_bus_error
*error
) {
54 flags
|= UNIT_PRIVATE
;
56 if (streq(name
, "ConcurrencyHardMax"))
57 return bus_set_transient_unsigned(u
, name
, &s
->concurrency_hard_max
, message
, flags
, error
);
59 if (streq(name
, "ConcurrencySoftMax"))
60 return bus_set_transient_unsigned(u
, name
, &s
->concurrency_soft_max
, message
, flags
, error
);
65 int bus_slice_set_property(
68 sd_bus_message
*message
,
70 sd_bus_error
*error
) {
78 r
= bus_cgroup_set_property(u
, &s
->cgroup_context
, name
, message
, flags
, error
);
82 if (u
->transient
&& u
->load_state
== UNIT_STUB
) {
83 /* This is a transient unit, let's allow a little more */
85 r
= bus_slice_set_transient_property(s
, name
, message
, flags
, error
);
93 int bus_slice_commit_properties(Unit
*u
) {
96 (void) unit_realize_cgroup(u
);