[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 0/2] kern/xen: Add Xen command line parsing



The purpose of this patch is to allow the Xen hypervisor to pass extra
data to GRUB in the form of a kernel command line, allowing the host to
customize the boot process of the guest. The command line from Xen is
parsed, and any variables within that start with the string
`xen_grub_env_` are exposed as environment variables. The grub.cfg
script can then use those environment variables as it sees fit.

The main reason for doing this is to allow implementing boot modes in
Qubes OS while also using in-VM kernels. For more context on Qubes boot
modes, see [1]. In order for this to work with in-VM kernels, it is
necessary for dom0 to pass kernel parameters to the guest without
modifying the guest's grub.cfg manually. This patch allows this to be
done, by allowing dom0 to pass kernel parameters to GRUB, which then
provides them to grub.cfg as an environment variable. The grub.cfg
script within the VM can then append those variables to the kernel
command line.

All of the changes from version 3 of the patch are simply refinements
after a review from Daniel Kiper (coding style cleanups, avoiding
global variables, double-checking NUL-termination after using
grub_strncpy, etc.). The patch's functionality is unchanged.

Since there are substantial changes since version 3, I've re-run the
entire battery of tests that were used against the v3 patch, plus an
extra test to ensure an escaped control character won't be accepted in
variable values. The test results can be seen at [2]. As previously, the
tests were done by booting a patched GRUB in Xen with various different
parameters passed to it via the Xen-provided kernel command line. The
effects of these parameters on the bootloader's environment were then
tested, and then an Arch Linux image was booted to ensure that boot
still worked.

[1] https://github.com/QubesOS/qubes-linux-pvgrub2/pull/16
[2] https://bpa.st/3SBQ

Aaron Rainbolt (2):
  include/xen: Rename MAX_GUEST_CMDLINE to GRUB_XEN_MAX_GUEST_CMDLINE
  kern/xen: Add Xen command line parsing

 docs/grub.texi                |  51 +++++
 grub-core/Makefile.core.def   |   2 +
 grub-core/kern/i386/xen/pvh.c |  23 +++
 grub-core/kern/xen/cmdline.c  | 376 ++++++++++++++++++++++++++++++++++
 grub-core/kern/xen/init.c     |   2 +
 include/grub/xen.h            |   2 +
 include/xen/xen.h             |   4 +-
 7 files changed, 458 insertions(+), 2 deletions(-)
 create mode 100644 grub-core/kern/xen/cmdline.c

-- 
2.50.1

Attachment: pgphdLpLlpEg_.pgp
Description: OpenPGP digital signature


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.