Skip to content

Commit

Permalink
virtme: use kernel modules from the rootfs when --root is used
Browse files Browse the repository at this point in the history
If we use a separate directory (chroot) as the root filesystem we should
always rely on the content of /lib/modules inside that chroot.

We don't want to try to symlink the modules in the kernel build
directory or any other directory, because we may not be able to reach
that directory from inside the chroot, and this could actually create
problems in some cases (like hiding the modules behind a broken
symlink).

So simply rely on what is available inside the chroot and be happy with
that.

We may improve this in the future by creating additional exports to the
guest (either via 9pfs or virtiofs), but it sounds a bit overkill, so
let's just stick with the simple and most intuitive behavior for now
(that is searching the modules inside the chroot).

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
Andrea Righi committed Dec 19, 2023
1 parent d768cbf commit 93cc871
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion virtme/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ def find_kernel_and_mods(arch, args) -> Kernel:
else:
# Try to automatically detect modules' path
root_dir = get_rootfs_from_kernel_path(kernel.kimg)
if root_dir == "/":
# If we are using the entire host filesystem or if we are using
# a chroot (via --root) we don't have to do anything special action
# the modules, just rely on /lib/modules in the target rootfs.
if root_dir == "/" or args.root != '/':
kernel.use_root_mods = True
elif root_dir.startswith("/tmp"):
sys.stderr.write(
Expand Down

0 comments on commit 93cc871

Please sign in to comment.