summaryrefslogtreecommitdiff
path: root/sysutils/xentools45/patches
diff options
context:
space:
mode:
Diffstat (limited to 'sysutils/xentools45/patches')
-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
45 files changed, 1359 insertions, 0 deletions
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);