vhost-device/vhost-device-rng
Stefano Garzarella 9191a0c1de chore: remove pub visibility from exit event fields
The `exit_consumer` and `exit_notifier` fields are only used internally
by the exit_event() method implementation or by send_exit_event() in the
sound device. So, they do not need to be exposed in the public API of
backend structures.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-11-19 12:09:37 +02:00
..
src chore: remove pub visibility from exit event fields 2025-11-19 12:09:37 +02:00
Cargo.toml build(deps): bump the rust-vmm group across 2 directories with 6 updates 2025-11-19 11:28:08 +02:00
CHANGELOG.md chore: standardize changelogs 2024-07-24 19:37:19 +05:30
LICENSE-APACHE Move all crates to workspace root 2023-10-16 12:03:57 +05:30
LICENSE-BSD-3-Clause Move all crates to workspace root 2023-10-16 12:03:57 +05:30
README.md vhost-device-rng: reformat synopsis and options 2025-09-12 14:22:27 +03:00

vhost-device-rng - RNG emulation backend daemon

Description

This program is a vhost-user backend that emulates a VirtIO random number generator (RNG). It uses the host's random number generator pool, /dev/urandom by default but configurable at will, to satisfy requests from guests.

The daemon is designed to respect limitation on possible random generator hardware using the --max-bytes and --period options. As such 5 kilobyte per second would translate to "--max-bytes 5000 --period 1000". If an application requests more bytes than the allowed limit the thread will block until the start of a new period. The daemon will automatically split the available bandwidth equally between the guest when several threads are requested.

Though developed and tested with QEMU, the implementation is based on the vhost-user protocol and as such should be interoperable with other virtual machine managers. Please see below for working examples.

Synopsis

vhost-device-rng [OPTIONS] --socket-path <SOCKET>

Options

 vhost-device-rng

 -h, --help

  Print help.

 -s, --socket-path=PATH

  Location of vhost-user Unix domain sockets, this path will be suffixed with
  0,1,2..socket_count-1.

 -f, --filename
  Random number generator source file, defaults to /dev/urandom.

 -c, --socket-count=INT

  Number of guests (sockets) to attach to, default set to 1.

 -p, --period

  Rate, in milliseconds, at which the RNG hardware can generate random data.
  Used in conjunction with the --max-bytes option.

 -m, --max-bytes

  In conjunction with the --period parameter, provides the maximum number of byte
  per milliseconds a RNG device can generate.

Examples

The daemon should be started first:

::

host# vhost-device-rng --socket-path=/some/path/rng.sock -c 1 -m 512 -p 1000

Note that from the above command the socket path "/some/path/rng.sock0" will be created. This in turn needs to be communicated as a chardev socket to QEMU in order for the backend RNG device to communicate with the vhost RNG daemon:

::

host# qemu-system -M virt
-object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on
-chardev socket,path=/some/path/rng.sock0,id=rng0
-device vhost-user-rng-pci,chardev=rng0
-numa node,memdev=mem
...

License

This project is licensed under either of