diff --git a/.github/workflows/hyperlight-e2e.yml b/.github/workflows/hyperlight-e2e.yml index db1a1758..5a2fa66a 100644 --- a/.github/workflows/hyperlight-e2e.yml +++ b/.github/workflows/hyperlight-e2e.yml @@ -67,10 +67,10 @@ jobs: $pyhlHome = Join-Path $env:LOCALAPPDATA "pyhl" New-Item -ItemType Directory -Force -Path $pyhlHome | Out-Null - .\crane.exe export ghcr.io/danbugs/hyperlight-unikraft/python-agent-driver-kernel:latest kernel.tar + .\crane.exe export ghcr.io/hyperlight-dev/hyperlight-unikraft/python-agent-driver-kernel:latest kernel.tar tar -xf kernel.tar -C $pyhlHome kernel - .\crane.exe export ghcr.io/danbugs/hyperlight-unikraft/python-agent-driver-initrd:latest initrd.tar + .\crane.exe export ghcr.io/hyperlight-dev/hyperlight-unikraft/python-agent-driver-initrd:latest initrd.tar tar -xf initrd.tar -C $pyhlHome initrd.cpio Write-Host "Downloaded to ${pyhlHome}:" diff --git a/src/Cargo.lock b/src/Cargo.lock index c628f40a..7c120415 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -844,15 +844,17 @@ dependencies = [ [[package]] name = "hyperlight-unikraft-host" version = "0.1.0" -source = "git+https://github.com/hyperlight-dev/hyperlight-unikraft?branch=main#a72768132b699176ac348f5d2d1765f3ed62a061" +source = "git+https://github.com/hyperlight-dev/hyperlight-unikraft?branch=main#8affbccb1f7a2f9aa0c8e0aea08c82f76b45bbe5" dependencies = [ "anyhow", "base64", "clap", "hyperlight-host", + "libc", "memmap2", "nix", "serde_json", + "windows-sys", ] [[package]] diff --git a/src/wxc_common/src/hyperlight_runner.rs b/src/wxc_common/src/hyperlight_runner.rs index e0c14991..37a3f52e 100644 --- a/src/wxc_common/src/hyperlight_runner.rs +++ b/src/wxc_common/src/hyperlight_runner.rs @@ -63,8 +63,10 @@ //! //! ## Exit codes //! -//! 0 on clean `run_code` completion, -1 on any error (preflight, install, -//! runtime, guest crash). The specific failure mode is in `error_message`. +//! Guest exit code on clean `run_code` completion (0 for normal exit, +//! non-zero for `sys.exit(N)` or unhandled exceptions), -1 on any +//! runner error (preflight, install, runtime, guest crash). The specific +//! failure mode is in `error_message`. use std::path::{Path, PathBuf}; @@ -474,11 +476,11 @@ impl ScriptRunner for HyperlightScriptRunner { match rt.run_code(&request.script_code) { Ok(timing) => { logger.log_line(&format!( - "hyperlight: run ok (restore={:.1}ms call={:.1}ms)", - timing.restore_ms, timing.call_ms + "hyperlight: run ok (restore={:.1}ms call={:.1}ms exit={})", + timing.restore_ms, timing.call_ms, timing.exit_code )); ScriptResponse { - exit_code: 0, + exit_code: timing.exit_code, ..Default::default() } } diff --git a/src/wxc_e2e_tests/tests/e2e_windows.rs b/src/wxc_e2e_tests/tests/e2e_windows.rs index a6369777..b911ece5 100644 --- a/src/wxc_e2e_tests/tests/e2e_windows.rs +++ b/src/wxc_e2e_tests/tests/e2e_windows.rs @@ -596,6 +596,12 @@ fn hyperlight_suite() { expected_exit: 0, output_contains: Some("'x':"), }, + HyperlightCase { + config: "hyperlight_exit_code.json", + description: "sys.exit(42) propagates exit code", + expected_exit: 42, + output_contains: None, + }, ]; let mut failures = Vec::new(); diff --git a/test_configs/hyperlight_exit_code.json b/test_configs/hyperlight_exit_code.json new file mode 100644 index 00000000..50f4f0de --- /dev/null +++ b/test_configs/hyperlight_exit_code.json @@ -0,0 +1,7 @@ +{ + "process": { + "commandLine": "import sys; sys.exit(42)", + "timeout": 30000 + }, + "containment": "hyperlight" +}