Commit graph

878 commits

Author SHA1 Message Date
Alexandre Courbot
b6f790632e virtio: video: move desc_map into Worker
This removes the need to pass the descriptor map as an argument of all
Worker's methods.

BUG=b:161774071
TEST=GTS DashTest passes on hatch-arc-r.

Change-Id: Ide8d1a858bb09f1098a38c49643fdf365ae7aec1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2932300
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-08 01:52:05 +00:00
Alexandre Courbot
0e8e812921 virtio: video: add command and event queues to Worker
The command and event queues are not replaced throughout the Worker's
life, and their ownership is given to it when run() is invoked. Make
them members of Worker so we don't need to pass them around with each
method call.

BUG=b:161774071
TEST=GTS DashTest passes on hatch-arc-r.

Change-Id: I92441a8be5e9dbc2fdaddc1546632ea404de0aaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2932299
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-06-08 01:52:03 +00:00
Stephen Barber
76cc214ce7 net: implement VIRTIO_NET_F_MTU
A given net device should expose the minimum MTU of all its
tap interfaces. This ensures that the guest won't inadvertently
produce frames that the host will have to drop, if a lower MTU
is in use on the host (common with cellular links).

BUG=b:171098377
TEST=create tap with MTU < 1500 and start crosvm

Change-Id: I6add14b532e4c2d070d2fe4410272421afc1303f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2917620
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-06-05 01:39:35 +00:00
Alexandre Courbot
ecd3a42fb4 virtio: video: worker: add constructor
All the members of Worker are currently public to allow users to
build them inline. Use a constructor instead so all members can be made
private.

BUG=b:161774071
TEST=GTS DashTest passes on hatch-arc-r.

Change-Id: I093d7e9b9183b46c7ffe6717199e0ed654b6236e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2932298
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-03 12:48:29 +00:00
Chirantan Ekbote
2ee9dcd4bb devices: Support vhost-user-wl
Support running the wl device as an out-of-tree process.  Unlike other
vhost-user devices, this one uses a second socket for additional
wayland-specific messages between the device and VMM.  Since
virtio-wayland is not a standardized device and it's likely it will be
merged into the gpu device, it's not worth the effort to try to
incorporate the wayland-specific extensions into the regular vhost-user
protocol.

BUG=b:179755841
TEST=start a crostini vm with a vhost-user-wl device and play
     gnome-mahjongg

Change-Id: I455d32393426aff2acd392092ff82f6cc970d903
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2919156
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-03 09:58:01 +00:00
Chirantan Ekbote
a409b106e4 Add vhost-user-wl device
BUG=b:179755841
TEST=start a crostini vm with a vhost-user-wl device and play
     gnome-mahjongg

Change-Id: I4bbb084eed972e783908b23b37443ebb2f4847ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2919155
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-03 09:58:00 +00:00
Alexandre Courbot
0cd9040119 virtio: video: worker: avoid unneeded call to peek()
We can directly call pop() in write_event() and return an error if no
item is available. pop() actually does exactly what we were doing, but
makes the code a bit shorter.

BUG=b:161774071
TEST=GTS DashTest passes on hatch-arc-r.

Change-Id: I893666de0132f573164687e78fe0ac4e8996da71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2932297
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-06-03 06:44:24 +00:00
Chirantan Ekbote
4d5b350602 wl: Move queue handling to standalone functions
This will make it easier to run the virtqueues from a vhost-user
process.

BUG=b:179755841
TEST=Start crostini and play gnome-mahjongg.

Change-Id: Ic4132a66ef7718fe85307f5d743110645288967a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2910215
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-05-31 11:56:05 +00:00
Woody Chow
b47434378d devices: vios: Fix SampleFormat => VIRTIO_SND_PCM_FMT mapping
Signed should be mapped to sigend

BUG=None
TEST=CQ

Change-Id: I06aa06e895dab63efe7f4e72de800fae614800d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2919153
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-05-31 06:17:07 +00:00
Alexandre Courbot
fbd2559acd virtio: video: encoder: wait until EOS buffer is available if needed
Currently, the encoder returns an error if no buffer was available to
signal the end of stream after a flush had completed. Fix this
non-compliant behavior by just waiting until the next output buffer is
queued by the client, and returning that buffer immediately to signal
the end of stream.

Since this behavior is also needed for the decoder, and is a workaround
for libvda's inability to signal the last buffer of a stream, make that
functionality available through a new EosBufferManager struct that can
easily be reused and removed.

BUG=b:168750131
BUG=b:186374269
BUG=b:161774071
TEST=arc.VideoEncodeAccel.h264_360p_i420_vm passes on hatch-arc-r.
TEST=android.mediav2.cts.EncoderProfileLevelTest passes 100 times on
eve-arc-r.

Change-Id: Iebac5f3342393cc6763dbeedda041cf0c3983085
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2914232
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-30 05:37:34 +00:00
Noah Gold
e6b5a3725d Move VMM usages of rust-vmm/vhost into the wrapper.
For cross platform purposes, we need to be able to switch out the
implementation of rust-vmm/vhost. To make this easier, this CL moves all
VMM side calls into that crate into VhostUesrHandler. (The device side
calls are already in DeviceRequestHandler, so no further change is
needed there.)

Note that vmm_vhost::vhost_user::message::* are fine to use directly for cross
platform purposes.

BUG=None
TEST=builds

Change-Id: I5252e8522efa61dc773a74889915ec9a7ef58ec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2913139
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-05-28 21:13:47 +00:00
Alexandre Courbot
e0c32ce8d0 virtio: video: decoder: remove Default impl of Context
We don't have (neither do we want) to build Contexts without parameters.

BUG=b:161774071
TEST=cargo build --features "video-decoder,video-encoder"

Change-Id: I62d60b7baa820a16b5a188e8196b0b04643b0a85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2918809
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-27 06:03:14 +00:00
Abhishek Kumar
f426f9ed08 devices: vfio: Fix io bar index calculation
Fixes https://crrev.com/c/2689084 , wrong bar_idx cause
gpu hang in TGL(volteer-manatee).

BUG=b:187772152
TEST=Boot volteer-manatee

Change-Id: Ia9394d61e509c87d082ffc3923be2820535cec2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2915767
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-26 17:55:42 +00:00
Dylan Reid
050c9b8205 devices: Move block code to a module
Move all the block related code to a module under virtio.
This is deemed better than manual namespacing with block_....rs

Change-Id: I8543ef0345011679e02d3762ff94729b0a4eb1f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2915763
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2021-05-26 05:10:32 +00:00
Dylan Reid
4452db6ba0 devices: block - move duplicated code to common file
It has taken a while to get the non-async code removed so make the
shared parts explicitly shared instead of duplicated.

Change-Id: I58d092eefad37bc23da80f0ecac394bb6155efc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2910993
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2021-05-26 05:10:31 +00:00
Daniel Verkamp
b792ffdcec devices: vios: remove unnecessary mut reference
The seq_socket_send() function only requires a non-mutable reference;
drop the mut.

Fixes clippy warning "the function `seq_socket_send` doesn't need a
mutable reference".

BUG=None
TEST=bin/clippy

Change-Id: I517a8d782601f33653db33c201666707beddd5ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885787
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-25 21:50:48 +00:00
Alexandre Courbot
d6c0f61489 virtio: video: encoder: move EOS buffer dequeueing into a method
Make the act of dequeueing the EOS buffer a method of its own, so it can
be invoked from different points of the code.

BUG=b:168750131
BUG=b:186374269
TEST=arc.VideoEncodeAccel.h264_360p_i420_vm passes on hatch-arc-r.

Change-Id: Ic8c2cc118df234093ae15aada0737063c8ad80c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2914231
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-25 03:25:31 +00:00
Daniel Verkamp
f1439d444b devices: add "usb" feature for emulated xHCI
Add a default-enabled "usb" feature to allow compiling out the emulated
USB controller and host device provider when not needed (e.g. for
crosvm-direct).

This reduces the crosvm-direct binary size by about 400 KiB.

BUG=b:173824333
TEST=cargo build --no-default-features
TEST=cargo build # ensure xhci controller is added

Change-Id: I1fc0eeb09c647854e5df57cd2fe7e92140256853
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2913136
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-24 21:37:22 +00:00
Jorge E. Moreira
6635ca47cb Allow more than one input device per type
In order to have multiple touchscreen devices working with multiple displays.

BUG=b:186263031

Change-Id: I02334f49dee4c57f139bcba84757089bd4bd4d37
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2857171
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-24 20:03:14 +00:00
Daniel Verkamp
561abaffdb devices: vios: remove redundant map_err closures
Fixes clippy warning "redundant closure found".

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

BUG=None
TEST=bin/clippy

Change-Id: Ic87dacb1a60f2125d3eb60aae60ffbcd6a774ada
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885785
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-22 00:43:29 +00:00
Daniel Verkamp
34d2b36a42 devices: irqchip: rewrite if-let-else None with ?
Replace an else block that just returns None with the equivalent use of
the question mark operator, and rewrite the comment that used to be in
the else block to match.

Fixes the clippy warning "this if-let-else may be rewritten with the `?`
operator".

https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

BUG=None
TEST=bin/clippy
TEST=cargo test -p devices

Change-Id: Ifda6d55c16e12fc7939343757d7f2843b4df9b27
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885784
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-22 00:43:29 +00:00
Daniel Verkamp
3638ae21f8 Remove needless returns
Fixes clippy warning "unneeded `return` statement".

BUG=None
TEST=bin/clippy

Change-Id: Ib31ce9c31d4edccd9c3a518dfa3a07186124d259
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885783
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-22 00:43:28 +00:00
Daniel Verkamp
15fadba6ea devices: replace .into_iter() on ref with .iter()
Fixes clippy warning:

  this `.into_iter()` call is equivalent to `.iter()` and will not
  consume the `slice`

https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref

BUG=None
TEST=bin/clippy

Change-Id: Id31c3f6252b86a7f453ab4e6e7dac0ed6654bc52
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885782
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-05-22 00:43:27 +00:00
Daniel Verkamp
358101242a devices: drop redundant clone calls
Fixes clippy warnings like:

  using `clone` on type `...` which implements the `Copy` trait

and

  redundant clone
  note: this value is dropped without further use

BUG=None
TEST=bin/clippy
TEST=cargo test -p devices

Change-Id: I8c13b79b54265e5527cadcb8a2e9f54419044bcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885781
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-22 00:43:27 +00:00
Chirantan Ekbote
584fc8944d wl: Switch to thiserror
BUG=b:179755841
TEST=cargo build

Change-Id: Iaafae1cb235b7611f36f1b88d3e9e20d6a36d2ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2910214
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-05-21 10:55:51 +00:00
Alexandre Courbot
582d68acf9 virtio: video: encoder: add VDA encoder constructor
Add a constructor for building a VDA-backed encoder instead of requiring
the user to build one.

BUG=b:169295147
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes on hatch-arc-r.

Change-Id: I712499904845b3cccb52a3e9e07c87cc1a3c92c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-21 09:36:40 +00:00
Alexandre Courbot
71b2ddb962 virtio: video: make Worker work on Device trait objects
The current generic Worker code is being instanciated once per kind of
video decoder and encoder. This results in quite a bit of duplication to
avoid one virtual call per device event, and also prevents us from
selecting the codec backend dynamically.

Convert that code to use a Device trait object instead for both
simplicity and flexibility.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: I9aacd0286022d9eaa44bd57656d1959de78322a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891143
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-21 09:36:39 +00:00
Alexandre Courbot
2ddc36d222 virtio: video: encoder: use the same backend code layout as the decoder
Move the backend code into a module of the same name, to mirror the
structure used by the decoder.

BUG=b:169295147
TEST=cargo build --features="video-decoder,video-encoder"

Change-Id: I9175b054811d294c338f8b58961e4b45b10c99ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891142
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-21 09:36:38 +00:00
Alexandre Courbot
de3a48a651 virtio: video: move VDA common code into its own module
Move VDA code that is used by both the decoder and encoder into its own
module, so it can be easily included (or not) during compilation.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: Ic42f94a1118fad5d60da0d5358a28a9b27c3dbc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891141
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-21 09:36:37 +00:00
Alexandre Courbot
c9f43bf6be virtio: video: decoder: move capability and decoder building into VDA backend
These operations are backend-specific and reference libvda, so move them
out of the generic code into the backend so they can easily be compiled
out.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: Id5b32684df8aabef0c9ee2a00977339e0191d41b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891140
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-21 09:36:36 +00:00
Alexandre Courbot
96e3fb363f virtio: video: use the thiserror crate with VideoError
The thiserror crate is available to crosvm, so use it to make our
error handling code a bit more readable.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: I2aacc63ffa8311d7e0bb4d1192fd0b11b4ca5d03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891139
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-20 19:29:28 +00:00
Alexandre Courbot
f148e1b0df virtio: video: encoder: remove EncoderError
Make all the encoder backend methods return a VideoError, similarly to
what the decoder does. This allows us to merge the EncoderError's enums
into VideoError and return a BackendFailure when a backend-related
problem has occured, removing references to the encoder-specific code in
the generic video code.

BUG=b:169295147
TEST=cargo build --features="video-encoder"

Change-Id: I948927ae43cbbac70c4b829fbbb314122a0b6628
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891138
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-20 19:29:27 +00:00
Alexandre Courbot
0d714e1572 virtio: video: decoder: replace decoder VDA errors with generic backend error.
This follows the more flexible model that is used with the encoder and
removes references to libvda in the generic code.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: Idff2894c9ea84c7bc26c5d02374c167756767a15
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891137
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
2021-05-20 19:29:26 +00:00
Alexandre Courbot
3727976368 virtio: video: decoder: replace ContextMap's new() method by Default implementation
This is more idiomatic for constructors that take no arguments, and
spares us one compiler warning if decoding support is enabled without
any backend (in which case nobody creates ContextMaps).

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: I01b909eac6d443e43617f6e8cb91c6254dea5cc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891136
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
2021-05-20 19:29:25 +00:00
Jorge E. Moreira
3a5178e3b2 Error on stream creation no longer blocks stream ids
BUG=b:184059723
Change-Id: I553b77e5557e6c2058d4bacac96093736dfb8c86

Change-Id: I226e6eeb92b3d9e73fe5fcfbf43e2fa61bc2033c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2854381
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-20 00:56:46 +00:00
Tomasz Jeznach
f622e504d3 crosvm/kvm: enable runtime detection of IOAPIC pins
Enable support for runtime verification of number
of irqchip kernel emulated inputs, up to 120 pins.

KVM implementation supporting extended input pins shall
report KVM_CHECK_EXTENSION/KVM_CAP_IOAPIC_NUM_PINS value.

BUG=b:179648314
TEST=On systems with 24/120 pin IOAPIC kvm emulation.

Change-Id: I80063216310e427d664e3eaca3aba27e8a972cde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2893366
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-20 00:37:59 +00:00
Keiichi Watanabe
ac63740cf7 devices: virtio: Remove unused method
Remove `VirtioDevice::acked_features()` which is unused.

BUG=none
TEST=build

Change-Id: I35323bb67b23e0d739a100643a81a890919df589
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2902072
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-18 18:52:33 +00:00
Keiichi Watanabe
03f4c754d7 devices: net: Avoid causing busy loop for interrupt resample
We must have read the resample event before calling
`SignalableInterrupt::do_interrupt_resample`.

BUG=b:179755448
TEST=run crosvm with net device

Change-Id: Ic4bd74d3c89cc8af69401d2c1ebc095a474fba04
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2902057
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-18 18:52:29 +00:00
Chirantan Ekbote
82cddfef8e net: Switch to thiserror
BUG=none
TEST=cargo build

Change-Id: Iec87dca59eb577e01fb772efb11bb435174d482f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2894325
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2021-05-17 11:23:24 +00:00
Chirantan Ekbote
c4ce3791e9 wl: Fix unused_imports and dead_code warnings
These functions are only used when the gpu feature is enabled.

BUG=none
TEST=`cargo build` and see no warnings

Change-Id: I8c354b0122032a6d6c57d16837d9d9e857ac03c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891122
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-17 11:23:22 +00:00
Alexandre Courbot
e1dff2eef8 virtio: video: decoder: add format getters to Capability
Capability is read-only once it has been built, so access its members
using getter methods instead of making them public.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Change-Id: Ia5d30d94a04fc9b4e87d783c85b3ab5650ca9815
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891135
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-14 05:32:22 +00:00
Alexandre Courbot
b77b936d42 virtio: video: encoder: make encoder own its VEA instance
The current design of having the VEA instance outside of the encoder was
mandated by the use of lifetimes on libvda Sessions, which have been
removed from libvda. So it is now possible for the encoder to own its
VEA instance.

This makes sense in itself since there is no reason for the VEA instance
to also be used by someone else, but is also required to add support for
non-libvda encoder backends.

BUG=b:169295147
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes on hatch-arc-r

Change-Id: Idb4356dde6124f00d87915da7da0910c7d816863
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2887526
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-13 04:41:13 +00:00
Alexandre Courbot
0b96ae0720 virtio: video: encoder: remove lifetimes on VEA instance/sessions
The libvda API has been changed and both instances and sessions do not
use lifetimes anymore. Remove them from our code or it won't compile.

BUG=b:169295147
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes on hatch-arc-r

Cq-Depend: chromium:2887389
Change-Id: I9821e7f3b92b89fceb843fb0e60d041a44602f20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2887525
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-13 04:40:59 +00:00
Daniel Verkamp
a8423d73c3 devices: pass MMIO and IO bus to PciRoot::new()
This will be used to dynamically add and remove bus ranges when the PCI
command register is updated to enable/disable memory and IO decode.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I6bb175e0628bf598d049562700e2f55a2a62df59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689081
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-05-12 00:09:37 +00:00
Keiichi Watanabe
8c817dd349 vhost_user_devices: Add vhost-user net device
Add a vhost-user net device executable which communiates with a VMM having vhost-user net device.

Example command:
vhost-user-net-device \
         --tap 10.0.2.2,255.255.255.0,12:34:56:78:9a:bc \
         --socket /tmp/vhost-net.sock

BUG=b:179755448
TEST=run as a backend of crosvm with vhost-user net device

Cq-Depend: chromium:2861979
Change-Id: Ib723cdd00381b29464855378e568a9fa3de01536
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2807205
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-05-11 18:34:40 +00:00
Keiichi Watanabe
8e7bc96616 Add vhost_user_devices crate
Add `vhost_user_devices` crate which will be used to create a vhost-user
device executables.

BUG=b:185089400
TEST=cargo test in /vhost_user_devices

Change-Id: I7256d68316f7763d3ceaa65abc97663975e7608f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2822169
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-11 18:34:39 +00:00
Keiichi Watanabe
8ec40a7fa0 device: vhost: user: Fix offset of GET_CONFIG
BUG=none
TEST=run vhost-user block vmm with dpdk

Cq-Depend: chromium:2861979
Change-Id: I7cf6694338b3eadf910e85af7c0db85805e32451
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2856171
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-10 13:08:00 +00:00
Daniel Verkamp
7fb40344ff devices: pci: add PciDevice function to get BARs
This will be used to enumerate BARs when the command register is updated
to enable/disable memory or I/O decode.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I992a2004dc58955b464467914c4ad735fb2cdd44
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689085
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:49 +00:00
Daniel Verkamp
2da1f27fd5 devices: vfio: use PciBarConfiguration struct
Replace the VFIO-specific MmioInfo and IoInfo structs with
PciBarConfiguration.

This will allow a unified interface for retrieving BAR information for
all PciDevice implementations; all other PciDevices use PciConfiguration
to store a list of PciBarConfiguration, so this brings VfioPciDevice in
line with those.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: Idafd8f9af2ce817877450cfb842805475785ba20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689084
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:49 +00:00
Daniel Verkamp
8954f04e82 devices: pci: add config support for ROM BAR
Extend PciBarConfiguration to support the expansion ROM BAR in addition
to the usual 6 BARs.

This will be used when adapting vfio_pci to use PciBarConfiguration.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I712728def41b0f2981029d77c3b9d7ec065e9d9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689083
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:48 +00:00