summaryrefslogtreecommitdiff
path: root/sysutils/xentools45
diff options
context:
space:
mode:
authorbouyer <bouyer>2015-01-20 16:42:13 +0000
committerbouyer <bouyer>2015-01-20 16:42:13 +0000
commita7b141ddbb240c895d8fe6673b18bd58dd23ae55 (patch)
treea7948ace3328ed77419623b8f8a4137d03f54b3c /sysutils/xentools45
parent18cb903eed571fc2435849c78438600fe0117373 (diff)
downloadpkgsrc-a7b141ddbb240c895d8fe6673b18bd58dd23ae55.tar.gz
Xen is a virtual machine monitor which supports running multiple
guests operating systems on a single machine. Guest OSes (also called "domains") require a modified kernel which supports Xen hypercalls in replacement to access to the physical hardware. At boot, the xen kernel is loaded along with the guest kernel for the first domain (called domain0). domain0 has privileges to access the physical hardware (PCI and ISA devices), administrate other domains and provide virtual devices (disks and network) to other domains. xenkernel45 and xentools45 contains the kernel and tools from the Xen 4.5.x branch
Diffstat (limited to 'sysutils/xentools45')
-rw-r--r--sysutils/xentools45/DESCR5
-rw-r--r--sysutils/xentools45/MESSAGE11
-rw-r--r--sysutils/xentools45/MESSAGE.NetBSD17
-rw-r--r--sysutils/xentools45/Makefile219
-rw-r--r--sysutils/xentools45/PLIST403
-rw-r--r--sysutils/xentools45/TODO7
-rw-r--r--sysutils/xentools45/distinfo53
-rw-r--r--sysutils/xentools45/files/blk_netbsd.c38
-rw-r--r--sysutils/xentools45/files/blktapctrl_netbsd.c16
-rw-r--r--sysutils/xentools45/files/xen-watchdog.sh17
-rw-r--r--sysutils/xentools45/files/xencommons.sh107
-rw-r--r--sysutils/xentools45/files/xendomains.sh129
-rw-r--r--sysutils/xentools45/patches/patch-.._Config.mk22
-rw-r--r--sysutils/xentools45/patches/patch-.._docs_man_xl.cfg.pod.529
-rw-r--r--sysutils/xentools45/patches/patch-.._docs_man_xl.conf.pod.530
-rw-r--r--sysutils/xentools45/patches/patch-.._docs_man_xl.pod.144
-rw-r--r--sysutils/xentools45/patches/patch-.._docs_man_xlcpupool.cfg.pod.528
-rw-r--r--sysutils/xentools45/patches/patch-Makefile13
-rw-r--r--sysutils/xentools45/patches/patch-blktap_drivers_Makefile16
-rw-r--r--sysutils/xentools45/patches/patch-configure39
-rw-r--r--sysutils/xentools45/patches/patch-examples_Makefile12
-rw-r--r--sysutils/xentools45/patches/patch-firmware_etherboot_Makefile26
-rw-r--r--sysutils/xentools45/patches/patch-firmware_etherboot_patches_series9
-rw-r--r--sysutils/xentools45/patches/patch-firmware_hvmloader_Makefile13
-rw-r--r--sysutils/xentools45/patches/patch-hotplug_NetBSD_Makefile46
-rw-r--r--sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-bridge16
-rw-r--r--sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-ip15
-rw-r--r--sysutils/xentools45/patches/patch-hotplug_common_Makefile24
-rw-r--r--sysutils/xentools45/patches/patch-include_xen-sys_NetBSD_gntdev.h110
-rw-r--r--sysutils/xentools45/patches/patch-libfsimage_common_Makefile13
-rw-r--r--sysutils/xentools45/patches/patch-libfsimage_ufs_ufs.h13
-rw-r--r--sysutils/xentools45/patches/patch-libxc_xc__netbsd.c251
-rw-r--r--sysutils/xentools45/patches/patch-libxl_Makefile22
-rw-r--r--sysutils/xentools45/patches/patch-libxl_libxl__create.c40
-rw-r--r--sysutils/xentools45/patches/patch-libxl_libxl_uuid.c22
-rw-r--r--sysutils/xentools45/patches/patch-ocaml_common.make13
-rw-r--r--sysutils/xentools45/patches/patch-ocaml_xenstored_Makefile12
-rw-r--r--sysutils/xentools45/patches/patch-ocaml_xenstored_define.ml20
-rw-r--r--sysutils/xentools45/patches/patch-ocaml_xenstored_utils.ml13
-rw-r--r--sysutils/xentools45/patches/patch-pygrub_Makefile13
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_Makefile84
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_block-raw-posix.c62
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_configure31
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_e1000.c34
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_ide.c27
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.c13
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.h18
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_piix4acpi.c17
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-graphics.c13
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.c15
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.h12
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_i386-dm_hookstarget.mak12
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen-traditional_xen-hooks.mak34
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen_audio_audio.c12
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen_qemu-doc.texi15
-rw-r--r--sysutils/xentools45/patches/patch-qemu-xen_util_hbitmap.c18
-rw-r--r--sysutils/xentools45/patches/patch-xenstore_xc.c18
57 files changed, 2381 insertions, 0 deletions
diff --git a/sysutils/xentools45/DESCR b/sysutils/xentools45/DESCR
new file mode 100644
index 00000000000..d61406e1b18
--- /dev/null
+++ b/sysutils/xentools45/DESCR
@@ -0,0 +1,5 @@
+The Xen virtual machine monitor allows running several virtual machines
+on a single physical machine. The xentools45 package contains the
+tools to create, destroy and control the virtual machines.
+
+This package contains the tools for Xen 4.5.x
diff --git a/sysutils/xentools45/MESSAGE b/sysutils/xentools45/MESSAGE
new file mode 100644
index 00000000000..c59c0d36742
--- /dev/null
+++ b/sysutils/xentools45/MESSAGE
@@ -0,0 +1,11 @@
+===========================================================================
+$NetBSD: MESSAGE,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+Please note that the xm command has been removed.
+You have to switch to the xl command, which is now functional on NetBSD.
+
+Also note that the rc.d scripts have been updated in this version.
+If you don't use PKG_RCD_SCRIPTS=YES then it is very important for
+you to copy the new rc.d scripts to /etc/rc.d.
+
+===========================================================================
diff --git a/sysutils/xentools45/MESSAGE.NetBSD b/sysutils/xentools45/MESSAGE.NetBSD
new file mode 100644
index 00000000000..878f90159a1
--- /dev/null
+++ b/sysutils/xentools45/MESSAGE.NetBSD
@@ -0,0 +1,17 @@
+===========================================================================
+$NetBSD: MESSAGE.NetBSD,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+Please ensure that the Xen-specific devices needed by xend(8) exist:
+
+ cd /dev && sh MAKEDEV xen
+
+There are example configuration files for setting up a guest domain in:
+
+ ${EGDIR}/
+
+Please also refer to the the "NetBSD/xen How-To" for more information on
+creating a Xen setup:
+
+ http://www.NetBSD.org/ports/xen/howto.html
+
+===========================================================================
diff --git a/sysutils/xentools45/Makefile b/sysutils/xentools45/Makefile
new file mode 100644
index 00000000000..c996fb70cf8
--- /dev/null
+++ b/sysutils/xentools45/Makefile
@@ -0,0 +1,219 @@
+# $NetBSD: Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+VERSION= 4.5.0
+VERSION_IPXE= 9a93db3f0947484e30e753bbd61a10b17336e20e
+
+DISTNAME= xen-${VERSION}
+PKGNAME= xentools45-${VERSION}
+#PKGREVISION= 1
+CATEGORIES= sysutils
+MASTER_SITES= http://bits.xensource.com/oss-xen/release/${VERSION}/
+
+DISTFILES= ${DISTNAME}.tar.gz
+DISTFILES+= ipxe-git-${VERSION_IPXE}.tar.gz
+SITES.ipxe-git-${VERSION_IPXE}.tar.gz += http://xenbits.xensource.com/xen-extfiles/
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+HOMEPAGE= http://xen.org/
+COMMENT= Userland Tools for Xen 4.5.x
+LICENSE= gnu-gpl-v2
+
+# XXX add version check: Xen requires dev86 >= 0.16.14
+BUILD_DEPENDS+= dev86-[0-9]*:../../devel/dev86 # needed to build firmware
+.if !exists(/usr/bin/iasl)
+BUILD_DEPENDS+= acpica-utils-[0-9]*:../../sysutils/acpica-utils
+.endif
+DEPENDS+= ${PYPKGPREFIX}-curses>=0nb4:../../devel/py-curses
+DEPENDS+= ${PYPKGPREFIX}-lxml-[0-9]*:../../textproc/py-lxml
+
+PYTHON_VERSIONS_INCOMPATIBLE= 33 34 # py-xml
+
+PKG_SYSCONFSUBDIR= xen
+
+ONLY_FOR_PLATFORM= Linux-2.6*-i386 Linux-2.6*-x86_64
+ONLY_FOR_PLATFORM+= NetBSD-[5-9].*-x86_64 NetBSD-[5-9].*-i386
+
+CONFLICTS+= libxen-[0-9]*
+CONFLICTS+= xentools20-[0-9]*
+CONFLICTS+= xentools3-[0-9]*
+CONFLICTS+= xenstoretools-[0-9]*
+
+XENTOP= ${WRKDIR}/xen-${VERSION}
+WRKSRC= ${XENTOP}/tools
+CHECK_PORTABILITY_SKIP= examples/*
+
+EGDIR= ${PREFIX}/share/examples/xen
+MESSAGE_SUBST+= EGDIR=${EGDIR}
+
+USE_TOOLS+= pod2man gmake pkg-config makeinfo perl bash
+
+GNU_CONFIGURE= YES
+#CONFIGURE_ARGS+= --enable-xenapi
+CONFIGURE_ARGS+= --disable-seabios
+
+MAKE_ENV+= PREFIX=${prefix:Q} WRKSRC=${WRKSRC}
+MAKE_ENV+= EGDIR=${EGDIR}
+MAKE_ENV+= XEN_EXAMPLES_DIR=${EGDIR}
+MAKE_ENV+= BASH_COMPLETION_DIR=${EGDIR}
+MAKE_ENV+= MV=${MV:Q} PYTHON=${PYTHONBIN:Q} SED=${SED:Q}
+MAKE_ENV+= VARBASE=${VARBASE}
+MAKE_ENV+= XEN_CONFIG_DIR=${PKG_SYSCONFDIR}
+MAKE_ENV+= V=YES
+MAKE_ENV+= NO_WERROR=1
+
+#MAKE_ENV+= INSTALL_DIR=${BSD_INSTALL_DATA_DIR}
+#MAKE_ENV+= INSTALL_DATA=${BSD_INSTALL_DATA}
+#MAKE_ENV+= INSTALL_PROG=${BSD_INSTALL_PROGRAM}
+
+PY_PATCHPLIST= yes
+REPLACE_PYTHON+= misc/sbdf2devicepath misc/xen-bugtool
+REPLACE_PYTHON+= misc/xen-ringwatch misc/xencons
+REPLACE_PYTHON+= misc/xenpvnetboot misc/xensymoops
+REPLACE_PYTHON+= xenmon/xenmon.py
+
+SUBST_CLASSES+= perlpath
+SUBST_STAGE.perlpath= pre-configure
+SUBST_FILES.perlpath= ../tools/misc/xencov_split
+SUBST_FILES.perlpath+= ../tools/firmware/rombios/makesym.perl
+SUBST_FILES.perlpath+= ../tools/qemu-xen-traditional/texi2pod.pl
+SUBST_FILES.perlpath+= ../tools/examples/xeninfo.pl
+SUBST_FILES.perlpath+= ../tools/include/xen-external/bsd-sys-queue-h-seddery
+SUBST_FILES.perlpath+= ../tools/qemu-xen/scripts/texi2pod.pl
+SUBST_FILES.perlpath+= ../tools/qemu-xen/scripts/get_maintainer.pl
+SUBST_FILES.perlpath+= ../tools/qemu-xen/scripts/checkpatch.pl
+SUBST_FILES.perlpath+= ../tools/libxl/libxl_save_msgs_gen.pl
+SUBST_FILES.perlpath+= ../tools/libxl/check-libxl-api-rules
+SUBST_FILES.perlpath+= ../../ipxe/src/drivers/infiniband/qib_genbits.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/catrom.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/diffsize.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/disrom.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/get-pci-ids
+SUBST_FILES.perlpath+= ../../ipxe/src/util/licence.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/mergerom.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/modrom.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/padimg.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/parserom.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/sortobjdump.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/swapdevids.pl
+SUBST_FILES.perlpath+= ../../ipxe/src/util/symcheck.pl
+SUBST_SED.perlpath= -e "s|/usr/bin/perl|${PREFIX}/bin/perl|g"
+
+SUBST_CLASSES+= pathsvar
+SUBST_STAGE.pathsvar= pre-configure
+SUBST_FILES.pathsvar= Makefile \
+ hotplug/Linux/init.d/sysconfig.xendomains
+SUBST_SED.pathsvar= -e "s|/var/lib|${VARBASE}/run|g"
+
+SUBST_CLASSES+= conf
+SUBST_STAGE.conf= pre-configure
+SUBST_FILES.conf+= ocaml/xenstored/define.ml
+SUBST_SED.conf= -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g"
+
+.include "../../mk/bsd.prefs.mk"
+
+XEND_SCRIPTS= block vif-bridge vif-ip qemu-ifup hotplugpath.sh
+
+.if ${OPSYS} == "NetBSD"
+SUBST_CLASSES+= proc
+SUBST_STAGE.proc= pre-configure
+SUBST_FILES.proc+= ocaml/xenstored/define.ml
+SUBST_SED.proc= -e "s|/proc|/kern|g"
+PROCPATH= /kern
+.else
+PROCPATH= /proc
+.endif
+
+SUBST_CLASSES+= procdev
+SUBST_STAGE.procdev= pre-configure
+SUBST_FILES.procdev= ocaml/xenstored/define.ml
+.if ${OPSYS} == "NetBSD"
+SUBST_SED.procdev= -e "s|@PROCDEV@|/dev|g"
+.else
+SUBST_SED.procdev= -e "s|@PROCDEV@|/proc/xen|g"
+.endif
+
+.if ${OPSYS} == "NetBSD"
+MESSAGE_SRC= ${.CURDIR}/MESSAGE ${.CURDIR}/MESSAGE.NetBSD
+.endif
+
+RCD_SCRIPTS= xen-watchdog xencommons xendomains
+FILES_SUBST+= RCD_INTERPRETER=${PYTHONBIN:Q}
+FILES_SUBST+= PROCPATH=${PROCPATH:Q}
+FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
+FILES_SUBST+= PREFIX=${PREFIX}
+
+BLKTAP_FILES= blk_netbsd.c blktapctrl_netbsd.c
+
+CONF_FILES+= ${EGDIR}/xl.conf ${PKG_SYSCONFDIR}/xl.conf
+CONF_FILES+= ${EGDIR}/oxenstored.conf ${PKG_SYSCONFDIR}/oxenstored.conf
+
+OWN_DIRS= ${PKG_SYSCONFDIR}/scripts ${VARBASE}/log/xen
+OWN_DIRS+= ${VARBASE}/lib/xen
+
+.for s in ${XEND_SCRIPTS}
+CONF_FILES_PERMS+= ${EGDIR}/scripts/${s} ${PKG_SYSCONFDIR}/scripts/${s} \
+ ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0755
+.endfor
+
+pre-build:
+ rm -f ${WRKSRC}/check/check_x11_devel
+.for s in ${BLKTAP_FILES}
+ ${CP} -f ${FILESDIR}/${s} ${WRKSRC}/blktap/drivers/
+.endfor
+ ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+ ${XENTOP}/docs/man/xl.pod.1 |\
+ pod2man >${WRKDIR}/xl.1
+ ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+ ${XENTOP}/docs/man/xl.cfg.pod.5 |\
+ pod2man >${WRKDIR}/xl.cfg.5
+ ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+ ${XENTOP}/docs/man/xl.conf.pod.5 |\
+ pod2man >${WRKDIR}/xl.conf.5
+ ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+ ${XENTOP}/docs/man/xlcpupool.cfg.pod.5 |\
+ pod2man >${WRKDIR}/xlcpupool.cfg.5
+
+INSTALLATION_DIRS= ${EGDIR} ${PKGMANDIR}/man5
+
+BUILD_DEFS+= VARBASE
+
+post-install:
+ ${INSTALL_DATA} ${WRKDIR}/xl.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+ ${INSTALL_DATA} ${WRKDIR}/xl.cfg.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+ ${INSTALL_DATA} ${WRKDIR}/xl.conf.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+ ${INSTALL_DATA} ${WRKDIR}/xlcpupool.cfg.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+
+.if ${OPSYS} == "NetBSD" && !exists(/var/shm)
+CPPFLAGS+= -Dshm_open=open -Dshm_unlink=unlink
+.endif
+
+.include "../../mk/compiler.mk"
+.if !empty(PKGSRC_COMPILER:Mclang)
+EXTRA_HOSTCFLAGS+= -Wno-error=ignored-attributes
+EXTRA_CFLAGS+= -Wno-error=ignored-attributes -no-integrated-as \
+ -Wno-error=tautological-compare -Wno-error=null-dereference \
+ -Wno-error=empty-body -Wno-error=self-assign \
+ -Wno-error=sometimes-uninitialized \
+ -Wno-error=unused-function -Wno-error=format \
+ -Wno-error=unused-const-variable \
+ -Wno-error=gnu-designator -Wno-error=uninitialized \
+ -Wno-error=parentheses-equality
+BUILDLINK_TRANSFORM+= rm:-falign-jumps=1 rm:-falign-loops=1 \
+ rm:-mpreferred-stack-boundary=2
+.endif
+
+MAKE_ENV+= EXTRA_HOSTCFLAGS=${EXTRA_HOSTCFLAGS:Q} EXTRA_CFLAGS=${EXTRA_CFLAGS:M*:Q}
+
+.include "../../lang/python/application.mk"
+.include "../../lang/python/extension.mk"
+.include "../../textproc/py-xml/buildlink3.mk"
+.include "../../devel/ncurses/buildlink3.mk"
+#.include "../../devel/SDL/buildlink3.mk"
+.include "../../lang/ocaml/buildlink3.mk"
+.include "../../devel/ocaml-findlib/buildlink3.mk"
+.include "../../sysutils/pciutils/buildlink3.mk"
+.include "../../devel/glib2/buildlink3.mk"
+.include "../../devel/yajl/buildlink3.mk"
+.include "../../x11/pixman/buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/xentools45/PLIST b/sysutils/xentools45/PLIST
new file mode 100644
index 00000000000..b12be33ab47
--- /dev/null
+++ b/sysutils/xentools45/PLIST
@@ -0,0 +1,403 @@
+@comment $NetBSD: PLIST,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+bin/pygrub
+bin/qemu-img-xen
+bin/xen-detect
+bin/xencons
+bin/xencov_split
+bin/xenstore
+bin/xenstore-chmod
+bin/xenstore-control
+bin/xenstore-exists
+bin/xenstore-list
+bin/xenstore-ls
+bin/xenstore-read
+bin/xenstore-rm
+bin/xenstore-watch
+bin/xenstore-write
+bin/xentrace
+bin/xentrace_format
+bin/xentrace_setsize
+include/_libxl_list.h
+include/_libxl_types.h
+include/_libxl_types_json.h
+include/fsimage.h
+include/fsimage_grub.h
+include/fsimage_plugin.h
+include/libxl.h
+include/libxl_event.h
+include/libxl_json.h
+include/libxl_utils.h
+include/libxl_uuid.h
+include/xen/COPYING
+include/xen/arch-arm.h
+include/xen/arch-arm/hvm/save.h
+include/xen/arch-x86/cpuid.h
+include/xen/arch-x86/hvm/save.h
+include/xen/arch-x86/xen-mca.h
+include/xen/arch-x86/xen-x86_32.h
+include/xen/arch-x86/xen-x86_64.h
+include/xen/arch-x86/xen.h
+include/xen/arch-x86_32.h
+include/xen/arch-x86_64.h
+include/xen/callback.h
+include/xen/dom0_ops.h
+include/xen/domctl.h
+include/xen/elfnote.h
+include/xen/event_channel.h
+include/xen/features.h
+include/xen/foreign/arm32.h
+include/xen/foreign/arm64.h
+include/xen/foreign/x86_32.h
+include/xen/foreign/x86_64.h
+include/xen/gcov.h
+include/xen/grant_table.h
+include/xen/hvm/e820.h
+include/xen/hvm/hvm_info_table.h
+include/xen/hvm/hvm_op.h
+include/xen/hvm/hvm_xs_strings.h
+include/xen/hvm/ioreq.h
+include/xen/hvm/params.h
+include/xen/hvm/pvdrivers.h
+include/xen/hvm/save.h
+include/xen/io/blkif.h
+include/xen/io/console.h
+include/xen/io/fbif.h
+include/xen/io/fsif.h
+include/xen/io/kbdif.h
+include/xen/io/libxenvchan.h
+include/xen/io/netif.h
+include/xen/io/pciif.h
+include/xen/io/protocols.h
+include/xen/io/ring.h
+include/xen/io/tpmif.h
+include/xen/io/usbif.h
+include/xen/io/vscsiif.h
+include/xen/io/xenbus.h
+include/xen/io/xs_wire.h
+include/xen/kexec.h
+include/xen/mem_event.h
+include/xen/memory.h
+include/xen/nmi.h
+include/xen/physdev.h
+include/xen/platform.h
+include/xen/sched.h
+include/xen/sys/evtchn.h
+include/xen/sys/gntdev.h
+include/xen/sys/privcmd.h
+include/xen/sysctl.h
+include/xen/tmem.h
+include/xen/trace.h
+include/xen/vcpu.h
+include/xen/version.h
+include/xen/xen-compat.h
+include/xen/xen.h
+include/xen/xencomm.h
+include/xen/xenoprof.h
+include/xen/xsm/flask_op.h
+include/xenctrl.h
+include/xenctrlosdep.h
+include/xenguest.h
+include/xenstat.h
+include/xenstore-compat/xs.h
+include/xenstore-compat/xs_lib.h
+include/xenstore.h
+include/xenstore_lib.h
+include/xentoollog.h
+include/xs.h
+include/xs_lib.h
+lib/fs/ext2fs/fsimage.so
+lib/fs/fat/fsimage.so
+lib/fs/iso9660/fsimage.so
+lib/fs/reiserfs/fsimage.so
+lib/fs/ufs/fsimage.so
+lib/fs/xfs/fsimage.so
+lib/fs/zfs/fsimage.so
+lib/libfsimage.so
+lib/libfsimage.so.1.0
+lib/libfsimage.so.1.0.0
+lib/libxenctrl.a
+lib/libxenctrl.so
+lib/libxenctrl.so.4.5
+lib/libxenctrl.so.4.5.0
+lib/libxenguest.a
+lib/libxenguest.so
+lib/libxenguest.so.4.5
+lib/libxenguest.so.4.5.0
+lib/libxenlight.a
+lib/libxenlight.so
+lib/libxenlight.so.4.5
+lib/libxenlight.so.4.5.0
+lib/libxenstat.a
+lib/libxenstat.so
+lib/libxenstat.so.0
+lib/libxenstat.so.0.0
+lib/libxenstore.a
+lib/libxenstore.so
+lib/libxenstore.so.3.0
+lib/libxenstore.so.3.0.3
+lib/libxlutil.a
+lib/libxlutil.so
+lib/libxlutil.so.4.3
+lib/libxlutil.so.4.3.0
+lib/ocaml/site-lib/xenbus/META
+lib/ocaml/site-lib/xenbus/dllxenbus_stubs.so
+lib/ocaml/site-lib/xenbus/libxenbus_stubs.a
+lib/ocaml/site-lib/xenbus/xenbus.a
+lib/ocaml/site-lib/xenbus/xenbus.cma
+lib/ocaml/site-lib/xenbus/xenbus.cmi
+lib/ocaml/site-lib/xenbus/xenbus.cmo
+lib/ocaml/site-lib/xenbus/xenbus.cmx
+lib/ocaml/site-lib/xenbus/xenbus.cmxa
+lib/ocaml/site-lib/xenctrl/META
+lib/ocaml/site-lib/xenctrl/dllxenctrl_stubs.so
+lib/ocaml/site-lib/xenctrl/libxenctrl_stubs.a
+lib/ocaml/site-lib/xenctrl/xenctrl.a
+lib/ocaml/site-lib/xenctrl/xenctrl.cma
+lib/ocaml/site-lib/xenctrl/xenctrl.cmi
+lib/ocaml/site-lib/xenctrl/xenctrl.cmx
+lib/ocaml/site-lib/xenctrl/xenctrl.cmxa
+lib/ocaml/site-lib/xeneventchn/META
+lib/ocaml/site-lib/xeneventchn/dllxeneventchn_stubs.so
+lib/ocaml/site-lib/xeneventchn/libxeneventchn_stubs.a
+lib/ocaml/site-lib/xeneventchn/xeneventchn.a
+lib/ocaml/site-lib/xeneventchn/xeneventchn.cma
+lib/ocaml/site-lib/xeneventchn/xeneventchn.cmi
+lib/ocaml/site-lib/xeneventchn/xeneventchn.cmx
+lib/ocaml/site-lib/xeneventchn/xeneventchn.cmxa
+lib/ocaml/site-lib/xenlight/META
+lib/ocaml/site-lib/xenlight/dllxenlight_stubs.so
+lib/ocaml/site-lib/xenlight/libxenlight_stubs.a
+lib/ocaml/site-lib/xenlight/xenlight.a
+lib/ocaml/site-lib/xenlight/xenlight.cma
+lib/ocaml/site-lib/xenlight/xenlight.cmi
+lib/ocaml/site-lib/xenlight/xenlight.cmx
+lib/ocaml/site-lib/xenlight/xenlight.cmxa
+lib/ocaml/site-lib/xenmmap/META
+lib/ocaml/site-lib/xenmmap/dllxenmmap_stubs.so
+lib/ocaml/site-lib/xenmmap/libxenmmap_stubs.a
+lib/ocaml/site-lib/xenmmap/xenmmap.a
+lib/ocaml/site-lib/xenmmap/xenmmap.cma
+lib/ocaml/site-lib/xenmmap/xenmmap.cmi
+lib/ocaml/site-lib/xenmmap/xenmmap.cmx
+lib/ocaml/site-lib/xenmmap/xenmmap.cmxa
+lib/ocaml/site-lib/xenstore/META
+lib/ocaml/site-lib/xenstore/xenstore.a
+lib/ocaml/site-lib/xenstore/xenstore.cma
+lib/ocaml/site-lib/xenstore/xenstore.cmi
+lib/ocaml/site-lib/xenstore/xenstore.cmo
+lib/ocaml/site-lib/xenstore/xenstore.cmx
+lib/ocaml/site-lib/xenstore/xenstore.cmxa
+lib/ocaml/site-lib/xentoollog/META
+lib/ocaml/site-lib/xentoollog/dllxentoollog_stubs.so
+lib/ocaml/site-lib/xentoollog/libxentoollog_stubs.a
+lib/ocaml/site-lib/xentoollog/xentoollog.a
+lib/ocaml/site-lib/xentoollog/xentoollog.cma
+lib/ocaml/site-lib/xentoollog/xentoollog.cmi
+lib/ocaml/site-lib/xentoollog/xentoollog.cmx
+lib/ocaml/site-lib/xentoollog/xentoollog.cmxa
+${PYSITELIB}/fsimage.so
+${PYSITELIB}/grub/ExtLinuxConf.py
+${PYSITELIB}/grub/ExtLinuxConf.pyc
+${PYSITELIB}/grub/GrubConf.py
+${PYSITELIB}/grub/GrubConf.pyc
+${PYSITELIB}/grub/LiloConf.py
+${PYSITELIB}/grub/LiloConf.pyc
+${PYSITELIB}/grub/__init__.py
+${PYSITELIB}/grub/__init__.pyc
+${PYSITELIB}/xen/__init__.py
+${PYSITELIB}/xen/__init__.pyc
+${PYSITELIB}/xen/lowlevel/__init__.py
+${PYSITELIB}/xen/lowlevel/__init__.pyc
+${PYSITELIB}/xen/lowlevel/xc.so
+${PYSITELIB}/xen/lowlevel/xs.so
+libexec/xen/bin/libxl-save-helper
+libexec/xen/bin/lsevtchn
+libexec/xen/bin/pygrub
+libexec/xen/bin/qemu-dm
+libexec/xen/bin/qemu-img
+libexec/xen/bin/qemu-io
+libexec/xen/bin/qemu-nbd
+libexec/xen/bin/qemu-system-i386
+libexec/xen/bin/readnotes
+libexec/xen/bin/xen-init-dom0
+libexec/xen/bin/xenconsole
+libexec/xen/bin/xenctx
+libexec/xen/bin/xenpaging
+libexec/xen/bin/xenpvnetboot
+libexec/xen/boot/hvmloader
+libexec/xen/etc/qemu/target-x86_64.conf
+man/man1/xentop.1
+man/man1/xentrace_format.1
+man/man1/xl.1
+man/man5/xl.cfg.5
+man/man5/xl.conf.5
+man/man5/xlcpupool.cfg.5
+man/man8/xentrace.8
+sbin/gdbsx
+sbin/gtracestat
+sbin/gtraceview
+sbin/kdd
+sbin/oxenstored
+sbin/xen-bugtool
+sbin/xen-hptool
+sbin/xen-hvmcrash
+sbin/xen-hvmctx
+sbin/xen-lowmemd
+sbin/xen-mfndump
+sbin/xen-ringwatch
+sbin/xen-tmem-list-parse
+sbin/xenbackendd
+sbin/xenbaked
+sbin/xenconsoled
+sbin/xencov
+sbin/xenlockprof
+sbin/xenmon.py
+sbin/xenperf
+sbin/xenpm
+sbin/xenpmd
+sbin/xenstored
+sbin/xentop
+sbin/xentrace_setmask
+sbin/xenwatchdogd
+sbin/xl
+share/doc/xen/README.xenmon
+share/examples/xen/README
+share/examples/xen/README.incompatibilities
+share/examples/xen/cpupool
+share/examples/xen/oxenstored.conf
+share/examples/xen/scripts/block
+share/examples/xen/scripts/hotplugpath.sh
+share/examples/xen/scripts/qemu-ifup
+share/examples/xen/scripts/vif-bridge
+share/examples/xen/scripts/vif-ip
+share/examples/xen/xl.conf
+share/examples/xen/xl.sh
+share/examples/xen/xlexample.hvm
+share/examples/xen/xlexample.pvlinux
+share/qemu-xen/qemu/QEMU,cgthree.bin
+share/qemu-xen/qemu/QEMU,tcx.bin
+share/qemu-xen/qemu/acpi-dsdt.aml
+share/qemu-xen/qemu/bamboo.dtb
+share/qemu-xen/qemu/bios-256k.bin
+share/qemu-xen/qemu/bios.bin
+share/qemu-xen/qemu/efi-e1000.rom
+share/qemu-xen/qemu/efi-eepro100.rom
+share/qemu-xen/qemu/efi-ne2k_pci.rom
+share/qemu-xen/qemu/efi-pcnet.rom
+share/qemu-xen/qemu/efi-rtl8139.rom
+share/qemu-xen/qemu/efi-virtio.rom
+share/qemu-xen/qemu/keymaps/ar
+share/qemu-xen/qemu/keymaps/bepo
+share/qemu-xen/qemu/keymaps/common
+share/qemu-xen/qemu/keymaps/cz
+share/qemu-xen/qemu/keymaps/da
+share/qemu-xen/qemu/keymaps/de
+share/qemu-xen/qemu/keymaps/de-ch
+share/qemu-xen/qemu/keymaps/en-gb
+share/qemu-xen/qemu/keymaps/en-us
+share/qemu-xen/qemu/keymaps/es
+share/qemu-xen/qemu/keymaps/et
+share/qemu-xen/qemu/keymaps/fi
+share/qemu-xen/qemu/keymaps/fo
+share/qemu-xen/qemu/keymaps/fr
+share/qemu-xen/qemu/keymaps/fr-be
+share/qemu-xen/qemu/keymaps/fr-ca
+share/qemu-xen/qemu/keymaps/fr-ch
+share/qemu-xen/qemu/keymaps/hr
+share/qemu-xen/qemu/keymaps/hu
+share/qemu-xen/qemu/keymaps/is
+share/qemu-xen/qemu/keymaps/it
+share/qemu-xen/qemu/keymaps/ja
+share/qemu-xen/qemu/keymaps/lt
+share/qemu-xen/qemu/keymaps/lv
+share/qemu-xen/qemu/keymaps/mk
+share/qemu-xen/qemu/keymaps/modifiers
+share/qemu-xen/qemu/keymaps/nl
+share/qemu-xen/qemu/keymaps/nl-be
+share/qemu-xen/qemu/keymaps/no
+share/qemu-xen/qemu/keymaps/pl
+share/qemu-xen/qemu/keymaps/pt
+share/qemu-xen/qemu/keymaps/pt-br
+share/qemu-xen/qemu/keymaps/ru
+share/qemu-xen/qemu/keymaps/sl
+share/qemu-xen/qemu/keymaps/sv
+share/qemu-xen/qemu/keymaps/th
+share/qemu-xen/qemu/keymaps/tr
+share/qemu-xen/qemu/kvmvapic.bin
+share/qemu-xen/qemu/linuxboot.bin
+share/qemu-xen/qemu/multiboot.bin
+share/qemu-xen/qemu/openbios-ppc
+share/qemu-xen/qemu/openbios-sparc32
+share/qemu-xen/qemu/openbios-sparc64
+share/qemu-xen/qemu/palcode-clipper
+share/qemu-xen/qemu/petalogix-ml605.dtb
+share/qemu-xen/qemu/petalogix-s3adsp1800.dtb
+share/qemu-xen/qemu/ppc_rom.bin
+share/qemu-xen/qemu/pxe-e1000.rom
+share/qemu-xen/qemu/pxe-eepro100.rom
+share/qemu-xen/qemu/pxe-ne2k_pci.rom
+share/qemu-xen/qemu/pxe-pcnet.rom
+share/qemu-xen/qemu/pxe-rtl8139.rom
+share/qemu-xen/qemu/pxe-virtio.rom
+share/qemu-xen/qemu/q35-acpi-dsdt.aml
+share/qemu-xen/qemu/qemu-icon.bmp
+share/qemu-xen/qemu/qemu_logo_no_text.svg
+share/qemu-xen/qemu/s390-ccw.img
+share/qemu-xen/qemu/s390-zipl.rom
+share/qemu-xen/qemu/sgabios.bin
+share/qemu-xen/qemu/slof.bin
+share/qemu-xen/qemu/spapr-rtas.bin
+share/qemu-xen/qemu/vgabios-cirrus.bin
+share/qemu-xen/qemu/vgabios-qxl.bin
+share/qemu-xen/qemu/vgabios-stdvga.bin
+share/qemu-xen/qemu/vgabios-vmware.bin
+share/qemu-xen/qemu/vgabios.bin
+share/xen/qemu/bamboo.dtb
+share/xen/qemu/bios.bin
+share/xen/qemu/keymaps/ar
+share/xen/qemu/keymaps/common
+share/xen/qemu/keymaps/da
+share/xen/qemu/keymaps/de
+share/xen/qemu/keymaps/de-ch
+share/xen/qemu/keymaps/en-gb
+share/xen/qemu/keymaps/en-us
+share/xen/qemu/keymaps/es
+share/xen/qemu/keymaps/et
+share/xen/qemu/keymaps/fi
+share/xen/qemu/keymaps/fo
+share/xen/qemu/keymaps/fr
+share/xen/qemu/keymaps/fr-be
+share/xen/qemu/keymaps/fr-ca
+share/xen/qemu/keymaps/fr-ch
+share/xen/qemu/keymaps/hr
+share/xen/qemu/keymaps/hu
+share/xen/qemu/keymaps/is
+share/xen/qemu/keymaps/it
+share/xen/qemu/keymaps/ja
+share/xen/qemu/keymaps/lt
+share/xen/qemu/keymaps/lv
+share/xen/qemu/keymaps/mk
+share/xen/qemu/keymaps/modifiers
+share/xen/qemu/keymaps/nl
+share/xen/qemu/keymaps/nl-be
+share/xen/qemu/keymaps/no
+share/xen/qemu/keymaps/pl
+share/xen/qemu/keymaps/pt
+share/xen/qemu/keymaps/pt-br
+share/xen/qemu/keymaps/ru
+share/xen/qemu/keymaps/sl
+share/xen/qemu/keymaps/sv
+share/xen/qemu/keymaps/th
+share/xen/qemu/keymaps/tr
+share/xen/qemu/openbios-ppc
+share/xen/qemu/openbios-sparc32
+share/xen/qemu/openbios-sparc64
+share/xen/qemu/ppc_rom.bin
+share/xen/qemu/pxe-e1000.bin
+share/xen/qemu/pxe-ne2k_pci.bin
+share/xen/qemu/pxe-pcnet.bin
+share/xen/qemu/pxe-rtl8139.bin
+share/xen/qemu/vgabios-cirrus.bin
+share/xen/qemu/vgabios.bin
+share/xen/qemu/video.x
+@pkgdir share/examples/xen/auto
diff --git a/sysutils/xentools45/TODO b/sysutils/xentools45/TODO
new file mode 100644
index 00000000000..63fa18b5829
--- /dev/null
+++ b/sysutils/xentools45/TODO
@@ -0,0 +1,7 @@
+- remove all #XXX
+- get qemu going
+- fix grant table stuff
+- get xenapi functioning
+- figure out why xl hangs in kernel if daemons aren't running
+- find out why xl can't create domains if xenbackendd has ever been run
+- find and add support for any new features
diff --git a/sysutils/xentools45/distinfo b/sysutils/xentools45/distinfo
new file mode 100644
index 00000000000..dbb6afe9967
--- /dev/null
+++ b/sysutils/xentools45/distinfo
@@ -0,0 +1,53 @@
+$NetBSD: distinfo,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+SHA1 (ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz) = fecadf952821e830ce1a1d19655288eef8488f88
+RMD160 (ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz) = 539bfa12db7054228250d6dd380bbf96c1a040f8
+Size (ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz) = 2867999 bytes
+SHA1 (xen-4.5.0.tar.gz) = c4aab5fb366496ad1edc7fe0a935a0d604335637
+RMD160 (xen-4.5.0.tar.gz) = e35ba0cb484492c1a289218eb9bf53b57dbd3a45
+Size (xen-4.5.0.tar.gz) = 18404933 bytes
+SHA1 (patch-.._Config.mk) = 36a8942a9fc0f7d601c9b5f7fd1332db99f9ac4b
+SHA1 (patch-.._docs_man_xl.cfg.pod.5) = e2058495b6fe85af338e22560d46996d36aeedab
+SHA1 (patch-.._docs_man_xl.conf.pod.5) = 015da24a45388468d56f1ecfa60f6acf07bdfef8
+SHA1 (patch-.._docs_man_xl.pod.1) = b194f2c5608c6f0e80a4abd8655808cf91355cd5
+SHA1 (patch-.._docs_man_xlcpupool.cfg.pod.5) = b44813af965e4d9d0d51c18b22d286736a4663b2
+SHA1 (patch-Makefile) = 5d5b9678ed9764275ee95f49d24e8538a0e8a01c
+SHA1 (patch-blktap_drivers_Makefile) = 7cc53b2a0dea1694a969046ab8542271ca63f9e7
+SHA1 (patch-configure) = d1a1b9c9e00dd79bb872190282006201510ce2c1
+SHA1 (patch-examples_Makefile) = 5fe7bb876d254cf0c4f774ed0f08dcaea5b355ff
+SHA1 (patch-firmware_etherboot_Makefile) = f55e14948b7191e533a82b8fc3575f1052f23c45
+SHA1 (patch-firmware_etherboot_patches_series) = 2fa1342c78094c6dd5d60a07c236c4a1c0599fc4
+SHA1 (patch-firmware_hvmloader_Makefile) = bc5e81ddfc5e95887c2af4bb32eced9c5748b3c6
+SHA1 (patch-hotplug_NetBSD_Makefile) = 5afbf8dc910c93fcc0904ba09164a441704e31a2
+SHA1 (patch-hotplug_NetBSD_vif-bridge) = ac4cc7446715330b504b8cce8cbd47c8035cf33c
+SHA1 (patch-hotplug_NetBSD_vif-ip) = ed23b0c16d87bd05230399d921e28860c5857b01
+SHA1 (patch-hotplug_common_Makefile) = 1c8af96a3d0d1d5e9c168b1eb75fabb3e2164a19
+SHA1 (patch-include_xen-sys_NetBSD_gntdev.h) = b1f60f46e606b7591d68d98655d1cb29df977c14
+SHA1 (patch-libfsimage_common_Makefile) = 9c80a669805ba2e1f224985c71ca976fbe60e8b5
+SHA1 (patch-libfsimage_ufs_ufs.h) = ce1461ab83499edb4e127e3b7af9dfc1e9c0267f
+SHA1 (patch-libxc_xc__netbsd.c) = 547a713bbe9ddc92ee51b57a7b58a619f01225f1
+SHA1 (patch-libxl_Makefile) = 5b5dede29e5d9c579cdd7d6497f692ecf3a3c2cb
+SHA1 (patch-libxl_libxl__create.c) = d4c94e9a389e9a7601513460f31c82e4f4bf28c9
+SHA1 (patch-libxl_libxl_uuid.c) = d14286be8ccdbcb5fae544a1968e7b681b63e884
+SHA1 (patch-ocaml_common.make) = 4d4bddca7b5d93489a3f6620af51d95bbe265abb
+SHA1 (patch-ocaml_xenstored_Makefile) = 8014db42b65ca9290013069d1f3cb816e3f023c2
+SHA1 (patch-ocaml_xenstored_define.ml) = 18d6878ae536554e8831f3732d2a8ea1b13a9b63
+SHA1 (patch-ocaml_xenstored_utils.ml) = 04997cb9189a3331522c344aa1957e61febfd4d2
+SHA1 (patch-pygrub_Makefile) = 4380d7ddeed41c80e47f8130760f4bdc6842a394
+SHA1 (patch-qemu-xen-traditional_Makefile) = aac50189b3e359314c5d47745d50113f190bbbe0
+SHA1 (patch-qemu-xen-traditional_block-raw-posix.c) = fb03fe527515424d72758b606ab8d2e5bf8c341b
+SHA1 (patch-qemu-xen-traditional_configure) = 34499887d6e426c29e0514407a9b6e23d2496064
+SHA1 (patch-qemu-xen-traditional_hw_e1000.c) = d94874baa64a0974d29c8c3a117cf0fae030952d
+SHA1 (patch-qemu-xen-traditional_hw_ide.c) = fb674b326321f4865183eee889967b1a948698e0
+SHA1 (patch-qemu-xen-traditional_hw_pass-through.c) = b87481f764e16fb1345c44b4f46fa3837901a4e2
+SHA1 (patch-qemu-xen-traditional_hw_pass-through.h) = 0bf5cbc1d6f5506c1878296fce98ca3e42fc6560
+SHA1 (patch-qemu-xen-traditional_hw_piix4acpi.c) = 432cbbd922a2453d3aab37e49cced767a3f1ad34
+SHA1 (patch-qemu-xen-traditional_hw_pt-graphics.c) = 7c887bfea57f601dba439a2ee20061a772a0aca5
+SHA1 (patch-qemu-xen-traditional_hw_pt-msi.c) = bc22e828a0cb9c93448b6f14284318963b7088e6
+SHA1 (patch-qemu-xen-traditional_hw_pt-msi.h) = e2028d255bdfaee9e7eb4ca3be2edb061196809c
+SHA1 (patch-qemu-xen-traditional_i386-dm_hookstarget.mak) = 50c6bc068406effe94b638ffced7d8edf5729717
+SHA1 (patch-qemu-xen-traditional_xen-hooks.mak) = ccc055fdb56ee796e1464f709aa576ab8cd9c6f1
+SHA1 (patch-qemu-xen_audio_audio.c) = 8452d63fe90e38a64111d0cf425bacd565fe6d82
+SHA1 (patch-qemu-xen_qemu-doc.texi) = 721e80d15ac30ac71df3d6c4c485b0bf70897cf9
+SHA1 (patch-qemu-xen_util_hbitmap.c) = 5a495ae2b47d1ff6dd342633b8d655582f21dffe
+SHA1 (patch-xenstore_xc.c) = 51b39e9929062e72d0ff85f0ee6d13a6ac04ac65
diff --git a/sysutils/xentools45/files/blk_netbsd.c b/sysutils/xentools45/files/blk_netbsd.c
new file mode 100644
index 00000000000..7ba8d407db3
--- /dev/null
+++ b/sysutils/xentools45/files/blk_netbsd.c
@@ -0,0 +1,38 @@
+#include <inttypes.h>
+#include <sys/ioctl.h>
+#include <sys/disklabel.h>
+#include "tapdisk.h"
+#include "blk.h"
+
+int blk_getimagesize(int fd, uint64_t *size)
+{
+ int rc;
+ struct disklabel dl;
+
+ *size = 0;
+ rc = ioctl(fd, DIOCGDINFO, &dl);
+ if (rc) {
+ DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
+ return -EINVAL;
+ }
+
+ *size = dl.d_secsize * dl.d_secpercyl;
+
+ return 0;
+}
+
+int blk_getsectorsize(int fd, uint64_t *sector_size)
+{
+ int rc;
+ struct disklabel dl;
+
+ *sector_size = DEV_BSIZE;
+ rc = ioctl(fd, DIOCGDINFO, &dl);
+ if (rc) {
+ DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
+ return 0; /* fallback to DEV_BSIZE */
+ }
+
+ *sector_size = dl.d_secsize;
+ return 0;
+}
diff --git a/sysutils/xentools45/files/blktapctrl_netbsd.c b/sysutils/xentools45/files/blktapctrl_netbsd.c
new file mode 100644
index 00000000000..02a1e9f3018
--- /dev/null
+++ b/sysutils/xentools45/files/blktapctrl_netbsd.c
@@ -0,0 +1,16 @@
+
+#include "blktaplib.h"
+#include "blktapctrl.h"
+
+
+int blktap_interface_open(void)
+{
+ /* not yet implemented */
+ return -1;
+}
+
+int blktap_interface_create(int ctlfd, int *major, int *minor, blkif_t *blkif)
+{
+ /* not yet implemented */
+ return -1;
+}
diff --git a/sysutils/xentools45/files/xen-watchdog.sh b/sysutils/xentools45/files/xen-watchdog.sh
new file mode 100644
index 00000000000..4d2a96b24ce
--- /dev/null
+++ b/sysutils/xentools45/files/xen-watchdog.sh
@@ -0,0 +1,17 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# PROVIDE: xen-watchdog
+# REQUIRE: DAEMON
+#
+# description: Run domain watchdog daemon
+#
+
+. /etc/rc.subr
+
+name="xenwatchdog"
+rcvar=$name
+command="@PREFIX@/sbin/xenwatchdogd"
+start_cmd="echo Starting ${name}. && PATH=${PATH}:@PREFIX@/sbin ${command} 30 15"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/sysutils/xentools45/files/xencommons.sh b/sysutils/xentools45/files/xencommons.sh
new file mode 100644
index 00000000000..d106ccb54c0
--- /dev/null
+++ b/sysutils/xentools45/files/xencommons.sh
@@ -0,0 +1,107 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# PROVIDE: xencommons
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="xencommons"
+rcvar=$name
+start_precmd="xen_precmd"
+start_cmd="xen_startcmd"
+stop_cmd="xen_stop"
+status_cmd="xen_status"
+extra_commands="status"
+required_files="/kern/xen/privcmd"
+
+XENSTORED_PIDFILE="/var/run/xenstored.pid"
+XENCONSOLED_PIDFILE="/var/run/xenconsoled.pid"
+
+BINDIR=@PREFIX@/bin
+SBINDIR=@PREFIX@/sbin
+
+xen_precmd()
+{
+ mkdir -p /var/run/xen || exit 1
+ mkdir -p /var/run/xenstored || exit 1
+}
+
+xen_startcmd()
+{
+ printf "Starting xenservices: xenstored, xenconsoled.\n"
+ if test ! -r ${required_files}; then
+ warn "${required_files} is not readable."
+ fi
+ XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
+ if [ -n "${XENSTORED_TRACE}" ]; then
+ XENSTORED_ARGS="${XENSTORED_ARGS} -T /var/log/xen/xenstored-trace.log"
+ fi
+
+ ${SBINDIR}/xenstored ${XENSTORED_ARGS}
+ sleep 5
+
+ printf "Setting domain 0 name and domid...\n"
+ ${BINDIR}/xenstore-write "/local/domain/0/name" "Domain-0" \
+ "domid" 0
+
+ XENCONSOLED_ARGS=""
+ if [ -n "${XENCONSOLED_TRACE}" ]; then
+ XENCONSOLED_ARGS="${XENCONSOLED_ARGS} --log=${XENCONSOLED_TRACE}"
+ fi
+
+ ${SBINDIR}/xenconsoled ${XENCONSOLED_ARGS}
+}
+
+xen_stop()
+{
+ pids=""
+ printf "Stopping xencommons"
+
+ rc_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${SBINDIR}/xenconsoled)
+ pids="$pids $rc_pid"
+ rc_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${SBINDIR}/xenstored)
+ pids="$pids $rc_pid"
+
+ kill -${sig_stop:-TERM} $pids
+ wait_for_pids $pids
+
+ printf ".\n"
+}
+
+xen_status()
+{
+ xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${SBINDIR}/xenstored)
+ if test -n ${xenstored_pid}; then
+ pids="$pids $xenstored_pid"
+ fi
+
+ xenconsoled_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${SBINDIR}/xenconsoled)
+ if test -n ${xenconsoled_pid}; then
+ pids="$pids $xenconsoled_pid"
+ fi
+
+ if test -n "$xenconsoled_pid" -a -n "$xenstored_pid";
+ then
+ echo "xencommons are running as pids $pids."
+ return 0
+ fi
+ if test -a -z "$xenconsoled_pid" -a -z "$xenstored_pid";
+ then
+ echo "xencommons are not running."
+ return 0
+ fi
+
+ if test -n "$xenstored_pid"; then
+ echo "xenstored is running as pid $xenstored_pid."
+ else
+ echo "xenstored is not running."
+ fi
+ if test -n "$xenconsoled_pid"; then
+ echo "xenconsoled is running as pid $xenconsoled_pid."
+ else
+ echo "xenconsoled is not running."
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/sysutils/xentools45/files/xendomains.sh b/sysutils/xentools45/files/xendomains.sh
new file mode 100644
index 00000000000..c33bf592abd
--- /dev/null
+++ b/sysutils/xentools45/files/xendomains.sh
@@ -0,0 +1,129 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# PROVIDE: xendomains
+# REQUIRE: xencommons
+# KEYWORD: shutdown
+#
+# xendomains This required variable is a whitespace-separated
+# list of domains, e.g., xendomains="dom1 dom2 dom3".
+#
+# xendomains_config This optional variable is a format string that
+# represents the path to the configuration file for
+# each domain. "%s" is substituted with the name of
+# the domain. The default is "@PKG_SYSCONFDIR@/%s".
+#
+# xendomains_prehook This optional variable is a format string that
+# represents the command to run, if it exists, before
+# starting each domain. "%s" is substituted with the
+# name of the domain. The default is
+# "@PKG_SYSCONFDIR@/%s-pre".
+#
+# xendomains_posthook This optional variable is a format string that
+# represents the command to run, if it exists, after
+# stopping each domain. "%s" is substituted with the
+# name of the domain. The default is
+# "@PKG_SYSCONFDIR@/%s-post".
+#
+
+. /etc/rc.subr
+
+name="xendomains"
+ctl_command="@PREFIX@/sbin/xl"
+start_cmd="xendomains_start"
+stop_cmd="xendomains_stop"
+list_cmd="xendomains_list"
+extra_commands="list"
+required_files="/kern/xen/privcmd"
+
+xendomains_start()
+{
+ [ -n "$xendomains" ] || return
+
+ echo "Starting xen domains."
+ for domain in $xendomains; do
+ case "$domain" in
+ "") continue ;;
+ esac
+
+ # Start off by running the pre-hook script if it's present.
+ if [ -n "${xendomains_prehook}" ]; then
+ cmdline=`printf "${xendomains_prehook}" $domain`
+ cmd="${cmdline%% *}"
+ if [ -x "$cmd" ]; then
+ if ! $cmdline; then
+ echo "Pre-hook \`\`$cmdline'' failed... skipping $domain."
+ continue
+ fi
+ fi
+ fi
+
+ # Ask xend to create the domain.
+ if [ -n "${xendomains_config}" ]; then
+ file=`printf "${xendomains_config}" $domain`
+ if [ -f "$file" ]; then
+ ${ctl_command} create "$file"
+ fi
+ fi
+ done
+}
+
+xendomains_list() {
+ # Output a whitespace-separated list of live guest domains.
+ ${ctl_command} list | awk '
+ (FNR <= 2) { next }
+ ($5 !~ /s/) { s = s " " $1 }
+ END { sub(" *", "", s); print s }'
+}
+
+xendomains_stop()
+{
+ # Determine an appropriate timeout waiting for all domains to
+ # stop -- always wait at least 60s, and add 5s per active domain.
+ #
+ numdomains=$(xendomains_list | awk '{ print NF }')
+ [ $numdomains -gt 0 ] || return
+ timeout=$((60 + numdomains * 5))
+
+ # Ask xend to stop every domain, and poll xend every 10s up to the
+ # timeout period to check if all the domains are stopped. We
+ # consider a domain in the "s" (shutdown) state to be stopped.
+ #
+ echo "Stopping xen domains."
+ for domain in $(xendomains_list); do
+ ${ctl_command} shutdown -F $domain
+ done
+ while [ $timeout -gt 0 ]; do
+ livedomains=$(xendomains_list)
+ [ -n "$livedomains" ] || break
+ timeout=$((timeout - 10))
+ sleep 10
+ done
+ livedomains=$(xendomains_list)
+ if [ -n "$livedomains" ]; then
+ echo "Failed to stop: $livedomains"
+ else
+ echo "All domains stopped."
+ fi
+
+ # Finish off by running the post-hook script if it's present.
+ for domain in $xendomains; do
+ case "$domain" in
+ "") continue ;;
+ esac
+ if [ -n "${xendomains_posthook}" ]; then
+ cmdline=`printf "${xendomains_posthook}" $domain`
+ cmd="${cmdline%% *}"
+ if [ -x "$cmd" ]; then
+ $cmdline || echo "Post-hook \`\`$cmdline'' failed."
+ fi
+ fi
+ done
+}
+
+load_rc_config $name
+
+: ${xendomains_config="@PKG_SYSCONFDIR@/%s"}
+: ${xendomains_prehook="@PKG_SYSCONFDIR@/%s-pre"}
+: ${xendomains_posthook="@PKG_SYSCONFDIR@/%s-post"}
+
+run_rc_command "$1"
diff --git a/sysutils/xentools45/patches/patch-.._Config.mk b/sysutils/xentools45/patches/patch-.._Config.mk
new file mode 100644
index 00000000000..879b1c10cbd
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-.._Config.mk
@@ -0,0 +1,22 @@
+$NetBSD: patch-.._Config.mk,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ../Config.mk.orig 2015-01-12 17:53:24.000000000 +0100
++++ ../Config.mk 2015-01-19 13:16:16.000000000 +0100
+@@ -38,7 +38,7 @@
+ # Tools to run on system hosting the build
+ HOSTCC = gcc
+ HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
+-HOSTCFLAGS += -fno-strict-aliasing
++HOSTCFLAGS += -fno-strict-aliasing ${EXTRA_HOSTCFLAGS}
+
+ DISTDIR ?= $(XEN_ROOT)/dist
+ DESTDIR ?= /
+@@ -194,6 +194,8 @@
+ # and is a bit too fierce about unused return values
+ CFLAGS-$(clang) += -Wno-parentheses -Wno-format -Wno-unused-value
+
++CFLAGS += ${EXTRA_CFLAGS}
++
+ $(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement)
+ $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement)
+ $(call cc-option-add,CFLAGS,CC,-Wno-unused-but-set-variable)
diff --git a/sysutils/xentools45/patches/patch-.._docs_man_xl.cfg.pod.5 b/sysutils/xentools45/patches/patch-.._docs_man_xl.cfg.pod.5
new file mode 100644
index 00000000000..f9674fee26a
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-.._docs_man_xl.cfg.pod.5
@@ -0,0 +1,29 @@
+$NetBSD: patch-.._docs_man_xl.cfg.pod.5,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ../docs/man/xl.cfg.pod.5.orig 2015-01-12 17:53:24.000000000 +0100
++++ ../docs/man/xl.cfg.pod.5 2015-01-19 15:32:47.000000000 +0100
+@@ -4,13 +4,13 @@
+
+ =head1 SYNOPSIS
+
+- /etc/xen/xldomain
++ @XENDCONFDIR@/xldomain
+
+ =head1 DESCRIPTION
+
+ To create a VM (a domain in Xen terminology, sometimes called a guest)
+ with xl requires the provision of a domain config file. Typically
+-these live in `/etc/xen/DOMAIN.cfg` where DOMAIN is the name of the
++these live in `@XENDCONFDIR@/DOMAIN.cfg` where DOMAIN is the name of the
+ domain.
+
+ =head1 SYNTAX
+@@ -1604,7 +1604,7 @@
+
+ =head1 FILES
+
+-F</etc/xen/NAME.cfg>
++F<@XENDCONFDIR@/NAME.cfg>
+ F</var/xen/dump/NAME>
+
+ =head1 BUGS
diff --git a/sysutils/xentools45/patches/patch-.._docs_man_xl.conf.pod.5 b/sysutils/xentools45/patches/patch-.._docs_man_xl.conf.pod.5
new file mode 100644
index 00000000000..f4c4dc03d22
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-.._docs_man_xl.conf.pod.5
@@ -0,0 +1,30 @@
+$NetBSD: patch-.._docs_man_xl.conf.pod.5,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ../docs/man/xl.conf.pod.5.orig 2015-01-12 17:53:24.000000000 +0100
++++ ../docs/man/xl.conf.pod.5 2015-01-19 13:18:33.000000000 +0100
+@@ -1,6 +1,6 @@
+ =head1 NAME
+
+-/etc/xen/xl.conf - XL Global/Host Configuration
++@XENDCONFDIR@/xl.conf - XL Global/Host Configuration
+
+ =head1 DESCRIPTION
+
+@@ -83,7 +83,7 @@
+
+ The old B<vifscript> option is deprecated and should not be used.
+
+-Default: C</etc/xen/scripts/vif-bridge>
++Default: C<@XENDCONFDIR@/scripts/vif-bridge>
+
+ =item B<vif.default.bridge="NAME">
+
+@@ -109,7 +109,7 @@
+
+ Configures the default script used by Remus to setup network buffering.
+
+-Default: C</etc/xen/scripts/remus-netbuf-setup>
++Default: C<@XENDCONFDIR@/scripts/remus-netbuf-setup>
+
+ =item B<output_format="json|sxp">
+
diff --git a/sysutils/xentools45/patches/patch-.._docs_man_xl.pod.1 b/sysutils/xentools45/patches/patch-.._docs_man_xl.pod.1
new file mode 100644
index 00000000000..0845d7e8378
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-.._docs_man_xl.pod.1
@@ -0,0 +1,44 @@
+$NetBSD: patch-.._docs_man_xl.pod.1,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ../docs/man/xl.pod.1.orig 2015-01-12 17:53:24.000000000 +0100
++++ ../docs/man/xl.pod.1 2015-01-19 13:19:15.000000000 +0100
+@@ -33,10 +33,10 @@
+
+ =over 4
+
+-=item start the script B</etc/init.d/xencommons> at boot time
++=item start the script B</etc/rc.d/xencommons> at boot time
+
+ Most B<xl> operations rely upon B<xenstored> and B<xenconsoled>: make
+-sure you start the script B</etc/init.d/xencommons> at boot time to
++sure you start the script B</etc/rc.d/xencommons> at boot time to
+ initialize all the daemons needed by B<xl>.
+
+ =item setup a B<xenbr0> bridge in dom0
+@@ -50,7 +50,7 @@
+
+ If you specify the amount of memory dom0 has, passing B<dom0_mem> to
+ Xen, it is highly recommended to disable B<autoballoon>. Edit
+-B</etc/xen/xl.conf> and set it to 0.
++B<@XENDCONFDIR@/xl.conf> and set it to 0.
+
+ =item run xl as B<root>
+
+@@ -168,7 +168,7 @@
+
+ xl create DebianLenny
+
+-This creates a domain with the file /etc/xen/DebianLenny, and returns as
++This creates a domain with the file @XENDCONFDIR@/DebianLenny, and returns as
+ soon as it is run.
+
+ =item I<with extra parameters>
+@@ -463,7 +463,7 @@
+ =item B<-N> I<netbufscript>
+
+ Use <netbufscript> to setup network buffering instead of the
+-default script (/etc/xen/scripts/remus-netbuf-setup).
++default script (@XENDCONFDIR@/scripts/remus-netbuf-setup).
+
+ =item B<-F>
+
diff --git a/sysutils/xentools45/patches/patch-.._docs_man_xlcpupool.cfg.pod.5 b/sysutils/xentools45/patches/patch-.._docs_man_xlcpupool.cfg.pod.5
new file mode 100644
index 00000000000..20f07e52dea
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-.._docs_man_xlcpupool.cfg.pod.5
@@ -0,0 +1,28 @@
+$NetBSD: patch-.._docs_man_xlcpupool.cfg.pod.5,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ../docs/man/xlcpupool.cfg.pod.5.orig 2015-01-12 17:53:24.000000000 +0100
++++ ../docs/man/xlcpupool.cfg.pod.5 2015-01-19 13:16:17.000000000 +0100
+@@ -4,12 +4,12 @@
+
+ =head1 SYNOPSIS
+
+- /etc/xen/xlcpupool
++ @XENDCONFDIR@/xlcpupool
+
+ =head1 DESCRIPTION
+
+ To create a Cpupool with xl requires the provision of a cpupool config
+-file. Typically these live in `/etc/xen/CPUPOOL.cfg` where CPUPOOL is
++file. Typically these live in `@XENDCONFDIR@/CPUPOOL.cfg` where CPUPOOL is
+ the name of the cpupool.
+
+ =head1 SYNTAX
+@@ -101,7 +101,7 @@
+
+ =head1 FILES
+
+-F</etc/xen/CPUPOOL.cfg>
++F<@XENDCONFDIR@/CPUPOOL.cfg>
+
+ =head1 BUGS
+
diff --git a/sysutils/xentools45/patches/patch-Makefile b/sysutils/xentools45/patches/patch-Makefile
new file mode 100644
index 00000000000..56ae74131cb
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-Makefile
@@ -0,0 +1,13 @@
+$NetBSD: patch-Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ Makefile 2015-01-19 13:16:17.000000000 +0100
+@@ -33,7 +33,7 @@
+ SUBDIRS-$(CONFIG_X86) += xenpaging
+ SUBDIRS-$(CONFIG_X86) += debugger/gdbsx
+ SUBDIRS-$(CONFIG_X86) += debugger/kdd
+-SUBDIRS-$(CONFIG_TESTS) += tests
++#XXX SUBDIRS-$(CONFIG_TESTS) += tests
+
+ # These don't cross-compile
+ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
diff --git a/sysutils/xentools45/patches/patch-blktap_drivers_Makefile b/sysutils/xentools45/patches/patch-blktap_drivers_Makefile
new file mode 100644
index 00000000000..f5d30d57653
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-blktap_drivers_Makefile
@@ -0,0 +1,16 @@
+$NetBSD: patch-blktap_drivers_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- blktap/drivers/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ blktap/drivers/Makefile 2015-01-19 13:16:17.000000000 +0100
+@@ -44,9 +44,11 @@
+ BLK-OBJS-y += aes.o
+ BLK-OBJS-y += tapaio.o
+ BLK-OBJS-$(CONFIG_Linux) += blk_linux.o
++BLK-OBJS-$(CONFIG_NetBSD) += blk_netbsd.o
+
+ BLKTAB-OBJS-y := blktapctrl.o
+ BLKTAB-OBJS-$(CONFIG_Linux) += blktapctrl_linux.o
++BLKTAB-OBJS-$(CONFIG_NetBSD) += blktapctrl_netbsd.o
+
+ all: $(IBIN) qcow-util
+
diff --git a/sysutils/xentools45/patches/patch-configure b/sysutils/xentools45/patches/patch-configure
new file mode 100644
index 00000000000..753c6b43df2
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-configure
@@ -0,0 +1,39 @@
+$NetBSD: patch-configure,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- configure.orig 2015-01-12 17:53:24.000000000 +0100
++++ configure 2015-01-19 20:34:47.000000000 +0100
+@@ -2276,7 +2276,7 @@
+
+
+
+-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/systemd/proc-xen.mount hotplug/Linux/systemd/var-lib-xenstored.mount hotplug/Linux/systemd/xen-init-dom0.service hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service hotplug/Linux/systemd/xen-watchdog.service hotplug/Linux/systemd/xenconsoled.service hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xenstored.service hotplug/Linux/systemd/xenstored.socket hotplug/Linux/systemd/xenstored_ro.socket hotplug/Linux/vif-setup hotplug/Linux/xen-backend.rules hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons"
++ac_config_files="$ac_config_files ../config/Tools.mk ../config/Paths.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/systemd/proc-xen.mount hotplug/Linux/systemd/var-lib-xenstored.mount hotplug/Linux/systemd/xen-init-dom0.service hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service hotplug/Linux/systemd/xen-watchdog.service hotplug/Linux/systemd/xenconsoled.service hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xenstored.service hotplug/Linux/systemd/xenstored.socket hotplug/Linux/systemd/xenstored_ro.socket hotplug/Linux/vif-setup hotplug/Linux/xen-backend.rules hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons"
+
+ ac_config_headers="$ac_config_headers config.h"
+
+@@ -3710,7 +3710,7 @@
+
+ if test "x$sysconfdir" = 'x${prefix}/etc' ; then
+ case "$host_os" in
+- *freebsd*)
++ *freebsd*|*netbsd*)
+ sysconfdir=$prefix/etc
+ ;;
+ *solaris*)
+@@ -9483,6 +9483,8 @@
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
++ : Avoid regenerating within pkgsrc
++ exit 0
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+@@ -9566,6 +9568,7 @@
+ do
+ case $ac_config_target in
+ "../config/Tools.mk") CONFIG_FILES="$CONFIG_FILES ../config/Tools.mk" ;;
++ "../config/Paths.mk") CONFIG_FILES="$CONFIG_FILES ../config/Paths.mk" ;;
+ "hotplug/FreeBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xencommons" ;;
+ "hotplug/Linux/init.d/sysconfig.xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/sysconfig.xencommons" ;;
+ "hotplug/Linux/init.d/xen-watchdog") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xen-watchdog" ;;
diff --git a/sysutils/xentools45/patches/patch-examples_Makefile b/sysutils/xentools45/patches/patch-examples_Makefile
new file mode 100644
index 00000000000..ebca750439c
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-examples_Makefile
@@ -0,0 +1,12 @@
+$NetBSD: patch-examples_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- examples/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ examples/Makefile 2015-01-19 13:37:18.000000000 +0100
+@@ -1,6 +1,6 @@
+ XEN_ROOT = $(CURDIR)/../..
+ include $(XEN_ROOT)/tools/Rules.mk
+-
++XEN_CONFIG_DIR=${XEN_EXAMPLES_DIR}
+ # Xen configuration dir and configs to go there.
+ XEN_READMES = README
+ XEN_READMES += README.incompatibilities
diff --git a/sysutils/xentools45/patches/patch-firmware_etherboot_Makefile b/sysutils/xentools45/patches/patch-firmware_etherboot_Makefile
new file mode 100644
index 00000000000..0659f76fa47
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-firmware_etherboot_Makefile
@@ -0,0 +1,26 @@
+$NetBSD: patch-firmware_etherboot_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- firmware/etherboot/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ firmware/etherboot/Makefile 2015-01-19 13:42:54.000000000 +0100
+@@ -27,18 +27,10 @@
+ %.rom: $D/src/arch/i386/Makefile
+ $(MAKE) -C $D/src bin/$(*F).rom
+
+-$T:
+- if ! $(FETCHER) _$T $(IPXE_TARBALL_URL); then \
+- $(GIT) clone $(IPXE_GIT_URL) $D.git; \
+- (cd $D.git && $(GIT) archive --format=tar --prefix=$D/ \
+- $(IPXE_GIT_TAG) | gzip >../_$T); \
+- rm -rf $D.git; \
+- fi
+- mv _$T $T
++$D:
++ ln -sf $(WRKSRC)/../../ipxe $D
+
+-$D/src/arch/i386/Makefile: $T Config
+- rm -rf $D
+- gzip -dc $T | tar xf -
++$D/src/arch/i386/Makefile: $D Config
+ for i in $$(cat patches/series) ; do \
+ patch -d $D -p1 --quiet <patches/$$i || exit 1 ; \
+ done
diff --git a/sysutils/xentools45/patches/patch-firmware_etherboot_patches_series b/sysutils/xentools45/patches/patch-firmware_etherboot_patches_series
new file mode 100644
index 00000000000..c53d56bbc68
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-firmware_etherboot_patches_series
@@ -0,0 +1,9 @@
+$NetBSD: patch-firmware_etherboot_patches_series,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- firmware/etherboot/patches/series.orig 2015-01-12 17:53:24.000000000 +0100
++++ firmware/etherboot/patches/series 2015-01-19 13:16:37.000000000 +0100
+@@ -1,4 +1,3 @@
+ boot_prompt_option.patch
+ build_fix_1.patch
+ build_fix_2.patch
+-build_fix_3.patch
diff --git a/sysutils/xentools45/patches/patch-firmware_hvmloader_Makefile b/sysutils/xentools45/patches/patch-firmware_hvmloader_Makefile
new file mode 100644
index 00000000000..cda57d3e510
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-firmware_hvmloader_Makefile
@@ -0,0 +1,13 @@
+$NetBSD: patch-firmware_hvmloader_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- firmware/hvmloader/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ firmware/hvmloader/Makefile 2015-01-19 13:16:37.000000000 +0100
+@@ -26,7 +26,7 @@
+ # The HVM loader is started in 32-bit mode at the address below:
+ LOADADDR = 0x100000
+
+-CFLAGS += $(CFLAGS_xeninclude)
++CFLAGS += $(CFLAGS_xeninclude) $(EXTRA_CFLAGS)
+
+ OBJS = hvmloader.o mp_tables.o util.o smbios.o
+ OBJS += smp.o cacheattr.o xenbus.o
diff --git a/sysutils/xentools45/patches/patch-hotplug_NetBSD_Makefile b/sysutils/xentools45/patches/patch-hotplug_NetBSD_Makefile
new file mode 100644
index 00000000000..ae90341de43
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-hotplug_NetBSD_Makefile
@@ -0,0 +1,46 @@
+$NetBSD: patch-hotplug_NetBSD_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- hotplug/NetBSD/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ hotplug/NetBSD/Makefile 2015-01-19 14:18:22.000000000 +0100
+@@ -8,7 +8,7 @@
+ XEN_SCRIPTS += vif-ip
+
+ XEN_SCRIPT_DATA =
+-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog
++#XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog
+
+ .PHONY: all
+ all:
+@@ -21,10 +21,11 @@
+
+ .PHONY: install-scripts
+ install-scripts:
+- $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
++ $(INSTALL_DIR) $(DESTDIR)$(XEN_EXAMPLES_DIR)
++ $(INSTALL_DIR) $(DESTDIR)$(XEN_EXAMPLES_DIR)/scripts
+ set -e; for i in $(XEN_SCRIPTS); \
+ do \
+- $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
++ $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_EXAMPLES_DIR)/scripts; \
+ done
+ set -e; for i in $(XEN_SCRIPT_DATA); \
+ do \
+@@ -33,12 +34,12 @@
+
+ .PHONY: install-rcd
+ install-rcd:
+- $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
+- set -e; for i in $(XEN_RCD_PROG); \
+- do \
+- $(INSTALL_PROG) $$i $(DESTDIR)$(INITD_DIR); \
+- done
+- $(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(INITD_DIR)/xen-hotplugpath.sh
++# $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
++# set -e; for i in $(XEN_RCD_PROG); \
++# do \
++# $(INSTALL_PROG) $$i $(DESTDIR)$(INITD_DIR); \
++# done
++# $(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(INITD_DIR)/xen-hotplugpath.sh
+
+ .PHONY: clean
+ clean:
diff --git a/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-bridge b/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-bridge
new file mode 100644
index 00000000000..c8a25ac10c9
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-bridge
@@ -0,0 +1,16 @@
+$NetBSD: patch-hotplug_NetBSD_vif-bridge,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- hotplug/NetBSD/vif-bridge.orig 2015-01-12 17:53:24.000000000 +0100
++++ hotplug/NetBSD/vif-bridge 2015-01-19 13:16:37.000000000 +0100
+@@ -23,7 +23,10 @@
+ xbridge=$(xenstore-read "$xpath/bridge")
+ xfid=$(xenstore-read "$xpath/frontend-id")
+ xhandle=$(xenstore-read "$xpath/handle")
+- iface=$(xenstore-read "$xpath/vifname")
++ iface=$(xenstore-read "$xpath/vifname") || true
++ if [ x${iface} = "x" ] ; then
++ iface=xvif$xfid.$xhandle
++ fi
+ ifconfig $iface up
+ brconfig $xbridge add $iface
+ xenstore-write $xpath/hotplug-status connected
diff --git a/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-ip b/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-ip
new file mode 100644
index 00000000000..8f5925f403d
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-hotplug_NetBSD_vif-ip
@@ -0,0 +1,15 @@
+$NetBSD: patch-hotplug_NetBSD_vif-ip,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- hotplug/NetBSD/vif-ip.orig 2015-01-12 17:53:24.000000000 +0100
++++ hotplug/NetBSD/vif-ip 2015-01-19 13:16:37.000000000 +0100
+@@ -24,6 +24,10 @@
+ xfid=$(xenstore-read "$xpath/frontend-id")
+ xhandle=$(xenstore-read "$xpath/handle")
+ iface=$(xenstore-read "$xpath/vifname")
++ iface=$(xenstore-read "$xpath/vifname") || true
++ if [ x${iface} = "x" ] ; then
++ iface=xvif$xfid.$xhandle
++ fi
+ ifconfig $iface $xip up
+ xenstore-write $xpath/hotplug-status connected
+ exit 0
diff --git a/sysutils/xentools45/patches/patch-hotplug_common_Makefile b/sysutils/xentools45/patches/patch-hotplug_common_Makefile
new file mode 100644
index 00000000000..ddd907c1923
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-hotplug_common_Makefile
@@ -0,0 +1,24 @@
+$NetBSD: patch-hotplug_common_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- hotplug/common/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ hotplug/common/Makefile 2015-01-19 13:16:37.000000000 +0100
+@@ -23,15 +23,15 @@
+
+ .PHONY: install-scripts
+ install-scripts: build
+- [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
+- $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
++ [ -d $(DESTDIR)${XEN_EXAMPLES_DIR}/scripts ] || \
++ $(INSTALL_DIR) $(DESTDIR)${XEN_EXAMPLES_DIR}/scripts
+ set -e; for i in $(XEN_SCRIPTS); \
+ do \
+- $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
++ $(INSTALL_PROG) $$i $(DESTDIR)${XEN_EXAMPLES_DIR}/scripts; \
+ done
+ set -e; for i in $(XEN_SCRIPT_DATA); \
+ do \
+- $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
++ $(INSTALL_DATA) $$i $(DESTDIR)${XEN_EXAMPLES_DIR}/scripts; \
+ done
+
+ .PHONY: clean
diff --git a/sysutils/xentools45/patches/patch-include_xen-sys_NetBSD_gntdev.h b/sysutils/xentools45/patches/patch-include_xen-sys_NetBSD_gntdev.h
new file mode 100644
index 00000000000..140c85ba073
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-include_xen-sys_NetBSD_gntdev.h
@@ -0,0 +1,110 @@
+$NetBSD: patch-include_xen-sys_NetBSD_gntdev.h,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- include/xen-sys/NetBSD/gntdev.h.orig 2015-01-19 13:16:37.000000000 +0100
++++ include/xen-sys/NetBSD/gntdev.h 2015-01-19 13:16:37.000000000 +0100
+@@ -0,0 +1,105 @@
++/******************************************************************************
++ * gntdev.h
++ *
++ * Interface to /dev/xen/gntdev.
++ *
++ * Copyright (c) 2007, D G Murray
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#ifndef __NetBSD_PUBLIC_GNTDEV_H__
++#define __NetBSD_PUBLIC_GNTDEV_H__
++
++struct ioctl_gntdev_grant_ref {
++ /* The domain ID of the grant to be mapped. */
++ uint32_t domid;
++ /* The grant reference of the grant to be mapped. */
++ uint32_t ref;
++};
++
++/*
++ * Inserts the grant references into the mapping table of an instance
++ * of gntdev. N.B. This does not perform the mapping, which is deferred
++ * until mmap() is called with @index as the offset.
++ */
++#define IOCTL_GNTDEV_MAP_GRANT_REF \
++ _IOWR('G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
++struct ioctl_gntdev_map_grant_ref {
++ /* IN parameters */
++ /* The number of grants to be mapped. */
++ uint32_t count;
++ uint32_t pad;
++ /* OUT parameters */
++ /* The offset to be used on a subsequent call to mmap(). */
++ uint64_t index;
++ /* Variable IN parameter. */
++ /* Array of grant references, of size @count. */
++ struct ioctl_gntdev_grant_ref refs[1];
++};
++
++/*
++ * Removes the grant references from the mapping table of an instance of
++ * of gntdev. N.B. munmap() must be called on the relevant virtual address(es)
++ * before this ioctl is called, or an error will result.
++ */
++#define IOCTL_GNTDEV_UNMAP_GRANT_REF \
++ _IOW('G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))
++struct ioctl_gntdev_unmap_grant_ref {
++ /* IN parameters */
++ /* The offset was returned by the corresponding map operation. */
++ uint64_t index;
++ /* The number of pages to be unmapped. */
++ uint32_t count;
++ uint32_t pad;
++};
++
++/*
++ * Returns the offset in the driver's address space that corresponds
++ * to @vaddr. This can be used to perform a munmap(), followed by an
++ * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by
++ * the caller. The number of pages that were allocated at the same time as
++ * @vaddr is returned in @count.
++ *
++ * N.B. Where more than one page has been mapped into a contiguous range, the
++ * supplied @vaddr must correspond to the start of the range; otherwise
++ * an error will result. It is only possible to munmap() the entire
++ * contiguously-allocated range at once, and not any subrange thereof.
++ */
++#define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \
++ _IOWR('G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))
++struct ioctl_gntdev_get_offset_for_vaddr {
++ /* IN parameters */
++ /* The virtual address of the first mapped page in a range. */
++ uint64_t vaddr;
++ /* OUT parameters */
++ /* The offset that was used in the initial mmap() operation. */
++ uint64_t offset;
++ /* The number of pages mapped in the VM area that begins at @vaddr. */
++ uint32_t count;
++ uint32_t pad;
++};
++
++#endif /* __NetBSD_PUBLIC_GNTDEV_H__ */
diff --git a/sysutils/xentools45/patches/patch-libfsimage_common_Makefile b/sysutils/xentools45/patches/patch-libfsimage_common_Makefile
new file mode 100644
index 00000000000..734eb33aa4c
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libfsimage_common_Makefile
@@ -0,0 +1,13 @@
+$NetBSD: patch-libfsimage_common_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libfsimage/common/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ libfsimage/common/Makefile 2015-01-19 13:16:38.000000000 +0100
+@@ -4,6 +4,8 @@
+ MAJOR = 1.0
+ MINOR = 0
+
++CFLAGS += -DFSIMAGE_FSDIR=\"$(LIBDIR)/fs\"
++
+ LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS
+ LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU
+ LDFLAGS = $(LDFLAGS-y)
diff --git a/sysutils/xentools45/patches/patch-libfsimage_ufs_ufs.h b/sysutils/xentools45/patches/patch-libfsimage_ufs_ufs.h
new file mode 100644
index 00000000000..07e62f4dd7b
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libfsimage_ufs_ufs.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-libfsimage_ufs_ufs.h,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libfsimage/ufs/ufs.h.orig 2015-01-12 17:53:24.000000000 +0100
++++ libfsimage/ufs/ufs.h 2015-01-19 13:16:38.000000000 +0100
+@@ -4,7 +4,7 @@
+ */
+
+ #ifndef _GRUB_UFS_H
+-#define _GRUB_UFS_H_
++#define _GRUB_UFS_H
+
+ /* ufs specific constants */
+ #define UFS_SBLOCK 16
diff --git a/sysutils/xentools45/patches/patch-libxc_xc__netbsd.c b/sysutils/xentools45/patches/patch-libxc_xc__netbsd.c
new file mode 100644
index 00000000000..3db9e43d3cf
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libxc_xc__netbsd.c
@@ -0,0 +1,251 @@
+$NetBSD: patch-libxc_xc__netbsd.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libxc/xc_netbsd.c.orig 2015-01-12 17:53:24.000000000 +0100
++++ libxc/xc_netbsd.c 2015-01-19 13:16:38.000000000 +0100
+@@ -18,13 +18,19 @@
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+-#include "xc_private.h"
+-
+-#include <xen/sys/evtchn.h>
+-#include <unistd.h>
++#include <sys/mman.h>
++#include <sys/types.h>
+ #include <fcntl.h>
+ #include <malloc.h>
+-#include <sys/mman.h>
++#include <unistd.h>
++
++#include <xen/memory.h>
++#include <xen/sys/evtchn.h>
++#include <xen/sys/gntdev.h>
++/* #include <xen/sys/gntalloc.h> */
++#include "xc_private.h"
++#include "xenctrl.h"
++#include "xenctrlosdep.h"
+
+ static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch)
+ {
+@@ -390,6 +396,210 @@
+ return valloc(size);
+ }
+
++#if 0
++#define DEVXEN "/dev/xen/"
++
++static xc_osdep_handle
++netbsd_gnttab_open(xc_gnttab *xcg)
++{
++ int fd;
++
++ fd = open(DEVXEN "gntdev", O_RDWR);
++ if (fd == -1)
++ return XC_OSDEP_OPEN_ERROR;
++
++ return (xc_osdep_handle)fd;
++}
++
++static int
++netbsd_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h)
++{
++ int fd = (int)h;
++ return close(fd);
++}
++
++static int netbsd_gnttab_set_max_grants(xc_gnttab *xch, xc_osdep_handle h,
++ uint32_t count)
++{
++ int fd = (int)h, rc;
++ struct ioctl_gntdev_set_max_grants max_grants = { .count = count };
++
++ rc = ioctl(fd, IOCTL_GNTDEV_SET_MAX_GRANTS, &max_grants);
++ if (rc) {
++ /*
++ * Newer (e.g. pv-ops) kernels don't implement this IOCTL,
++ * so ignore the resulting specific failure.
++ */
++ if (errno == ENOTTY)
++ rc = 0;
++ else
++ PERROR("netbsd_gnttab_set_max_grants: ioctl SET_MAX_GRANTS failed");
++ }
++ return rc;
++}
++
++static void *netbsd_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h,
++ uint32_t count, int flags, int prot,
++ uint32_t *domids, uint32_t *refs,
++ uint32_t notify_offset,
++ evtchn_port_t notify_port)
++{
++ int fd = (int)h;
++ struct ioctl_gntdev_map_grant_ref *map;
++ unsigned int map_size = ROUNDUP((sizeof(*map) + (count - 1) *
++ sizeof(struct ioctl_gntdev_map_grant_ref)),
++ XC_PAGE_SHIFT);
++ void *addr = NULL;
++ int domids_stride = 1;
++ int i;
++
++ if (flags & XC_GRANT_MAP_SINGLE_DOMAIN)
++ domids_stride = 0;
++
++ if ( map_size <= XC_PAGE_SIZE )
++ map = alloca(sizeof(*map) +
++ (count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref));
++ else
++ {
++ map = mmap(NULL, map_size, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANON | MAP_POPULATE, -1, 0);
++ if ( map == MAP_FAILED )
++ {
++ PERROR("netbsd_gnttab_grant_map: mmap of map failed");
++ return NULL;
++ }
++ }
++
++ for ( i = 0; i < count; i++ )
++ {
++ map->refs[i].domid = domids[i * domids_stride];
++ map->refs[i].ref = refs[i];
++ }
++
++ map->count = count;
++
++ if ( ioctl(fd, IOCTL_GNTDEV_MAP_GRANT_REF, map) ) {
++ PERROR("netbsd_gnttab_grant_map: ioctl MAP_GRANT_REF failed");
++ goto out;
++ }
++
++ retry:
++ addr = mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd,
++ map->index);
++
++ if (addr == MAP_FAILED && errno == EAGAIN)
++ {
++ /*
++ * The grant hypercall can return EAGAIN if the granted page is
++ * swapped out. Since the paging daemon may be in the same domain, the
++ * hypercall cannot block without causing a deadlock.
++ *
++ * Because there are no notificaitons when the page is swapped in, wait
++ * a bit before retrying, and hope that the page will arrive eventually.
++ */
++ usleep(1000);
++ goto retry;
++ }
++
++ if (addr != MAP_FAILED)
++ {
++ int rv = 0;
++ struct ioctl_gntdev_unmap_notify notify;
++ notify.index = map->index;
++ notify.action = 0;
++ if (notify_offset < XC_PAGE_SIZE * count) {
++ notify.index += notify_offset;
++ notify.action |= UNMAP_NOTIFY_CLEAR_BYTE;
++ }
++ if (notify_port != -1) {
++ notify.event_channel_port = notify_port;
++ notify.action |= UNMAP_NOTIFY_SEND_EVENT;
++ }
++ if (notify.action)
++ rv = ioctl(fd, IOCTL_GNTDEV_SET_UNMAP_NOTIFY, &notify);
++ if (rv) {
++ PERROR("netbsd_gnttab_grant_map: ioctl SET_UNMAP_NOTIFY failed");
++ munmap(addr, count * XC_PAGE_SIZE);
++ addr = MAP_FAILED;
++ }
++ }
++
++ if (addr == MAP_FAILED)
++ {
++ int saved_errno = errno;
++ struct ioctl_gntdev_unmap_grant_ref unmap_grant;
++
++ /* Unmap the driver slots used to store the grant information. */
++ PERROR("xc_gnttab_map_grant_refs: mmap failed");
++ unmap_grant.index = map->index;
++ unmap_grant.count = count;
++ ioctl(fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
++ errno = saved_errno;
++ addr = NULL;
++ }
++
++ out:
++ if ( map_size > XC_PAGE_SIZE )
++ munmap(map, map_size);
++
++ return addr;
++}
++
++static int
++netbsd_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h,
++ void *start_address, uint32_t count)
++{
++ int fd = (int)h;
++ struct ioctl_gntdev_get_offset_for_vaddr get_offset;
++ struct ioctl_gntdev_unmap_grant_ref unmap_grant;
++ int rc;
++
++ if ( start_address == NULL )
++ {
++ errno = EINVAL;
++ return -1;
++ }
++
++ /* First, it is necessary to get the offset which was initially used to
++ * mmap() the pages.
++ */
++ get_offset.vaddr = (unsigned long)start_address;
++ rc = ioctl(fd, IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR, &get_offset);
++ if ( rc )
++ return rc;
++
++ if ( get_offset.count != count )
++ {
++ errno = EINVAL;
++ return -1;
++ }
++
++ /* Next, unmap the memory. */
++ rc = munmap(start_address, count * getpagesize());
++ if ( rc )
++ return rc;
++
++ /* Finally, unmap the driver slots used to store the grant information. */
++ unmap_grant.index = get_offset.offset;
++ unmap_grant.count = count;
++ rc = ioctl(fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
++ if ( rc )
++ return rc;
++ return 0;
++}
++
++static struct xc_osdep_ops netbsd_gnttab_ops = {
++ .open = &netbsd_gnttab_open,
++ .close = &netbsd_gnttab_close,
++
++ .u.gnttab = {
++ .set_max_grants = netbsd_gnttab_set_max_grants,
++ .grant_map = &netbsd_gnttab_grant_map,
++ .munmap = &netbsd_gnttab_munmap,
++ },
++};
++#endif
++
+ static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_type type)
+ {
+ switch ( type )
+@@ -398,6 +608,10 @@
+ return &netbsd_privcmd_ops;
+ case XC_OSDEP_EVTCHN:
+ return &netbsd_evtchn_ops;
++#if 0
++ case XC_OSDEP_GNTTAB:
++ return &netbsd_gnttab_ops;
++#endif
+ default:
+ return NULL;
+ }
diff --git a/sysutils/xentools45/patches/patch-libxl_Makefile b/sysutils/xentools45/patches/patch-libxl_Makefile
new file mode 100644
index 00000000000..800ef3b7838
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libxl_Makefile
@@ -0,0 +1,22 @@
+$NetBSD: patch-libxl_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libxl/Makefile.orig 2015-01-19 21:18:26.000000000 +0100
++++ libxl/Makefile 2015-01-19 21:18:49.000000000 +0100
+@@ -253,7 +253,7 @@
+ $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+- $(INSTALL_DIR) $(DESTDIR)$(BASH_COMPLETION_DIR)
++ $(INSTALL_DIR) $(DESTDIR)$(XEN_EXAMPLES_DIR)
+ $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+ $(INSTALL_PROG) xl $(DESTDIR)$(SBINDIR)
+ $(INSTALL_PROG) xen-init-dom0 $(DESTDIR)$(LIBEXEC_BIN)
+@@ -267,7 +267,7 @@
+ $(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(LIBDIR)/libxlutil.so
+ $(INSTALL_DATA) libxlutil.a $(DESTDIR)$(LIBDIR)
+ $(INSTALL_DATA) libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h $(DESTDIR)$(INCLUDEDIR)
+- $(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
++ $(INSTALL_DATA) bash-completion $(DESTDIR)$(XEN_EXAMPLES_DIR)/xl.sh
+
+ .PHONY: clean
+ clean:
diff --git a/sysutils/xentools45/patches/patch-libxl_libxl__create.c b/sysutils/xentools45/patches/patch-libxl_libxl__create.c
new file mode 100644
index 00000000000..de72b787567
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libxl_libxl__create.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-libxl_libxl__create.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libxl/libxl_create.c.orig 2015-01-12 17:53:24.000000000 +0100
++++ libxl/libxl_create.c 2015-01-19 14:08:19.000000000 +0100
+@@ -432,7 +432,7 @@
+ vments[2] = "image/ostype";
+ vments[3] = "hvm";
+ vments[4] = "start_time";
+- vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++ vments[5] = libxl__sprintf(gc, "%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+
+ localents = libxl__calloc(gc, 9, sizeof(char *));
+ i = 0;
+@@ -469,7 +469,7 @@
+ vments[i++] = "image/kernel";
+ vments[i++] = (char *) state->pv_kernel.path;
+ vments[i++] = "start_time";
+- vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++ vments[i++] = libxl__sprintf(gc, "%jd.%02d", (intmax_t)start_time.tv_sec, (int)start_time.tv_usec/10000);
+ if (state->pv_ramdisk.path) {
+ vments[i++] = "image/ramdisk";
+ vments[i++] = (char *) state->pv_ramdisk.path;
+@@ -1061,7 +1061,7 @@
+ vments[2] = "image/ostype";
+ vments[3] = "hvm";
+ vments[4] = "start_time";
+- vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++ vments[5] = libxl__sprintf(gc, "%jd.%02d", (intmax_t)start_time.tv_sec, (int)start_time.tv_usec/10000);
+ break;
+ case LIBXL_DOMAIN_TYPE_PV:
+ vments = libxl__calloc(gc, 11, sizeof(char *));
+@@ -1071,7 +1071,7 @@
+ vments[i++] = "image/kernel";
+ vments[i++] = (char *) state->pv_kernel.path;
+ vments[i++] = "start_time";
+- vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++ vments[i++] = libxl__sprintf(gc, "%jd.%02d", (intmax_t)start_time.tv_sec, (int)start_time.tv_usec/10000);
+ if (state->pv_ramdisk.path) {
+ vments[i++] = "image/ramdisk";
+ vments[i++] = (char *) state->pv_ramdisk.path;
diff --git a/sysutils/xentools45/patches/patch-libxl_libxl_uuid.c b/sysutils/xentools45/patches/patch-libxl_libxl_uuid.c
new file mode 100644
index 00000000000..f2df2f6a861
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-libxl_libxl_uuid.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-libxl_libxl_uuid.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- libxl/libxl_uuid.c.orig 2015-01-19 17:05:02.000000000 +0100
++++ libxl/libxl_uuid.c 2015-01-19 17:18:47.000000000 +0100
+@@ -77,7 +77,7 @@
+ assert(status == uuid_s_ok);
+ }
+
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in)
+ {
+ uint32_t status;
+@@ -112,7 +112,7 @@
+ memset(&uuid->uuid, 0, sizeof(uuid->uuid));
+ }
+
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2)
+ {
+
diff --git a/sysutils/xentools45/patches/patch-ocaml_common.make b/sysutils/xentools45/patches/patch-ocaml_common.make
new file mode 100644
index 00000000000..9f201f0ea12
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-ocaml_common.make
@@ -0,0 +1,13 @@
+$NetBSD: patch-ocaml_common.make,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ocaml/common.make.orig 2015-01-12 17:53:24.000000000 +0100
++++ ocaml/common.make 2015-01-19 13:16:38.000000000 +0100
+@@ -3,7 +3,7 @@
+ CC ?= gcc
+ OCAMLOPT ?= ocamlopt
+ OCAMLC ?= ocamlc
+-OCAMLMKLIB ?= ocamlmklib
++OCAMLMKLIB ?= ocamlmklib -elfmode
+ OCAMLDEP ?= ocamldep
+ OCAMLLEX ?= ocamllex
+ OCAMLYACC ?= ocamlyacc
diff --git a/sysutils/xentools45/patches/patch-ocaml_xenstored_Makefile b/sysutils/xentools45/patches/patch-ocaml_xenstored_Makefile
new file mode 100644
index 00000000000..88d3c134489
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-ocaml_xenstored_Makefile
@@ -0,0 +1,12 @@
+$NetBSD: patch-ocaml_xenstored_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ocaml/xenstored/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ ocaml/xenstored/Makefile 2015-01-19 14:06:50.000000000 +0100
+@@ -1,6 +1,7 @@
+ XEN_ROOT = $(CURDIR)/../../..
+ OCAML_TOPLEVEL = $(CURDIR)/..
+ include $(OCAML_TOPLEVEL)/common.make
++XEN_CONFIG_DIR=${XEN_EXAMPLES_DIR}
+
+ CFLAGS += -I$(XEN_ROOT)/tools/
+ CFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_CFLAGS)
diff --git a/sysutils/xentools45/patches/patch-ocaml_xenstored_define.ml b/sysutils/xentools45/patches/patch-ocaml_xenstored_define.ml
new file mode 100644
index 00000000000..371a1ff3a3b
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-ocaml_xenstored_define.ml
@@ -0,0 +1,20 @@
+$NetBSD: patch-ocaml_xenstored_define.ml,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ocaml/xenstored/define.ml.orig 2015-01-12 17:53:24.000000000 +0100
++++ ocaml/xenstored/define.ml 2015-01-19 13:16:38.000000000 +0100
+@@ -17,13 +17,13 @@
+ let xenstored_major = 1
+ let xenstored_minor = 0
+
+-let xenstored_proc_kva = "/proc/xen/xsd_kva"
++let xenstored_proc_kva = "@PROCDEV@/xsd_kva"
+ let xenstored_proc_port = "/proc/xen/xsd_port"
+
+ let xs_daemon_socket = "/var/run/xenstored/socket"
+ let xs_daemon_socket_ro = "/var/run/xenstored/socket_ro"
+
+-let default_config_dir = "/etc/xen"
++let default_config_dir = "@XENDCONFDIR@"
+
+ let maxwatch = ref (50)
+ let maxtransaction = ref (20)
diff --git a/sysutils/xentools45/patches/patch-ocaml_xenstored_utils.ml b/sysutils/xentools45/patches/patch-ocaml_xenstored_utils.ml
new file mode 100644
index 00000000000..00c4baf05c2
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-ocaml_xenstored_utils.ml
@@ -0,0 +1,13 @@
+$NetBSD: patch-ocaml_xenstored_utils.ml,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- ocaml/xenstored/utils.ml.orig 2015-01-12 17:53:24.000000000 +0100
++++ ocaml/xenstored/utils.ml 2015-01-19 13:16:38.000000000 +0100
+@@ -94,7 +94,7 @@
+ let buf = String.make 20 (char_of_int 0) in
+ let sz = Unix.read fd buf 0 20 in
+ Unix.close fd;
+- int_of_string (String.sub buf 0 sz)
++ int_of_string (String.trim (String.sub buf 0 sz))
+
+ let path_complete path connection_path =
+ if String.get path 0 <> '/' then
diff --git a/sysutils/xentools45/patches/patch-pygrub_Makefile b/sysutils/xentools45/patches/patch-pygrub_Makefile
new file mode 100644
index 00000000000..d0c3e835fe5
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-pygrub_Makefile
@@ -0,0 +1,13 @@
+$NetBSD: patch-pygrub_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- pygrub/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ pygrub/Makefile 2015-01-19 14:19:44.000000000 +0100
+@@ -15,7 +15,7 @@
+ --install-scripts=$(LIBEXEC_BIN) --force
+ set -e; if [ $(BINDIR) != $(LIBEXEC_BIN) -a \
+ "`readlink -f $(DESTDIR)/$(BINDIR)`" != \
+- "`readlink -f $(LIBEXEC_BIN)`" ]; then \
++ "`readlink -f $(DESTDIR)/$(LIBEXEC_BIN)`" ]; then \
+ ln -sf $(LIBEXEC_BIN)/pygrub $(DESTDIR)/$(BINDIR); \
+ fi
+
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_Makefile b/sysutils/xentools45/patches/patch-qemu-xen-traditional_Makefile
new file mode 100644
index 00000000000..0b89abd420e
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_Makefile
@@ -0,0 +1,84 @@
+$NetBSD: patch-qemu-xen-traditional_Makefile,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/Makefile.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/Makefile 2015-01-19 14:16:12.000000000 +0100
+@@ -1,7 +1,7 @@
+ # Makefile for QEMU.
+
+-include config-host.mak
+-include $(SRC_PATH)/rules.mak
++-include config-host.mak
++-include $(SRC_PATH)/rules.mak
+
+ .PHONY: all clean cscope distclean dvi html info install install-doc \
+ recurse-all speed tar tarbin test
+@@ -231,30 +231,30 @@
+ endif
+
+ install-doc: $(DOCS)
+- mkdir -p "$(DESTDIR)$(docdir)"
+- $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
++ $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
++ $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
+ ifndef CONFIG_WIN32
+- mkdir -p "$(DESTDIR)$(mandir)/man1"
+- $(INSTALL) -m 644 qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
+- mkdir -p "$(DESTDIR)$(mandir)/man8"
+- $(INSTALL) -m 644 qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
++ $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
++ $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
++ $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
++ $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
+ endif
+
+ install: all $(if $(BUILD_DOCS),install-doc)
+- mkdir -p "$(DESTDIR)$(bindir)"
++ $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
+ ifneq ($(TOOLS),)
+ $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
+ endif
+ ifneq ($(BLOBS),)
+- mkdir -p "$(DESTDIR)$(datadir)"
++ $(INSTALL_DIR) "$(DESTDIR)$(datadir)"
+ set -e; for x in $(BLOBS); do \
+- $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
++ $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
+ done
+ endif
+ ifndef CONFIG_WIN32
+- mkdir -p "$(DESTDIR)$(datadir)/keymaps"
++ $(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
+ set -e; for x in $(KEYMAPS); do \
+- $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
++ $(INSTALL_DATA) $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
+ done
+ endif
+ for d in $(TARGET_DIRS); do \
+@@ -275,7 +275,7 @@
+
+ # documentation
+ %.html: %.texi
+- texi2html -monolithic -number $<
++ texi2html -monolithic -number-sections $<
+
+ %.info: %.texi
+ makeinfo $< -o $@
+@@ -284,15 +284,15 @@
+ texi2dvi $<
+
+ qemu.1: qemu-doc.texi
+- $(SRC_PATH)/texi2pod.pl $< qemu.pod
++ perl $(SRC_PATH)/texi2pod.pl $< qemu.pod
+ pod2man --section=1 --center=" " --release=" " qemu.pod > $@
+
+ qemu-img.1: qemu-img.texi
+- $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
++ perl $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
+ pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
+
+ qemu-nbd.8: qemu-nbd.texi
+- $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod
++ perl $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod
+ pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@
+
+ info: qemu-doc.info qemu-tech.info
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_block-raw-posix.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_block-raw-posix.c
new file mode 100644
index 00000000000..738952c82e8
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_block-raw-posix.c
@@ -0,0 +1,62 @@
+$NetBSD: patch-qemu-xen-traditional_block-raw-posix.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+- if given a block device, use the character device instead.
+
+--- qemu-xen-traditional/block-raw-posix.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/block-raw-posix.c 2015-01-19 13:16:38.000000000 +0100
+@@ -65,6 +65,7 @@
+ #include <sys/disklabel.h>
+ #include <sys/dkio.h>
+ #include <sys/disk.h>
++#include <sys/param.h>
+ #endif
+
+ #ifdef __OpenBSD__
+@@ -72,6 +73,13 @@
+ #include <sys/disklabel.h>
+ #include <sys/dkio.h>
+ #endif
++#if defined(__NetBSD__)
++#include <sys/ioctl.h>
++#include <sys/disklabel.h>
++#include <sys/dkio.h>
++#define SLIST_ENTRY(x) int /*XXXX !*/
++#include <sys/disk.h>
++#endif
+
+ //#define DEBUG_FLOPPY
+
+@@ -1008,6 +1016,33 @@
+ {
+ BDRVRawState *s = bs->opaque;
+ int fd, open_flags, ret;
++#ifdef __NetBSD__
++ struct stat sb;
++ static char namebuf[MAXPATHLEN];
++ const char *dp;
++
++ if (lstat(filename, &sb) < 0) {
++ fprintf(stderr, "%s: stat failed: %s\n", filename, strerror(errno));
++ return -errno;
++ }
++ if (S_ISLNK(sb.st_mode)) {
++ fprintf(stderr, "%s: symolink links not supported by qemu-dm\n",
++ filename);
++ return -EINVAL;
++ }
++ if (S_ISBLK(sb.st_mode)) {
++ dp = strrchr(filename, '/');
++ if (dp == NULL) {
++ snprintf(namebuf, MAXPATHLEN, "r%s", filename);
++ } else {
++ snprintf(namebuf, MAXPATHLEN, "%.*s/r%s",
++ (int)(dp - filename), filename, dp + 1);
++ }
++ fprintf(stderr, "%s is a block device", filename);
++ filename = namebuf;
++ fprintf(stderr, ", using %s\n", filename);
++ }
++#endif
+
+ posix_aio_init();
+
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_configure b/sysutils/xentools45/patches/patch-qemu-xen-traditional_configure
new file mode 100644
index 00000000000..120ad97a9fd
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_configure
@@ -0,0 +1,31 @@
+$NetBSD: patch-qemu-xen-traditional_configure,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/configure.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/configure 2015-01-19 14:17:28.000000000 +0100
+@@ -1089,7 +1089,7 @@
+ # Check if tools are available to build documentation.
+ if [ -x "`which texi2html 2>/dev/null`" ] && \
+ [ -x "`which pod2man 2>/dev/null`" ]; then
+- build_docs="yes"
++# build_docs="yes"
+ fi
+
+ ##########################################
+@@ -1124,7 +1124,7 @@
+ if test -z "$prefix" ; then
+ prefix="/usr/local"
+ fi
+- mansuffix="/share/man"
++ mansuffix="/man"
+ datasuffix="/share/qemu"
+ docsuffix="/share/doc/qemu"
+ binsuffix="/bin"
+@@ -1216,6 +1216,8 @@
+ echo "MAKE=$make" >> $config_mak
+ echo "INSTALL=$install" >> $config_mak
+ echo "INSTALL_PROG=$install -m 0755" >> $config_mak
++echo "INSTALL_DATA=$install -m0644" >> $config_mak
++echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_mak
+ echo "CC=$cc" >> $config_mak
+ echo "HOST_CC=$host_cc" >> $config_mak
+ echo "AR=$ar" >> $config_mak
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_e1000.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_e1000.c
new file mode 100644
index 00000000000..6e754eb20ec
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_e1000.c
@@ -0,0 +1,34 @@
+$NetBSD: patch-qemu-xen-traditional_hw_e1000.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+From sysutils/xentools33/patches/patch-ak.
+
+qemu-0.13.x will include this fix:
+http://git.qemu.org/qemu.git/commit/?id=9651ac55e5de0e1534d898316cc851af6ffc4334
+
+--- qemu-xen-traditional/hw/e1000.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/e1000.c 2015-01-19 13:16:38.000000000 +0100
+@@ -265,16 +265,20 @@
+
+ s->eecd_state.old_eecd = val & (E1000_EECD_SK | E1000_EECD_CS |
+ E1000_EECD_DI|E1000_EECD_FWE_MASK|E1000_EECD_REQ);
++ if (!(E1000_EECD_CS & val)) // CS inactive; nothing to do
++ return;
++ if (E1000_EECD_CS & (val ^ oldval)) { // CS rise edge; reset state
++ s->eecd_state.val_in = 0;
++ s->eecd_state.bitnum_in = 0;
++ s->eecd_state.bitnum_out = 0;
++ s->eecd_state.reading = 0;
++ }
+ if (!(E1000_EECD_SK & (val ^ oldval))) // no clock edge
+ return;
+ if (!(E1000_EECD_SK & val)) { // falling edge
+ s->eecd_state.bitnum_out++;
+ return;
+ }
+- if (!(val & E1000_EECD_CS)) { // rising, no CS (EEPROM reset)
+- memset(&s->eecd_state, 0, sizeof s->eecd_state);
+- return;
+- }
+ s->eecd_state.val_in <<= 1;
+ if (val & E1000_EECD_DI)
+ s->eecd_state.val_in |= 1;
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_ide.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_ide.c
new file mode 100644
index 00000000000..3d8d3d0ca57
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_ide.c
@@ -0,0 +1,27 @@
+$NetBSD: patch-qemu-xen-traditional_hw_ide.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/ide.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/ide.c 2015-01-19 13:16:38.000000000 +0100
+@@ -761,6 +761,7 @@
+ put_le16(p + 61, s->nb_sectors >> 16);
+ put_le16(p + 62, 0x07); /* single word dma0-2 supported */
+ put_le16(p + 63, 0x07); /* mdma0-2 supported */
++ put_le16(p + 64, 0x03); /* pio3-4 supported */
+ put_le16(p + 65, 120);
+ put_le16(p + 66, 120);
+ put_le16(p + 67, 120);
+@@ -812,13 +813,12 @@
+ put_le16(p + 53, 7); /* words 64-70, 54-58, 88 valid */
+ put_le16(p + 62, 7); /* single word dma0-2 supported */
+ put_le16(p + 63, 7); /* mdma0-2 supported */
+- put_le16(p + 64, 0x3f); /* PIO modes supported */
+ #else
+ put_le16(p + 49, 1 << 9); /* LBA supported, no DMA */
+ put_le16(p + 53, 3); /* words 64-70, 54-58 valid */
+ put_le16(p + 63, 0x103); /* DMA modes XXX: may be incorrect */
+- put_le16(p + 64, 1); /* PIO modes */
+ #endif
++ put_le16(p + 64, 3); /* pio3-4 supported */
+ put_le16(p + 65, 0xb4); /* minimum DMA multiword tx cycle time */
+ put_le16(p + 66, 0xb4); /* recommended DMA multiword tx cycle time */
+ put_le16(p + 67, 0x12c); /* minimum PIO cycle time without flow control */
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.c
new file mode 100644
index 00000000000..5fc3ac8a2ce
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-qemu-xen-traditional_hw_pass-through.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/pass-through.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/pass-through.c 2015-01-19 13:16:38.000000000 +0100
+@@ -84,8 +84,6 @@
+ */
+
+ #include "pass-through.h"
+-#include "pci/header.h"
+-#include "pci/pci.h"
+ #include "pt-msi.h"
+ #include "qemu-xen.h"
+ #include "iomulti.h"
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.h b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.h
new file mode 100644
index 00000000000..2f8bef0b87b
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pass-through.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-qemu-xen-traditional_hw_pass-through.h,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/pass-through.h.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/pass-through.h 2015-01-19 13:16:38.000000000 +0100
+@@ -20,8 +20,13 @@
+
+ #include "hw.h"
+ #include "pci.h"
++#ifdef __NetBSD__
++#include "pciutils/header.h"
++#include "pciutils/pci.h"
++#else
+ #include "pci/header.h"
+ #include "pci/pci.h"
++#endif
+ #include "exec-all.h"
+ #include "sys-queue.h"
+ #include "qemu-timer.h"
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_piix4acpi.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_piix4acpi.c
new file mode 100644
index 00000000000..66f981b4234
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_piix4acpi.c
@@ -0,0 +1,17 @@
+$NetBSD: patch-qemu-xen-traditional_hw_piix4acpi.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/piix4acpi.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/piix4acpi.c 2015-01-19 13:16:38.000000000 +0100
+@@ -41,8 +41,12 @@
+ #define PIIX4ACPI_LOG(level, fmt, ...) do { if (level <= PIIX4ACPI_LOGLEVEL) qemu_log(fmt, ## __VA_ARGS__); } while (0)
+
+ #ifdef CONFIG_PASSTHROUGH
++#ifdef __NetBSD__
++#include <pciutils/header.h>
++#else
+ #include <pci/header.h>
+ #endif
++#endif
+
+ /* PM1a_CNT bits, as defined in the ACPI specification. */
+ #define SCI_EN (1 << 0)
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-graphics.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-graphics.c
new file mode 100644
index 00000000000..f165f889524
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-graphics.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-qemu-xen-traditional_hw_pt-graphics.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/pt-graphics.c.orig 2015-01-19 16:14:46.000000000 +0100
++++ qemu-xen-traditional/hw/pt-graphics.c 2015-01-19 16:14:51.000000000 +0100
+@@ -4,8 +4,6 @@
+
+ #include "pass-through.h"
+ #include "pci.h"
+-#include "pci/header.h"
+-#include "pci/pci.h"
+
+ #include <unistd.h>
+ #include <sys/ioctl.h>
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.c b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.c
new file mode 100644
index 00000000000..8dce08158e2
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-qemu-xen-traditional_hw_pt-msi.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/pt-msi.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/pt-msi.c 2015-01-19 13:16:38.000000000 +0100
+@@ -22,6 +22,10 @@
+ #include "pt-msi.h"
+ #include <sys/mman.h>
+
++#ifdef __NetBSD__
++#define MAP_LOCKED MAP_WIRED
++#endif
++
+ void msi_set_enable(struct pt_dev *dev, int en)
+ {
+ uint16_t val = 0;
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.h b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.h
new file mode 100644
index 00000000000..6f6f37db59f
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_hw_pt-msi.h
@@ -0,0 +1,12 @@
+$NetBSD: patch-qemu-xen-traditional_hw_pt-msi.h,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/hw/pt-msi.h.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/hw/pt-msi.h 2015-01-19 13:16:38.000000000 +0100
+@@ -1,7 +1,6 @@
+ #ifndef _PT_MSI_H
+ #define _PT_MSI_H
+
+-#include "pci/pci.h"
+ #include "pass-through.h"
+
+ #define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_i386-dm_hookstarget.mak b/sysutils/xentools45/patches/patch-qemu-xen-traditional_i386-dm_hookstarget.mak
new file mode 100644
index 00000000000..0a238939308
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_i386-dm_hookstarget.mak
@@ -0,0 +1,12 @@
+$NetBSD: patch-qemu-xen-traditional_i386-dm_hookstarget.mak,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen-traditional/i386-dm/hookstarget.mak.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/i386-dm/hookstarget.mak 2015-01-19 13:16:38.000000000 +0100
+@@ -2,5 +2,5 @@
+
+ install-hook:
+ $(INSTALL_DIR) "$(DESTDIR)/$(bindir)"
+- $(INSTALL_DIR) "$(DESTDIR)/$(configdir)"
+- $(INSTALL_PROG) $(QEMU_ROOT)/i386-dm/qemu-ifup-$(IOEMU_OS) "$(DESTDIR)/$(configdir)/qemu-ifup"
++ $(INSTALL_DIR) "$(DESTDIR)/$(XEN_EXAMPLES_DIR)/scripts"
++ $(INSTALL_PROG) $(QEMU_ROOT)/i386-dm/qemu-ifup-$(IOEMU_OS) "$(DESTDIR)/$(XEN_EXAMPLES_DIR)/scripts/qemu-ifup"
diff --git a/sysutils/xentools45/patches/patch-qemu-xen-traditional_xen-hooks.mak b/sysutils/xentools45/patches/patch-qemu-xen-traditional_xen-hooks.mak
new file mode 100644
index 00000000000..55df33d14b4
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen-traditional_xen-hooks.mak
@@ -0,0 +1,34 @@
+$NetBSD: patch-qemu-xen-traditional_xen-hooks.mak,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+enable PCI passthrough when pciutils is present
+
+--- qemu-xen-traditional/xen-hooks.mak.orig 2014-10-06 17:50:24.000000000 +0200
++++ qemu-xen-traditional/xen-hooks.mak 2015-01-19 13:16:38.000000000 +0100
+@@ -59,17 +59,25 @@
+ ifdef CONFIG_STUBDOM
+ CONFIG_PASSTHROUGH=1
+ else
+- ifeq (,$(wildcard /usr/include/pci))
++ ifeq ($(CONFIG_NetBSD), y)
++CONFIG_PASSTHROUGH=1
++ else
++ ifeq (,$(wildcard /usr/include/pci))
+ $(warning === pciutils-dev package not found - missing /usr/include/pci)
+ $(warning === PCI passthrough capability has been disabled)
+- else
++ else
+ CONFIG_PASSTHROUGH=1
++ endif
+ endif
+ endif
+
+ ifdef CONFIG_PASSTHROUGH
+ OBJS+= pass-through.o pt-msi.o pt-graphics.o
++ifeq ($(CONFIG_NetBSD), y)
++LIBS += -lpciutils -lpci
++else
+ LIBS += -lpci
++endif
+ CFLAGS += -DCONFIG_PASSTHROUGH
+ $(info === PCI passthrough capability has been enabled ===)
+ endif
diff --git a/sysutils/xentools45/patches/patch-qemu-xen_audio_audio.c b/sysutils/xentools45/patches/patch-qemu-xen_audio_audio.c
new file mode 100644
index 00000000000..fc2b87ee46f
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen_audio_audio.c
@@ -0,0 +1,12 @@
+$NetBSD: patch-qemu-xen_audio_audio.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- qemu-xen/audio/audio.c.orig 2014-12-02 11:41:02.000000000 +0100
++++ qemu-xen/audio/audio.c 2015-01-19 13:16:38.000000000 +0100
+@@ -1173,6 +1173,7 @@
+ return 0;
+ }
+
++#undef read
+ bytes = sw->hw->pcm_ops->read (sw, buf, size);
+ return bytes;
+ }
diff --git a/sysutils/xentools45/patches/patch-qemu-xen_qemu-doc.texi b/sysutils/xentools45/patches/patch-qemu-xen_qemu-doc.texi
new file mode 100644
index 00000000000..92ebb192c7d
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen_qemu-doc.texi
@@ -0,0 +1,15 @@
+$NetBSD: patch-qemu-xen_qemu-doc.texi,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+Avoid encoding issues in pod2man.
+
+--- qemu-xen/qemu-doc.texi.orig 2014-12-02 11:41:02.000000000 +0100
++++ qemu-xen/qemu-doc.texi 2015-01-19 14:24:23.000000000 +0100
+@@ -220,7 +220,7 @@
+ QEMU uses YM3812 emulation by Tatsuyuki Satoh.
+
+ QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
+-by Tibor "TS" Schütz.
++by Tibor "TS" Schuetz.
+
+ Note that, by default, GUS shares IRQ(7) with parallel ports and so
+ QEMU must be told to not have parallel ports to have working GUS.
diff --git a/sysutils/xentools45/patches/patch-qemu-xen_util_hbitmap.c b/sysutils/xentools45/patches/patch-qemu-xen_util_hbitmap.c
new file mode 100644
index 00000000000..a74b35f3211
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-qemu-xen_util_hbitmap.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-qemu-xen_util_hbitmap.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+conflits with the popcountl from <strings.h>, no need to redefine one.
+
+--- qemu-xen/util/hbitmap.c.orig 2015-01-19 16:33:58.000000000 +0100
++++ qemu-xen/util/hbitmap.c 2015-01-19 16:40:45.000000000 +0100
+@@ -92,11 +92,6 @@
+ unsigned long *levels[HBITMAP_LEVELS];
+ };
+
+-static inline int popcountl(unsigned long l)
+-{
+- return BITS_PER_LONG == 32 ? ctpop32(l) : ctpop64(l);
+-}
+-
+ /* Advance hbi to the next nonzero word and return it. hbi->pos
+ * is updated. Returns zero if we reach the end of the bitmap.
+ */
diff --git a/sysutils/xentools45/patches/patch-xenstore_xc.c b/sysutils/xentools45/patches/patch-xenstore_xc.c
new file mode 100644
index 00000000000..73c18e6291e
--- /dev/null
+++ b/sysutils/xentools45/patches/patch-xenstore_xc.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-xenstore_xc.c,v 1.1 2015/01/20 16:42:13 bouyer Exp $
+
+--- xenstore/xs.c.orig 2015-01-19 15:40:00.000000000 +0100
++++ xenstore/xs.c 2015-01-19 15:46:56.000000000 +0100
+@@ -725,9 +725,13 @@
+
+ #ifdef USE_PTHREAD
+ #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
++#ifndef PTHREAD_STACK_MIN
++#define READ_THREAD_STACKSIZE DEFAULT_THREAD_STACKSIZE
++#else
+ #define READ_THREAD_STACKSIZE \
+ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \
+ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
++#endif
+
+ /* We dynamically create a reader thread on demand. */
+ mutex_lock(&h->request_mutex);