Skip to content

libkrun: Produce a proper Rust library#588

Open
d-e-s-o wants to merge 2 commits intocontainers:mainfrom
d-e-s-o:topic/rust-lib
Open

libkrun: Produce a proper Rust library#588
d-e-s-o wants to merge 2 commits intocontainers:mainfrom
d-e-s-o:topic/rust-lib

Conversation

@d-e-s-o
Copy link
Contributor

@d-e-s-o d-e-s-o commented Mar 14, 2026

Produce a proper Rust library to avoid the need for C library
installation as well as binding generation/definition. Basically, we can
now reference the crate via Cargo.toml:

[dependencies]
libkrun = ...

instead of having to rely on constructs like:

#[link(name = "krun")]
extern "C" {
  pub fn krun_create_ctx() -> i32;
  ...
}

For a brief discussion of the topic, see #494 (comment)

@d-e-s-o
Copy link
Contributor Author

d-e-s-o commented Mar 14, 2026

Still blocked on rust-vmm/linux-loader#223 or rust-vmm/linux-loader#229 and it being included in a new release.

@d-e-s-o d-e-s-o force-pushed the topic/rust-lib branch 4 times, most recently from 5987285 to c834676 Compare March 14, 2026 18:21
@ggoodman
Copy link
Contributor

I had my 🤖 help me put together a PR describing something I hope we can land before introducing the rust api: #593.

The main intent is that we not couple the init into the crate and instead have it as an optional sibling crate.

d-e-s-o added 2 commits March 22, 2026 05:38
The existing version specification for the vm-memory dependency is
wrong: it includes incompatible versions that, when used, will break the
build. 0.18, for example does not build. Neither does 0.17. We cannot
go to 0.18, because linux-loader folks are reluctant to update to 0.18.
Hence, move the entire workspace to using vm-memory 0.17.

Signed-off-by: Daniel Müller <deso@posteo.net>
Produce a proper Rust library to avoid the need for C library
installation as well as binding generation/definition. Basically, we can
now reference the crate via Cargo.toml:

  [dependencies]
  libkrun = ...

instead of having to rely on constructs like:

  #[link(name = "krun")]
  extern "C" {
    pub fn krun_create_ctx() -> i32;
    ...
  }

Signed-off-by: Daniel Müller <deso@posteo.net>
@d-e-s-o
Copy link
Contributor Author

d-e-s-o commented Mar 22, 2026

Still blocked on rust-vmm/linux-loader#223 or rust-vmm/linux-loader#229 and it being included in a new release.

Doesn't seem as if one of those is going to get merged anytime soon. So we have to stick with vm-memory 0.17. Updated PR accordingly.

@d-e-s-o d-e-s-o force-pushed the topic/rust-lib branch 4 times, most recently from 8c40869 to ac1e901 Compare March 22, 2026 13:51
@d-e-s-o d-e-s-o marked this pull request as ready for review March 22, 2026 13:56
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