kata-types: emit agent.debug_console_shell on the guest cmdline

Add a debug_console_shell field to the [agent] config and, when it is set,
inject agent.debug_console_shell=<path> onto the guest kernel cmdline next to
the existing debug_console options. This is how the runtime-rs shims tell the
guest agent which shell the debug console should exec (the agent added support
for the option and its extension-prefix guard in a previous commit).

An empty value is not emitted, so default configurations are unchanged.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Fabiano Fidêncio
2026-07-22 19:15:58 +02:00
parent 5ad8a4c8e3
commit cab005483d
2 changed files with 38 additions and 0 deletions

View File

@@ -93,6 +93,12 @@ pub struct Agent {
#[serde(default)]
pub debug_console_enabled: bool,
/// Guest path of the shell the debug console execs; empty uses the agent's
/// built-in candidates (/bin/bash, /bin/sh). The agent only honors it if it
/// resolves under /run/kata-extensions/ (a guest extension mount).
#[serde(default)]
pub debug_console_shell: String,
/// When enabled, the agent translates a container's VISIBLE_CDI_DEVICES
/// environment variable into CDI GPU device requests (nvidia.com/gpu) so
/// that the container sees the matching GPUs present in the VM.
@@ -186,6 +192,7 @@ impl std::default::Default for Agent {
log_level: "info".to_string(),
enable_tracing: false,
debug_console_enabled: false,
debug_console_shell: String::new(),
visible_cdi_devices: false,
server_port: DEFAULT_AGENT_VSOCK_PORT,
log_port: DEFAULT_AGENT_LOG_PORT,

View File

@@ -53,6 +53,8 @@ pub const LOG_LEVEL_OPTION: &str = "agent.log";
pub const LOG_LEVEL_DEBUG: &str = "debug";
/// Option of which port will the debug console connect to
pub const DEBUG_CONSOLE_VPORT_OPTION: &str = "agent.debug_console_vport";
/// Option selecting the guest shell the debug console execs
pub const DEBUG_CONSOLE_SHELL_OPTION: &str = "agent.debug_console_shell";
/// Option of which port the agent's log will connect to
pub const LOG_VPORT_OPTION: &str = "agent.log_vport";
/// Option of setting the container's pipe size
@@ -248,6 +250,12 @@ impl TomlConfig {
DEFAULT_AGENT_DBG_CONSOLE_PORT.to_string(),
);
}
if !cfg.debug_console_shell.is_empty() {
kv.insert(
DEBUG_CONSOLE_SHELL_OPTION.to_string(),
cfg.debug_console_shell.clone(),
);
}
if cfg.visible_cdi_devices {
kv.insert(VISIBLE_CDI_DEVICES_OPTION.to_string(), "true".to_string());
}
@@ -504,6 +512,7 @@ mod tests {
enable_tracing: true,
container_pipe_size: 20,
debug_console_enabled: true,
debug_console_shell: "/run/kata-extensions/devkit/bin/devkit-sh".to_string(),
launch_process_timeout: 60,
visible_cdi_devices: true,
..Default::default()
@@ -518,7 +527,29 @@ mod tests {
assert_eq!(kv.get("agent.container_pipe_size").unwrap(), "20");
kv.get("agent.debug_console").unwrap();
assert_eq!(kv.get("agent.debug_console_vport").unwrap(), "1026"); // 1026 is the default port
assert_eq!(
kv.get("agent.debug_console_shell").unwrap(),
"/run/kata-extensions/devkit/bin/devkit-sh"
);
assert_eq!(kv.get("agent.launch_process_timeout").unwrap(), "60");
assert_eq!(kv.get("agent.visible_cdi_devices").unwrap(), "true");
}
#[test]
fn test_get_agent_kernel_params_no_debug_console_shell() {
let mut config = TomlConfig {
..Default::default()
};
let agent_config = Agent {
debug_console_enabled: true,
..Default::default()
};
let agent_name = "test_agent";
config.runtime.agent_name = agent_name.to_string();
config.agent.insert(agent_name.to_owned(), agent_config);
// An empty debug_console_shell must not be emitted on the cmdline.
let kv = config.get_agent_kernel_params().unwrap();
assert!(kv.get("agent.debug_console_shell").is_none());
}
}