following libkrun/libkrun#735 (review)
creating the issue there:
krunkit fails to build against libkrun main branch
Problem
krunkit cannot compile against libkrun's main branch due to a removed API symbol: krun_set_console_output.
The linker error:
Undefined symbols for architecture arm64:
"_krun_set_console_output", referenced from:
_$LT$krunkit..virtio..VirtioDeviceConfig$u20$as$u20$krunkit..virtio..KrunContextSet$GT$::krun_ctx_set::h71bc32d8d6465b25
Root Cause
libkrun commit ce4146d ("lib: remove krun_disable_implicit_console, krun_set_console_output, and implicit console") removed krun_set_console_output from
the library. This function was gated behind #[cfg(feature = "aws-nitro")] and its dependencies are Linux-only (target.'cfg(target_os = "linux")' in Cargo.toml), so it could never actually work on macOS.
However, krunkit unconditionally declares and calls it in src/virtio.rs:
- extern declaration (line 56):
fn krun_set_console_output(ctx_id: u32, c_filepath: *const c_char) -> i32;
- usage in
SerialConfig::krun_ctx_set() (lines 248-259): calls krun_set_console_output to redirect console output to a virtio-serial log file
Additional Notes
- Building against
stable-1.19.x works fine — that branch still exports the symbol.
- libkrun must also be built with
BLK=1 NET=1 flags to export krun_add_disk2, krun_add_net_unixgram, and krun_add_net_unixstream, which are behind cargo feature gates disabled by default.
- libkrun
main also removed implicit vsock creation (commit de84d01 "lib: remove krun_disable_implicit_vsock and implicit vsock creation"), requiring an
explicit krun_add_vsock() call before krun_add_vsock_port2(). krunkit does not currently make this call.
Suggested Fix
- Remove
krun_set_console_output from the extern "C" block in src/virtio.rs
- Gate
SerialConfig::krun_ctx_set() by platform:
#[cfg(target_os = "macos")]: log a warning and return Ok(()) (aws-nitro is Linux-only)
#[cfg(not(target_os = "macos"))]: keep the current implementation with a local extern block
- Add a
krun_add_vsock(ctx_id, 0) call in src/context.rs before configuring vsock ports, to support libkrun versions that removed implicit vsock
following libkrun/libkrun#735 (review)
creating the issue there:
krunkit fails to build against libkrun
mainbranchProblem
krunkit cannot compile against libkrun's
mainbranch due to a removed API symbol:krun_set_console_output.The linker error:
Undefined symbols for architecture arm64:
"_krun_set_console_output", referenced from:
_$LT$krunkit..virtio..VirtioDeviceConfig$u20$as$u20$krunkit..virtio..KrunContextSet$GT$::krun_ctx_set::h71bc32d8d6465b25
Root Cause
libkrun commit
ce4146d("lib: remove krun_disable_implicit_console, krun_set_console_output, and implicit console") removedkrun_set_console_outputfromthe library. This function was gated behind
#[cfg(feature = "aws-nitro")]and its dependencies are Linux-only (target.'cfg(target_os = "linux")'in Cargo.toml), so it could never actually work on macOS.However, krunkit unconditionally declares and calls it in
src/virtio.rs:fn krun_set_console_output(ctx_id: u32, c_filepath: *const c_char) -> i32;SerialConfig::krun_ctx_set()(lines 248-259): callskrun_set_console_outputto redirect console output to a virtio-serial log fileAdditional Notes
stable-1.19.xworks fine — that branch still exports the symbol.BLK=1 NET=1flags to exportkrun_add_disk2,krun_add_net_unixgram, andkrun_add_net_unixstream, which are behind cargo feature gates disabled by default.mainalso removed implicit vsock creation (commitde84d01"lib: remove krun_disable_implicit_vsock and implicit vsock creation"), requiring anexplicit
krun_add_vsock()call beforekrun_add_vsock_port2(). krunkit does not currently make this call.Suggested Fix
krun_set_console_outputfrom theextern "C"block insrc/virtio.rsSerialConfig::krun_ctx_set()by platform:#[cfg(target_os = "macos")]: log a warning and returnOk(())(aws-nitro is Linux-only)#[cfg(not(target_os = "macos"))]: keep the current implementation with a localexternblockkrun_add_vsock(ctx_id, 0)call insrc/context.rsbefore configuring vsock ports, to support libkrun versions that removed implicit vsock