On Mon, 2014-08-25 at 22:46 +0100, Colin Watson wrote: > On Sat, Aug 23, 2014 at 09:38:07PM +0100, Ian Campbell wrote: > > I'm attaching a new version with a grub.cfg which is tested and seems to > > work. I've also taken the liberty of filing this into a wishlist bug > > (keeping entire quoted text below for the bug). > > This generally looks good to me, thanks! As you said in a follow-up, > there is the matter of establishing this as a boot protocol upstream, > which I hope I can leave up to you to sort out.
Ack. > For the information of pkg-grub-devel: I have given Ian commit access to > pkg-grub, on the basis that he is much more familiar with Xen than I am > and can start maintaining the Xen-related bits himself. Welcome! Thanks. Is there a policy regarding using e.g. people/foo branches in the main grub.git or shall I go create myself a gitorious repo for WIP stuff? I've attached a little mini series which addresses the issues you raised and switches to the proposed /boot/xen naming scheme. I've also added some new patches. The first causes grub-xen to actually produce things under /boot/xen, I'm not entirely sure about it though -- it places /boot/xen/pvboot-x86_64.elf as required but grubdir (e.g. all the modules etc) are still under /boot/grub. I wasn't sure if it was better to actually move grubdir to /boot/xen too. The implementation is a bit unsatisfactory since grub-mkimage doesn't let you change only the output file without moving grubdir (AFAICT), so it generates and then moves it. Lastly I made grub-xen not conflict with the other grub-* package. grub-xen is a bit of a special case since you can have a filesystem which is bootable both as PV (grub-xen) or HVM (grub-pc or grub-efi). > > I needed to do a little hack which is to rmmod memdisk before searching > > for /boot/grub/grub.cfg or else it just loops infinitely finding the > > grub.cfg in the memdisk. I have a feeling that the same thing might > > apply to debian/grub-firmware-qemu_grub.cfg. > > This is what > https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00185.html and > subthread was about, but that never reached a clear conclusion, although > Andrey's patch seemed fairly reasonable to me. The rmmod hack is OK for > now. Switching to using "normal" made this go away in the end, since the bootstrap.cfg doesn't need to use /boot/grub/grub.cfg as it's next stage, so there is no conflict. Ian.
From 836a409fc5474d657beef0f6bc5807daa39d935d Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Mon, 25 Aug 2014 22:43:13 +0100 Subject: [PATCH 1/4] Add EXTRA_PACKAGES to debian/rules which for now contains only grub-rescue-pc. --- debian/rules | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index f478e94..4a6a52c 100755 --- a/debian/rules +++ b/debian/rules @@ -35,7 +35,11 @@ confflags = PACKAGE_VERSION="$(deb_version)" PACKAGE_STRING="GRUB $(deb_version) 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-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 ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU))) COMMON_PLATFORM := pc @@ -107,7 +111,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) -- 2.0.1
From 81510bf5f8090577b17dfdad52438cf22c6f52a6 Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Sun, 27 Jul 2014 18:48:01 +0100 Subject: [PATCH 2/4] Provide prebuilt grub-xen binaries for host use in a new grub-xen-host package. These can be referenced via kernel= in guest cfg to boot a guest using grub2. debian/grub-xen-host_grub.cfg is the same as the qemu-firmware variant, although I'm not sure what the best content is so it's more of a placeholder for now. --- v3: Use EXTRA_PACKAGES, drop unnecessary debian/grub-xen-host.dirs, use "normal" command/shell to interpret the grub.cfg which allows proper use of "if" etc., use proposed spec paths. http://lists.xen.org/archives/html/xen-devel/2014-08/msg02964.html v2: Include a usable grub.cfg --- debian/changelog | 5 +++++ debian/control | 17 +++++++++++++++++ debian/grub-xen-host.install | 2 ++ debian/grub-xen-host_grub-bootstrap.cfg | 1 + debian/grub-xen-host_grub.cfg | 24 +++++++++++++++++++++++ debian/rules | 34 +++++++++++++++++++++++++++++---- 6 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 debian/grub-xen-host.install create mode 100644 debian/grub-xen-host_grub-bootstrap.cfg create mode 100644 debian/grub-xen-host_grub.cfg diff --git a/debian/changelog b/debian/changelog index 3babeee..70efa0a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,12 @@ grub2 (2.02~beta2-12) UNRELEASED; urgency=medium + [ Colin Watson ] * Point Vcs-* fields back at master. + [ Ian Campbell ] + * Provide prebuilt grub-xen binaries for host use in a new grub-xen-host + package. + -- Colin Watson <cjwat...@debian.org> Tue, 19 Aug 2014 13:19:40 +0100 grub2 (2.02~beta2-11) unstable; urgency=medium diff --git a/debian/control b/debian/control index bb4540d..b6dec59 100644 --- a/debian/control +++ b/debian/control @@ -632,6 +632,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_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/rules b/debian/rules index 4a6a52c..6a84461 100755 --- a/debian/rules +++ b/debian/rules @@ -39,7 +39,7 @@ BUILD_PACKAGES := $(strip $(shell dh_listpackages)) # 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-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 +EXTRA_PACKAGES = grub-rescue-pc grub-xen-host ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU))) COMMON_PLATFORM := pc @@ -181,6 +181,32 @@ debian/stamps/build-grub-efi-ia32 debian/stamps/build-grub-efi-amd64 debian/stam 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) @@ -360,7 +386,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 @@ -387,8 +413,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 (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes)) override_dh_installinit: -- 2.0.1
From 6a0290e4c084a75cd078cd1ab531db78635a8b5d Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Wed, 27 Aug 2014 00:35:08 +0100 Subject: [PATCH 3/4] Build/Install binaries into /boot/xen when installing grub-xen. --- debian/changelog | 1 + debian/postinst.in | 10 ++++++++++ debian/rules | 3 +++ 3 files changed, 14 insertions(+) diff --git a/debian/changelog b/debian/changelog index 70efa0a..d6d39b4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ grub2 (2.02~beta2-12) UNRELEASED; 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. -- Colin Watson <cjwat...@debian.org> Tue, 19 Aug 2014 13:19:40 +0100 diff --git a/debian/postinst.in b/debian/postinst.in index 558a50d..dcaea1d 100644 --- a/debian/postinst.in +++ b/debian/postinst.in @@ -719,6 +719,16 @@ 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. + grub-install --target=x86_64-xen && mv /boot/grub/x86_64-xen/core.elf /boot/xen/pvboot-x86_64.elf + case $(dpkg --print-architecture) in + i386) + grub-install --target=i386-xen && mv /boot/grub/i386-xen/core.elf /boot/xen/pvboot-i386.elf + ;; + esac + ;; esac # If grub.cfg has been generated, update it. diff --git a/debian/rules b/debian/rules index 6a84461..44b8db9 100755 --- a/debian/rules +++ b/debian/rules @@ -343,6 +343,9 @@ install/grub-pc install/grub-efi-ia32 install/grub-efi-amd64 install/grub-efi-ia echo "$(package_bin): binary-from-other-architecture *efiemu64.o" \ >> debian/$(package_bin)/usr/share/lintian/overrides/$(package_bin) ; \ fi + if [ "$@" = "install/grub-xen" ] ; then \ + mkdir -p debian/$(package_bin)/boot/xen ; \ + fi mkdir -p debian/$(package_dbg)/usr/share/lintian/overrides echo "$(package_dbg): unstripped-binary-or-object *.module" \ -- 2.0.1
From 12380143dce29ee969859b50dedf363b06b4dfec Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Wed, 27 Aug 2014 00:39:00 +0100 Subject: [PATCH 4/4] Allow grub-xen to be coinstallable with other grub-*. This allows grub-xen and grub-{pc,efi,etc} to be coninstalled which allows for a filesystem image to be booted either PV or HVM. --- debian/changelog | 2 ++ debian/control | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index d6d39b4..03fbabb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ grub2 (2.02~beta2-12) UNRELEASED; urgency=medium * 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. + * Allow grub-xen to be coinstallable with other grub-*, to allow switching a + guest from HVM to PV (and vice versa) -- Colin Watson <cjwat...@debian.org> Tue, 19 Aug 2014 13:19:40 +0100 diff --git a/debian/control b/debian/control index b6dec59..11467bc 100644 --- a/debian/control +++ b/debian/control @@ -155,7 +155,7 @@ Priority: optional Architecture: any-i386 any-amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-pc-bin (= ${binary:Version}), ucf, freebsd-utils (>= 8.0-4) [kfreebsd-any], ${gfxpayload-depends} Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<= 1.97~beta2-1), grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275 -Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275, grub-xen +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275 Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (PC/BIOS version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a @@ -220,7 +220,7 @@ Package: grub-coreboot Architecture: any-i386 any-amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-coreboot-bin (= ${binary:Version}), ucf Replaces: grub-legacy, grub2 (<< ${source:Version}), grub-common (<= 1.97~beta2-1), grub-linuxbios, grub-efi-amd64, grub-efi-ia32, grub-pc, grub-ieee1275 -Conflicts: grub (<< 0.97-54), grub-legacy, grub-linuxbios (<< ${source:Version}), grub-efi-amd64, grub-efi-ia32, grub-pc, grub-ieee1275, grub-xen +Conflicts: grub (<< 0.97-54), grub-legacy, grub-linuxbios (<< ${source:Version}), grub-efi-amd64, grub-efi-ia32, grub-pc, grub-ieee1275 Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (Coreboot version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a @@ -269,7 +269,7 @@ Package: grub-efi-ia32 Architecture: any-i386 any-amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-efi-ia32-bin (= ${binary:Version}), ucf Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<= 1.97~beta2-1), grub-efi, grub-efi-amd64, grub-pc, grub-coreboot, grub-ieee1275 -Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-pc, grub-coreboot, grub-ieee1275, grub-xen, elilo +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-pc, grub-coreboot, grub-ieee1275, elilo Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (EFI-IA32 version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a @@ -319,7 +319,7 @@ Package: grub-efi-amd64 Architecture: i386 kopensolaris-i386 any-amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-efi-amd64-bin (= ${binary:Version}), ucf Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<= 1.97~beta2-1), grub-pc, grub-efi-ia32, grub-coreboot, grub-ieee1275 -Conflicts: grub, grub-legacy, grub-efi-ia32, grub-pc, grub-coreboot, grub-ieee1275, grub-xen, elilo +Conflicts: grub, grub-legacy, grub-efi-ia32, grub-pc, grub-coreboot, grub-ieee1275, elilo Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (EFI-AMD64 version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a @@ -506,7 +506,7 @@ Package: grub-ieee1275 Architecture: any-i386 any-amd64 any-powerpc any-ppc64 any-ppc64el any-sparc any-sparc64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-ieee1275-bin (= ${binary:Version}), ucf, powerpc-ibm-utils (>= 1.2.12-1) [any-powerpc any-ppc64 any-ppc64el], powerpc-utils [any-powerpc any-ppc64 any-ppc64el] Replaces: grub-legacy, grub2 (<< ${source:Version}), grub-common (<= 1.97~beta2-1), grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-pc -Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-pc, grub-xen +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-pc Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (Open Firmware version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a @@ -617,7 +617,7 @@ Description: GRand Unified Bootloader, version 2 (Xen debug files) Package: grub-xen Architecture: i386 amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, grub2-common (= ${binary:Version}), grub-xen-bin (= ${binary:Version}), ucf -Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275, grub-pc +Conflicts: grub (<< 0.97-54), grub-legacy Multi-Arch: foreign Description: GRand Unified Bootloader, version 2 (Xen version) GRUB is a portable, powerful bootloader. This version of GRUB is based on a -- 2.0.1