Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fdbbd47
virtio/fs: extract init binary blob into its own crate
mtjhrc May 12, 2026
66d7e99
virtio/fs: introduce InodeAllocator for shared inode numbering
mtjhrc May 12, 2026
614a504
virtio/fs: introduce generic AugmentFs overlay for files like init.krun
mtjhrc May 12, 2026
6d17493
lib: add krun_disable_implicit_init()
mtjhrc May 12, 2026
3ab23ad
lib: add krun_fs_add_overlay_file(), krun_fs_add_overlay_dir() APIs
mtjhrc May 12, 2026
3f57196
lib: add krun_get_default_init()
mtjhrc May 12, 2026
3f85d98
libkrun.h: document that implicit resource creation will become opt-in
mtjhrc May 12, 2026
60e878c
virtio/fs: add NullFs, a minimal empty-root FileSystem
mtjhrc May 12, 2026
32c3d0c
lib: rewrite krun_set_root_disk_remount to use NullFs
mtjhrc May 12, 2026
d0d2764
virtio/fs: remove REMOVE_ROOT_DIR ioctl and allow_root_dir_delete
mtjhrc May 12, 2026
fdeab1c
virtio/fs: move EXIT_CODE ioctl to AugmentFs
mtjhrc May 12, 2026
00b5bdd
tests: add augmentfs integration test
mtjhrc May 12, 2026
2596f98
tests: add root-disk-remount integration test
mtjhrc May 12, 2026
da074ab
CI: enable BLK=1 and install e2fsprogs in integration tests
mtjhrc May 13, 2026
1240ab2
init-blob: add InitConfig builder for guest init configuration
mtjhrc May 20, 2026
6770521
lib: switch krun_set_exec/env/workdir/rlimits to InitConfig
mtjhrc May 20, 2026
7c8ea8a
lib: add krun_set_oci_config_json() and krun_inject_init() APIs
mtjhrc May 20, 2026
5bc8efc
examples: replace deprecated krun_set_root_disk/krun_set_data_disk wi…
mtjhrc May 20, 2026
a438481
tests: use krun_disable_implicit_init + krun_inject_init everywhere
mtjhrc May 20, 2026
116d2e8
lib: remove krun_disable_implicit_init and implicit init injection
mtjhrc May 20, 2026
ef83853
lib: remove deprecated krun_set_root_disk and krun_set_data_disk
mtjhrc May 20, 2026
c69fe6d
lib: remove deprecated krun_set_passt_fd, krun_set_gvproxy_path, krun…
mtjhrc May 20, 2026
eb51844
tests/examples: replace krun_set_log_level with krun_init_log
mtjhrc May 20, 2026
53ea22f
lib: propagate KRUN_NITRO_DEBUG flag in krun_init_log
mtjhrc May 20, 2026
750f825
lib: remove deprecated krun_set_log_level
mtjhrc May 20, 2026
1cc6d5b
tests/examples: replace old numbered API variants with latest
mtjhrc May 20, 2026
7e27698
lib: remove old numbered API variants
mtjhrc May 20, 2026
3d80dbd
lib: remove unsupported krun_set_mapped_volumes
mtjhrc May 20, 2026
c0a0d41
lib: remove krun_get_default_init
mtjhrc May 20, 2026
d49d62d
tests/examples: use explicit krun_add_virtio_console_default everywhere
mtjhrc May 20, 2026
f5e0c87
lib: remove krun_disable_implicit_console, krun_set_console_output, a…
mtjhrc May 20, 2026
f5b1865
tests/examples: use explicit krun_add_vsock everywhere
mtjhrc May 20, 2026
203f72f
lib: remove krun_disable_implicit_vsock and implicit vsock creation
mtjhrc May 20, 2026
a789674
include: remove stale implicit resource creation comment
mtjhrc May 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: rustup target add x86_64-unknown-linux-musl

- name: Build and install libkrun to test prefix
run: make test-prefix NET=1
run: make test-prefix NET=1 BLK=1

- name: Clippy (test_cases guest)
run: |
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
sudo usermod -a -G kvm $USER

- name: Install additional packages
run: sudo apt-get install -y --no-install-recommends build-essential patchelf pkg-config net-tools buildah dnsmasq iperf3
run: sudo apt-get install -y --no-install-recommends build-essential patchelf pkg-config net-tools buildah dnsmasq iperf3 e2fsprogs

- name: Install passt from source
run: |
Expand All @@ -58,7 +58,7 @@ jobs:
run: TAG=`curl -sL https://api.github.com/repos/containers/libkrunfw/releases/latest |jq -r .tag_name` && curl -L -o /tmp/libkrunfw-x86_64.tgz https://github.com/containers/libkrunfw/releases/download/$TAG/libkrunfw-x86_64.tgz && mkdir tmp && tar xf /tmp/libkrunfw-x86_64.tgz -C tmp && sudo mv tmp/lib64/* /lib/x86_64-linux-gnu

- name: Integration tests
run: KRUN_ENOMEM_WORKAROUND=1 KRUN_TEST_BASE_DIR=/tmp/libkrun-tests make test NET=1 IPERF_DURATION=3 TEST_FLAGS="--keep-all --github-summary"
run: KRUN_ENOMEM_WORKAROUND=1 KRUN_TEST_BASE_DIR=/tmp/libkrun-tests make test NET=1 BLK=1 IPERF_DURATION=3 TEST_FLAGS="--keep-all --github-summary"

- name: Upload test logs
if: always()
Expand All @@ -84,7 +84,7 @@ jobs:
run: rustup target add aarch64-unknown-linux-musl

- name: Build and install libkrun to test prefix
run: make test-prefix NET=1
run: make test-prefix NET=1 BLK=1

- name: Clippy (test_cases guest)
run: |
Expand All @@ -107,7 +107,7 @@ jobs:
cargo clippy --locked --target aarch64-unknown-linux-musl -p guest-agent -- -D warnings

- name: Install additional packages
run: sudo apt-get install -y --no-install-recommends build-essential patchelf pkg-config net-tools dnsmasq iperf3 git uidmap
run: sudo apt-get install -y --no-install-recommends build-essential patchelf pkg-config net-tools dnsmasq iperf3 git uidmap e2fsprogs

- name: Install passt from source
run: |
Expand All @@ -123,7 +123,7 @@ jobs:
run: rm -fr /tmp/libkrun-tests

- name: Integration tests
run: KRUN_ENOMEM_WORKAROUND=1 KRUN_NO_UNSHARE=1 KRUN_TEST_BASE_DIR=/tmp/libkrun-tests make test NET=1 IPERF_DURATION=3 TEST_FLAGS="--keep-all --github-summary"
run: KRUN_ENOMEM_WORKAROUND=1 KRUN_NO_UNSHARE=1 KRUN_TEST_BASE_DIR=/tmp/libkrun-tests make test NET=1 BLK=1 IPERF_DURATION=3 TEST_FLAGS="--keep-all --github-summary"

- name: Upload test logs
if: always()
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"src/libkrun",
"src/init-blob",
"src/input",
"src/display",
"src/utils",
Expand Down
10 changes: 8 additions & 2 deletions examples/boot_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int main(int argc, char *const argv[])
}

// Set the log level to "off".
err = krun_set_log_level(0);
err = krun_init_log(KRUN_LOG_TARGET_DEFAULT, KRUN_LOG_LEVEL_OFF, KRUN_LOG_STYLE_AUTO, 0);
if (err) {
errno = -err;
perror("Error configuring log level");
Expand All @@ -191,13 +191,19 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_add_virtio_console_default(ctx_id, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO)) {
errno = -err;
perror("Error configuring console");
return -1;
}

if (err = krun_set_firmware(ctx_id, cmdline.efi_fw)) {
errno = -err;
perror("Error configuring EFI FW path");
return -1;
}

if (err = krun_set_root_disk(ctx_id, cmdline.disk_image)) {
if (err = krun_add_disk3(ctx_id, "root", cmdline.disk_image, KRUN_DISK_FORMAT_RAW, false, false, KRUN_SYNC_FULL)) {
errno = -err;
perror("Error configuring disk image");
return -1;
Expand Down
26 changes: 17 additions & 9 deletions examples/chroot_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_add_virtio_console_default(ctx_id, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO)) {
errno = -err;
perror("Error configuring console");
return -1;
}

// Configure vhost-user RNG if requested
if (cmdline.vhost_user_rng_socket != NULL) {
// Test sentinel-terminated array: auto-detect queue count, use custom size
Expand Down Expand Up @@ -357,14 +363,8 @@ int main(int argc, char *const argv[])
printf("Using vhost-user sound backend at %s\n", cmdline.vhost_user_snd_socket);
}

// Configure vhost-user vsock if requested
// Configure vsock: either vhost-user or built-in with TSI
if (cmdline.vhost_user_vsock_socket != NULL) {
// Disable the implicit vsock device to avoid conflict
if (!check_krun_error(krun_disable_implicit_vsock(ctx_id),
"Error disabling implicit vsock")) {
return -1;
}

if (!check_krun_error(krun_add_vhost_user_device(ctx_id, KRUN_VIRTIO_DEVICE_VSOCK,
cmdline.vhost_user_vsock_socket, NULL,
KRUN_VHOST_USER_VSOCK_NUM_QUEUES,
Expand Down Expand Up @@ -413,14 +413,22 @@ int main(int argc, char *const argv[])

uint32_t virgl_flags = VIRGLRENDERER_USE_EGL | VIRGLRENDERER_DRM |
VIRGLRENDERER_THREAD_SYNC | VIRGLRENDERER_USE_ASYNC_FENCE_CB;
if (err = krun_set_gpu_options(ctx_id, virgl_flags)) {
if (err = krun_set_gpu_options2(ctx_id, virgl_flags, (uint64_t)1 << 33)) {
errno = -err;
perror("Error configuring gpu");
return -1;
}

// Add built-in vsock with TSI when not using vhost-user-vsock
if (cmdline.vhost_user_vsock_socket == NULL) {
if (err = krun_add_vsock(ctx_id, KRUN_TSI_HIJACK_INET)) {
errno = -err;
perror("Error configuring vsock");
return -1;
}
}

// Map port 18000 in the host to 8000 in the guest (if networking uses TSI)
// Skip port mapping when using vhost-user-vsock (TSI requires built-in vsock)
if (cmdline.net_mode == NET_MODE_TSI && cmdline.vhost_user_vsock_socket == NULL) {
if (err = krun_set_port_map(ctx_id, &port_map[0])) {
errno = -err;
Expand Down
8 changes: 1 addition & 7 deletions examples/consoles.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,12 @@ int main(int argc, char *const argv[])
const char *const *command_args = (argc > 3) ? (const char *const *)&argv[3] : NULL;
const char *const envp[] = { 0 };

krun_set_log_level(KRUN_LOG_LEVEL_WARN);
krun_init_log(KRUN_LOG_TARGET_DEFAULT, KRUN_LOG_LEVEL_WARN, KRUN_LOG_STYLE_AUTO, 0);

int err;
int ctx_id = krun_create_ctx();
if (ctx_id < 0) { errno = -ctx_id; perror("krun_create_ctx"); return 1; }

if ((err = krun_disable_implicit_console(ctx_id))) {
errno = -err;
perror("krun_disable_implicit_console");
return 1;
}

int console_id = krun_add_virtio_console_multiport(ctx_id);
if (console_id < 0) {
errno = -console_id;
Expand Down
13 changes: 10 additions & 3 deletions examples/external_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int main(int argc, char *const argv[])
}

// Set the log level to "off".
err = krun_set_log_level(0);
err = krun_init_log(KRUN_LOG_TARGET_DEFAULT, KRUN_LOG_LEVEL_OFF, KRUN_LOG_STYLE_AUTO, 0);
if (err)
{
errno = -err;
Expand All @@ -243,9 +243,16 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_add_virtio_console_default(ctx_id, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO))
{
errno = -err;
perror("Error configuring console");
return -1;
}

if (cmdline.boot_disk)
{
if (err = krun_add_disk(ctx_id, "boot", cmdline.boot_disk, 0))
if (err = krun_add_disk3(ctx_id, "boot", cmdline.boot_disk, KRUN_DISK_FORMAT_RAW, 0, 0, KRUN_SYNC_FULL))
{
errno = -err,
perror("Error configuring boot disk");
Expand All @@ -254,7 +261,7 @@ int main(int argc, char *const argv[])
}
if (cmdline.data_disk)
{
if (err = krun_add_disk(ctx_id, "data", cmdline.data_disk, 0))
if (err = krun_add_disk3(ctx_id, "data", cmdline.data_disk, KRUN_DISK_FORMAT_RAW, 0, 0, KRUN_SYNC_FULL))
{
errno = -err,
perror("Error configuring data disk");
Expand Down
22 changes: 15 additions & 7 deletions examples/gui_vm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ use gtk_display::{
};

use krun_sys::{
KRUN_LOG_LEVEL_TRACE, KRUN_LOG_LEVEL_WARN, KRUN_LOG_STYLE_ALWAYS, KRUN_LOG_TARGET_DEFAULT,
VIRGLRENDERER_RENDER_SERVER, VIRGLRENDERER_THREAD_SYNC, VIRGLRENDERER_USE_ASYNC_FENCE_CB,
VIRGLRENDERER_USE_EGL, VIRGLRENDERER_VENUS, krun_add_display, krun_add_input_device,
krun_add_input_device_fd, krun_create_ctx, krun_display_set_dpi,
krun_add_display, krun_add_input_device, krun_add_input_device_fd,
krun_add_virtio_console_default, krun_create_ctx, krun_display_set_dpi,
krun_display_set_physical_size, krun_display_set_refresh_rate, krun_init_log,
krun_set_display_backend, krun_set_exec, krun_set_gpu_options2, krun_set_root,
krun_set_vm_config, krun_start_enter,
krun_set_vm_config, krun_start_enter, KRUN_LOG_LEVEL_TRACE, KRUN_LOG_LEVEL_WARN,
KRUN_LOG_STYLE_ALWAYS, KRUN_LOG_TARGET_DEFAULT, VIRGLRENDERER_RENDER_SERVER,
VIRGLRENDERER_THREAD_SYNC, VIRGLRENDERER_USE_ASYNC_FENCE_CB, VIRGLRENDERER_USE_EGL,
VIRGLRENDERER_VENUS,
};
use log::LevelFilter;
use regex::{Captures, Regex};
use std::ffi::{CString, c_void};
use std::ffi::{c_void, CString};
use std::fmt::Display;
use std::fs::{File, OpenOptions};
use std::mem::size_of_val;

use anyhow::Context;
use std::os::fd::IntoRawFd;
use std::os::fd::{AsRawFd, IntoRawFd};
use std::path::PathBuf;
use std::process::exit;
use std::ptr::null;
Expand Down Expand Up @@ -150,6 +151,13 @@ fn krun_thread(

krun_call!(krun_set_vm_config(ctx, 4, 4096))?;

krun_call!(krun_add_virtio_console_default(
ctx,
std::io::stdin().as_raw_fd(),
std::io::stdout().as_raw_fd(),
std::io::stderr().as_raw_fd(),
))?;

krun_call!(krun_set_gpu_options2(
ctx,
VIRGLRENDERER_USE_EGL
Expand Down
12 changes: 9 additions & 3 deletions examples/launch-tee.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char *const argv[])
}

// Set the log level to "error".
err = krun_set_log_level(1);
err = krun_init_log(KRUN_LOG_TARGET_DEFAULT, KRUN_LOG_LEVEL_ERROR, KRUN_LOG_STYLE_AUTO, 0);
if (err) {
errno = -err;
perror("Error configuring log level");
Expand All @@ -67,8 +67,14 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_add_virtio_console_default(ctx_id, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO)) {
errno = -err;
perror("Error configuring console");
return -1;
}

// Use the first command line argument as the disk image containing the root fs.
if (err = krun_set_root_disk(ctx_id, argv[1])) {
if (err = krun_add_disk3(ctx_id, "root", argv[1], KRUN_DISK_FORMAT_RAW, false, false, KRUN_SYNC_FULL)) {
errno = -err;
perror("Error configuring root disk image");
return -1;
Expand Down Expand Up @@ -114,7 +120,7 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_set_data_disk(ctx_id, argv[3])) {
if (err = krun_add_disk3(ctx_id, "data", argv[3], KRUN_DISK_FORMAT_RAW, false, false, KRUN_SYNC_FULL)) {
errno = -err;
perror("Error configuring the TEE config data disk");
return -1;
Expand Down
6 changes: 3 additions & 3 deletions examples/nitro.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int main(int argc, char *const argv[])

// Enable debug output if configured.
log_level = (cmdline.debug) ? KRUN_LOG_LEVEL_DEBUG : KRUN_LOG_LEVEL_OFF;
err = krun_set_log_level(log_level);
err = krun_init_log(KRUN_LOG_TARGET_DEFAULT, log_level, KRUN_LOG_STYLE_AUTO, 0);
if (err) {
errno = -err;
perror("Error configuring log level");
Expand All @@ -203,9 +203,9 @@ int main(int argc, char *const argv[])
return -1;
}

if (err = krun_set_console_output(ctx_id, "/dev/stdout")) {
if (err = krun_add_virtio_console_default(ctx_id, -1, STDOUT_FILENO, -1)) {
errno = -err;
perror("Error configuring the console output");
perror("Error configuring the console");
return -1;
}

Expand Down
Loading
Loading