mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
Merge pull request #22485 from poettering/cgroup-id-not-support
cgroup: downgrade warnings of "cgroup ID" can't be read (on old kernels)
This commit is contained in:
@@ -2452,6 +2452,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -3023,6 +3025,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -3599,6 +3603,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
@@ -4334,6 +4340,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -4929,6 +4937,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -5499,6 +5509,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
@@ -6123,6 +6135,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -6646,6 +6660,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -7134,6 +7150,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
@@ -7885,6 +7903,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -8394,6 +8414,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -8868,6 +8890,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
@@ -9478,6 +9502,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -9629,6 +9655,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -9783,6 +9811,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
@@ -9961,6 +9991,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly s ControlGroup = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t ControlGroupId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryCurrent = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly t MemoryAvailable = ...;
|
||||
@@ -10130,6 +10162,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
||||
|
||||
<!--property Slice is not documented!-->
|
||||
|
||||
<!--property ControlGroupId is not documented!-->
|
||||
|
||||
<!--property MemoryCurrent is not documented!-->
|
||||
|
||||
<!--property CPUUsageNSec is not documented!-->
|
||||
@@ -10312,6 +10346,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroup"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="ControlGroupId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryCurrent"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="MemoryAvailable"/>
|
||||
|
||||
@@ -462,14 +462,11 @@ int cg_kill_recursive(
|
||||
}
|
||||
|
||||
static const char *controller_to_dirname(const char *controller) {
|
||||
const char *e;
|
||||
|
||||
assert(controller);
|
||||
|
||||
/* Converts a controller name to the directory name below
|
||||
* /sys/fs/cgroup/ we want to mount it to. Effectively, this
|
||||
* just cuts off the name= prefixed used for named
|
||||
* hierarchies, if it is specified. */
|
||||
/* Converts a controller name to the directory name below /sys/fs/cgroup/ we want to mount it
|
||||
* to. Effectively, this just cuts off the name= prefixed used for named hierarchies, if it is
|
||||
* specified. */
|
||||
|
||||
if (streq(controller, SYSTEMD_CGROUP_CONTROLLER)) {
|
||||
if (cg_hybrid_unified() > 0)
|
||||
@@ -478,18 +475,14 @@ static const char *controller_to_dirname(const char *controller) {
|
||||
controller = SYSTEMD_CGROUP_CONTROLLER_LEGACY;
|
||||
}
|
||||
|
||||
e = startswith(controller, "name=");
|
||||
if (e)
|
||||
return e;
|
||||
|
||||
return controller;
|
||||
return startswith(controller, "name=") ?: controller;
|
||||
}
|
||||
|
||||
static int join_path_legacy(const char *controller, const char *path, const char *suffix, char **fs) {
|
||||
static int join_path_legacy(const char *controller, const char *path, const char *suffix, char **ret) {
|
||||
const char *dn;
|
||||
char *t = NULL;
|
||||
|
||||
assert(fs);
|
||||
assert(ret);
|
||||
assert(controller);
|
||||
|
||||
dn = controller_to_dirname(controller);
|
||||
@@ -505,14 +498,14 @@ static int join_path_legacy(const char *controller, const char *path, const char
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
*fs = t;
|
||||
*ret = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int join_path_unified(const char *path, const char *suffix, char **fs) {
|
||||
static int join_path_unified(const char *path, const char *suffix, char **ret) {
|
||||
char *t;
|
||||
|
||||
assert(fs);
|
||||
assert(ret);
|
||||
|
||||
if (isempty(path) && isempty(suffix))
|
||||
t = strdup("/sys/fs/cgroup");
|
||||
@@ -525,34 +518,34 @@ static int join_path_unified(const char *path, const char *suffix, char **fs) {
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
*fs = t;
|
||||
*ret = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cg_get_path(const char *controller, const char *path, const char *suffix, char **fs) {
|
||||
int cg_get_path(const char *controller, const char *path, const char *suffix, char **ret) {
|
||||
int r;
|
||||
|
||||
assert(fs);
|
||||
assert(ret);
|
||||
|
||||
if (!controller) {
|
||||
char *t;
|
||||
|
||||
/* If no controller is specified, we return the path
|
||||
* *below* the controllers, without any prefix. */
|
||||
/* If no controller is specified, we return the path *below* the controllers, without any
|
||||
* prefix. */
|
||||
|
||||
if (!path && !suffix)
|
||||
return -EINVAL;
|
||||
|
||||
if (!suffix)
|
||||
if (isempty(suffix))
|
||||
t = strdup(path);
|
||||
else if (!path)
|
||||
else if (isempty(path))
|
||||
t = strdup(suffix);
|
||||
else
|
||||
t = path_join(path, suffix);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
*fs = path_simplify(t);
|
||||
*ret = path_simplify(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -563,13 +556,13 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
r = join_path_unified(path, suffix, fs);
|
||||
r = join_path_unified(path, suffix, ret);
|
||||
else
|
||||
r = join_path_legacy(controller, path, suffix, fs);
|
||||
r = join_path_legacy(controller, path, suffix, ret);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
path_simplify(*fs);
|
||||
path_simplify(*ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2134,7 +2134,6 @@ static int unit_update_cgroup(
|
||||
bool created, is_root_slice;
|
||||
CGroupMask migrate_mask = 0;
|
||||
_cleanup_free_ char *cgroup_full_path = NULL;
|
||||
uint64_t cgroup_id = 0;
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
@@ -2154,11 +2153,14 @@ static int unit_update_cgroup(
|
||||
created = r;
|
||||
|
||||
if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) {
|
||||
uint64_t cgroup_id = 0;
|
||||
|
||||
r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, NULL, &cgroup_full_path);
|
||||
if (r == 0) {
|
||||
r = cg_path_get_cgroupid(cgroup_full_path, &cgroup_id);
|
||||
if (r < 0)
|
||||
log_unit_warning_errno(u, r, "Failed to get cgroup ID on cgroup %s, ignoring: %m", cgroup_full_path);
|
||||
log_unit_full_errno(u, ERRNO_IS_NOT_SUPPORTED(r) ? LOG_DEBUG : LOG_WARNING, r,
|
||||
"Failed to get cgroup ID of cgroup %s, ignoring: %m", cgroup_full_path);
|
||||
} else
|
||||
log_unit_warning_errno(u, r, "Failed to get full cgroup path on cgroup %s, ignoring: %m", empty_to_root(u->cgroup_path));
|
||||
|
||||
@@ -2169,7 +2171,6 @@ static int unit_update_cgroup(
|
||||
(void) unit_watch_cgroup(u);
|
||||
(void) unit_watch_cgroup_memory(u);
|
||||
|
||||
|
||||
/* For v2 we preserve enabled controllers in delegated units, adjust others,
|
||||
* for v1 we figure out which controller hierarchies need migration. */
|
||||
if (created || !u->cgroup_realized || !unit_cgroup_delegate(u)) {
|
||||
|
||||
@@ -1588,6 +1588,7 @@ const sd_bus_vtable bus_unit_cgroup_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_PROPERTY("Slice", "s", property_get_slice, 0, 0),
|
||||
SD_BUS_PROPERTY("ControlGroup", "s", property_get_cgroup, 0, 0),
|
||||
SD_BUS_PROPERTY("ControlGroupId", "t", NULL, offsetof(Unit, cgroup_id), 0),
|
||||
SD_BUS_PROPERTY("MemoryCurrent", "t", property_get_current_memory, 0, 0),
|
||||
SD_BUS_PROPERTY("MemoryAvailable", "t", property_get_available_memory, 0, 0),
|
||||
SD_BUS_PROPERTY("CPUUsageNSec", "t", property_get_cpu_usage, 0, 0),
|
||||
|
||||
Reference in New Issue
Block a user