devices: vhost-user: wl: add vvu support

Add vvu support to vhost-user-wl.

BUG=b:201745804
TEST=launch crostini gui application on ManaTEE

Change-Id: I3f8416c2de0419e4ef517866c964fd0c32b3f2a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765018
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
David Stevens 2022-07-05 13:19:06 +09:00 committed by crosvm LUCI
parent 5451eaf8b3
commit 589905763f

View file

@ -312,7 +312,10 @@ pub fn parse_wayland_sock(value: &str) -> Result<(String, PathBuf), String> {
pub struct Options {
#[argh(option, arg_name = "PATH")]
/// path to bind a listening vhost-user socket
socket: String,
socket: Option<String>,
#[argh(option, arg_name = "STRING")]
/// VFIO-PCI device name (e.g. '0000:00:07.0')
vfio: Option<String>,
#[argh(option, from_str_fn(parse_wayland_sock), arg_name = "PATH[,name=NAME]")]
/// path to one or more Wayland sockets. The unnamed socket is used for
/// displaying virtual screens while the named ones are used for IPC
@ -328,6 +331,7 @@ pub fn run_wl_device(opts: Options) -> anyhow::Result<()> {
let Options {
wayland_sock,
socket,
vfio,
resource_bridge,
} = opts;
@ -354,9 +358,10 @@ pub fn run_wl_device(opts: Options) -> anyhow::Result<()> {
let ex = Executor::new().context("failed to create executor")?;
let backend = Box::new(WlBackend::new(&ex, wayland_paths, resource_bridge));
let listener =
VhostUserListener::new_from_socket_or_vfio(&socket, &vfio, wl::QUEUE_SIZES.len(), None)?;
let listener = VhostUserListener::new_socket(&socket, None)?;
let backend = Box::new(WlBackend::new(&ex, wayland_paths, resource_bridge));
// run_until() returns an Result<Result<..>> which the ? operator lets us flatten.
ex.run_until(listener.run_backend(backend, &ex))?
}