Skip to content

Commit

Permalink
fix(mmserver): bind-mount nvidia devices, if present
Browse files Browse the repository at this point in the history
These appear to be used by the NVIDIA proprietary drivers.
  • Loading branch information
colinmarc committed Dec 11, 2024
1 parent f16c6e5 commit 4bb63d3
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions mm-server/src/compositor/child/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ const DEV_BIND_MOUNTS: &[DevBindMount] = &[
path: "/dev/fuse",
is_dir: false,
},
// Needed for NVIDIA proprietary drivers.
DevBindMount {
path: "/dev/nvidiactl",
is_dir: false,
},
DevBindMount {
path: "/dev/nvidia0",
is_dir: false,
},
DevBindMount {
path: "/dev/nvidia-modeset",
is_dir: false,
},
DevBindMount {
path: "/dev/nvidia-uvm",
is_dir: false,
},
DevBindMount {
path: "/dev/nvidia-uvm-tools",
is_dir: false,
},
DevBindMount {
path: "/dev/nvidia-caps",
is_dir: true,
},
];

#[cfg(debug_assertions)]
Expand Down Expand Up @@ -454,9 +479,10 @@ impl Container {
// instead.
preexec_debug!("collecting detached bind mounts");
for (src_path, _, _, ref mut device_fd) in bind_mounts.iter_mut() {
let fd = must!(detach_mount(src_path,));

*device_fd = Some(fd)
if src_path.exists() {
let fd = must!(detach_mount(src_path,));
*device_fd = Some(fd)
}
}

// Grab a detached mount for the temporary dir we're going to mount as
Expand Down Expand Up @@ -580,21 +606,21 @@ impl Container {

// Attach detached bind mounts, now that the filesystem is prepared.
for (_src_path, dst_path, is_dir, mount_fd) in bind_mounts {
preexec_debug!(
"bind-mounting {} (outside) to {} (inside)",
_src_path.display(),
dst_path.display()
);

let detached_mount_fd = mount_fd.take().unwrap();
if let Some(detached_mount_fd) = mount_fd.take() {
preexec_debug!(
"bind-mounting {} (outside) to {} (inside)",
_src_path.display(),
dst_path.display()
);

if *is_dir {
let _ = mkdirat(AT_FDCWD, &*dst_path, Mode::empty());
} else {
must!(touch(&*dst_path, Mode::empty()));
}

if *is_dir {
let _ = mkdirat(AT_FDCWD, &*dst_path, Mode::empty());
} else {
must!(touch(&*dst_path, Mode::empty()));
must!(reattach_mount(detached_mount_fd, dst_path));
}

must!(reattach_mount(detached_mount_fd, dst_path));
}

preexec_debug!("finished initial setup, waiting for mmserver");
Expand Down

0 comments on commit 4bb63d3

Please sign in to comment.