systemd: Add support for managing cgroups through systemd

`SystemdCgroup` takes a `parent`, which is the name of a slice, and a
`unit`, which is the name of a slice or a scope unit, and provides methods
to start, kill the unit, as well as set properties for the unit.

The mods, `cpu`, `memory`, `cpuset`, and `pids`, are designed to generate
properties quickly. It hides the difference between cgroups v1 and v2, and
does simple checks for the systemd version and arguments.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
Xuewei Niu
2025-07-03 20:02:03 +08:00
parent 1250cbe182
commit 4a68c762e1
17 changed files with 1804 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# Systemd Dbus
How to generate `xxx_proxy.rs` files
```shell
# install zbus-xmlgen if not
$ cargo install zbus-xmlgen
# generate interface in XML format
$ busctl introspect --xml-interface \
org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager > /tmp/systemd1-manager.xml
# generate Rust code from XML
$ zbus-xmlgen file /tmp/systemd1-manager.xml \
--output src/systemd/dbus/systemd_manager_proxy.rs
$ rm -rf /tmp/systemd1-manager.xml
```