Port virtio media simple device as a vhost user media device.#1895
Port virtio media simple device as a vhost user media device.#1895ser-io wants to merge 1 commit intogoogle:mainfrom
Conversation
Why are you copying this code here instead of depending on it? Would it be possible to contribute changes upstream and only implement the cuttlefish-specific changes here? |
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/Cargo.toml
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/src/simple_device.rs
Outdated
Show resolved
Hide resolved
d42f8bd to
db5b139
Compare
Removed the copy depending on the upstream implementation. |
833efed to
fadcf29
Compare
fadcf29 to
8b2a123
Compare
8b2a123 to
774f02d
Compare
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/src/main.rs
Outdated
Show resolved
Hide resolved
Databean
left a comment
There was a problem hiding this comment.
Some of the comments apply in multiple places, like reducing map_err usage in favor of automatic conversion with From.
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
cdc74cb to
61f4245
Compare
61f4245 to
9771f15
Compare
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/src/main.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs
Outdated
Show resolved
Hide resolved
|
|
||
| impl<S, D, F> VhuMediaBackend<S, D, F> | ||
| where | ||
| S: VirtioMediaDeviceSession + Send + Sync, |
There was a problem hiding this comment.
The documentation for VirtioMediaDeviceSession writes
The preferred way to use this trait is to wrap implementations in a
VirtioMediaDeviceRunner, which takes care of reading and dispatching commands.
The implementation of VirtioMediaDeviceRunner::handle_command looks quite similar to process_commandq_requests. Is it possible to use this common utility?
| S: VirtioMediaDeviceSession, | ||
| D: for<'a> VirtioMediaDevice<Reader<'a>, Writer<'a>>, | ||
| F: Fn(EventQueue, HostMemoryMapper) -> D, |
There was a problem hiding this comment.
I can't really tell here, but is it possible to use a Box<dyn Xyz> for any of these traits? e.g.
sessions: HashMap<u32, Box<dyn VirtioMediaDeviceSession>>,
device: Option<Box<dyn for<'a> VirtioMediaDevice<Reader<'a>, Writer<'a>>>>,
create_device_fn: Box<dyn Fn(EventQueue, HostMemoryMapper) -> Box<dyn for<'a> VirtioMediaDevice<Reader<'a>, Writer<'a>>>>
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/src/main.rs
Outdated
Show resolved
Hide resolved
base/cvd/cuttlefish/host/commands/vhost_user_media/simple_device/src/main.rs
Outdated
Show resolved
Hide resolved
Run the device. ``` RUST_LOG=trace cargo run --bin simple_device -- --socket-path /tmp/simple_device.sock or RUST_LOG=trace bazel run simple_device:simple_device -- --socket-path /tmp/simple_device.sock ``` Run the VM. ``` cargo run -- --log-level=debug run --cpus 4 --mem 4096 \ --rwdisk /path/to/debian-12.img \ --params "root=/dev/vda1" \ --vhost-user media,socket=/tmp/simple_device.sock \ /path/to/bzImage v4l2-compliance -d0 -s ``` Bug: 445229097
9771f15 to
6d56a54
Compare
Port virtio media reference device
simple_deviceas a vhost user implementation.First iteration of
simple_device/src/simple_device.rsis the same as in virtio-media upstream https://github.com/chromeos/virtio-media/blob/main/device/src/devices/simple_device.rs.Bug: 445229097