add upstream GRUB to the Xen build system
PATCH 1/1 add upstream GRUB to the Xen build system
Clone and build upstream GRUB to generate x86_64 and i386 pvgrub2 binaries. See Ian's blog post for more information:
https://blog.xenproject.org/2015/01/07/using-grub-2-as-a-bootloader-for-xen-pv-guests/
--- Config.mk | 3 ++ tools/Makefile | 1 + tools/pvgrub2/Makefile | 68 ++++++++++++++++++++++++++++++++++++++ tools/pvgrub2/grub-bootstrap.cfg | 1 + tools/pvgrub2/grub.cfg | 21 ++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 tools/pvgrub2/Makefile create mode 100644 tools/pvgrub2/grub-bootstrap.cfg create mode 100644 tools/pvgrub2/grub.cfg
Config.mk +3 -0
@@ -246,16 +246,19 @@ QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-upstream-unstable.git QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-unstable.git SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git +GRUB_UPSTREAM_URL ?= http://git.savannah.gnu.org/r/grub.git else OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-upstream-unstable.git QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-unstable.git SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git +GRUB_UPSTREAM_URL ?= git://git.savannah.gnu.org/grub.git endif OVMF_UPSTREAM_REVISION ?= a065efc7c7ce8bb3e5cb3e463099d023d4a92927 QEMU_UPSTREAM_REVISION ?= master MINIOS_UPSTREAM_REVISION ?= edfd5aae6ec5ba7d0a8834a3e9dfe5e69424150a +GRUB_UPSTREAM_REVISION ?= master # Thu Mar 12 19:08:05 2015 +0100 # Fix accidentally removed brace causing a build error.
tools/Makefile +1 -0
@@ -32,6 +32,7 @@ SUBDIRS-y += libxl SUBDIRS-$(CONFIG_X86) += xenpaging SUBDIRS-$(CONFIG_X86) += debugger/gdbsx SUBDIRS-$(CONFIG_X86) += debugger/kdd +SUBDIRS-$(CONFIG_X86) += pvgrub2 SUBDIRS-$(CONFIG_TESTS) += tests # These don't cross-compile
tools/pvgrub2/Makefile new file +68 -0
68 lines not on this page · raw message
tools/pvgrub2/grub-bootstrap.cfg new file +1 -0
@@ -0,0 +1 @@ +normal (memdisk)/grub.cfg
tools/pvgrub2/grub.cfg new file +21 -0
@@ -0,0 +1,21 @@ +if search -s -f /boot/xen/pvboot-x86_64.elf ; then + echo "Chainloading (${root})/boot/xen/pvboot-x86_64.elf" + multiboot "/boot/xen/pvboot-x86_64.elf" + boot +fi + +if search -s -f /xen/pvboot-x86_64.elf ; then + echo "Chainloading (${root})/xen/pvboot-x86_64.elf" + multiboot "/xen/pvboot-x86_64.elf" + boot +fi + +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
Signature · 1 line
1.7.10.4
Quoted 6 lines · Stefano Stabellini
Clone and build upstream GRUB to generate
x86_64and i386 pvgrub2 binaries. See Ian's blog post for more information:https://blog.xenproject.org/2015/01/07/using-grub-2-as-a-bootloader-for-xen-pv-guests/
Signed-off-by Stefano Stabellini <[email protected]>
The two GRUB_UPSTREAM URLs below need to be changed to point to local xenbits mirrors, but it can be done directly be the committer.
Quoted 157 lines
Config.mk | 3 ++ tools/Makefile | 1 + tools/pvgrub2/Makefile | 68 ++++++++++++++++++++++++++++++++++++++ tools/pvgrub2/grub-bootstrap.cfg | 1 + tools/pvgrub2/grub.cfg | 21 ++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 tools/pvgrub2/Makefile create mode 100644 tools/pvgrub2/grub-bootstrap.cfg create mode 100644 tools/pvgrub2/grub.cfgConfig.mk +3
-0@@ -246,16 +246,19 @@ QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-upstream-unstable.git QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-unstable.git SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git +GRUB_UPSTREAM_URL ?= http://git.savannah.gnu.org/r/grub.git else OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-upstream-unstable.git QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-unstable.git SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git +GRUB_UPSTREAM_URL ?= git://git.savannah.gnu.org/grub.git endif OVMF_UPSTREAM_REVISION ?= a065efc7c7ce8bb3e5cb3e463099d023d4a92927 QEMU_UPSTREAM_REVISION ?= master MINIOS_UPSTREAM_REVISION ?= edfd5aae6ec5ba7d0a8834a3e9dfe5e69424150a +GRUB_UPSTREAM_REVISION ?= master # Thu Mar 12 19:08:05 2015 +0100 # Fix accidentally removed brace causing a build error.tools/Makefile +1
-0@@ -32,6 +32,7 @@ SUBDIRS-y += libxl SUBDIRS-$(CONFIG_X86) += xenpaging SUBDIRS-$(CONFIG_X86) += debugger/gdbsx SUBDIRS-$(CONFIG_X86) += debugger/kdd +SUBDIRS-$(CONFIG_X86) += pvgrub2 SUBDIRS-$(CONFIG_TESTS) += tests # These don't cross-compiletools/pvgrub2/Makefile new file +68
-0@@ -0,0 +1,68 @@ +XEN_ROOT = $(CURDIR)/../.. +include $(XEN_ROOT)/tools/Rules.mk + +TARGET64 := grub-x86_64-xen +TARGET32 := grub-i386-xen +INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR) + +grub-dir: + GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(GRUB_UPSTREAM_URL) $(GRUB_UPSTREAM_REVISION) grub-dir + cd grub-dir && ./autogen.sh + +.PHONY: build +build: grub-build32 grub-build64 + +memdisk.tar: + tar cf memdisk.tar grub.cfg + +grub-build32: grub-dir memdisk.tar + test -d grub-build32 || mkdir grub-build32 + cd grub-build32 && \ + ../grub-dir/configure --target=i386 --with-platform=xen + $(MAKE) -C grub-build32 + cd grub-build32 && \ + ./grub-mkimage -d grub-core -O i386-xen -c ../grub-bootstrap.cfg \ + -m ../memdisk.tar -o $(TARGET32) grub-core/*mod + +grub-build64: grub-dir memdisk.tar + test -d grub-build64 || mkdir grub-build64 + cd grub-build64 && ../grub-dir/configure --target=amd64 --with-platform=xen + $(MAKE) -C grub-build64 + cd grub-build64 && \ + ./grub-mkimage -d grub-core -O x86_64-xen -c ../grub-bootstrap.cfg \ + -m ../memdisk.tar -o $(TARGET64) grub-core/*mod + +.PHONY: install +install: build + test -d $(INST_DIR) || mkdir -p $(INST_DIR) + cp grub-build32/$(TARGET32) $(INST_DIR) + cp grub-build64/$(TARGET64) $(INST_DIR) + +.PHONY: distclean +distclean: subdir-distclean-grub-dir + +.PHONY: clean +clean: subdir-clean-grub-dir + +subdir-distclean-grub-dir: subdir-clean-grub-dir + rm -rf grub-dir + +subdir-clean-grub-dir: + rm -rf memdisk.tar + rm -rf grub-build32 + rm -rf grub-build64 + +.PHONY: grub-dir-force-update +grub-dir-force-update: grub-dir + set -ex; \ + if [ "$(GRUB_UPSTREAM_REVISION)" ]; then \ + cd grub-dir-dir; \ + $(GIT) fetch origin; \ + $(GIT) reset --hard $(GRUB_UPSTREAM_REVISION); \ + fi + +subtree-force-update: + $(MAKE) grub-dir-force-update + +subtree-force-update-all: + $(MAKE) grub-dir-force-updatetools/pvgrub2/grub-bootstrap.cfg new file +1
-0@@ -0,0 +1 @@ +normal (memdisk)/grub.cfgtools/pvgrub2/grub.cfg new file +21
-0@@ -0,0 +1,21 @@ +if search -s -f /boot/xen/pvboot-x86_64.elf ; then + echo "Chainloading (${root})/boot/xen/pvboot-x86_64.elf" + multiboot "/boot/xen/pvboot-x86_64.elf" + boot +fi + +if search -s -f /xen/pvboot-x86_64.elf ; then + echo "Chainloading (${root})/xen/pvboot-x86_64.elf" + multiboot "/xen/pvboot-x86_64.elf" + boot +fi + +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 +fiSignature · 1 line
1.7.10.4
Quoted 2 lines · Stefano Stabellini
Clone and build upstream GRUB to generate
x86_64and i386 pvgrub2 binaries. See Ian's blog post for more information:
Why? If pvgrub2 is available on the system libxl should make use of it, but there doesn't seem to be a good reason for cloning and building yet another third-party project as part of the Xen build.
At a minimum this needs a configure option to disable it.
David
Quoted 9 lines · David Vrabel
Quoted 2 lines · Stefano Stabellini
Clone and build upstream GRUB to generate
x86_64and i386 pvgrub2 binaries. See Ian's blog post for more information:Why? If pvgrub2 is available on the system libxl should make use of it, but there doesn't seem to be a good reason for cloning and building yet another third-party project as part of the Xen build.
At a minimum this needs a configure option to disable it.
It is the only way to boot grub2 pv guests securely. More importantly it is also the first step toward adding an osstest test for upstream grub.
Finally it will allow us to get rid of pvgrub1 in the future. As a matter of fact I already have a patch to remove pvgrub, if the maintainers feel that it is already the time I am happy to send it out.
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · David Vrabel
Quoted 2 lines · Stefano Stabellini
Clone and build upstream GRUB to generate
x86_64and i386 pvgrub2 binaries. See Ian's blog post for more information:Why? If pvgrub2 is available on the system libxl should make use of it, but there doesn't seem to be a good reason for cloning and building yet another third-party project as part of the Xen build.
Quoted 5 lines
Quoted 1 line
At a minimum this needs a configure option to disable it.
It is the only way to boot grub2 pv guests securely. More importantly it is also the first step toward adding an osstest test for upstream grub.
osstest can clone and build grub if necessary, it doesn't need to be part of the Xen build.
Quoted 3 lines
Finally it will allow us to get rid of pvgrub1 in the future. As a matter of fact I already have a patch to remove pvgrub, if the maintainers feel that it is already the time I am happy to send it out.
The majority of projects would handle this by listing grub 2.x as a requirement in the release notes or similar.
David
Il 13/03/2015 17:24, David Vrabel ha scritto:
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · David Vrabel
Quoted 7 lines · Stefano Stabellini
Quoted 2 lines
Clone and build upstream GRUB to generate
x86_64and i386 pvgrub2 binaries. See Ian's blog post for more information:Why? If pvgrub2 is available on the system libxl should make use of it, but there doesn't seem to be a good reason for cloning and building yet another third-party project as part of the Xen build.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
At a minimum this needs a configure option to disable it.
It is the only way to boot grub2 pv guests securely. More importantly it is also the first step toward adding an osstest test for upstream grub.
osstest can clone and build grub if necessary, it doesn't need to be part of the Xen build.
I think that add upstream pvgrub2 build in xen is good but I think that is good add also all these things about:
- make build of it optional even if enabled by default
- make possible choose it from system binary instead build it (see seabios, upstream qemu and ovmf)
- make easy and fast select and use it from libxl in both cases, for example with bootloader="pvgrub2"
Thanks for any reply and sorry for my bad english.
Quoted 14 lines
Quoted 4 lines
Finally it will allow us to get rid of pvgrub1 in the future. As a matter of fact I already have a patch to remove pvgrub, if the maintainers feel that it is already the time I am happy to send it out.
The majority of projects would handle this by listing grub 2.x as a requirement in the release notes or similar.
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel