From 17ef9bc420772a8aae99f765c7a3789d1305e38c Mon Sep 17 00:00:00 2001 From: Vanient Date: Mon, 28 Aug 2023 14:52:56 +0800 Subject: [PATCH] vmm-task:individually specify task.debug to enable debug_console Before this we reuse "task.log_level" to determine whether listening debug console port, which is not so good, individually specifying task.debug to enable debug_console is needed. Signed-off-by: Vanient --- ...o-run-kuasar-with-isulad-and-stratovirt.md | 38 +++++++++++++------ vmm/task/src/config.rs | 4 ++ vmm/task/src/main.rs | 3 +- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/docs/vmm/how-to-run-kuasar-with-isulad-and-stratovirt.md b/docs/vmm/how-to-run-kuasar-with-isulad-and-stratovirt.md index 6584d9b2..b22f659a 100644 --- a/docs/vmm/how-to-run-kuasar-with-isulad-and-stratovirt.md +++ b/docs/vmm/how-to-run-kuasar-with-isulad-and-stratovirt.md @@ -65,7 +65,7 @@ After installation, you will find the required files in the specified path ## Build and configure iSulad [iSulad](https://gitee.com/openeuler/iSulad) supports Kuasar with its dev-sandbox branch at the moment. For building iSulad from scratch, please refer to [iSulad build guide](https://gitee.com/openeuler/iSulad/blob/master/docs/build_docs/guide/build_guide.md). Here we only emphasize the difference of the building steps. - + ### Build LCR ```bash @@ -260,6 +260,32 @@ POD ID CREATED STATE NAME 5cbcf744949d8 About a minute ago Ready busybox-sandbox2 default 1 ``` +### Set up a debug console + +Kuasar vmm supports setting up a shell debug console by adding `task.debug` to kernel_params in config file, this requires the guest image to include /bin/bash. + +```toml +[hypervisor] + kernel_params = "task.debug" +``` + +After starting pod, get the `vsock guest-cid` from stratovirt vm process: + +```bash +$ ps -ef | grep stratovirt | grep 5cbcf744949d8 +/usr/bin/stratovirt -name sandbox-5cbcf744949d8500e7159d6bd1e3894211f475549c0be15d9c60d3c502c7ede3 ... +-device vhost-vsock-pci,id=vsock-395568061,guest-cid=395568061,bus=pcie.0,addr=0x3,vhostfd=3 +... +``` + +Then developers could enter the guest os debug console shell environment by: + +```bash +# ncat --vsock +# enter the guest os debug console shell +$ ncat --vsock 395568061 1025 +``` + ### Create and start container in the pod sandbox with config file Create a container in the podsandbox @@ -296,17 +322,7 @@ c11df540f913e docker.io/library/busybox:latest 2 minutes ago Runni ### Test Network Connectivity -Get the `vsock guest-cid` from stratovirt vm process -```bash -$ ps -ef | grep stratovirt | grep 5cbcf744949d8 -/usr/bin/stratovirt -name sandbox-5cbcf744949d8500e7159d6bd1e3894211f475549c0be15d9c60d3c502c7ede3 ... --device vhost-vsock-pci,id=vsock-395568061,guest-cid=395568061,bus=pcie.0,addr=0x3,vhostfd=3 -... -``` - -Enter the guest os debug console shell environment: ```bash -# ncat --vsock # enter the guest os debug console shell $ ncat --vsock 395568061 1025 diff --git a/vmm/task/src/config.rs b/vmm/task/src/config.rs index 81d19456..c614c7f3 100644 --- a/vmm/task/src/config.rs +++ b/vmm/task/src/config.rs @@ -19,6 +19,7 @@ use tokio::fs::read_to_string; const SHAREFS_TYPE: &str = "task.sharefs_type"; const LOG_LEVEL: &str = "task.log_level"; +const TASK_DEBUG: &str = "task.debug"; macro_rules! parse_cmdline { ($param:ident, $key:ident, $field:expr) => { @@ -40,6 +41,7 @@ macro_rules! parse_cmdline { pub struct TaskConfig { pub(crate) sharefs_type: String, pub(crate) log_level: String, + pub(crate) debug: bool, } impl Default for TaskConfig { @@ -47,6 +49,7 @@ impl Default for TaskConfig { TaskConfig { sharefs_type: "9p".to_string(), log_level: "info".to_string(), + debug: false, } } } @@ -62,6 +65,7 @@ impl TaskConfig { let param: Vec<&str> = p.split('=').collect(); parse_cmdline!(param, SHAREFS_TYPE, config.sharefs_type, String::from); parse_cmdline!(param, LOG_LEVEL, config.log_level, String::from); + parse_cmdline!(param, TASK_DEBUG, config.debug); } Ok(config) } diff --git a/vmm/task/src/main.rs b/vmm/task/src/main.rs index 85d938d3..713fe1c0 100644 --- a/vmm/task/src/main.rs +++ b/vmm/task/src/main.rs @@ -147,8 +147,7 @@ async fn main() { warn!("sharefs_type should be either 9p or virtiofs"); } } - // TODO reuse log_level temporarily, maybe we should have a config named by "task.debug" - if config.log_level == "debug" { + if config.debug { debug!("listen vsock port 1025 for debug console"); if let Err(e) = listen_debug_console("vsock://-1:1025").await { error!("failed to listen debug console port, {:?}", e);