300 Commits

Author SHA1 Message Date
Xuewei Niu
799d02d266 Merge pull request #169 from kata-containers/ci/test-cgroup-v1-v2
ci: Test cgroup v1 and v2 in QEMU
2026-07-30 15:08:59 +08:00
Xuewei Niu
c2abd0229d ci: Test cgroup v1 and v2 in QEMU
Run the complete test suite in pinned Ubuntu guests so cgroupfs and
systemd coverage does not depend on the GitHub runner's hierarchy.
Cross-compile static test binaries on the host to keep TCG execution
practical.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2026-07-28 06:23:16 -05:00
Xuewei Niu
091d694c00 tests: Make cgroup tests hierarchy-aware
Resolve cgroup filesystem paths according to the active hierarchy and
assert systemd's expected cgroup v1 limitations. This lets the existing
manager and D-Bus tests run in both guest modes without changing library
behavior.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2026-07-28 06:11:17 -05:00
Bin Liu
7a7fd32e4f Merge pull request #168 from kata-containers/release-0.5.1
release: v0.5.1
v0.5.1
2026-07-14 18:04:33 +08:00
Xuewei Niu
3961c4b0dd release: v0.5.1
Changes since v0.5.0:

* 7cd1cda Fix race condition in create_v2_cgroup
* 0d10296 ci: bump Rust toolchain to 1.90.0
* a32f96e build: Bump oci-spec to 0.10.0
* 3eeab4e docs: improve README formatting and badges

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2026-07-14 04:51:40 -05:00
Xuewei Niu
fdcf75b27b Merge pull request #166 from burgerdev/fix-cgroup-create-race
Fix race condition in create_v2_cgroup
2026-07-14 17:00:41 +08:00
Markus Rudy
7cd1cda42f Fix race condition in create_v2_cgroup
There used to be a race condition while creating the cgroup hierarchy:
if a parent directory was created after .exists() but before
.create_dir, the function failed unnecessarily.

This commit changes the function to use create_dir_all, which is the
atomic variant of the above pattern, and fixes some surrounding
docstrings on the way.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2026-07-13 14:31:03 +02:00
Tim Zhang
0236d210d5 Merge pull request #167 from zvonkok/bump-oci-spec
build: Bump oci-spec to 0.10.0
2026-07-10 12:02:56 +08:00
Tim Zhang
0d1029646c ci: bump Rust toolchain to 1.90.0
New zbus and zvariant releases require a newer Rust compiler.

Use Rust 1.90.0 in CI so dependency resolution can complete.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2026-07-10 12:00:01 +08:00
Zvonko Kaiser
a32f96e473 build: Bump oci-spec to 0.10.0
cgroups-rs exposes oci-spec types in its public API (e.g.
Manager::set() takes &LinuxResources), so the version pinned here
dictates which oci-spec version every consumer must use: 0.x lines
are semver-incompatible, and a consumer on a newer oci-spec gets
"expected LinuxResources, found LinuxResources" type mismatches.

Kata Containers is moving its workspace to oci-spec 0.10.0 and
cannot call into cgroups-rs until this crate follows. The 0.8 to
0.10 changes are additive for everything cgroups-rs touches (no
code changes needed): the crate builds warning-free with the oci
feature and the unit tests pass (the only failures are the
pre-existing fs manager tests that need root to write cgroupfs).

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 21:18:34 +00:00
Tim Zhang
acad18f4a5 Merge pull request #162 from gaius-qi/feature/readme
docs: update README with badges and formatting
2026-02-03 14:38:00 +08:00
Gaius
3eeab4ef1c docs: improve README formatting and badges
- Add crates.io badge
- Simplify header and description
- Fix markdown heading levels (# -> ##)
- Fix code block language annotation spacing
- Remove redundant blank lines

Signed-off-by: Gaius <gaius.qi@gmail.com>
2026-02-02 22:26:06 +08:00
Alex Lyn
b99114bf40 Merge pull request #161 from Tim-Zhang/release-0.5.0
release: v0.5.0
v0.5.0
2025-11-21 10:41:36 +08:00
Tim Zhang
f44ae5d4da release: v0.5.0
Bump major(minor actually) version for incompatible changes in #154.

Changelog:
- #152
- #154
- #159

Signed-off-by: Tim Zhang <tim@hyper.sh>
2025-11-21 10:31:47 +08:00
Tim Zhang
cf4c62dd34 Merge pull request #159 from Lu-yq/fix-verify-path
cgroups-rs: fix verify_path() logic
2025-11-21 10:24:26 +08:00
Lu-yq
c1a99fff50 cgroups-rs: fix verify_path() logic
remove the verify_path() logic because the
semantics change of controller.base.

Signed-off-by: Lu-yq <443471302@qq.com>
2025-11-21 01:26:26 +08:00
Xuewei Niu
6a11b32b64 Merge pull request #152 from jokemanfire/dev
fix(Controller): Errors are hidden by default
2025-11-20 19:18:36 +08:00
jokemanfire
a30729bcf1 fix(Controller): Errors are hidden by defaul
Fixed an error hidden during the creation of cgroup,
which resulted in subsequent error propagation

Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
2025-11-20 19:09:55 +08:00
Tim Zhang
69e3897a6d Merge pull request #154 from justxuewei/systemd-version
systemd: Do not check systemd version
2025-08-08 11:19:32 +08:00
Xuewei Niu
c49bee218f systemd: Do not check systemd version
The systemd version is purely informational and should not be parsed, as
documented in the [1]. In practice, systemd version has different formats
on OpenShift and Ubuntu.

This commit skips the version check and allows all operations. The errors
will be thrown from dbus when performing unsupported operations on obsolete
versions of systemd.

1: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.systemd1.html

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-08-07 15:05:53 +08:00
Fupan Li
5d74a1dfc9 Merge pull request #150 from Tim-Zhang/release-v0.4.0
release: v0.4.0
v0.4.0
2025-07-22 18:19:27 +08:00
Tim Zhang
daa71aca91 release: v0.4.0
Changelog:
- #148
- #149

Signed-off-by: Tim Zhang <tim@hyper.sh>
2025-07-22 18:11:47 +08:00
Fupan Li
fefbdc8665 Merge pull request #148 from kata-containers/manager
Introduce FsManager and SystemdManager
2025-07-22 17:37:55 +08:00
Xuewei Niu
c774e9e123 manager: Add unit test cases
The tests cover the methods of `conv` mod, `FsManager`, and
`SystemdManager`. Since we have to manipulate the cgroups during testing,
the tests related to this part are set to be run in sequence.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-18 15:17:12 +08:00
Xuewei Niu
d69517847b systemd: Add unit test cases
The tests cover `SystemdClient` and methods from `utils` mods.

Please note that the `SystemdClient` tests do not run well in parallel, but
work well in sequence. Please run them with `--test-threads=1`.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-18 15:17:12 +08:00
Xuewei Niu
0c26caecfc manager: Introduce SystemdManager
Systemd manager takes cgroups path in the format of
"parent:scope_prefix:name" to create and manipulate cgroups through
systemd. It does value conversions for resources defined in the Linux
resources from the OCI spec, such as CPU quota, period, etc.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-18 15:17:12 +08:00
Xuewei Niu
4a68c762e1 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>
2025-07-18 15:17:12 +08:00
Xuewei Niu
1250cbe182 manager: Introduce FsManager
`Manager` is a trait to unify the interface of cgroups. It is designed for
OCI containers. Its `set()` takes Linux resources of the OCI spec to set
cgroups.

The `FsManager`, the concrete implementation of `Manager`, manipulates
cgroups through cgroupfs, and supports both cgroups v1 and v2.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-18 15:17:12 +08:00
Xuewei Niu
b8031f1a21 fs: Move all files to fs subdirectory
Prepare to implement FsManager, which should be done in the following-up
commits. Apart from that, no code is not modified.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-18 15:17:12 +08:00
Fabiano Fidêncio
6e273cd2fb Merge pull request #149 from kata-containers/bump-rust
Bump Rust version to 1.85.1
2025-07-09 09:37:32 +02:00
Xuewei Niu
bce4b0bb3b Fix the warning about config file
The cargo complaints that ".cargo/config" is deprecated in favor of
".cargo/config.toml". Therefore, the file is renamed to it to make cargo
happy.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-08 23:56:57 +08:00
Xuewei Niu
f5a67c632e Fix the issues that makes cargo clippy unhappy
Most of the issues are small, but `fold()`. The usage of `fold()` in these
cases confuses me a lot, so that I don't follow the sugguestions from
clippy to replace `fold()` with `try_fold()`. Instead, I replace them with
`map() + collect()`.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-08 23:56:55 +08:00
Xuewei Niu
c8febbc67d .github: Bump Rust version to 1.85.1
Rust 1.69.0, released in 2023, lags significantly behind the version used
by Kata Containers. Therefore, we bump it to 1.85.1.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2025-07-08 17:07:52 +08:00
Fupan Li
2536e33696 Merge pull request #143 from oguzbilgener/no-regex
refactor: Parse HugeTLB size without Regex
2025-06-12 10:23:34 +08:00
Oguz Bilgener
694627e2fc refactor: Parse HugeTLB size without Regex
This removes the only place the regex crate is used, which could lead to significant binary size savings in projects that don't use the regex craate.

Signed-off-by: Oguz Bilgener <oguz@bilgener.me>
2025-05-29 11:05:53 -04:00
Fupan Li
de9625ff57 Merge pull request #146 from fidencio/topic/release-v0.3.5
release: v0.3.5
v0.3.5
2025-05-29 16:33:54 +08:00
Fupan Li
b6b65f79d1 Merge pull request #141 from michelhe/remove-outdated-docs
hierarchies: Remove outdated documentation
2025-05-29 16:31:55 +08:00
Fupan Li
547fb08c03 Merge pull request #140 from jokemanfire/dev
fix bug: if cgroup path has ":"
2025-05-29 16:31:14 +08:00
Fupan Li
ec9f3547ed Merge pull request #135 from zzzzzzzzzy9/pull-branch
rdma: read rdma.max file
2025-05-29 16:30:09 +08:00
Michel Heily
82a6aa491a hierarchies: Remove outdated documentation
The documentation in the hierarchies module is outdated, this project
does support cgroups2 and the unified hierarchy :)

Signed-off-by: Michel Heily <michelheily@gmail.com>
2025-05-29 10:21:27 +02:00
zzzzzzzzzy9
65c36214b7 rdma: read rdma.max file
This is a simple one, just support rdma.max.

Signed-off-by: zzzzzzzzzy9 <zhang.yu58@zte.com.cn>
Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-29 10:12:10 +02:00
Fabiano Fidêncio
e0d0b8f4bc release: v0.3.5
There are several fixes since the last release, and itś been a few years
waiting for a new one.

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-29 08:53:03 +02:00
Fabiano Fidêncio
db822470e5 Merge pull request #116 from xueruini/fix-mem-panic
Use default memory stats instead of panic.
2025-05-29 08:14:51 +02:00
Fabiano Fidêncio
362373b3ec memory: Fix test_procs_iterator_cgroup test
Otherwise it simply breaks.

Signed-off-by: Alex Man <alexman@stripe.com>
Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-28 23:02:04 +02:00
Ruini Xue
eadbf53140 memory: Use default memory stats instead of panic.
When containers are terminated, cgroup v2 memory metrics under
/sys/fs/cgroup may disappear.  Previously, kata-agent assumed these
metrics always exist, leading to panics as reported in
kata-containers#138.

This commit returns default value (0) when memory metric files are
missing.  This behaviour aligns with cgroup v1, which also defaults to 0
memory metric files are missing:
- Memory.limit_in_bytes which maps to m.max
  https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635
- Memory.soft_limit_in_bytes which maps to m.low
  https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661
- MemSwap.fail_cnt:
  https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631

Signed-off-by: Ruini Xue <ruini.xue@gmail.com>
Signed-off-by: Alex Man <alexman@stripe.com>
Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-28 23:02:04 +02:00
Fabiano Fidêncio
b3c57840ee lib: Ignore dead_code warning
I'm not fmiliar with this crate, so let's just ignore the warning for
now instead of removing the code.

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-28 23:02:04 +02:00
Fabiano Fidêncio
b10e52d85f Merge pull request #133 from nxfs/controllers-parsing
controllers parsing is resilient to trailing newline
2025-05-28 22:44:03 +02:00
jokemanfire
7d4d4579a3 fix bug: if cgroup path has ":"
This bug is occur in cgroup path "which has :"

Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
2024-11-02 20:23:48 +08:00
Tim Zhang
eb3e37a4bc Merge pull request #132 from aa624545345/collect-cgroup-path
Correct path of cgroup when running a container in a container
2024-05-13 17:38:52 +08:00
乔琛 10307740
4005ad844d cgroup: collect path of cgroup when running a container in a container
Path of cgroup is wrong when running a container in a container. Use
the root path of mountinfo fetched from /proc/$(shim_pid)/mountinfo
to trim the path obtained from /proc/self/mountinfo.

Fixes: #131

Signed-off-by: 乔琛 10307740 <qiao.chen@zte.com.cn>
2024-04-16 16:40:05 +08:00