virtio-vhost: Enable handler to be built and tested on Windows

Still need to enable:
 * balloon (try_clone not implemented)
 * console (Need to enable Serial)
 * snd (Unix code not conditionally compiled out)
 * gpu (Waiting for graphics team to upstream)
 * vhost-user block

BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --arch=win64 --verbose"

Change-Id: If2b69250477f88ded7176054196107733736786e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3721868
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
This commit is contained in:
Richard 2022-06-24 14:57:01 -07:00 committed by Chromeos LUCI
parent e5c6e65731
commit b9ddd723ce
4 changed files with 14 additions and 4 deletions

View file

@ -78,6 +78,9 @@ power_monitor = { path = "../power_monitor" }
usb_util = { path = "../usb_util" }
vfio_sys = { path = "../vfio_sys" }
[target.'cfg(windows)'.dependencies]
tube_transporter = { path = "../tube_transporter" }
[dependencies.futures]
version = "*"
features = ["async-await", "std"]

View file

@ -127,7 +127,13 @@ pub fn create_guest_memory(
region.memory_size,
GuestAddress(region.guest_phys_addr),
region.mmap_offset,
Arc::new(SharedMemory::from_safe_descriptor(SafeDescriptor::from(file), None).unwrap()),
Arc::new(
SharedMemory::from_safe_descriptor(
SafeDescriptor::from(file),
Some(region.memory_size),
)
.unwrap(),
),
)
.map_err(|e| {
error!("failed to create a memory region: {}", e);
@ -753,10 +759,12 @@ mod tests {
fn stop_queue(&mut self, _idx: usize) {}
}
#[cfg(unix)]
fn temp_dir() -> TempDir {
Builder::new().prefix("/tmp/vhost_test").tempdir().unwrap()
}
#[cfg(unix)]
#[test]
fn test_vhost_user_activate() {
use vmm_vhost::{

View file

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
pub(crate) use base::SharedMemoryWindows as SharedMemorySys;
use std::fs::File;
use std::mem::ManuallyDrop;
use std::sync::Arc;

View file

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
mod handler;
cfg_if::cfg_if! {
if #[cfg(unix)] {
mod block;
@ -11,7 +13,6 @@ cfg_if::cfg_if! {
#[cfg(feature = "audio_cras")]
mod cras_snd;
mod fs;
mod handler;
mod net;
mod vsock;
mod vvu;