Skip to content

Use cross-platform capability in enable_cap example - #384

Open
rogersnm wants to merge 1 commit into
rust-vmm:mainfrom
rogersnm:halt-poll-enable-cap-example
Open

Use cross-platform capability in enable_cap example#384
rogersnm wants to merge 1 commit into
rust-vmm:mainfrom
rogersnm:halt-poll-enable-cap-example

Conversation

@rogersnm

Copy link
Copy Markdown
Contributor

Summary of the PR

Replace the x86-specific KVM_CAP_SPLIT_IRQCHIP capability in the VmFd::enable_cap documentation example with KVM_CAP_HALT_POLL.

KVM_CAP_HALT_POLL is documented as supporting all architectures and is enabled through the VM fd, so the example no longer needs an architecture-specific cfg.

Check support with check_extension_raw before enabling the capability. This keeps the example compatible with older kernels that may not support KVM_CAP_HALT_POLL.

This follows @andreeaflorescu’s suggestion during the review of #382.

Testing

  • Ran RUSTDOCFLAGS="-D warnings" cargo doc -p kvm-ioctls --no-deps.
  • Compiled the revised doctest with warnings denied.
  • Ran Clippy with warnings denied for aarch64, x86_64 and riscv64.
  • Ran the example against KVM on aarch64 and x86_64. Both hosts reported KVM_CAP_HALT_POLL as supported and enabled it successfully.
  • Ran cargo fmt --all --check.
  • Ran git diff --check.

Requirements

  • All commits in this PR have Signed-Off-By trailers.
  • The changed documentation example is compiled as a doctest.
  • No changelog entry is required because this does not change the public API or functionality.
  • No new unsafe code is added.

Use KVM_CAP_HALT_POLL in the VmFd::enable_cap documentation example.
It is available on all architectures and targets the VM fd.

Check for support before enabling it so the doctest also works on older
kernels. This follows the review discussion in rust-vmm#382.

Signed-off-by: Nick Rogers <1903140+rogersnm@users.noreply.github.com>
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.

3 participants