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

Re: [Xen-devel] [PATCH] add upstream GRUB to the Xen build system



On Fri, 13 Mar 2015, Stefano Stabellini wrote:
> 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/
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

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.


>  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
> 
> diff --git a/Config.mk b/Config.mk
> index b243fac..907d79e 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -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.
>  
> diff --git a/tools/Makefile b/tools/Makefile
> index 5d7a75f..f58da71 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -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
> diff --git a/tools/pvgrub2/Makefile b/tools/pvgrub2/Makefile
> new file mode 100644
> index 0000000..79860e3
> --- /dev/null
> +++ b/tools/pvgrub2/Makefile
> @@ -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-update
> diff --git a/tools/pvgrub2/grub-bootstrap.cfg 
> b/tools/pvgrub2/grub-bootstrap.cfg
> new file mode 100644
> index 0000000..e988314
> --- /dev/null
> +++ b/tools/pvgrub2/grub-bootstrap.cfg
> @@ -0,0 +1 @@
> +normal (memdisk)/grub.cfg
> diff --git a/tools/pvgrub2/grub.cfg b/tools/pvgrub2/grub.cfg
> new file mode 100644
> index 0000000..1600b1e
> --- /dev/null
> +++ b/tools/pvgrub2/grub.cfg
> @@ -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
> -- 
> 1.7.10.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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