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>
Previous commit added categories to Cargo.toml, but the only value was
`multimedia::audio`.
Thanks @stefano-garzarella for noticing I missed this.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Add self to CODEOWNERS to contribute with reviewing, merging other
PRs and maintaining the vhost-device-sound crate.
Also remove Mathieu Poirier, who is unavailable for maintainer duties at
this time.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
A subtraction between unsigned integers is made, which by default panics
on overflow. However, we don't really need to know the difference, only
that it is not zero or less.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
in this context, epoll listener can be already registered via other TX
event, so let it try epoll_modify first to avoid 'silent' failure which
possibly drops packets.
Signed-off-by: Jeongik Cha <jeongik@google.com>
instead of consume() fn name, use read_output() fn which
is more appropriate and in sync with the write_input() fn.
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
We have the following circular references found by Li Zebin:
VhostUserBackend ==> VhostUserVsockThread ==> VringEpollHandler
In addition to causing a resource leak, this causes also an error
after we merged commit 38caab2 ("vsock: Don't allow duplicate CIDs").
When the VM reboot or shutdown, the application exits with the
following error:
[ERROR vhost_device_vsock] Could not create backend:
CID already in use by another vsock device
This happened because we have these circular references and
VhostUserVsockThread::drop() is never invoked. So, we don't remove
the cid from the map.
Let's fix this problem by simply removing the reference to
VringEpollHandler from VhostUserVsockThread. In fact, we do not
need to keep the reference for the lifetime of VhostUserVsockThread,
as we only need to add the handlers once.
Let's also rename the fields to follow the current VhostUserDaemon
API.
Closes#438
Reported-by: Li Zebin <cutelizebin@gmail.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add a method to return the length of the descriptor memory region and
make `data_descriptor` field private.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
We use input/output direction values in many places, yet we lose Rust's
exhaustive static checks when matching for a stream's direction. This
commits adds a Direction enum and From/Into implementations for audio
backend respective direction types.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This new version contains alsa and pipewire libraries to build
vhost-device-sound audio backends.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
- Add some documentation comments
- Rename TxState to IoState in preparation for RX implementation
- Fix inline rust code not being escaped properly in doc comments
- Rename some fields to make their function clearer
- Cleanup some error log messages
- Replace an old TODO comment about queue size with an explanation
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
The latency field specifies how long it will take until the device
finishes playing the I/O message's buffers.
Since the I/O message is dropped as soon as the last bytes are copied
over to the host's internal buffers, assume the message is dropped
almost after the host has started playing this buffer.
This solves the issue of a guest app exiting before the host has done
playing audio because it kept sending new buffers as fast as possible
without waiting (latency).
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
The host's period and buffer sizes were not being calculated correctly.
This resulted in timing mismatches.
This commit calculates the correct sizes by taking the guest's
parameters into account.
Impossible cases when matching with stream parameters will lead to
unreachable!().
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Use of consume() method was incorrect. This commit fixes the buffer
bounds used with playback in ALSA.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Queued buffers were played even after the guest issued PCM_STOP.
This commit:
- makes the ALSA worker threads respect the stopped status instead
- send a start signal to worker threads on PCM_START to handle
pre-buffering
- reduce the time of playback callbacks holding the stream lock
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
When handling controlq messages, handle StreamWithIdNotFound the same
way on all methods:
- if we are passed a &mut ControlMessage, set it to
VIRTIO_SND_S_BAD_MSG.
- if we are passed a stream_id, return StreamWithIdNotFound.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Handle some state transition errors more gracefully by retrying ALSA
operations if possible. Also rewrite the PCM_RELEASE handler to make it
more clear.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>