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>
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>
When compiling for a musl target, use the same CGROUP2_SUPER_MAGIC
constant that we use for other linux targets
Signed-off-by: Andrés Medina <andresnrx@gmail.com>
When setting memory.max/memory.swap.max in cgroup v2, Linux uses "max"
instead of "-1" to indicate no restriction on memory usage. The
set_limit and set_memswap_limit functions of the memory controller
accept i64 as a parameter. In cgroupv2, if the parameter is -1, "max"
should be written into the cgroup file.
Fixes#128
Signed-off-by: mengze <mengze@linux.alibaba.com>
Kernel 5.19 introduces `memory.peak` and kernel 6.5 introduces
`memory.swap.peak` to expose the memory and swap usage watermark.
This change use these values to fill `max_usage_in_bytes`.
Signed-off-by: HeRaNO <heran55@126.com>
The included patches are
- 89edba0f85: gha: Bump Rust version to 1.69.0
- 66a93b1c3d: devices: Throw an error if device resources are invalid
- 55505e0b3e: Minor changes for cgroup and devices subsystem
- 0b6b229a38: add .path() method
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
The changes include:
- Expose `create()` and add `exists()` for `Cgroup`: The changes
are allowed to load cgroup and test if the cgroup exists. If not exists,
performing the `create()` directly to avoid performing `new()`.
- Make path of devices cgroup error more details: The origin path is
either `devices.allow` or `devices.deny`. It not shows which cgroup it
belongs to.
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
The cgroup-rs should throw errors while setting devices cgroup if the rule
is invalid. For example, if a cgroup has permissions of some devices. Then
we set a `a *:* rwm` to its parent's `devices.deny`. An error should be
thrown to make users realize that it is a invalid rule.
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
Determine the cgroup mode in add_task() to avoid the wrong operation of the caller writing threads to cgroup.threads in non-thread mode.
Fixes: #103
Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
Some system has the `Discard` field in io service data, current the
library can't handle it correctly.
With this commit the blkio can get metrics whether it has the discard field.
Fixes: #109
Signed-off-by: bin liu <liubin0329@gmail.com>
Fixes: #98
Add a Kill method for cgroups v2. This uses the new functionality in
kernels 5.14+ where writing to a cgroup.kill file will send a SIGKILL
to every process running in the cgroup. This would be useful for
kata to avoid freezing+manually sending SIGKILL+thawing process it
does currently to emulate runc's behavior.
Signed-off-by: Danny Canter <danny@dcantah.dev>
Support to set threaded mode in cgroup v2. The premise of switching to threaded mode is that only the cgroup of cpuset, cpu and pids is supported.
Fixes: #90
Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
For some cgroup file operations, when failed, add the path
and the value (for write operation) to the error message.
Fixes: #93
Signed-off-by: bin liu <liubin0329@gmail.com>