From ec444d213c336c225dff6c0431fae33a8e9b463b Mon Sep 17 00:00:00 2001 From: shell-skrimp <116320856+shell-skrimp@users.noreply.github.com> Date: Sun, 23 Jun 2024 20:24:35 +0000 Subject: [PATCH] Update manager.go Allow for setting properties Signed-off-by: shell-skrimp <116320856+shell-skrimp@users.noreply.github.com> --- cgroup2/manager.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cgroup2/manager.go b/cgroup2/manager.go index 0305471b..021af659 100644 --- a/cgroup2/manager.go +++ b/cgroup2/manager.go @@ -830,7 +830,7 @@ func dashesToPath(in string) string { return path } -func NewSystemd(slice, group string, pid int, resources *Resources) (*Manager, error) { +func NewSystemd(slice, group string, pid int, resources *Resources, properties []systemdDbus.Property) (*Manager, error) { if slice == "" { slice = defaultSlice } @@ -842,12 +842,14 @@ func NewSystemd(slice, group string, pid int, resources *Resources) (*Manager, e } defer conn.Close() - properties := []systemdDbus.Property{ - systemdDbus.PropDescription("cgroup " + group), - newSystemdProperty("DefaultDependencies", false), - newSystemdProperty("MemoryAccounting", true), - newSystemdProperty("CPUAccounting", true), - newSystemdProperty("IOAccounting", true), + if len(properties) == 0 { + properties = []systemdDbus.Property{ + systemdDbus.PropDescription("cgroup " + group), + newSystemdProperty("DefaultDependencies", false), + newSystemdProperty("MemoryAccounting", true), + newSystemdProperty("CPUAccounting", true), + newSystemdProperty("IOAccounting", true), + } } // if we create a slice, the parent is defined via a Wants=