From c88014834b6f0aacef23a38e06d38a80aa1c1d56 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Fri, 29 Mar 2024 19:45:12 +0800 Subject: [PATCH] kata-agent: enabling cgroups-v2 by systemd.unified_cgroup_hierarchy Configure the system to mount cgroups-v2 by default during system boot by the systemd system, We must add systemd.unified_cgroup_hierarchy=1 parameter to kernel cmdline, which will be passed by kernel_params in configuration.toml. To enable cgroup-v2, just add systemd.unified_cgroup_hierarchy=true[1] to kernel_params. Fixes: #9336 Signed-off-by: Alex Lyn --- src/agent/README.md | 4 ++-- src/agent/src/config.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/agent/README.md b/src/agent/README.md index 622cdfdc87..79dd4596c3 100644 --- a/src/agent/README.md +++ b/src/agent/README.md @@ -133,7 +133,7 @@ The kata agent has the ability to configure agent options in guest kernel comman | `agent.passfd_listener_port` | File descriptor passthrough IO listener port | Allow to set the file descriptor passthrough IO listener port | integer | `0` | | `agent.server_addr` | Server address | Allow the ttRPC server address to be specified | string | `"vsock://-1:1024"` | | `agent.trace` | Trace mode | Allow to static tracing | boolean | `false` | -| `agent.unified_cgroup_hierarchy` | `Cgroup hierarchy` | Allow to setup v2 cgroups | boolean | `false` | +| `systemd.unified_cgroup_hierarchy` | `Cgroup hierarchy` | Allow to setup v2 cgroups | boolean | `false` | > **Note:** Accepted values for some agent options > - `agent.config_file`: If we enable `agent.config_file` in guest kernel command line, @@ -145,7 +145,7 @@ The kata agent has the ability to configure agent options in guest kernel comman > - `agent.log`: "critical"("fatal" | "panic") | "error" | "warn"("warning") | "info" | "debug" > - `agent.server_addr`: "{VSOCK_ADDR}:{VSOCK_PORT}" > - `agent.trace`: true | false -> - `agent.unified_cgroup_hierarchy`: true | false +> - `systemd.unified_cgroup_hierarchy`: true | false For instance, you can enable the debug console and set the agent log level to debug by configuring the guest kernel command line in the configuration file: ```toml diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index e27d6fb2b6..4dfab4e670 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -24,7 +24,7 @@ const HOTPLUG_TIMOUT_OPTION: &str = "agent.hotplug_timeout"; const DEBUG_CONSOLE_VPORT_OPTION: &str = "agent.debug_console_vport"; const LOG_VPORT_OPTION: &str = "agent.log_vport"; const CONTAINER_PIPE_SIZE_OPTION: &str = "agent.container_pipe_size"; -const UNIFIED_CGROUP_HIERARCHY_OPTION: &str = "agent.unified_cgroup_hierarchy"; +const UNIFIED_CGROUP_HIERARCHY_OPTION: &str = "systemd.unified_cgroup_hierarchy"; const CONFIG_FILE: &str = "agent.config_file"; // Configure the proxy settings for HTTPS requests in the guest, @@ -625,28 +625,28 @@ mod tests { ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.hotplug_timeout=100 agent.unified_cgroup_hierarchy=a", + contents: "agent.devmode agent.debug_console agent.hotplug_timeout=100 systemd.unified_cgroup_hierarchy=a", debug_console: true, dev_mode: true, hotplug_timeout: time::Duration::from_secs(100), ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.hotplug_timeout=0 agent.unified_cgroup_hierarchy=11", + contents: "agent.devmode agent.debug_console agent.hotplug_timeout=0 systemd.unified_cgroup_hierarchy=11", debug_console: true, dev_mode: true, unified_cgroup_hierarchy: true, ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.container_pipe_size=2097152 agent.unified_cgroup_hierarchy=false", + contents: "agent.devmode agent.debug_console agent.container_pipe_size=2097152 systemd.unified_cgroup_hierarchy=false", debug_console: true, dev_mode: true, container_pipe_size: 2097152, ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.container_pipe_size=100 agent.unified_cgroup_hierarchy=true", + contents: "agent.devmode agent.debug_console agent.container_pipe_size=100 systemd.unified_cgroup_hierarchy=true", debug_console: true, dev_mode: true, container_pipe_size: 100, @@ -654,13 +654,13 @@ mod tests { ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.container_pipe_size=0 agent.unified_cgroup_hierarchy=0", + contents: "agent.devmode agent.debug_console agent.container_pipe_size=0 systemd.unified_cgroup_hierarchy=0", debug_console: true, dev_mode: true, ..Default::default() }, TestData { - contents: "agent.devmode agent.debug_console agent.container_pip_siz=100 agent.unified_cgroup_hierarchy=1", + contents: "agent.devmode agent.debug_console agent.container_pip_siz=100 systemd.unified_cgroup_hierarchy=1", debug_console: true, dev_mode: true, unified_cgroup_hierarchy: true,