- 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>
If a PCM_RELEASE control request comes from the guest and the state
transition is invalid by spec standards, release the buffers anyway.
This doesn't change the current behavior.
When dealing with an unrelated vhost-user issue, the state transitions
became invalid because of unexpected errors in the virto-snd driver.
Making this change made the issue obvious while debugging. Plus, the
spec does not state rejecting a PCM lifecycle control request if the
transition is not possible. (The possible state transitions are
non-normative statements.)
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Add v4l2 wrapper functions to be able
to mock (and test) v4l2r library responses
without the need of having a underlying video device.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Complete the README file for the video crate
with the help information for the CLI, and a
working example to run and test the device.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Add test for all modules, with dev-dependencies
(including rstest [1] for parametrized tests), and
infrastructure.
[1] - https://docs.rs/rstest/latest/rstest/
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Add new v4l2-decoder backend, that
uses v4l2r [1] for interactions with the
video device in the host. Specialized for
Linux systems.
[1] - https://github.com/Gnurou/v4l2r
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Initial skeleton for virtio-video crate.
This crate is based on the v3 of the virtio-video
specs patch[1].
It has a big part of the infrastructure
required, although not all commands are implemented,
and does not have any backend available.
Includes support for async responses to the driver
(through VIDEO_EVENT) to QueueResource messages.
[1] -
https://lists.oasis-open.org/archives/virtio-dev/202002/msg00002.html
Related: #364
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Let's use custom pipelines to run CI tests in the nested worskpace.
We have included all the tests we usually run in the main workspace
(rust-vmm-ci/.buildkite/test_description.json), except for "commit-format"
which also covers commits for staging crates.
Let's add a `staging\coverage_config_x86_64.json` for testing coverage of
crates in staging.
All staging tests have `soft_fail = true` to prevent failures in staging
from affecting the CI of the main workspace.
Closes#478
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Lets be super clear and explicit about what it takes to include a
backend in the repository as well as the minimum requirements for
being included in staging.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Having all the workspace crates under the crates/ directory is
unnecessary. Rust documentation itself recommends all crates to be in
the root directory:
https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html#creating-the-second-package-in-the-workspace
I paste the text content here, in case the online page ever changes or
becomes unavailable:
## Creating the Second Package in the Workspace
Next, let’s create another member package in the workspace and call it add_one. Change the top-level Cargo.toml to specify the add_one path in the members list:
Filename: Cargo.toml
[workspace]
members = [
"adder",
"add_one",
]
Then generate a new library crate named add_one:
$ cargo new add_one --lib
Created library `add_one` package
Your add directory should now have these directories and files:
├── Cargo.lock
├── Cargo.toml
├── add_one
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── adder
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── target
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Add a new workspace for devices that have no final specification merged
into the virtio spec.
Closes#459
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
With the refactoring before this commit, `PhysDevice` is `Sync` and
`Send` automatically. So let's drop the unsafe impls to prevent future
type changes to result in unsound behaviour (again).
Fixes: #442
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
RwLock allows multiple concurrent readers. libgpiod, however, does not
offer thread-safety for any function - even if they look like innocent
getters. Therefore, libgpiod objects do not implement `Sync`.
Now, `PhysDevice` is incorrectly marked as `Sync`, giving multiple threads
access to thw RwLock - resulting in unsafe behaviour.
We fix this by just turning the `RwLock` into a `Mutex`.
Issue: #442
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
The Chip is not `Sync` (as wrongly claimed by the `Sync` marker on
`PhysDevice`). So if we want to share the `PhysDevice` across threads,
we will need to guard it by a `Mutex`.
These calls do not block for very long. So this should not cause any new
deadlock conditions.
Issue: #442
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
The compiler warns with the move that:
error: variants `CouldNotOpenDevice`, `CouldNotCreateGpioController`, `CouldNotCreateBackend`, and `CouldNotCreateDaemon` are never constructed
--> crates/vhost-device-gpio/src/backend.rs:43:5
|
31 | pub(crate) enum Error {
| ----- variants in this enum
...
43 | CouldNotOpenDevice(crate::gpio::Error),
| ^^^^^^^^^^^^^^^^^^
44 | #[error("Could not create gpio controller: {0}")]
45 | CouldNotCreateGpioController(crate::gpio::Error),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46 | #[error("Could not create gpio backend: {0}")]
47 | CouldNotCreateBackend(crate::vhu_gpio::Error),
| ^^^^^^^^^^^^^^^^^^^^^
48 | #[error("Could not create daemon: {0}")]
49 | CouldNotCreateDaemon(vhost_user_backend::Error),
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `Error` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `-D dead-code` implied by `-D warnings`
error: could not compile `vhost-device-gpio` (bin "vhost-device-gpio") due to previous error
Because we never really care about failure within the spawn loop.
Handle this by ensuring errors propagate back to the caller.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
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>
This should group updates into a single PR. Hopefully, that simplfies
updates.
Updates that do _actually_ require code changes, will need a separate PR
anyway, after which dependabot can be asked to rebase/recreate.
Suggested-by: Patrick Roy <roypat@amazon.co.uk>
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>