There is not much point having a MockGpioDevice if you don't get to
see when it state changes. Currently only MockGpioDevice emits
anything bellow an error or warning so we default to the "info" level.
Any debug added in the future will need to override RUST_LOG.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Now we have our plumbing in place we can separate the starting of the
device backend into a new function and call appropriately. As the
config is no longer parsed inside start_backend we can ensure we pass
any errors up rather than blindly unwrapping.
We can drop DeviceUnimplemented as we can't build a version where this
happens.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Update the configuration to accept the form n:sn:n:sn. Currently any
config for simulated devices gets skipped. This introduces
GpioDeviceType to represent the two types of GPIO device we have.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
We are about to use it to simulate a device for the real binary so
lets move it out of the gpio module into its own. We also migrate the
VirtIO constants to keep the imports somewhat sane.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Having the directory of a crate match the name of the crate (i.e. the
one defined in its Cargo.toml) is intuitive and unambiguous.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
For now, VhostUserVsockThread uses thread pool executor from futures,
but it doesn't need to use thread pool executor and futures because
we just need background worker thread, and a way to let it work.
So I removed unnecessary external dependency and made the logic simpler
by using just thread and channel
Signed-off-by: Jeongik Cha <jeongik@google.com>
Currently, while updating the `cid_map`, it is not checked if the map
already contained a key with the same CID before. So, fail to create the
vsock thread if the CID is already in use.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
This is a valid issue, but resolving takes some time. Meanwhile, we do
not want to block the CI.
Issue #442 was filed to track finding a real fix.
This should be reverted once the real fix happens.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
When a device help is requested with `-d help', the socket argument is
still required. This patch:
- replaces `-d help' with --help-devices;
- stops requiring the socket argument in such a case;
- prints help in case of command line parsing errors.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Industrial I/O (IIO) devices are present in /sys/bus/iio/devices/ on
Linux. This patch makes them accessible to the guests via the sensor
SCMI protocol.
The implementation no way covers all the possible IIO devices. It
supports some basic stuff, other sensors can be added as needed.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Make unit handling better SCMI compliant. Let's distinguish between
scalar sensors and axis sensors and report the units in the
appropriate SCMI commands. Also, let's change the unit type to u8 to
correspond to the number of unit bits in SCMI.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Making the device configuration polymorphic requires the device struct
to exist before the device parameters are checked and assigned to the
struct fields. Which means wrapping the struct fields by Option
unnecessarily or introducing other data confusion.
Let's extract the device configuration from traits to plain functions
in order to keep the device struct's unencumbered.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Writing `--device help' on the command line will list all the
available devices and their parameters.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Followup patches will allow connecting vhost-user-scmi to industrial
I/O devices. On host without IIO devices, it’s possible to use
emulated devices for testing. This patch documents how to use them
and also provides a slightly customized IIO dummy kernel module.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Different sensors will have similar handling. Let’s extract generic
parts from FakeSensor implementation into a reusable code, within the
limits of Rust.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
The code already contains support for creating devices that can serve
as SCMI-accessible sensors and a sample fake devices. But to actually
use the device, the code must be modified.
This patch adds a command line option to define the devices on start.
The format of the option value is in the QEMU style:
DEVICE,PROPERTY=VALUE,…
For example:
--device fake,name=fake1 fake,name=fake2
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
This patch implements the necessary parts of the SCMI sensor
management protocol, required either by the SCMI standard or by Linux
VIRTIO SCMI drivers to function correctly. A part of this
implementation is a fake sensor device, which is useful for both unit
testing here and a testing with a real guest OS.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Implementation of the mandatory parts of the SCMI base protocol. This
allows the daemon to communicate with the guest SCMI VIRTIO device,
although not yet providing any useful functionality.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
This patch adds support for a SCMI vhost-user device. It implements
the basic skeleton of the vhost-user daemon and of SCMI processing.
It doesn’t provide any real functionality yet, adding it will be the
subject of followup patches.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Restrict the VMs a given VM can communicate with by introducing VM groups.
A group is simply a list of names assigned to the device in the
configuration. A VM can communicate with another VM only if the list of
group names assigned to their devices have atleast one group name in
common.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
Currently need to provide all the fields in the yaml config file,
otherwise the application panics. Modify this behaviour to allow not
specifying the optional fields to make it consistent with specifying the
configuration using only CLI arguments.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
In virtio standard, vsock uses 3 vqs. crosvm expects 3 vqs from
vhost-user-vsock impl, but this vhost-user-vsock device sets up
only 2 vqs because event vq isn't handled. And it causes crash in
crosvm. To avoid crash in crosvm, I increase NUM_QUEUES to 3
Signed-off-by: Jeongik Cha <jeongik@google.com>
BACKEND_EVENT value depends on NUM_QUEUES, because it is the next value
of NUM_QUEUES, so set it based on NUM_QUEUES
Signed-off-by: Jeongik Cha <jeongik@google.com>
VsockConnection::stream which is cloned is always used for
epoll_register, except add_new_guest_conn. Only in add_new_guest_conn,
the original stream is used.
Because a stream's raw fd is used for the key of listener_map, it cannot
find proper listener after the first packet.
Signed-off-by: Jeongik Cha <jeongik@google.com>
There was some reference left in the documentation and sources to
"vhost-user-scsi" that we had changed during the rebase.
Let's change them to "vhost-device-scsi".
Everything should be safe.
We leave "vhost-user-scsi" in
crates/scsi/src/scsi/emulation/response_data.rs because it looks like
an identifier with some constant size. We will fix in the future.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
All other devices follow the "vhost-device-*" pattern, while for
vsock we used "vhost-user-vsock". Let's rename this as well to be
consistent.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
`timer` variable does not need to be mutable as clippy reported:
warning: variable does not need to be mutable
--> crates/rng/src/vhu_rng.rs:127:17
|
127 | let mut timer = &mut self.timer;
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Currently, the `raw_pkts_queue` is processed only when a
`SIBLING_VM_EVENT` is received. But it may happen that the
`raw_pkts_queue` could not be processed completely due to insufficient
space in the RX virtqueue at that time. So, try to process raw packets on
other events too similar to what happens in the RX of standard packets.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
The deadlock occurs when two sibling VMs simultaneously try to send each
other packets. The `VhostUserVsockThread`s corresponding to both the VMs
hold their own locks while executing `thread_backend.send_pkt` and then
try to lock each other to access their counterpart's `raw_pkts_queue`.
This ultimately results in a deadlock.
Resolved by separating the mutex over `raw_pkts_queue` from the mutex over
`VhostUserVsockThread`.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
The vhost_user::Error::Disconnected error code is returned by the
daemon if the VM is shutting down. Don't Warn the user in this case but
just point out that VM may be shutting down.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>