This commit removes ControlMessage from the release() method. The
backends process the release() command immediately thus not requiring the
audio backend to notify guest later. The notification happens in the
device after the cmd is processed. This also removes the need of
handling descriptors in the audio backend. This commit fixes the tests
in pw.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This commit removes ControlMessage in the set_param() method and
replaces it with the VirtioSndPcmSetParams structure that is already
parsed by the device. Both backends are able to handle that request
immediately so there is not need to pass ControlMessage to notify the
guest afterwards. By doing this, this commit removes any descriptor
manipulation from the audio backends. The commit fixes the test in pw.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This patch is to add support for vhost input device emulation.
The code skeleton heavily reuses vhost-device-i2c and vhost-device-rng,
including sharing the same license, and how to create the multi-thread
mode and daemon for backend virtual device.
It gives detailed usage for enabling virtual input device for guest in
the README.md.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Commit b37e7e5709 changed how
the --help-deices text output was used inadvertently by including it by
default in the help output. Restore the --help-devices argument and make
it exclusive: you cannot combine it with other arguments. This way,
socket_path does not have to be an Option<PathBuf>.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
The threadloop has to be stopped only when the audio backend is dropped
otherwise release() stops it and it is not started again. The threadloop
must be active all alone the life of the audio backend.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
clap can parse a PathBuf directly from the command line arguments, and
paths are not always UTF-8. Use PathBuf instead of a String to allow for
all valid filesystem paths.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
clap can parse a PathBuf directly from the command line arguments, and
paths are not always UTF-8. Use PathBuf instead of a String to allow for
all valid filesystem paths.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Use clap's derive attributes to print device help instead of doing it
manually with the parsed arguments.
Previous output
===============
```text
Usage: vhost-device-scmi [OPTIONS]
Options:
-s, --socket-path <SOCKET_PATH> vhost-user socket to use (required)
-d, --device <DEVICE>... Devices to expose
--help-devices Print help on available devices
-h, --help Print help
```
New output
==========
```text
vhost-user SCMI backend device
Usage: vhost-device-scmi [OPTIONS] --socket-path <SOCKET_PATH>
Options:
-s, --socket-path <SOCKET_PATH> vhost-user socket to use
-d, --device <DEVICE>... Devices to expose
-h, --help Print help
-V, --version Print version
Available devices:
- iio: industrial I/O sensor
Parameters:
- path: path to the device directory (e.g. /sys/bus/iio/devices/iio:device0)
- channel: prefix of the device type (e.g. in_accel)
- name: an optional name of the sensor, max. 15 characters
- fake: fake accelerometer
A simple 3-axes sensor providing fake pre-defined values.
Parameters:
- name: an optional name of the sensor, max. 15 characters
Device specification example:
--device iio,path=/sys/bus/iio/devices/iio:device0,channel=in_accel
```
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
clap can parse a PathBuf directly from the command line arguments, and
paths are not always UTF-8. Use PathBuf instead of a String to allow for
all valid filesystem paths.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
clap can parse a PathBuf directly from the command line arguments, and
paths are not always UTF-8. Use PathBuf instead of a String to allow for
all valid paths.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit adds the corresponding handling and propagation of errors
that may happen when device communicate with the pw backend.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This commit adds the corresponding handling and propagation of errors
that may happen when device communicates with the alsa backend.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This commit removes the need for a runner thread to be created when the
alsa backend is instantiated. This thread is responsible for handling
control requests and communicating with worker threads for starting and
stopping playback/capturing streams. When the virtio-sound daemon gets a
control cmd, a msg is sent over a channel and the runner processes the
request. With this commit, we propose that we handle the msg immediately
without needing to use a thread. The following reasons have led to the
removal of this thread:
* to propagate the error to the device in case an operation fails
* to simplify the backend by removing an extra thread
* to prepare the backend to remove ControlMsg from the header of the
set_param() and release() methods. Ideally, the audio backend shall
know nothing about descriptors. By removing the use of a thread to
handle the control request, notification to guest can happen
immediately in the device instead of letting the audio backend to handle
the notifications
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
In some cases, we don't realize that changes can break crates in
`staging` because CI is not blocking.
Let's make sure that at least the build of crates in `staging` is
blocking, while the rest (clippy, coverage, musl, etc.) remain
non-blocking for CI.
Suggested-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This adds a basic template crate, which will be useful for new
developers to understand how things work and layout all basic stuff they
are expected to write to make it work.
The current implementation just parses all the requests from the
virtqueue and prints the number of descriptor chains and size of each
descriptor buffer in there.
This adds basic sanity tests as well for the same, which can be run to
test the working of the crate.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Since everyone copied the first bits of code from the I2C crate, the
same issue is present almost everywhere. The returned value isn't
checked at all by the callers. Stop returning bool unnecessarily.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
During release(), the threadloop has to be stopped before the context is
destroyed, otherwise the threadloop continues to execute thus ending in
crashes due to SIGABRT or SIGSEGV.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Rename the file to avoid confusion and add a readme to better explain
why we want to keep it aligned with
`rust-vmm-ci/.buildkite/test_description.json`
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
The error from joining a thread is a bit confusing. It is only printed
if the other thread panicked. This means, effectively, we only get here
if something called .unwrap(), .expect() or panicked in a different way.
In these cases an (ugly) error was already printend. Printing a pretty
message about the join failure does not really help a lot...
So let's just continue the unwind as suggested by the docs on the join
`Result` [1].
Before:
thread '<unnamed>' panicked at 'Test panic', crates/gpio/src/backend.rs:146:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', crates/gpio/src/backend.rs:176:23
After:
thread '<unnamed>' panicked at 'Test panic', crates/gpio/src/backend.rs:146:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1]: https://doc.rust-lang.org/std/thread/type.Result.html
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
This become available with the recent vhost-user-backend [1] updates and
allows to get rid of some boilerplate code.
[1] https://github.com/rust-vmm/vhost/pull/173
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
`cargo audit` is warning us that the 0.38.22 version is yanked.
Let's update it manually (and its dependencies).
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
We forgot to tell dependabot to also run in the "staging" nested
workspace. Let's enable it.
Closes#536
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
- Features were renamed from slave -> backend
- Generics got simplified
- Some write and read functions on Volatile slice got turned into
standalone traits: ReadVolatile, WriteVolatile
- handle_event no longer returns a bool
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
These Read/Write implementations always read/wrote to the start of the
slice. This is a bit awkward and does not become easier by the test
relying on this behaviour.
Fix this by using a pair of VecDequeue, one for the read and one for the
write buffer. This better mimics a pair of network sockets. This allows
mocking the read/writes in a bit more natural ways.
VecDeque also implements Read/Write, making our impls for those a simple
forward.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
`test_start_backend_servers_failure` is failing intermittently.
In slow systems it can happen that one thread is exiting due to
an error (in this case we expect a CidAlreadyInUse error) and
another thread is creating files (Unix socket), so sometimes
test_dir.close() fails because after deleting all the files it
finds more. So let's discard eventual errors.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit adds simple tests for the structures in virtio_sound.rs. The
tests are split into two tests to fix a clippy error regarding the
cognitive complexity.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Add more tests in vhost-device-vsock to increase the coverage.
Some of them are really simple and perhaps nonsensical (tests for
Debug, Clone, etc.), but for now we don't know how to disable this
in the tool, so let's cover these cases.
The vhost-device-vsock functions coverage increases from 70.73% to
90.45%:
Filename Functions Missed Functions Executed
----------------------------------------------------------
main.rs 51 12 76.47%
rxops.rs 8 0 100.00%
rxqueue.rs 20 0 100.00%
thread_backend.rs 20 3 85.00%
txbuf.rs 17 0 100.00%
vhu_vsock.rs 37 1 97.30%
vhu_vsock_thread.rs 40 5 87.50%
vsock_conn.rs 27 0 100.00%
----------------------------------------------------------
TOTAL 220 21 90.45%
Closes#229
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Now that we support multiple VMs, we launch a thread for each
VM during startup.
If one of the threads other than the first one terminates with an
error or panic, the main thread waits for the first one in the join().
For example, if we launch two VMs with the same CID, if the first
thead starts after the second one, we see the error printed and
exit, otherwise we see nothing and the main stays waiting for the
first thread.
So let's introduce a channel where the various threads can notify main
and use `std::panic::catch_unwind()` to do so even if a panic happens.
If one of the threads terminates with an error or panic, we exit
immediately.
Add also a test to check this case
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit adds tests in test_sound_thread_failure to test that
process_control() returns Err() in the following four conditions:
* control request with a single descriptor
* control request in which first descriptor is write-only
* control request in which second descriptor is read-only
* control request with less than three descriptors for control requests
that require three, e.g., PcmInfo, ChmapInfo
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>