Skip to content

unable to compile krunkit with current main branch of libkrun #106

Description

@benoitf

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

  1. Remove krun_set_console_output from the extern "C" block in src/virtio.rs
  2. 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
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions