Make Null backend compiled unconditionally,
removing the null-backend feature. That
allows having the other backend choices in
the BackendType enum to be conditional, and
make them not available if their features is
opted out at compile time.
For example, compiled with no backend features,
there is only choice (i.e., null) for --backend:
```
$ target/debug/vhost-user-sound --help
Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>
Options:
--socket <SOCKET> vhost-user Unix domain socket path
--backend <BACKEND> audio backend to be used [possible values: null]
-h, --help Print help
-V, --version Print version
```
Fixes: #26
Signed-off-by: Albert Esteve <aesteve@redhat.com>
When compiled with no features, the `streams`
parameter of the alloc_audio_backend() function
is not used. Mark it as allowed to avoid the
compilation warning.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Change the CLI backend option to receive values
listed in a ValueEnum.
Current '--help' output:
```
A virtio-sound device using the vhost-user protocol.
Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>
Options:
--socket <SOCKET> vhost-user Unix domain socket path
--backend <BACKEND> audio backend to be used [possible values:
null, pipewire, alsa]
-h, --help Print help
-V, --version Print version
```
If a wrong backend is given, it give hints:
```
$ cargo run -- --socket /tmp/sound.sock --backend nul
error: invalid value 'nul' for '<BACKEND>'
[possible values: null, pipewire, alsa]
tip: a similar value exists: 'null'
```
Signed-off-by: Albert Esteve <aesteve@redhat.com>
This commit adds the set_param() method. This method can only be called
if the stream is in the "set parameters", "prepare" or "release" state.
For the pw backend, this method only updates the internal values for the
given stream.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This commit adds a vector named StreamInfo that contains the supported
configuration for the audio backends, e.g., rate, format. This
information is stored in the context of VhostUserSoundBackend. The
device reponses this information when getting the VIRTIO_SND_R_PCM_INFO
msg. The number of streams that are exposed in the device configuration
is got from this table.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
This commit handles the pcm i/o messages to the tx transmission queue.
These msgs contains three descriptors: hdr, data and status. The data
descriptor shall be processed by the audio backend. The data may be
split in multiples descriptors.
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Added device configuration and common definitions from the
virtio sound specifications to the header file
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
The virtio-queue crate doesn't allow invalid queue state since commit
d951283a8e88 ("don't allow processing descriptors for invalid q").
Initialize the queues properly to fix testing failures.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Rather incongruously the common VIRTIO feature flags where part of the
net binding. Now that the new binding are out we can update them to
something generic.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
The upstream version doesn't compile the .c files locally and depends on
the package to be locally compiled and installed in advance.
It also doesn't provide pre-generated bindings, and requires bindgen
support.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This is what we need eventually, while parsing the requests, lets store
the correct type instead of creating the same everytime.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The 0.2.1 version of virtio-vsock crate contains a fix [1] needed to
properly work with the virtio-vsock driver provided by Linux v6.3 and
later (originally the new driver was supposed to be in v6.2, but it
was postponed).
The fix was just a quick workaround, but in the future more work will
be needed in the virtio-vsock crate to not have a Linux-only specific
implementation of VsockPacket, as described in this issue [2].
[1] https://github.com/rust-vmm/vm-virtio/pull/207
[2] https://github.com/rust-vmm/vm-virtio/issues/216
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
As pointed out in https://gitlab.com/qemu-project/qemu/-/issues/1337
`-numa` is not supported by all machine types, so let's update the
example using the `memory-backend` machine property.
Since we are modifying the QEMU example, let's provide only the
QEMU's vhost-user-vsock required options in the "Usage" section.
In addition we also probide a working example.
Let's also remove a spurious rust section at the bottom of the file
that does not add any useful information.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
The I2C device names, /dev/i2c-N, can change from one boot to another of
the host machine and so aren't stable enough to be used for bus
selection.
Instead start accepting I2C master's name as parameter and parse based
on that.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The path "/dev/i2c-N" is valid only for Linux userspace and must be
handled within PhysDevice's implementation.
Move it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>