| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
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 个月前 | |
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 个月前 | |
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: fix send_command_over_stream() call arguments Root Cause Analysis: - The function send_command_over_stream() takes 8 arguments: (cmd_parts, io_mode, vm_keep_timeout_secs, extend_timeout_secs, env_vars, cwd, stdin, stream) - The call site passed 9 arguments with an extra bool daemon_keep_timeout.is_some() as the 3rd parameter - This was a leftover from a previous API that accepted bool Solution: - Remove the extra bool argument from both Windows and non-Windows function calls (send_command_over_named_pipe and send_command_over_stream) - Add #[allow(unused_imports)] for discover_vm_session export which is conditionally compiled for Linux without libkrun feature Fixes: make error[E0308]: mismatched types: expected &str, found &HashMap error[E0061]: this function takes 8 arguments but 9 arguments were supplied Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 | |
vm: fix session file to persist all vm start config (cpus, memory, timeout) ## Problem Test VM-9 failed: vm start with -s cpus=4 -s memory=2048 showed cpus=2, memory_mib=1024 in session file. Custom VM config was not persisted. ## Root Cause Analysis - register_vm_session_with_timeout() used VmConfig::default() and only set timeout - cpus and memory_mib from vm start CLI were lost - RunOptions has vm_cpus/vm_memory_mib but session registration ignored them ## Solution 1. Renamed register_vm_session_with_timeout -> register_vm_session_with_config 2. Added build_vm_config_from_run_options() helper to construct VmConfig from RunOptions 3. Updated all call sites to use full VmConfig: - timeout: run_options.vm_keep_timeout - cpus: run_options.vm_cpus (default 2) - memory_mib: run_options.vm_memory_mib (default 1024) - backend: vmm_order[0] or "libkrun" - extend: fixed default 10 ## Fixes: Test VM-9 - vm start custom parameters now persisted correctly Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 | |
vm: fix session file to persist actual timeout from vm start ## Problem Session file showed timeout=null when vm start with timeout=0 was called. register_vm_session_simple() used VmConfig::default() ignoring actual timeout. ## Root Cause Analysis - vm/start.rs:87 passed config.timeout to RunOptions.vm_keep_timeout - libkrun/core.rs called register_vm_session_simple() which used default config - VmConfig::default() has timeout=None, ignoring actual timeout value ## Solution 1. Renamed register_vm_session_simple -> register_vm_session_with_timeout 2. Added timeout parameter to the function 3. Updated all call sites to pass run_options.vm_keep_timeout 4. Session file now correctly persists timeout: - timeout=0: {"timeout": 0} (never timeout) - timeout=60: {"timeout": 60} (60s idle timeout) ## Fixes: epkg vm start --set timeout=0 session file showed {"timeout": null} Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 | |
vm: refactor env_name handling for vm subcommands Problem: - vm start/stop/status ENV parameter was treating ENV as potential path - env_name was being derived from env_root via get_env_name_from_path() which encodes the full path (e.g. /home/user/.epkg/envs/foo -> __home__user__.epkg__envs__foo) - This created mismatch between user-provided env_name and session file names Solution: - vm subcommands now accept ENV_NAME as parameter (consistent with -e option) - -r/--root global option is handled by parse_options_vm() in main.rs - env_name comes from config().common.env_name which is properly set by CLI parsing - Removed get_env_name_from_path() - env_name should always be explicit from user or config - VmReuseSession struct now stores env_name for efficient session cleanup Changes: - main.rs: add parse_options_vm() to handle vm subcommand options - vm/session.rs: simplify functions to use env_name parameter directly - vm/start.rs, stop.rs, status.rs: use config().common.env_name - libkrun/core.rs: pass env_name to session functions 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 个月前 |