Skip to content

libkrun: vhost-user-can support#617

Open
dorindabassey wants to merge 10 commits intocontainers:mainfrom
dorindabassey:vhost-user-can
Open

libkrun: vhost-user-can support#617
dorindabassey wants to merge 10 commits intocontainers:mainfrom
dorindabassey:vhost-user-can

Conversation

@dorindabassey
Copy link
Copy Markdown
Collaborator

@dorindabassey dorindabassey commented Apr 2, 2026

Add public API constants for vhost-user CAN devices and
example usage in chroot_vm. The underlying support already
exists via the generic VhostUserDevice wrapper.

Example integration:

Dorinda Bassey and others added 10 commits March 24, 2026 19:33
Implement vhost-user support for connecting
to external virtio device backends running
in separate processes.
Add vhost-user feature flag, vhost dependency,
and krun_add_vhost_user_device() generalized
API for adding vhost-user devices.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add memfd-backed memory region creation to enable memory
sharing with vhost-user backends via FD passing. When
vhost-user is enabled, all guest RAM regions are created
with memfd backing instead of anonymous mmap.

This lays the groundwork for vhost-user device support
while maintaining backward compatibility such that the
VM boots normally with standard memory when vhost-user
is not configured.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Implement generic vhost-user device wrapper
with connection, feature negotiation, and
Guest physical address(GPA) to Virtual
address(VA) translation. Supports protocol
feature negotiation (CONFIG, MQ) and forwards
backend interrupts to guest.

Co-authored-by: Matej Hrica <mhrica@redhat.com>
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add support for attaching vhost-user devices to the VM.
The VMM now automatically suppresses the implicit RNG
device when a vhost-user RNG is configured via
krun_add_vhost_user_device(), allowing seamless
switching between the standard virtio-rng and external
vhost-user-rng backend for better isolation and flexibility.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Adds --vhost-user-rng command line option to
specify a vhost-user RNG backend socket path.
When provided, the VM uses the external
vhost-user RNG device instead of the built-in
virtio-rng implementation.

Example usage:  ./examples/chroot_vm \
--vhost-user-rng=/tmp/vhost-rng.sock0 \
/ /bin/sh -c "head -c 32 /dev/hwrng | xxd"

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Implement read_config() for vhost-user devices using the
VHOST_USER_GET_CONFIG protocol message. This enables vhost-user
devices to expose their configuration space to the guest.

This provides a general mechanism for any vhost-user device that
needs to expose configuration to the guest (e.g., virtio-snd).

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add constants and device-specific configuration for virtio-snd
(vhost-user sound device).

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add --vhost-user-snd option to chroot_vm example,
allowing VMs to use external vhost-user sound backends
for audio playback and capture.

Usage:
  ./chroot_vm --vhost-user-snd=/path/to/sound.sock ...

Note: In the guest, the ALSA default device may not work without
additional configuration. Use explicit device specification:
  aplay -D hw:0,0 /path/to/audio.wav

Or create /etc/asound.conf in the guest:
  defaults.pcm.card 0
  defaults.pcm.device 0
  pcm.!default {
      type hw
      card 0
      device 0
  }

Tested with vhost-device-sound backend using PipeWire.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add public API constants for vhost-user vsock devices and example
usage in chroot_vm. The underlying support already exists via the
generic VhostUserDevice wrapper.

Example integration:
- Added --vhost-user-vsock option to chroot_vm
- Calls krun_disable_implicit_vsock() to avoid conflict with
  built-in device
- Skips TSI port mapping when vhost-user-vsock is active

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add public API constants for vhost-user CAN devices and
example usage in chroot_vm. The underlying support already
exists via the generic VhostUserDevice wrapper.

Example integration:
- Added --vhost-user-can option to chroot_vm
- Uses 3 queues (TX, RX, control) with 64-entry queue sizes
- Follows same pattern as other vhost-user device integrations

Signed-off-by: Dorinda Bassey <dbassey@redhat.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.

1 participant