firectl icon indicating copy to clipboard operation
firectl copied to clipboard

Extract kernel and cmdline from guest disk

Open qsuscs opened this issue 6 years ago • 1 comments

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 …

qsuscs avatar Nov 05 '19 11:11 qsuscs

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:

  • The host doesn't support the filesystem in use on the guest (especially in cases like squashfs), or doesn't support the specific filesystem version.
  • The case where the disk image is partitioned (firectl's --root-partition option)
  • It's likely that firecracker will get initrd support before too long (firecracker-microvm/firecracker#1246), so you'll want to track that and support it when it arrives
  • Probably other stuff that I haven't though of.

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

nmeyerhans avatar Nov 06 '19 22:11 nmeyerhans