Subject: [alpine-devel] [PATCH] testing/xen: add xen 4.1.2

From: Roger Pau Monne <[email-masked]>
Date: Tue, 27 Dec 2011 22:01:26 +0100

Build full Xen distribution.
---
 testing/xen/APKBUILD                       |   88 +++++++++++++++
 testing/xen/blktap2_libvhd_add_iconv.patch |   31 +++++
 testing/xen/define_fsimage_dir.patch       |   12 ++
 testing/xen/detect_libiconv.patch          |   22 ++++
 testing/xen/fix_bswap_blktap.patch         |   61 ++++++++++
 testing/xen/fix_bswap_blktap2.patch        |   62 +++++++++++
 testing/xen/fix_ipxe_no_pie_default.patch  |  165 ++++++++++++++++++++++++++++
 testing/xen/xencommons.initd               |   96 ++++++++++++++++
 testing/xen/xend.initd                     |   38 +++++++
 testing/xen/xendomains.initd               |   63 +++++++++++
 10 files changed, 638 insertions(+), 0 deletions(-)
 create mode 100644 testing/xen/APKBUILD
 create mode 100644 testing/xen/blktap2_libvhd_add_iconv.patch
 create mode 100644 testing/xen/define_fsimage_dir.patch
 create mode 100644 testing/xen/detect_libiconv.patch
 create mode 100644 testing/xen/fix_bswap_blktap.patch
 create mode 100644 testing/xen/fix_bswap_blktap2.patch
 create mode 100644 testing/xen/fix_ipxe_no_pie_default.patch
 create mode 100755 testing/xen/xencommons.initd
 create mode 100644 testing/xen/xend.initd
 create mode 100644 testing/xen/xendomains.initd

diff --git a/testing/xen/APKBUILD b/testing/xen/APKBUILD
new file mode 100644
index 0000000..5282a33
--- /dev/null
+++ b/testing/xen/APKBUILD
@@ -0,0 +1,88 @@
+# Contributor: Roger Pau Monne <[email-masked]>
+# Maintainer:
+pkgname=xen
+pkgver=4.1.2
+pkgrel=0
+pkgdesc="Xen hypervisor"
+url="http://www.xen.org"
+arch="x86 x86_64"
+license="GPL"
+depends="udev syslinux"
+depends_dev="openssl-dev python-dev e2fsprogs-dev gettext zlib-dev ncurses-dev libiconv-dev dev86 texinfo perl iasl sed"
+makedepends="$depends_dev"
+install=""
+subpackages="$pkgname-doc"
+source="http://bits.xensource.com/oss-xen/release/$pkgver/$pkgname-$pkgver.tar.gz
+	blktap2_libvhd_add_iconv.patch
+	detect_libiconv.patch
+	fix_bswap_blktap.patch
+	fix_bswap_blktap2.patch
+	fix_ipxe_no_pie_default.patch
+	define_fsimage_dir.patch
+	xencommons.initd
+	xend.initd
+	xendomains.initd"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+
+	# remove all -Werror
+	msg "Eradicating -Werror..."
+	find -name '*.mk' -o -name 'Make*' | xargs sed -i -e 's/-Werror//g'
+
+	echo "LIBLEAFDIR_x86_64=lib" >> .config
+}
+
+build() {
+	cd "$_builddir"
+
+	# Unset CFLAGS and LDFLAGS because the xen build system
+	# doesn't support them. Instead use .config in xen root
+	# folder if necessary.
+	unset CFLAGS
+	unset LDFLAGS
+
+	msg "Running preflight check..."
+        (cd tools/check; ./chk build) || return 1
+
+        msg "Building hypervisor..."
+        make -j1 xen || return 1
+
+        msg "Building tools..."
+        make -j1 tools || return 1
+
+        msg "Building stub domains..."
+        make -j1 stubdom || return 1
+}
+
+package() {
+	cd "$_builddir"
+
+	unset CFLAGS
+        unset LDFLAGS
+
+        make -j1 DESTDIR="$pkgdir" install-xen install-tools install-stubdom \
+                || return 1
+
+        install -m755 -D "$srcdir"/xencommons.initd "$pkgdir"/etc/init.d/xencommons
+        install -m755 -D "$srcdir"/xend.initd "$pkgdir"/etc/init.d/xend
+        install -m755 -D "$srcdir"/xendomains.initd "$pkgdir"/etc/init.d/xendomains
+}
+
+md5sums="73561faf3c1b5e36ec5c089b5db848ad  xen-4.1.2.tar.gz
+6d4b045ae56be6288733d0e078f591ea  blktap2_libvhd_add_iconv.patch
+ed3283697cb1ddff066f4087eabf68c6  detect_libiconv.patch
+503f0883f4a0b50fe4e37e09ed9a6177  fix_bswap_blktap.patch
+b973dc1ffcc6872e222b36f3b7b4836b  fix_bswap_blktap2.patch
+10dcf0b6a05691e9f88afc01bd414480  fix_ipxe_no_pie_default.patch
+0bb8a435020a5a49b38b1a447fb69977  define_fsimage_dir.patch
+196e3ec5293554affa1b570e0dcbe7e6  xencommons.initd
+5ee6a16ec70dfbcd4944ded71b393fa2  xend.initd
+a2b5234483f1b5892d22e9315d9c307f  xendomains.initd"
diff --git a/testing/xen/blktap2_libvhd_add_iconv.patch b/testing/xen/blktap2_libvhd_add_iconv.patch
new file mode 100644
index 0000000..2353e38
--- /dev/null
+++ b/testing/xen/blktap2_libvhd_add_iconv.patch
@@ -0,0 +1,31 @@
+# HG changeset patch
+# Parent 14e911353a91702b439bc06e2a77d67e8bd5f661
+blktap2/vhd: add -liconv when linking if using libiconv
+
+If libiconv is detected on the system add -liconv when linking the 
+libvhd library.
+
+If -liconv is not added when compiling libvhd with libiconv the 
+following error occours when linking vhd-util and vhd-update:
+
+gcc     -o vhd-util vhd-util.o -Llib -lvhd
+lib/libvhd.so: undefined reference to `libiconv_open'
+lib/libvhd.so: undefined reference to `libiconv_close'
+lib/libvhd.so: undefined reference to `libiconv'
+
+Signed-off-by: Roger Pau Monne <[email-masked]>
+
+diff -r 14e911353a91 tools/blktap2/vhd/lib/Makefile
+--- a/tools/blktap2/vhd/lib/Makefile	Tue Dec 20 02:30:12 2011 +0100
++++ b/tools/blktap2/vhd/lib/Makefile	Tue Dec 20 02:33:11 2011 +0100
+@@ -23,6 +23,10 @@ ifeq ($(CONFIG_Linux),y)
+ LIBS            := -luuid
+ endif
+ 
++ifeq ($(CONFIG_LIBICONV),y)
++LIBS            += -liconv
++endif
++
+ LIB-SRCS        := libvhd.c
+ LIB-SRCS        += libvhd-journal.c
+ LIB-SRCS        += vhd-util-coalesce.c
diff --git a/testing/xen/define_fsimage_dir.patch b/testing/xen/define_fsimage_dir.patch
new file mode 100644
index 0000000..04e4aed
--- /dev/null
+++ b/testing/xen/define_fsimage_dir.patch
@@ -0,0 +1,12 @@
+diff -r 2863b2f43a3b tools/libfsimage/common/Makefile
+--- a/tools/libfsimage/common/Makefile	Thu Dec 22 14:49:38 2011 +0000
++++ b/tools/libfsimage/common/Makefile	Tue Dec 27 21:00:54 2011 +0100
+@@ -4,6 +4,8 @@
+ MAJOR = 1.0
+ MINOR = 0
+ 
++CFLAGS += -DFSIMAGE_FSDIR=\"/usr/lib/fs\"
++
+ LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS
+ LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU
+ LDFLAGS = $(LDFLAGS-y)
diff --git a/testing/xen/detect_libiconv.patch b/testing/xen/detect_libiconv.patch
new file mode 100644
index 0000000..5b2359e
--- /dev/null
+++ b/testing/xen/detect_libiconv.patch
@@ -0,0 +1,22 @@
+# HG changeset patch
+# Parent 2bc60167b9f8791747d2cea09c5207a9c2d7ef7b
+build: detect is libiconv is present
+
+Detect if libiconv is present in the system, since we will have to
+link against it when using iconv.
+
+Signed-off-by: Roger Pau Monne <[email-masked]>
+
+diff -r 2bc60167b9f8 Config.mk
+--- a/Config.mk	Tue Dec 20 05:25:19 2011 +0100
++++ b/Config.mk	Tue Dec 20 07:52:38 2011 +0100
+@@ -9,6 +9,10 @@
+ XEN_OS              ?= $(shell uname -s)
+ 
+ CONFIG_$(XEN_OS) := y
++CONFIG_LIBICONV     := $(shell export OS="`uname -s`"; \
++                       export CHECK_LIB="$(CHECK_LIB)"; \
++                       . $(XEN_ROOT)/tools/check/funcs.sh; \
++                       has_lib libiconv.so && echo 'y' || echo 'n')
+ 
+ SHELL     ?= /bin/sh
diff --git a/testing/xen/fix_bswap_blktap.patch b/testing/xen/fix_bswap_blktap.patch
new file mode 100644
index 0000000..71671d9
--- /dev/null
+++ b/testing/xen/fix_bswap_blktap.patch
@@ -0,0 +1,61 @@
+# HG changeset patch
+# Parent d61e6300274bbc6bc464ad340146bd81e91f64f3
+blktap: remove local definitions and include byteswap.h
+
+Use the same approach as tools/blktap2/include/libvhd.h, remove local
+definitions of bswap* and include byteswap.h. Also remove the
+HAVE_BYTESWAP_H ifdef, since it was not defined in this context (it's
+defined by QEMU).
+
+Signed-off-by: Roger Pau Monne <[email-masked]>
+
+diff -r d61e6300274b tools/blktap/drivers/bswap.h
+--- a/tools/blktap/drivers/bswap.h	Tue Dec 20 05:20:02 2011 +0100
++++ b/tools/blktap/drivers/bswap.h	Tue Dec 20 05:24:16 2011 +0100
+@@ -13,45 +13,9 @@
+ #define bswap_16(x) swap16(x)
+ #define bswap_32(x) swap32(x)
+ #define bswap_64(x) swap64(x)
+-#else
++#elif defined(__linux__)
+ 
+-#ifdef HAVE_BYTESWAP_H
+ #include <byteswap.h>
+-#else
+-
+-#define bswap_16(x) \
+-({ \
+-	uint16_t __x = (x); \
+-	((uint16_t)( \
+-		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
+-		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
+-})
+-
+-#define bswap_32(x) \
+-({ \
+-	uint32_t __x = (x); \
+-	((uint32_t)( \
+-		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
+-		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
+-		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
+-		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
+-})
+-
+-#define bswap_64(x) \
+-({ \
+-	uint64_t __x = (x); \
+-	((uint64_t)( \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
+-	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
+-})
+-
+-#endif /* !HAVE_BYTESWAP_H */
+ 
+ static inline uint16_t bswap16(uint16_t x)
+ {
diff --git a/testing/xen/fix_bswap_blktap2.patch b/testing/xen/fix_bswap_blktap2.patch
new file mode 100644
index 0000000..69cd2e3
--- /dev/null
+++ b/testing/xen/fix_bswap_blktap2.patch
@@ -0,0 +1,62 @@
+# HG changeset patch
+# Parent 00d9ee3844121f4a7f01e42933751e49b0448abb
+blktap2: remove local definitions and include byteswap.h
+
+Use the same approach as tools/blktap2/include/libvhd.h, remove local
+definitions of bswap* and include byteswap.h. Also remove the
+HAVE_BYTESWAP_H ifdef, since it was not defined in this context (it's
+defined by QEMU).
+
+Signed-off-by: Roger Pau Monne <[email-masked]>
+
+diff -r 00d9ee384412 tools/blktap2/drivers/bswap.h
+--- a/tools/blktap2/drivers/bswap.h	Tue Dec 20 05:24:17 2011 +0100
++++ b/tools/blktap2/drivers/bswap.h	Tue Dec 20 05:25:18 2011 +0100
+@@ -13,45 +13,10 @@
+ #define bswap_16(x) swap16(x)
+ #define bswap_32(x) swap32(x)
+ #define bswap_64(x) swap64(x)
+-#else
++#elif defined(__linux__)
+ 
+-#ifdef HAVE_BYTESWAP_H
++#include <endian.h>
+ #include <byteswap.h>
+-#else
+-
+-#define bswap_16(x) \
+-({ \
+-	uint16_t __x = (x); \
+-	((uint16_t)( \
+-		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
+-		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
+-})
+-
+-#define bswap_32(x) \
+-({ \
+-	uint32_t __x = (x); \
+-	((uint32_t)( \
+-		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
+-		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
+-		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
+-		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
+-})
+-
+-#define bswap_64(x) \
+-({ \
+-	uint64_t __x = (x); \
+-	((uint64_t)( \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
+-	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
+-})
+-
+-#endif /* !HAVE_BYTESWAP_H */
+ 
+ static inline uint16_t bswap16(uint16_t x)
+ {
diff --git a/testing/xen/fix_ipxe_no_pie_default.patch b/testing/xen/fix_ipxe_no_pie_default.patch
new file mode 100644
index 0000000..3ffb538
--- /dev/null
+++ b/testing/xen/fix_ipxe_no_pie_default.patch
@@ -0,0 +1,165 @@
+# HG changeset patch
+# Parent b60667a56ae085ee2bcea896887d0907fb86af41
+ipxe: fix compilation issues with some gcc versions
+
+Backported some changes from current ipxe, to fix a issue with some 
+new versions of gcc that add -fPIC by default, and compilation fails 
+with the following error:
+
+arch/i386/core/cpu.c: In function 'get_cpuinfo':
+arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand 
+constraints in an 'asm'
+arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand 
+constraints in an 'asm'
+arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand 
+constraints in an 'asm'
+arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand 
+constraints in an 'asm'
+
+Two patches from ipxe git have been added. The problem is reproducible 
+with at least this version of gcc:
+
+Using built-in specs.
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-uclibc/4.6.2/lto-wrapper
+Target: x86_64-alpine-linux-uclibc
+Configured with: 
+/home/buildozer/aports/main/gcc/src/gcc-4.6.2/configure --prefix=/usr 
+--mandir=/usr/share/man --infodir=/usr/share/info 
+--build=x86_64-alpine-linux-uclibc --host=x86_64-alpine-linux-uclibc 
+--target=x86_64-alpine-linux-uclibc --with-pkgversion='Alpine 
+4.6.2-r1' --disable-altivec --disable-checking --disable-fixed-point 
+--disable-libssp --disable-libstdcxx-pch --disable-multilib 
+--disable-nls --disable-werror --enable-__cxa_atexit --enable-cld 
+--enable-esp --enable-cloog-backend 
+--enable-languages=c,c++,objc,java,go --enable-shared 
+--enable-target-optspace --enable-tls --enable-threads 
+--with-dynamic-linker=ld64-uClibc.so.0.9.32 
+--with-dynamic-linker-prefix=/lib --with-system-zlib 
+--without-system-libunwind
+Thread model: posix
+gcc version 4.6.2 (Alpine 4.6.2-r1) 
+
+Signed-off-by: Roger Pau Monne <[email-masked]>
+
+diff -r b60667a56ae0 tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51	Fri Dec 16 13:48:49 2011 +0100
+@@ -0,0 +1,72 @@
++commit b8924c1aed512aa40cf28a43635df383880f771d
++Author: Michael Brown <[email-masked]>
++Date:   Wed Mar 16 19:30:42 2011 +0000
++
++    [build] Allow workaround-specific flags to override default flags
++    
++    Signed-off-by: Michael Brown <[email-masked]>
++
++diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
++index 709f8de..78e78c9 100644
++--- a/src/Makefile.housekeeping
+++++ b/src/Makefile.housekeeping
++@@ -109,6 +109,10 @@ VERYCLEANUP	+= .toolcheck
++ # Check for various tool workarounds
++ #
++ 
+++WORKAROUND_CFLAGS :=
+++WORKAROUND_ASFLAGS :=
+++WORKAROUND_LDFLAGS :=
+++
++ # Make syntax does not allow use of comma or space in certain places.
++ # This ugly workaround is suggested in the manual.
++ #
++@@ -119,7 +123,7 @@ SPACE	:= $(EMPTY) $(EMPTY)
++ # Check for an old version of gas (binutils 2.9.1)
++ #
++ OLDGAS	:= $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
++-CFLAGS	+= $(OLDGAS)
+++WORKAROUND_CFLAGS += $(OLDGAS)
++ oldgas :
++ 	@$(ECHO) $(oldgas)
++ 
++@@ -131,7 +135,7 @@ ifeq ($(CCTYPE),gcc)
++ SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
++ 		-o /dev/null >/dev/null 2>&1
++ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
++-CFLAGS	+= $(SP_FLAGS)
+++WORKAROUND_CFLAGS += $(SP_FLAGS)
++ endif
++ 
++ # gcc 4.4 generates .eh_frame sections by default, which distort the
++@@ -141,7 +145,7 @@ ifeq ($(CCTYPE),gcc)
++ CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
++ 		 -o /dev/null >/dev/null 2>&1
++ CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
++-CFLAGS	+= $(CFI_FLAGS)
+++WORKAROUND_CFLAGS += $(CFI_FLAGS)
++ endif
++ 
++ # Some versions of gas choke on division operators, treating them as
++@@ -150,7 +154,7 @@ endif
++ #
++ DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
++ DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
++-ASFLAGS	+= $(DIVIDE_FLAGS)
+++WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
++ 
++ ###############################################################################
++ #
++@@ -375,9 +379,9 @@ CFLAGS		+= -diag-disable 1419 # Missing prototypes
++ CFLAGS		+= -diag-disable 1599 # Hidden variables
++ CFLAGS		+= -Wall -Wmissing-declarations
++ endif
++-CFLAGS		+= $(EXTRA_CFLAGS)
++-ASFLAGS		+= $(EXTRA_ASFLAGS)
++-LDFLAGS		+= $(EXTRA_LDFLAGS)
+++CFLAGS		+= $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
+++ASFLAGS		+= $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
+++LDFLAGS		+= $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
++ 
++ # Inhibit -Werror if NO_WERROR is specified on make command line
++ #
+diff -r b60667a56ae0 tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5	Fri Dec 16 13:48:49 2011 +0100
+@@ -0,0 +1,32 @@
++commit fe61f6de0dd5d39ac3de5e8e18742f9bd0aafad7
++Author: Gilles Espinasse <[email-masked]>
++Date:   Tue Mar 29 15:30:11 2011 +0100
++
++    [build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie
++    
++    Signed-off-by: Gilles Espinasse <[email-masked]>
++    Modified-by: Michael Brown <[email-masked]>
++    Signed-off-by: Michael Brown <[email-masked]>
++
++diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
++index 57e52c0..c184351 100644
++--- a/src/Makefile.housekeeping
+++++ b/src/Makefile.housekeeping
++@@ -138,6 +138,17 @@ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
++ WORKAROUND_CFLAGS += $(SP_FLAGS)
++ endif
++ 
+++# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
+++# default.  Note that gcc will exit *successfully* if it fails to
+++# recognise an option that starts with "no", so we have to test for
+++# output on stderr instead of checking the exit status.
+++#
+++ifeq ($(CCTYPE),gcc)
+++PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
+++PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
+++WORKAROUND_CFLAGS += $(PIE_FLAGS)
+++endif
+++
++ # gcc 4.4 generates .eh_frame sections by default, which distort the
++ # output of "size".  Inhibit this.
++ #
+diff -r b60667a56ae0 tools/firmware/etherboot/patches/series
+--- a/tools/firmware/etherboot/patches/series	Fri Dec 16 10:47:18 2011 +0100
++++ b/tools/firmware/etherboot/patches/series	Fri Dec 16 13:48:49 2011 +0100
+@@ -1,3 +1,5 @@
+ boot_prompt_option.patch
+ gpxe-git-0edf2405b457
+ gpxe-git-a803ef3dfeac
++gpxe-git-b8924c1aed51
++gpxe-git-fe61f6de0dd5
diff --git a/testing/xen/xencommons.initd b/testing/xen/xencommons.initd
new file mode 100755
index 0000000..29546dc
--- /dev/null
+++ b/testing/xen/xencommons.initd
@@ -0,0 +1,96 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+opts="start stop status restart"
+
+if [ -d /etc/sysconfig ]; then
+        xencommons_config=/etc/sysconfig
+else
+        xencommons_config=/etc/default
+fi
+
+test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
+
+XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+#shopt -s extglob
+
+if test "x$1" = xstart && \
+     test -d /proc/xen && \
+   ! test -f /proc/xen/capabilities && \
+   ! grep '^xenfs ' /proc/mounts >/dev/null;
+then
+        mount -t xenfs xenfs /proc/xen
+fi
+
+if ! grep -q "control_d" /proc/xen/capabilities ; then
+        exit 0
+fi
+
+depend() {
+        need net
+        before xend
+}
+
+start() {
+        local time=0
+        local timeout=30
+
+        modprobe xen-evtchn 2>/dev/null
+        modprobe xen-gntdev 2>/dev/null
+        modprobe evtchn 2>/dev/null
+        modprobe gntdev 2>/dev/null
+
+        if ! `xenstore-read -s / >/dev/null 2>&1`
+        then
+                test -z "$XENSTORED_ROOTDIR" || XENSTORED_ROOTDIR="/var/lib/xenstored"
+                rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
+                test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T /var/log/xen/xenstored-trace.log"
+
+                ebegin "Starting xenstored..."
+                xenstored --pid-file=/var/run/xenstored.pid $XENSTORED_ARGS
+
+                # Wait for xenstored to actually come up, timing out after 30 seconds
+                while [ $time -lt $timeout ] && ! `xenstore-read -s / >/dev/null 2>&1` ; do
+                        time=$(($time+1))
+                        sleep 1
+                done
+
+                # Exit if we timed out
+                if ! [ $time -lt $timeout ] ; then
+                        eend 1
+                        echo Could not start xenstored
+                        exit 1
+                fi
+                eend 0
+
+                ebegin "Setting domain 0 name..."
+                xenstore-write "/local/domain/0/name" "Domain-0"
+                eend $?
+        fi
+
+        ebegin "Starting xenconsoled..."
+        test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE"
+        xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS
+        eend $?
+
+        test -z "$XENBACKENDD_DEBUG" || XENBACKENDD_ARGS="-d"
+        test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS
+}
+
+stop() {
+        ebegin "Stopping xenconsoled"
+        if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then
+                kill $pid
+                while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+                rm -f $XENCONSOLED_PIDFILE
+        fi
+        eend 0
+
+        echo WARNING: Not stopping xenstored, as it cannot be restarted.
+}
+
+status() {
+        xenstore-read -s / >/dev/null 2>&1
+}
diff --git a/testing/xen/xend.initd b/testing/xen/xend.initd
new file mode 100644
index 0000000..ee26c3f
--- /dev/null
+++ b/testing/xen/xend.initd
@@ -0,0 +1,38 @@
+#!/sbin/runscript
+
+depend() {
+	need net xencommons
+	before xendomains sshd ntp-client ntpd nfs nfsmount rsyncd portmap dhcp
+}
+
+is_privileged_domain() {
+	grep -qsE '^control_d$' /proc/xen/capabilities
+	return $?
+}
+
+start() {
+	if is_privileged_domain ; then
+		ebegin "Starting Xen daemons"
+		/usr/sbin/xend start
+		eend $?
+	else
+		eerror "Can't start xend - not a privileged domain"
+		return 1
+	fi
+}
+
+stop() {
+	ebegin "Stopping Xen control daemon"
+	/usr/sbin/xend stop
+	eend $?
+}
+
+restart() {
+	ebegin "Restarting Xen control daemon"
+	/usr/sbin/xend restart
+	eend $?
+}
+
+status() {
+	is_privileged_domain && /usr/sbin/xend status
+}
diff --git a/testing/xen/xendomains.initd b/testing/xen/xendomains.initd
new file mode 100644
index 0000000..d12577c
--- /dev/null
+++ b/testing/xen/xendomains.initd
@@ -0,0 +1,63 @@
+#!/sbin/runscript
+
+depend() {
+	need xend
+	after dhcp
+}
+
+get_domname() {
+        local name_from_file=$(sed -rn 's/^name\W*=\W*\"?([[:alnum:]_\.-]+)\"?\W*;?/\1/p' "${1}" | tail -n 1)
+
+        if [[ -z ${name_from_file} ]] ; then
+                basename "${1}"
+        else
+                echo ${name_from_file}  
+        fi
+}
+
+is_running() {
+        /usr/sbin/xm list "${1}" >/dev/null 2>&1
+}
+
+start() {
+	einfo "Starting Xen domains in ${AUTODIR:=/etc/xen/auto}"
+
+	for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+		name=$(get_domname ${dom})
+		if ! is_running ${name} ; then
+			ebegin "  Starting domain ${name}"
+				xm create --quiet ${dom}
+			eend $?
+		else
+			einfo "  Not starting ${name} - already running."
+		fi
+	done
+}
+
+stop() {
+	einfo "Stopping Xen domains in ${AUTODIR:=/etc/xen/auto}"
+
+	for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+		name=$(get_domname ${dom})
+		if is_running ${name} ; then
+			ebegin "  Sending shutdown signal to ${name}"
+				xm shutdown ${name} >/dev/null
+			eend $?
+		fi
+	done
+
+	for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+		name=$(get_domname ${dom})
+		if is_running ${name} ; then
+			ebegin "  Waiting for domain ${name} to shutdown"
+				xm shutdown --wait ${name}
+			eend $?
+		else
+			einfo "  Not stopping ${name} - not running."
+		fi
+	done
+}
+
+status() {
+	/usr/sbin/xm list
+}
-- 
1.7.7.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---