Skip to content

Commit

Permalink
virtio/fs: plumb SHM region into worker
Browse files Browse the repository at this point in the history
After splitting the functionality into a worker, the SHM region was
left behind. Plumb it now to re-enable DAX support.

Signed-off-by: Sergio Lopez <[email protected]>
  • Loading branch information
slp committed Aug 29, 2024
1 parent c49f774 commit 5010aaa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/devices/src/virtio/fs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl VirtioDevice for Fs {
self.intc.clone(),
self.irq_line,
mem.clone(),
self.shm_region.clone(),
self.passthrough_cfg.clone(),
self.worker_stopfd.try_clone().unwrap(),
);
Expand Down
6 changes: 3 additions & 3 deletions src/devices/src/virtio/fs/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<F: FileSystem + Sync> Server<F> {
&self,
mut r: Reader,
w: Writer,
shm_region: Option<&VirtioShmRegion>,
shm_region: &Option<VirtioShmRegion>,
) -> Result<usize> {
let in_header: InHeader = r.read_obj().map_err(Error::DecodeMessage)?;

Expand Down Expand Up @@ -136,15 +136,15 @@ impl<F: FileSystem + Sync> Server<F> {
x if x == Opcode::Lseek as u32 => self.lseek(in_header, r, w),
x if x == Opcode::CopyFileRange as u32 => self.copyfilerange(in_header, r, w),
x if (x == Opcode::SetupMapping as u32) && shm_region.is_some() => {
let shm = shm_region.unwrap();
let shm = shm_region.as_ref().unwrap();
#[cfg(target_os = "linux")]
let shm_base_addr = shm.host_addr;
#[cfg(target_os = "macos")]
let shm_base_addr = shm.guest_addr;
self.setupmapping(in_header, r, w, shm_base_addr, shm.size as u64)
}
x if (x == Opcode::RemoveMapping as u32) && shm_region.is_some() => {
let shm = shm_region.unwrap();
let shm = shm_region.as_ref().unwrap();
#[cfg(target_os = "linux")]
let shm_base_addr = shm.host_addr;
#[cfg(target_os = "macos")]
Expand Down
6 changes: 5 additions & 1 deletion src/devices/src/virtio/fs/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::descriptor_utils::{Reader, Writer};
use super::passthrough::{self, PassthroughFs};
use super::server::Server;
use crate::legacy::Gic;
use crate::virtio::VirtioShmRegion;

pub struct FsWorker {
queues: Vec<Queue>,
Expand All @@ -23,6 +24,7 @@ pub struct FsWorker {
irq_line: Option<u32>,

mem: GuestMemoryMmap,
shm_region: Option<VirtioShmRegion>,
server: Server<PassthroughFs>,
stop_fd: EventFd,
}
Expand All @@ -37,6 +39,7 @@ impl FsWorker {
intc: Option<Arc<Mutex<Gic>>>,
irq_line: Option<u32>,
mem: GuestMemoryMmap,
shm_region: Option<VirtioShmRegion>,
passthrough_cfg: passthrough::Config,
stop_fd: EventFd,
) -> Self {
Expand All @@ -49,6 +52,7 @@ impl FsWorker {
irq_line,

mem,
shm_region,
server: Server::new(PassthroughFs::new(passthrough_cfg).unwrap()),
stop_fd,
}
Expand Down Expand Up @@ -149,7 +153,7 @@ impl FsWorker {
.map_err(FsError::QueueWriter)
.unwrap();

if let Err(e) = self.server.handle_message(reader, writer, None) {
if let Err(e) = self.server.handle_message(reader, writer, &self.shm_region) {
error!("error handling message: {:?}", e);
}

Expand Down

0 comments on commit 5010aaa

Please sign in to comment.