* [PATCH] add upstream GRUB to the Xen build system
@ 2015-03-13 15:33 Stefano Stabellini
2015-03-13 15:55 ` Stefano Stabellini
2015-03-13 15:58 ` David Vrabel
0 siblings, 2 replies; 6+ messages in thread
From: Stefano Stabellini @ 2015-03-13 15:33 UTC (permalink / raw)
To: xen-devel; +Cc: ian.jackson, wei.liu2, ian.campbell, stefano.stabellini
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@eu.citrix.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] add upstream GRUB to the Xen build system
2015-03-13 15:33 [PATCH] add upstream GRUB to the Xen build system Stefano Stabellini
@ 2015-03-13 15:55 ` Stefano Stabellini
2015-03-13 15:58 ` David Vrabel
1 sibling, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2015-03-13 15:55 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: ian.jackson, wei.liu2, ian.campbell, xen-devel
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@eu.citrix.com>
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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add upstream GRUB to the Xen build system
2015-03-13 15:33 [PATCH] add upstream GRUB to the Xen build system Stefano Stabellini
2015-03-13 15:55 ` Stefano Stabellini
@ 2015-03-13 15:58 ` David Vrabel
2015-03-13 16:02 ` Stefano Stabellini
1 sibling, 1 reply; 6+ messages in thread
From: David Vrabel @ 2015-03-13 15:58 UTC (permalink / raw)
To: Stefano Stabellini, xen-devel; +Cc: wei.liu2, ian.jackson, ian.campbell
On 13/03/15 15:33, Stefano Stabellini wrote:
> Clone and build upstream GRUB to generate x86_64 and 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add upstream GRUB to the Xen build system
2015-03-13 15:58 ` David Vrabel
@ 2015-03-13 16:02 ` Stefano Stabellini
2015-03-13 16:24 ` David Vrabel
0 siblings, 1 reply; 6+ messages in thread
From: Stefano Stabellini @ 2015-03-13 16:02 UTC (permalink / raw)
To: David Vrabel
Cc: ian.jackson, xen-devel, wei.liu2, ian.campbell,
Stefano Stabellini
On Fri, 13 Mar 2015, David Vrabel wrote:
> On 13/03/15 15:33, Stefano Stabellini wrote:
> > Clone and build upstream GRUB to generate x86_64 and 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add upstream GRUB to the Xen build system
2015-03-13 16:02 ` Stefano Stabellini
@ 2015-03-13 16:24 ` David Vrabel
2015-03-16 12:22 ` Fabio Fantoni
0 siblings, 1 reply; 6+ messages in thread
From: David Vrabel @ 2015-03-13 16:24 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: ian.jackson, wei.liu2, ian.campbell, xen-devel
On 13/03/15 16:02, Stefano Stabellini wrote:
> On Fri, 13 Mar 2015, David Vrabel wrote:
>> On 13/03/15 15:33, Stefano Stabellini wrote:
>>> Clone and build upstream GRUB to generate x86_64 and 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.
osstest can clone and build grub if necessary, it doesn't need to be
part of the Xen build.
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add upstream GRUB to the Xen build system
2015-03-13 16:24 ` David Vrabel
@ 2015-03-16 12:22 ` Fabio Fantoni
0 siblings, 0 replies; 6+ messages in thread
From: Fabio Fantoni @ 2015-03-16 12:22 UTC (permalink / raw)
To: David Vrabel, Stefano Stabellini
Cc: wei.liu2, ian.jackson, ian.campbell, xen-devel
Il 13/03/2015 17:24, David Vrabel ha scritto:
> On 13/03/15 16:02, Stefano Stabellini wrote:
>> On Fri, 13 Mar 2015, David Vrabel wrote:
>>> On 13/03/15 15:33, Stefano Stabellini wrote:
>>>> Clone and build upstream GRUB to generate x86_64 and 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.
> 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.
>
>> 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
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-16 12:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-13 15:33 [PATCH] add upstream GRUB to the Xen build system Stefano Stabellini
2015-03-13 15:55 ` Stefano Stabellini
2015-03-13 15:58 ` David Vrabel
2015-03-13 16:02 ` Stefano Stabellini
2015-03-13 16:24 ` David Vrabel
2015-03-16 12:22 ` Fabio Fantoni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.