The VM crashes if the root directory doesn't exist
wainersm opened this issue · 3 comments
wainersm commented
If I configure krun with an invalid root directory (krun_set_root()
) and start the VM then it will simply crash. Shouldn't rather it fails nicely?
It can be reproduced with the chroot_vm
program:
$ ./chroot_vm rootfs_not_exist_dir /bin/sh
[ 0.038923] Kernel panic - not syncing: Requested init /init.krun failed (error -2).
[ 0.039014] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.10 #1
[ 0.039044] Call Trace:
[ 0.039062] show_stack+0x3d/0x3f
[ 0.039124] dump_stack+0x5e/0x74
[ 0.039140] ? rest_init+0xa0/0xa5
[ 0.039159] panic+0xf6/0x2a4
[ 0.039178] ? kernel_execve+0x145/0x1b0
[ 0.039198] ? rest_init+0xa5/0xa5
[ 0.039220] kernel_init+0xa5/0xfb
[ 0.039238] ret_from_fork+0x1f/0x30
[ 0.039273] Kernel Offset: disabled
slp commented
It's the caller, chroot_vm
in this case, the one that's responsible to check that the directory specified as root filesystem is available by the time krun_start_enter()
is called. This also applies to the directories configured as mapped volumes.
I'll update the chroot_vm.c
example to do those checks. Thanks for pointing this out.