Package: release.debian.org Severity: normal User: [email protected] Usertags: unblock
grub2 2.02~beta2-16 finishes off Xen host/guest integration. GRUB has had most of this for a while, but the packaging work to make it possible to install grub-xen-host in the host, grub-xen in the guest, and then automatically boot GRUB in the guest wasn't present. I know this is a bit more than your standard unblock request, and indeed we're still waiting for this to pass through NEW. But we're anticipating this being *really* useful for administrators of Xen hosting setups - it beats the messes that were PV-GRUB Legacy and PyGrub, or even keeping track of kernel versions by hand - and it would be fantastic to have this in jessie. Here's a tidied-up version of the relevant git diff. diff --git a/debian/changelog b/debian/changelog index a75c97b..40db9e9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +grub2 (2.02~beta2-16) unstable; urgency=medium + + [ Ian Campbell ] + * Provide prebuilt grub-xen binaries for host use in a new grub-xen-host + package. + * Build/Install binaries into /boot/xen when installing grub-xen. + + -- Ian Campbell <[email protected]> Thu, 06 Nov 2014 13:32:01 +0000 + grub2 (2.02~beta2-15) unstable; urgency=medium * Disable nvram installation again on chrp_ibm machines that are emulated diff --git a/debian/control b/debian/control index 5563214..dedd1c5 100644 --- a/debian/control +++ b/debian/control @@ -634,6 +634,23 @@ Description: GRand Unified Bootloader, version 2 (Xen version) This package contains a version of GRUB that has been built for use with the Xen hypervisor (i.e. PV-GRUB). +Package: grub-xen-host +Architecture: i386 amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, grub-xen-bin (= ${binary:Version}) +Multi-Arch: foreign +Description: GRand Unified Bootloader, version 2 (Xen host version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub. + . + This package arranges for GRUB binary images which can be used to boot a Xen + guest (i.e. PV-GRUB) to be present in the control domain filesystem. + Package: grub-yeeloong-bin Architecture: any-mipsel Depends: ${shlibs:Depends}, ${misc:Depends}, grub-common (= ${binary:Version}) diff --git a/debian/grub-xen-host.install b/debian/grub-xen-host.install new file mode 100644 index 0000000..43c7506 --- /dev/null +++ b/debian/grub-xen-host.install @@ -0,0 +1,2 @@ +obj/grub-xen-host-i386/grub-i386-xen.bin usr/lib/grub-xen +obj/grub-xen-host-amd64/grub-x86_64-xen.bin usr/lib/grub-xen diff --git a/debian/grub-xen-host.lintian-overrides b/debian/grub-xen-host.lintian-overrides new file mode 100644 index 0000000..4f482a1 --- /dev/null +++ b/debian/grub-xen-host.lintian-overrides @@ -0,0 +1,2 @@ +grub-xen-host: statically-linked-binary usr/lib/grub-xen/grub-i386-xen.bin +grub-xen-host: statically-linked-binary usr/lib/grub-xen/grub-x86_64-xen.bin diff --git a/debian/grub-xen-host_grub-bootstrap.cfg b/debian/grub-xen-host_grub-bootstrap.cfg new file mode 100644 index 0000000..e988314 --- /dev/null +++ b/debian/grub-xen-host_grub-bootstrap.cfg @@ -0,0 +1 @@ +normal (memdisk)/grub.cfg diff --git a/debian/grub-xen-host_grub.cfg b/debian/grub-xen-host_grub.cfg new file mode 100644 index 0000000..319c3b3 --- /dev/null +++ b/debian/grub-xen-host_grub.cfg @@ -0,0 +1,24 @@ +# First search for a suitable grub to chainload +if search -s -f /boot/xen/pvboot-@@PVBOOT_ARCH@@.elf ; then + echo "Chainloading (${root})/boot/xen/pvboot-@@PVBOOT_ARCH@@.elf" + multiboot /boot/xen/pvboot-@@PVBOOT_ARCH@@.elf" + boot +fi + +if search -s -f /xen/pvboot-@@PVBOOT_ARCH@@.elf ; then + echo "Chainloading (${root})/xen/pvboot-@@PVBOOT_ARCH@@.elf" + multiboot /xen/pvboot-@@PVBOOT_ARCH@@.elf" + boot +fi + +# Second try looking for grub.cfg + +if search -s -f /boot/grub/grub.cfg ; then + echo "Reading (${root})/boot/grub/grub.cfg" + configfile /boot/grub/grub.cfg +fi + +if search -s -f /grub/grub.cfg ; then + echo "Reading (${root})/grub/grub.cfg" + configfile /grub/grub.cfg +fi diff --git a/debian/patches/grub-install-pvxen-paths.patch b/debian/patches/grub-install-pvxen-paths.patch new file mode 100644 index 0000000..6fdeb64 --- /dev/null +++ b/debian/patches/grub-install-pvxen-paths.patch @@ -0,0 +1,71 @@ +From c211ee1c228bc978ffc4b399155ebfeb7524d2e0 Mon Sep 17 00:00:00 2001 +From: Ian Campbell <[email protected]> +Date: Sat, 6 Sep 2014 12:20:12 +0100 +Subject: grub-install: Install PV Xen binaries into the upstream specified + path + +Upstream have defined a specification for where guests ought to place their +xenpv grub binaries in order to facilitate chainloading from a stage 1 grub +loaded from dom0. + +http://xenbits.xen.org/docs/unstable-staging/misc/x86-xenpv-bootloader.html + +The spec calls for installation into /boot/xen/pvboot-i386.elf or +/boot/xen/pvboot-x86_64.elf. + +Signed-off-by: Ian Campbell <[email protected]> + +Bug-Debian: https://bugs.debian.org/762307 +Forwarded: http://lists.gnu.org/archive/html/grub-devel/2014-10/msg00041.html +Last-Update: 2014-10-24 + +Patch-Name: grub-install-pvxen-paths.patch + +--- +v2: Respect bootdir, create /boot/xen as needed. +--- + util/grub-install.c | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +diff --git a/util/grub-install.c b/util/grub-install.c +index 70f514c..7a7734e 100644 +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -1979,6 +1979,28 @@ main (int argc, char *argv[]) + } + break; + ++ case GRUB_INSTALL_PLATFORM_I386_XEN: ++ { ++ char *path = grub_util_path_concat (2, bootdir, "xen"); ++ char *dst = grub_util_path_concat (2, path, "pvboot-i386.elf"); ++ grub_install_mkdir_p (path); ++ grub_install_copy_file (imgfile, dst, 1); ++ free (dst); ++ free (path); ++ } ++ break; ++ ++ case GRUB_INSTALL_PLATFORM_X86_64_XEN: ++ { ++ char *path = grub_util_path_concat (2, bootdir, "xen"); ++ char *dst = grub_util_path_concat (2, path, "pvboot-x86_64.elf"); ++ grub_install_mkdir_p (path); ++ grub_install_copy_file (imgfile, dst, 1); ++ free (dst); ++ free (path); ++ } ++ break; ++ + case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: + case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: + case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: +@@ -1987,8 +2009,6 @@ main (int argc, char *argv[]) + case GRUB_INSTALL_PLATFORM_MIPSEL_ARC: + case GRUB_INSTALL_PLATFORM_ARM_UBOOT: + case GRUB_INSTALL_PLATFORM_I386_QEMU: +- case GRUB_INSTALL_PLATFORM_I386_XEN: +- case GRUB_INSTALL_PLATFORM_X86_64_XEN: + grub_util_warn ("%s", + _("WARNING: no platform-specific install was performed")); + break; diff --git a/debian/patches/series b/debian/patches/series index b68e230..e675322 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -60,3 +60,4 @@ platform-none.patch mips-abiflags.patch ieee1275-clear-reset.patch ppc64el-disable-vsx.patch +grub-install-pvxen-paths.patch diff --git a/debian/postinst.in b/debian/postinst.in index 94c200c..30e6947 100644 --- a/debian/postinst.in +++ b/debian/postinst.in @@ -722,6 +722,17 @@ case "$1" in grub-yeeloong) grub-install --target=mipsel-loongson ;; + + grub-xen) + # Install for x86_64 regardless of arch, since a 32-bit userspace can still boot with a 64-bit kernel. + mkdir -p /boot/xen + grub-install --target=x86_64-xen + case $(dpkg --print-architecture) in + i386) + grub-install --target=i386-xen + ;; + esac + ;; esac # If grub.cfg has been generated, update it. diff --git a/debian/rules b/debian/rules index f6daa0c..5264310 100755 --- a/debian/rules +++ b/debian/rules @@ -36,7 +36,11 @@ substvars = AUTOGEN_DEB_FILES = config templates preinst postinst postrm dirs install links maintscript BUILD_PACKAGES := $(strip $(shell dh_listpackages)) +# REAL_PACKAGES build an actual grub variant (and therefore have both configure +# and build stages). EXTRA_PACKAGES do not build grub but may depend on a +# REAL_PACKAGE (and therefore only have a build stage) REAL_PACKAGES = grub-common grub-emu grub-pc grub-coreboot grub-efi-ia32 grub-efi-amd64 grub-efi-ia64 grub-efi-arm grub-efi-arm64 grub-ieee1275 grub-firmware-qemu grub-uboot grub-xen grub-yeeloong +EXTRA_PACKAGES = grub-rescue-pc grub-xen-host ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU))) COMMON_PLATFORM := pc @@ -109,7 +113,7 @@ override_dh_auto_build: $(patsubst %,build/%,$(BUILD_PACKAGES)) override_dh_auto_install: $(patsubst %,install/%,$(BUILD_PACKAGES)) $(patsubst %,configure/%,$(REAL_PACKAGES)) :: configure/% : debian/stamps/configure-% -$(patsubst %,build/%,$(REAL_PACKAGES) grub-rescue-pc) :: build/% : debian/stamps/build-% +$(patsubst %,build/%,$(REAL_PACKAGES) $(EXTRA_PACKAGES)) :: build/% : debian/stamps/build-% debian/stamps/configure-%: package = $(subst debian/stamps/configure-,,$@) debian/stamps/configure-%: export DH_OPTIONS = -p$(package) -Bobj/$(package) @@ -176,6 +180,32 @@ debian/stamps/build-grub-none debian/stamps/build-grub-efi-ia32 debian/stamps/bu dh_auto_build touch $@ +debian/stamps/build-grub-xen-host-i386: PVBOOT_ARCH := i386 +debian/stamps/build-grub-xen-host-amd64: PVBOOT_ARCH := x86_64 +debian/stamps/build-grub-xen-host-%: debian/stamps/build-grub-xen-% + target=$(subst debian/stamps/build-grub-xen-host-,,$@) ; \ + obj_dir=$(CURDIR)/obj/grub-xen-$${target} ; \ + grub_dir=`mktemp -d` ; \ + grub_memdisk=`mktemp` ; \ + trap "rm -rf $${grub_dir} $${grub_memdisk}" EXIT HUP INT QUIT TERM ; \ + mkdir -p $${grub_dir}/boot/grub ; \ + mkdir -p $(CURDIR)/obj/$(package) ; \ + sed -e "s/@@PVBOOT_ARCH@@/$(PVBOOT_ARCH)/g" \ + <debian/grub-xen-host_grub.cfg \ + >$${grub_dir}/grub.cfg ; \ + tar -cf - -C $${grub_dir} grub.cfg > $${grub_memdisk} ; \ + $${obj_dir}/grub-mkimage \ + -O $(PVBOOT_ARCH)-xen \ + -c $(CURDIR)/debian/grub-xen-host_grub-bootstrap.cfg \ + -d $${obj_dir}/grub-core \ + $${obj_dir}/grub-core/*.mod \ + -m $${grub_memdisk} \ + -o $(CURDIR)/obj/$(package)/grub-$(PVBOOT_ARCH)-xen.bin + touch $@ + +debian/stamps/build-grub-xen-host: debian/stamps/build-grub-xen-host-i386 debian/stamps/build-grub-xen-host-amd64 + touch $@ + debian/stamps/build-grub-pc: debian/stamps/configure-grub-pc dh_auto_build ifeq ($(with_check), yes) @@ -371,7 +401,7 @@ ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes)) endif override_dh_install: - dh_install -pgrub2 -pgrub-linuxbios -pgrub-efi -pgrub-rescue-pc -pgrub-firmware-qemu + dh_install -pgrub2 -pgrub-linuxbios -pgrub-efi -pgrub-rescue-pc -pgrub-firmware-qemu -pgrub-xen-host dh_install -pgrub-common -pgrub2-common -pgrub-theme-starfield -pgrub-mount-udeb --sourcedir=debian/tmp-grub-$(COMMON_PLATFORM) rm -f debian/grub2-common/usr/share/info/dir* rm -f debian/grub-theme-starfield/usr/share/grub/themes/starfield/COPYING.CC-BY-SA-3.0 @@ -400,8 +430,8 @@ endif endif override_dh_installdocs: - dh_installdocs -pgrub-common -pgrub-rescue-pc -pgrub-firmware-qemu -A AUTHORS NEWS README THANKS TODO - dh_installdocs -Ngrub-common -Ngrub-rescue-pc -Ngrub-firmware-qemu --link-doc=grub-common + dh_installdocs -pgrub-common -pgrub-rescue-pc -pgrub-firmware-qemu -pgrub-xen-host -A AUTHORS NEWS README THANKS TODO + dh_installdocs -Ngrub-common -Ngrub-rescue-pc -Ngrub-firmware-qemu -Ngrub-xen-host --link-doc=grub-common ifeq ($(FLICKER_FREE_BOOT),yes) override_dh_installinit: unblock grub2/2.02~beta2-16 Thanks, -- Colin Watson [[email protected]] -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: https://lists.debian.org/[email protected]

