Skip to content

lib: remove deprecated APIs and implicit resource creation#688

Open
mtjhrc wants to merge 14 commits into
libkrun:mainfrom
mtjhrc:remove-deprecated-func
Open

lib: remove deprecated APIs and implicit resource creation#688
mtjhrc wants to merge 14 commits into
libkrun:mainfrom
mtjhrc:remove-deprecated-func

Conversation

@mtjhrc

@mtjhrc mtjhrc commented May 20, 2026

Copy link
Copy Markdown
Collaborator

This PR removes deprecated and superseded API functions, preparing for the 2.0 API (#634).

The init-blob integration (krun_inject_init, krun_set_oci_config_json, init config delivery changes) has been split into a separate PR built on top of this one.

Deprecated functions removed

  • krun_set_log_levelkrun_init_log
  • krun_set_root_diskkrun_add_disk3
  • krun_set_data_diskkrun_add_disk3
  • krun_set_passt_fdkrun_add_net_unixstream
  • krun_set_gvproxy_pathkrun_add_net_unixgram
  • krun_set_net_mac → mac parameter on krun_add_net_*
  • krun_set_mapped_volumes — was already returning -EINVAL
  • krun_set_rootkrun_add_virtiofs3 with "/dev/root" tag
  • krun_set_console_outputkrun_add_virtio_console_default

Implicit resource creation removed

  • krun_disable_implicit_console → this is now the default behavior
  • krun_disable_implicit_vsock → this is now the default behavior

Tests and examples have been updated to use the current API equivalents.

@ggoodman

Copy link
Copy Markdown
Contributor

There's an interesting API design challenge here where krun_set_exec and some other methods are coupled to the specific init implementation. In other words, there's a contract with a pluggable init.

Another way to do this might be to explore passing the init-specific config when choosing the init binary. It's subtle but it makes it clear that the two things are coupled.

@mtjhrc

mtjhrc commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

There's an interesting API design challenge here where krun_set_exec and some other methods are coupled to the specific init implementation. In other words, there's a contract with a pluggable init.

This is not the final design, this is only the first step in untangling this, I'll decouple this more. The main motivation for this was to get rid of the buggy argv forwarding via the kernel command line and unify everything around our json config.

Currently the krun_set_exec and the other functions just forward to the init config builder methods defined in blob-init (this way, the output format produced by the builder and the format expected by the init binary stay in sync). In the future, you'll call the builder methods directly, but exposing them cleanly right now was complicated (you'd need something like a separate handle for the builder; a Rust/C bindings generator I'm working on should help with this).

If you wanted to use a different init, its configuration will be completely transparent to libkrun. I think the contract will simply be that you provide some virtual files (libkrun won't care if they are executables or configs or whatever) and add the appropriate kernel arguments (e.g. like set the init= kernel arg).

@mtjhrc mtjhrc force-pushed the remove-deprecated-func branch 3 times, most recently from a0af916 to 1da73b7 Compare June 2, 2026 11:30
@mtjhrc mtjhrc force-pushed the remove-deprecated-func branch 2 times, most recently from 9d9144c to 35f42d9 Compare June 4, 2026 10:51
@mtjhrc mtjhrc force-pushed the remove-deprecated-func branch from 35f42d9 to 90dcb6d Compare June 9, 2026 11:24
mtjhrc added 3 commits June 9, 2026 13:25
…th krun_add_disk

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
These were replaced by krun_add_disk. Also remove the internal
root_block_cfg/data_block_cfg fields and their setters, and simplify
get_block_cfg() now that the legacy compat path is gone.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
…_set_net_mac

These were replaced by krun_add_net_unixstream, krun_add_net_unixgram,
and krun_add_net_tap (which take mac as a parameter directly).

Also remove the internal LegacyNetworkConfig enum, legacy_net_cfg and
legacy_mac fields, the compat path in krun_start_enter that converted
them to the new net backend, and the now-unused NET_COMPAT_FEATURES
constant.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
@mtjhrc mtjhrc force-pushed the remove-deprecated-func branch from 90dcb6d to 7cf2e3a Compare June 9, 2026 11:46
@mtjhrc

mtjhrc commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

Note that I've removed the init configuration changes from this PR and moved them into:

That PR goes further in the init/libkrun decoupling as discussed above.

mtjhrc added 11 commits June 9, 2026 14:24
Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
krun_set_log_level set KRUN_NITRO_DEBUG when level==4 (debug), but
krun_init_log did not. Fix the omission so removing krun_set_log_level
doesn't regress nitro debug logging.

Also fix the condition to level >= 4 so that trace (level 5) also
enables nitro debug.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
Superseded by krun_init_log which provides control over target fd,
log style, and env override options.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
This function has been returning -EINVAL unconditionally. Remove it.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
Replace implicit console creation with explicit
krun_add_virtio_console_default calls. Also replace
krun_set_console_output in nitro.c with
krun_add_virtio_console_default.

No test or example relies on implicit console injection anymore.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
…nd implicit console

Console creation is now fully explicit via krun_add_virtio_console_default
or krun_add_virtio_console_multiport. No console is created unless the
caller requests one.

Remove the disable_implicit_console field from VmResources, the implicit
console and serial device creation paths in builder.rs, the console_output
field and setter on VmResources, and krun_set_console_output (kept only
behind cfg(aws-nitro) where NitroEnclave still needs it).

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
- test_tsi_tcp_guest_connect: add krun_add_vsock(ctx, KRUN_TSI_HIJACK_INET)
- test_tsi_tcp_guest_listen: same
- test_vsock_guest_connect: add krun_add_vsock(ctx, 0)
- chroot_vm.c: replace krun_disable_implicit_vsock + vhost-user
  with explicit krun_add_vsock when not using vhost-user-vsock

No test or example relies on implicit vsock creation anymore.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
Vsock creation is now fully explicit via krun_add_vsock(). No vsock
device is created unless the caller requests one.

Remove the Implicit variant from VsockConfig, the implicit vsock
creation heuristics in krun_start_enter, and krun_disable_implicit_vsock.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
All krun_disable_implicit_* functions are gone. The 2.0 API requires
explicit resource creation.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
Replace all callers of krun_set_root with explicit
krun_add_virtiofs3(ctx, "/dev/root", path, 0, false) calls.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
Callers should use krun_add_virtiofs3() with KRUN_FS_ROOT_TAG
("/dev/root") instead, which provides explicit control over DAX
window size and read-only mode.

Assisted-by: OpenCode:claude-opus-4.6
Signed-off-by: Matej Hrica <mhrica@redhat.com>
@mtjhrc mtjhrc force-pushed the remove-deprecated-func branch from 7cf2e3a to 38a816a Compare June 9, 2026 12:25
@mtjhrc mtjhrc marked this pull request as ready for review June 9, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants