--- /dev/null
+#!/bin/bash
+
+HOME_DIR=`pwd`
+OUT_DIR=$HOME_DIR/out
+BUILDER_LABEL="xenbuilder"
+DOM0_LABEL="dom0"
+
+
+# Create build container
+exists=`docker images $BUILDER_LABEL | grep $BUILDER_LABEL`
+if test -z "$exists"
+then
+ docker build -f dockerfiles/alpine-build -t $BUILDER_LABEL .
+fi
+
+
+# Run build container: build Xen and QEMU
+if ! test -d out
+then
+ mkdir out
+ docker run -v $SOURCE_DIR/xen:/root/xen -v $SOURCE_DIR/qemu:/root/qemu -v $OUT_DIR:/root/out -t $BUILDER_LABEL /root/alpine-build-script
+fi
+
+
+# Create Dom0
+exists=`docker images $DOM0_LABEL | grep $DOM0_LABEL`
+if test -z "$exists"
+then
+ docker build -f dockerfiles/alpine-assemble -t $DOM0_LABEL .
+fi
+if ! test -f "$DOM0_LABEL".tar
+then
+ # This is a workaround: find a better way
+ docker run $DOM0_LABEL /root/sleep &
+ sleep 1
+ container_id=`docker ps | grep $DOM0_LABEL | cut -f 1 -d " "`
+ docker export $container_id > "$DOM0_LABEL".tar
+ docker kill $container_id
+fi
+
+
+# Create system image
+if ! test -f image
+then
+ # 1GB image: make this customizable
+ dd if=/dev/zero of=image count=262144 bs=4096
+ losetup /dev/loop0 ./image
+ mkfs.ext3 /dev/loop0
+ mount /dev/loop0 /mnt
+ cd /mnt
+ tar xvf $HOME_DIR/"$DOM0_LABEL".tar
+ cd $HOME_DIR
+ umount /mnt
+ losetup -d /dev/loop0
+fi
+
+
+# Clean-up
--- /dev/null
+FROM alpine
+
+ADD out/xen /root/
+ADD out/qemu /root/
+ADD dockerfiles/udhcpc.script /usr/share/udhcpc/default.script
+
+RUN \
+ apk update && \
+# System
+ apk add openrc && \
+ rc-update add networking sysinit && \
+ rc-update add loopback sysinit && \
+ for i in /etc/init.d/*; do rc-update add $i default; done && \
+ echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
+# Install
+ cd /root && cp -ar * / && rm -rf * && \
+ echo "ttyS0" >> /etc/securetty && \
+ echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab && \
+# Xen run deps
+ apk add python2 gettext zlib ncurses dev86 texinfo yajl curl libaio autoconf automake iasl make xz-dev bash util-linux argp-standalone && \
+ rc-update add xencommons && \
+# QEMU run deps
+ apk add glib pixman libcap libattr
+
+ADD dockerfiles/sleep /root
+
+ENTRYPOINT ["/bin/sh"]
--- /dev/null
+FROM alpine
+
+COPY dockerfiles/xen-patch /root/
+COPY dockerfiles/qemu-patch /root/
+COPY dockerfiles/alpine-build-script /root/
+
+RUN \
+ apk update && \
+# Xen build deps
+ apk add gcc patch musl-dev git python2-dev gettext zlib-dev ncurses-dev dev86 texinfo yajl-dev curl-dev libaio-dev autoconf automake iasl make xz-dev bash util-linux-dev argp-standalone linux-headers && \
+# QEMU build deps
+ apk add glib-dev pixman-dev libcap-dev libattr && \
+ chmod +x /root/alpine-build-script
+ENTRYPOINT ["/bin/sh"]
--- /dev/null
+#!/bin/bash
+
+SOURCE_DIR=/root
+OUT_DIR=/root/out
+
+cd $SOURCE_DIR
+#git clone git://xenbits.xen.org/xen.git
+cd xen
+#patch -p1 < $SOURCE_DIR/xen-patch
+./configure --prefix=/usr --with-system-qemu=/usr/lib/xen/bin/qemu-system-i386 --disable-stubdom --disable-qemu-traditional --disable-rombios
+make -j4
+mkdir -p DESTDIR=$OUT_DIR/xen
+make DESTDIR=$OUT_DIR/xen install
+
+cd $SOURCE_DIR
+#git clone git://git.qemu.org/qemu.git
+cd qemu
+#patch -p1 < $SOURCE_DIR/qemu-patch
+export DIR=$SOURCE_DIR/xen
+export PKG_CONFIG_PATH=$DIR/tools/pkg-config
+./configure --prefix=/usr --enable-xen --target-list=i386-softmmu \
+ --extra-cflags="-I$DIR/tools/include \
+ -I$DIR/tools/libs/toollog/include \
+ -I$DIR/tools/libs/evtchn/include \
+ -I$DIR/tools/libs/gnttab/include \
+ -I$DIR/tools/libs/foreignmemory/include \
+ -I$DIR/tools/libs/devicemodel/include \
+ -I$DIR/tools/libs/toolcore/include \
+ -I$DIR/tools/libxc/include \
+ -I$DIR/tools/xenstore/include \
+ -I$DIR/tools/xenstore/compat/include" \
+ --extra-ldflags="-L$DIR/tools/libxc \
+ -L$DIR/tools/xenstore \
+ -L$DIR/tools/libs/evtchn \
+ -L$DIR/tools/libs/gnttab \
+ -L$DIR/tools/libs/foreignmemory \
+ -L$DIR/tools/libs/call \
+ -L$DIR/tools/libs/toolcore \
+ -L$DIR/tools/libs/devicemodel \
+ -Wl,-rpath-link=$DIR/tools/libs/toollog \
+ -Wl,-rpath-link=$DIR/tools/libs/evtchn \
+ -Wl,-rpath-link=$DIR/tools/libs/gnttab \
+ -Wl,-rpath-link=$DIR/tools/libs/call \
+ -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
+ -Wl,-rpath-link=$DIR/tools/libs/call \
+ -Wl,-rpath-link=$DIR/tools/libs/toolcore \
+ -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
+ --disable-kvm --enable-virtfs --disable-werror
+make -j 4
+mkdir -p DESTDIR=$OUT_DIR/qemu
+make DESTDIR=$OUT_DIR/qemu install
+mkdir -p DESTDIR=$OUT_DIR/xen/usr/lib/xen/bin
+cp i386-softmmu/qemu-system-i386 $OUT_DIR/xen/usr/lib/xen/bin
--- /dev/null
+diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
+index f8bbac251d..b417dfe58f 100644
+--- a/hw/9pfs/9p.c
++++ b/hw/9pfs/9p.c
+@@ -3312,6 +3312,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque)
+ }
+ trace_v9fs_xattrcreate(pdu->tag, pdu->id, fid, name.data, size, flags);
+
++#define XATTR_SIZE_MAX 65536
+ if (size > XATTR_SIZE_MAX) {
+ err = -E2BIG;
+ goto out_nofid;
--- /dev/null
+#!/bin/busybox sh
+
+# udhcp sample script by Gabriel Somlo (somlo at cmu edu)
+# - uses 'ip' instead of 'ifconfig' and 'route'
+# - make minimal changes, and only if required by changing dhcp options
+
+[ -z "$1" ] && echo 'Error: should be called from udhcpc' && exit 1
+
+# where to save config information for $interface:
+CFG="/var/run/udhcpc.${interface}.cfg"
+
+# names of files we might need to touch:
+RESOLV_CONF='/etc/resolv.conf'
+NTP_CONF='/etc/ntp.conf'
+
+# which interface configures DNS and NTP ? Comment out if none:
+#PEERDNS_IF=eth0
+#PEERNTP_IF=eth0
+
+case "$1" in
+ deconfig)
+ # bring interface up, but with no IP configured:
+ ip addr flush dev $interface
+ ip link set $interface up
+ # remove any stored config info for this $interface:
+ rm -f $CFG
+ # restore any pre-dhcp config files:
+ if [ "$interface" == "$PEERDNS_IF" ] ; then
+ [ -f ${RESOLV_CONF}.dhcsave ] && mv -f ${RESOLV_CONF}.dhcsave $RESOLV_CONF
+ fi
+ if [ "$interface" == "$PEERNTP_IF" ] ; then
+ [ -f ${NTP_CONF}.dhcsave ] && mv -f ${NTP_CONF}.dhcsave $NTP_CONF
+ fi
+ ;;
+ bound)
+ # save config info for $interface:
+ set > $CFG
+ # configure interface and routes:
+ ip addr flush dev $interface
+ ip addr add ${ip}/${mask} dev $interface
+ [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
+ # save pre-dhcp config files and generate new ones:
+ if [ "$interface" == "$PEERDNS_IF" ] ; then
+ [ -f $RESOLV_CONF ] && mv -f $RESOLV_CONF ${RESOLV_CONF}.dhcsave
+ [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
+ for i in $dns ; do
+ echo nameserver $i >> $RESOLV_CONF
+ done
+ fi
+ if [ "$interface" == "$PEERNTP_IF" ] ; then
+ [ -f $NTP_CONF ] && mv -f $NTP_CONF ${NTP_CONF}.dhcsave
+ > $NTP_CONF
+ for i in $ntpsrv ; do
+ echo server $i >> $NTP_CONF
+ done
+ fi
+ ;;
+ renew)
+ # compare new vs. previous config info:
+ set > ${CFG}.new
+ for i in $(diff -U1 $CFG ${CFG}.new | grep -E ^[+-] \
+ | tail +3 \
+ | awk -F[+-=] '{print $2}') ; do
+ case "$i" in
+ ip|mask|router)
+ REDO_NET='yes'
+ ;;
+ domain|dns)
+ REDO_DNS='yes'
+ ;;
+ ntpsrv)
+ REDO_NTP='yes'
+ ;;
+ esac
+ done
+ # save new config info:
+ mv -f ${CFG}.new $CFG
+ # make only necessary changes, as per config comparison:
+ if [ -n "$REDO_NET" ] ; then
+ ip addr flush dev $interface
+ ip addr add ${ip}/${mask} dev $interface
+ [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
+ fi
+ if [ -n "$REDO_DNS" -a "$interface" == "$PEERDNS_IF" ] ; then
+ [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
+ for i in $dns ; do
+ echo nameserver $i >> $RESOLV_CONF
+ done
+ fi
+ if [ -n "$REDO_NTP" -a "$interface" == "$PEERNTP_IF" ] ; then
+ > $NTP_CONF
+ for i in $ntpsrv ; do
+ echo server $i >> $NTP_CONF
+ done
+ # FIXME: RELOAD NTP DAEMON HERE
+ fi
+ ;;
+esac
+
+exit 0
+
--- /dev/null
+diff --git a/tools/Makefile b/tools/Makefile
+index ab7a01e..b2e3d60 100644
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -15,7 +15,7 @@ SUBDIRS-y += examples
+ SUBDIRS-y += hotplug
+ SUBDIRS-y += xentrace
+ SUBDIRS-$(CONFIG_XCUTILS) += xcutils
+-SUBDIRS-$(CONFIG_X86) += firmware
++#SUBDIRS-$(CONFIG_X86) += firmware
+ SUBDIRS-y += console
+ SUBDIRS-y += xenmon
+ SUBDIRS-y += xenstat
+diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c
+index ea7b033..3eae908 100644
+--- a/tools/libxc/xc_sr_restore.c
++++ b/tools/libxc/xc_sr_restore.c
+@@ -397,7 +397,7 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
+ (PAGE_SIZE * pages_of_data)) )
+ {
+ ERROR("PAGE_DATA record wrong size: length %u, expected "
+- "%zu + %zu + %lu", rec->length, sizeof(*pages),
++ "%zu + %zu + %u", rec->length, sizeof(*pages),
+ (sizeof(uint64_t) * pages->count), (PAGE_SIZE * pages_of_data));
+ goto err;
+ }