firecracker-microvm / firectl

firectl is a command-line tool to run Firecracker microVMs
Apache License 2.0
472 stars 73 forks source link

Extract kernel and cmdline from guest disk #47

Open qsuscs opened 4 years ago

qsuscs commented 4 years ago

As firecracker itself requires the kernel to be provided from the host, firectl relays this requirement. This is okay for environments where either one controls both the hypervisor and the guest, or where it is not desired that the VM itself may provide a kernel[1].

I would however like to be able to pass only a root drive to firectl and have it extract the kernel and/or cmdline from a well-defined path (e. g. /boot/vmlinux and /boot/cmdline). For example, I stumbled upon this issue when I created a VM with the kernel configured as per the sample config, and it wouldn’t mount my XFS root.

I am going to implement this anyway, but I’m glad to submit a patch if you’re not opposed to this feature per se.

[1]: I’m not sure whether kexec would work from inside, though …

nmeyerhans commented 4 years ago

In the model that you envision, firectl would mount the root filesystem, copy the kernel binary to some temporary location on disk, read the boot params into memory, then unmount the filesystem and configure the VM to use the values it extracted?

This doesn't seem like an unreasonable feature, though there are some edge cases that need to be considered. The ones I can think of off-hand include:

I'd certainly be willing to consider such a feature if you want to work on it.