From e4aefda81734fe5632dc0557512975ff178dd782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 14 Sep 2023 15:23:24 +0100 Subject: [PATCH] gpio: document the "mock_gpio" feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alex Bennée --- crates/vhost-device-gpio/README.md | 22 ++++++++++++++++++++++ crates/vhost-device-rng/CHANGELOG.md | 2 ++ 2 files changed, 24 insertions(+) diff --git a/crates/vhost-device-gpio/README.md b/crates/vhost-device-gpio/README.md index c063698..0daa190 100644 --- a/crates/vhost-device-gpio/README.md +++ b/crates/vhost-device-gpio/README.md @@ -43,6 +43,28 @@ Examples section below. --socket-count. For example, the GPIO device 0 will be allocated to the guest with "0" path. +## MockGpioDevice support + +As connecting VM guests to random GPIO pins on your host is generally +asking for trouble you can enable the "mock_gpio" feature in your build: + + cargo build --features "mock_gpio" + +You can then enable simulated GPIOs using the 's' prefix: + + --device-list s4,s8 + +Which will create two gpio devices, the first with 4 pins and the +second with 8. By default updates are display via env logger: + + vhost-device-gpio -s /tmp/vus.sock -c 1 -l s4 + [2023-09-14T14:15:14Z INFO vhost_device_gpio::mock_gpio] gpio dummy0 set value to 1 + [2023-09-14T14:15:14Z INFO vhost_device_gpio::mock_gpio] gpio dummy0 set direction to 1 + [2023-09-14T14:15:14Z INFO vhost_device_gpio::mock_gpio] gpio dummy0 set direction to 0 + [2023-09-14T14:15:19Z INFO vhost_device_gpio::mock_gpio] gpio dummy1 set value to 1 + [2023-09-14T14:15:19Z INFO vhost_device_gpio::mock_gpio] gpio dummy1 set direction to 1 + [2023-09-14T14:15:19Z INFO vhost_device_gpio::mock_gpio] gpio dummy1 set direction to 0 + ## Examples The daemon should be started first: diff --git a/crates/vhost-device-rng/CHANGELOG.md b/crates/vhost-device-rng/CHANGELOG.md index 51d3f04..362be20 100644 --- a/crates/vhost-device-rng/CHANGELOG.md +++ b/crates/vhost-device-rng/CHANGELOG.md @@ -3,6 +3,8 @@ ### Added + - optional "mock_gpio" feature for testing + ### Changed ### Fixed