| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
libkrun: increase vsock bridge connection retry count Problem: - connect_vsock_bridge() with max_retries=5 and 5ms delay gave only 25ms total wait time, insufficient for VM startup (~1-3 seconds) - Test failures: "Failed to connect to named pipe after 5 retries" Solution: - Keep original 5ms retry delay (simple, low latency) - Increase max_retries from 5 to 300 (defined as VSOCK_BRIDGE_MAX_RETRIES) giving ~1.5 seconds total wait time for VM startup Changes: 1. Define VSOCK_BRIDGE_MAX_RETRIES=300 constant in bridge.rs 2. Use constant in all connect_vsock_bridge() callers: - libkrun/core.rs: connect_to_existing_vm_socket() - libkrun/stream.rs: connect for batch mode - vm/stop.rs: send_session_done_windows() Test script fixes (simplified, no capture_with_retry needed): - Simplify Test 10: use trap setup test instead of kill -TERM - Increase vm start timeout to 120s with fallback check for VM-1/VM-9 Fixes: intermittent VM connection failures Results: All 34 tests pass Signed-off-by: Wu Fengguan <wfg@mail.ustc.edu.cn> | 3 个月前 | |
libkrun: split build_kernel_args() from build_libkrun_config() Problem/Purpose: build_libkrun_config() was too long (~273 lines), making it hard to read and maintain. The kernel cmdline building logic was the largest block (~165 lines) with multiple platform-specific branches. Solution: - Extract kernel cmdline building logic into build_kernel_args() - New function handles: base cmdline, user args, init_cmd, RUST_LOG, TSI, host OS env vars, init_pwd, virtiofs mounts - build_libkrun_config() now calls build_kernel_args() and focuses on vsock mode setup, guest command, kernel path/format Result: - build_libkrun_config(): 273 lines → ~110 lines - build_kernel_args(): ~170 lines (new) - Cleaner function separation, easier to navigate and modify Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 | |
vm: unify lifecycle management with vm_keep_timeout and remove reuse_vm/vm_reuse_connect ## Problem/Purpose The reuse_vm and vm_reuse_connect flags had confusing semantics that made the code hard to understand and maintain. VM lifecycle control was scattered across multiple flags and conditional checks. ## Background/Context Session file is the cross-process coordination mechanism. When a VM session exists, it MUST be reused ("能reuse就必须reuse"). The VM lifecycle is independent from epkg run lifecycle (VM lifecycle >= epkg run). ## Solution Unified VM lifecycle control through vm_keep_timeout (Option<u32>): - None: VM shuts down immediately after command completes - Some(0): VM never times out (persistent) - Some(N) > 0: VM shuts down after N seconds idle Key changes: 1. Changed VmConfig.timeout from u32 to Option<u32> 2. Removed reuse_vm and vm_reuse_connect fields from RunOptions 3. Removed --reuse CLI flag (reuse is now always attempted) 4. Made session file registration UNCONDITIONAL for cross-process discovery 5. Guest daemon decides lifecycle based solely on vm_keep_timeout_secs 6. Removed unused functions: is_vm_reuse_active_for_env, send_command_to_running_qemu_guest ## Usage - epkg run --isolate=vm /bin/ls: VM shuts down immediately (timeout=None) - epkg run --isolate=vm --vm-keep-timeout=30 /bin/ls: VM idle 30s then shutdown - epkg vm start --set timeout=60: VM persistent for 60s idle timeout - epkg vm start --set timeout=0: VM never shuts down until manual stop - Concurrent epkg run automatically discovers and reuses existing session Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 | |
libkrun: pass terminal size to guest PTY on command start Problem: - libkrun's build_command_request() was missing terminal field - Guest PTY started with default size (24x80) instead of host terminal size - $LINES/$COLUMNS showed wrong values in guest shell - vm/client.rs used Term::size() which returns default (24,80) when unavailable Solution: - Add terminal field to build_command_request() in libkrun/stream.rs - Use Term::size_checked() instead of Term::size() to avoid default values - Only set terminal when actual size can be determined from TTY Files changed: - src/libkrun/stream.rs: add terminal field for PTY mode - src/vm/client.rs: use size_checked() to avoid defaults Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 |