Compare commits

...

9 Commits

Author SHA1 Message Date
Bin Liu
7a7fd32e4f Merge pull request #168 from kata-containers/release-0.5.1
release: 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
4 changed files with 16 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
name: BVT
on: [pull_request]
env:
RUST_VERSION: 1.85.1
RUST_VERSION: 1.90.0
jobs:
build:
name: Build
@@ -35,4 +35,3 @@ jobs:
- run: rustup install ${{ env.RUST_VERSION }} && rustup default ${{ env.RUST_VERSION }}
- run: make test

View File

@@ -5,7 +5,7 @@ repository = "https://github.com/kata-containers/cgroups-rs"
keywords = ["linux", "cgroup", "containers", "isolation"]
categories = ["os", "api-bindings", "os::unix-apis"]
license = "MIT OR Apache-2.0"
version = "0.5.0"
version = "0.5.1"
authors = ["The Kata Containers community <kata-dev@lists.katacontainers.io>", "Levente Kurusa <lkurusa@acm.org>", "Sam Wilson <tecywiz121@hotmail.com>"]
edition = "2018"
homepage = "https://github.com/kata-containers/cgroups-rs"
@@ -17,7 +17,7 @@ nix = { version = "0.25.0", default-features = false, features = ["event", "fs",
libc = "0.2"
serde = { version = "1.0", features = ["derive"], optional = true }
thiserror = "1"
oci-spec = { version = "0.8.1", optional = true }
oci-spec = { version = "0.10.0", optional = true }
zbus = "5.8"
bit-vec = "0.6"

View File

@@ -1,15 +1,14 @@
# cgroups-rs ![Build](https://travis-ci.org/kata-containers/cgroups-rs.svg?branch=master)
Native Rust library for managing control groups under Linux
# cgroups-rs
Both v1 and v2 of cgroups are supported.
[![Crate](https://img.shields.io/crates/v/cgroups-rs.svg)](https://crates.io/crates/cgroups-rs)
# Examples
Native Rust library for managing Linux control groups. Supports both cgroups v1 and v2.
## Create a control group using the builder pattern
``` rust
## Examples
### Create a control group using the builder pattern
```rust
use cgroups_rs::*;
use cgroups_rs::cgroup_builder::*;
@@ -44,7 +43,7 @@ cg.delete();
// major version change.
```
# Disclaimer
## Disclaimer
This crate is licensed under:

View File

@@ -550,18 +550,18 @@ fn create_v2_cgroup(
// path: "a/b/c"
let elements = path.split('/').collect::<Vec<&str>>();
let last_index = elements.len() - 1;
// Build up the directory hierarchy element by element, enabling the controllers for all
// parents along the way.
for (i, ele) in elements.iter().enumerate() {
// ROOT/a
fp.push(ele);
// create dir, need not check if is a file or directory
if !fp.exists() {
if let Err(e) = std::fs::create_dir(fp.clone()) {
return Err(Error::with_cause(ErrorKind::FsError, e));
}
// create dir if necessary
if let Err(e) = std::fs::create_dir_all(fp.clone()) {
return Err(Error::with_cause(ErrorKind::FsError, e));
}
if i < last_index {
// enable controllers for substree
// enable controllers for subtree
enable_controllers(&controllers, &fp);
}
}