Skip to content

Commit

Permalink
Merge pull request #47 from abel-von/support-wasmtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Burning1020 authored and Vanient committed Aug 28, 2023
2 parents 4860bba + 46c7e87 commit 7edfca0
Show file tree
Hide file tree
Showing 12 changed files with 1,970 additions and 102 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
checks:
strategy:
matrix:
directories: [vmm/sandbox, vmm/task, shim, wasm, quark]
directories: [vmm/sandbox, vmm/task, shim, quark]
features: [--all-features]
include:
- directories: wasm
features: --features=wasmedge
wasmEdge: 0.11.2
- directories: wasm
features: --features=wasmtime
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -31,25 +35,28 @@ jobs:
run: curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v ${{ matrix.wasmEdge }} >> /dev/null
- name: Check
working-directory: ${{ matrix.directories }}
run: cargo check --examples --tests --all-features
run: cargo check --examples --tests ${{ matrix.features }}
- name: Nightly fmt
working-directory: ${{ matrix.directories }}
run: cargo +nightly fmt --all -- --check
- name: Clippy
working-directory: ${{ matrix.directories }}
run: cargo clippy --all-features -- -D warnings
run: cargo clippy ${{ matrix.features }} -- -D warnings
- name: Deny
working-directory: ${{ matrix.directories }}
run: cargo install cargo-deny && cargo deny -L warn --all-features check

run: cargo install cargo-deny && cargo deny -L warn ${{ matrix.features }} check

tests:
strategy:
matrix:
directories: [ vmm/sandbox, vmm/task, shim, wasm, quark ]
directories: [vmm/sandbox, vmm/task, shim, quark]
features: [--all-features]
include:
- directories: wasm
features: --features=wasmedge
wasmEdge: 0.11.2
- directories: wasm
features: --features=wasmtime
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -66,4 +73,4 @@ jobs:
env:
RUST_BACKTRACE: full
working-directory: ${{ matrix.directories }}
run: sudo -E $(command -v cargo) test --all-features
run: sudo -E $(command -v cargo) test ${{ matrix.features }}
27 changes: 27 additions & 0 deletions docs/vmm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,33 @@ Jul 13 15:33:41 node vmm-sandboxer[3619585]: [2023-07-13T07:33:41.644358Z ERROR
Jul 13 15:33:41 node vmm-sandboxer[3619585]: [2023-07-13T07:33:41.742550Z INFO containerd_sandbox::rpc] shutdown sandbox 31e668050c2031e9e7243720eaa8264c42b0283007e419948689cac2badb71cd
```

# Developer Guide

## 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 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 <guest-cid> <debug-console>
$ ncat --vsock 395568061 1025
```

# Note

Please note that this guide only teach you how to build kuasar from source code, if you want to run the kuasar, cloud hypervisor and virtiofsd are also needed!
4 changes: 4 additions & 0 deletions vmm/task/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -40,13 +41,15 @@ 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 {
fn default() -> Self {
TaskConfig {
sharefs_type: "9p".to_string(),
log_level: "info".to_string(),
debug: false,
}
}
}
Expand All @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions vmm/task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 7edfca0

Please sign in to comment.