Skip to content

Commit

Permalink
vmm: Create an export table and pass it to the FS and GPU code.
Browse files Browse the repository at this point in the history
Right now, this is done unconditionally for all filesystems. Should we
introduce a flag for this?

Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Oct 22, 2024
1 parent f758c13 commit 0cfb95b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -633,12 +633,20 @@ pub fn build_microvm(
intc.clone(),
vm_resources.console_output.clone(),
)?;

let export_table: Option<ExportTable> = 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")]
Expand All @@ -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,
Expand Down Expand Up @@ -1182,6 +1191,7 @@ fn attach_fs_devices(
vmm: &mut Vmm,
fs_devs: &[FsDeviceConfig],
shm_manager: &mut ShmManager,
mut export_table: Option<ExportTable>,
intc: Option<Arc<Mutex<Gic>>>,
#[cfg(target_os = "macos")] map_sender: Sender<MemoryMapping>,
) -> std::result::Result<(), StartMicrovmError> {
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -1465,6 +1479,7 @@ fn attach_gpu_device(
vmm: &mut Vmm,
event_manager: &mut EventManager,
shm_manager: &mut ShmManager,
mut export_table: Option<ExportTable>,
intc: Option<Arc<Mutex<Gic>>>,
virgl_flags: u32,
#[cfg(target_os = "macos")] map_sender: Sender<MemoryMapping>,
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 0cfb95b

Please sign in to comment.