Monday, 30 November 2015

Xenial/grub2: Changes for Xen

Version: GnuPG v2.0.22 (GNU/Linux)

Not sure who currently is doing grub2... A long while ago (I think the last time
when there was a Xen version bump, which was iirc vivid) Adam and I had a
discussion about this but then things were forgotten. With Xenial there will be
another bump (to Xen-4.6) so might as well talk about this again.

Currently I do a /etc/grub.d/xen.cfg which, apart from adding a nicely separated
place for Xen specific grub options (which I think is worth keeping), adds an
override string to boot into Xen by default. A better way for that long term
seems to be to simply change the order of the generator script
(/etc/grub.d/20_linux_xen). This only generates a real section if there is a Xen
hypervisor installed and doing that a user likely also wants that to become the
default. So the question is whether it sounds reasonable to rename 20_linux_xen
into something like 09_xen?

The the other thing probably needs more change than only grub: For a while now
xen-hypervisor ships a version that is normally used from grub (using multiboot)
and an EFI executable. The normal version cannot be used on UEFI systems because
multiboot protocol has some shortcomings and there is no way to transfer control
in a way to allow to get the memory layout (as one example).
Currently 20_linux_xen generates two grub entries, one for xen-*.gz and one for
xen-*.efi. The latter plainly is wrong and has only gone unnoticed because the
former is selected by default. But I would propose the following change:

xen_list=`for i in /boot/xen*; do
+ if echo "$i" | grep -q '\.efi$'; then continue; fi
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n
"$i " ; fi

As for the question on how to handle UEFI boot, I don't know what can be done
about that. The *.efi executable likely needs to be rather loaded directly from
the shim layer, and then sooner than later also needs to become signed. Or
alternatively there had been attempts to improve the multiboot protocol in a way
that would allow using the normal grub2->xen chain for the UEFI boot case. But I
am not sure there is an outtcome, yet. So I guess for now the primary target
would be to ignore the *.efi file when generating the grub.cfg.