From 0cfb95b2d03c90bb75034b6d7e64496af78fb5de Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Tue, 22 Oct 2024 23:19:41 +0900 Subject: [PATCH] vmm: Create an export table and pass it to the FS and GPU code. Right now, this is done unconditionally for all filesystems. Should we introduce a flag for this? Signed-off-by: Asahi Lina --- src/vmm/src/builder.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vmm/src/builder.rs b/src/vmm/src/builder.rs index f7d49ccc..e1377ca0 100644 --- a/src/vmm/src/builder.rs +++ b/src/vmm/src/builder.rs @@ -24,7 +24,7 @@ use devices::legacy::VcpuList; use devices::legacy::{Gic, Serial}; #[cfg(feature = "net")] use devices::virtio::Net; -use devices::virtio::{port_io, MmioTransport, PortDescription, Vsock}; +use devices::virtio::{fs::ExportTable, port_io, MmioTransport, PortDescription, Vsock}; #[cfg(target_os = "macos")] use hvf::MemoryMapping; @@ -633,12 +633,20 @@ pub fn build_microvm( intc.clone(), vm_resources.console_output.clone(), )?; + + let export_table: Option = if cfg!(feature = "gpu") && cfg!(not(feature = "tee")) { + Some(Default::default()) + } else { + None + }; + #[cfg(feature = "gpu")] if let Some(virgl_flags) = vm_resources.gpu_virgl_flags { attach_gpu_device( &mut vmm, event_manager, &mut _shm_manager, + export_table.clone(), intc.clone(), virgl_flags, #[cfg(target_os = "macos")] @@ -650,6 +658,7 @@ pub fn build_microvm( &mut vmm, &vm_resources.fs, &mut _shm_manager, + export_table, intc.clone(), #[cfg(target_os = "macos")] _map_sender, @@ -1182,6 +1191,7 @@ fn attach_fs_devices( vmm: &mut Vmm, fs_devs: &[FsDeviceConfig], shm_manager: &mut ShmManager, + mut export_table: Option, intc: Option>>, #[cfg(target_os = "macos")] map_sender: Sender, ) -> std::result::Result<(), StartMicrovmError> { @@ -1209,6 +1219,10 @@ fn attach_fs_devices( }); } + if let Some(export_table) = export_table.take() { + fs.lock().unwrap().set_export_table(export_table); + } + #[cfg(target_os = "macos")] fs.lock().unwrap().set_map_sender(map_sender.clone()); @@ -1465,6 +1479,7 @@ fn attach_gpu_device( vmm: &mut Vmm, event_manager: &mut EventManager, shm_manager: &mut ShmManager, + mut export_table: Option, intc: Option>>, virgl_flags: u32, #[cfg(target_os = "macos")] map_sender: Sender, @@ -1501,6 +1516,10 @@ fn attach_gpu_device( }); } + if let Some(export_table) = export_table.take() { + gpu.lock().unwrap().set_export_table(export_table); + } + // The device mutex mustn't be locked here otherwise it will deadlock. attach_mmio_device(vmm, id, MmioTransport::new(vmm.guest_memory().clone(), gpu)) .map_err(RegisterGpuDevice)?;