pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/sysutils



Module Name:    pkgsrc
Committed By:   bouyer
Date:           Thu Mar 30 09:15:10 UTC 2017

Modified Files:
        pkgsrc/sysutils: Makefile
Added Files:
        pkgsrc/sysutils/xenkernel48: DESCR MESSAGE Makefile PLIST distinfo
        pkgsrc/sysutils/xenkernel48/patches: patch-Config.mk patch-xen_Makefile
            patch-xen_Rules.mk patch-xen_arch_x86_Rules.mk
            patch-xen_arch_x86_boot_build32.mk patch-xen_tools_symbols.c
        pkgsrc/sysutils/xentools48: DESCR MESSAGE MESSAGE.NetBSD Makefile PLIST
            distinfo
        pkgsrc/sysutils/xentools48/files: blk_netbsd.c blktapctrl_netbsd.c
            locking.sh xen-watchdog.sh xencommons.sh xendomains.sh
        pkgsrc/sysutils/xentools48/patches: patch-.._ipxe_src_core_settings.c
            patch-.._ipxe_src_net_fcels.c
            patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h
            patch-._stubdom_vtpmmgr_tpm2_marshal.h patch-Config.mk
            patch-Makefile patch-XSA-211-1 patch-XSA-211-2
            patch-docs_man_xl.cfg.pod.5.in patch-docs_man_xl.conf.pod.5
            patch-docs_man_xl.pod.1.in patch-docs_man_xlcpupool.cfg.pod.5
            patch-docs_misc_xl-disk-configuration.txt
            patch-extras_mini-os_Config.mk
            patch-extras_mini-os_arch_x86_arch.mk
            patch-extras_mini-os_include_fcntl.h
            patch-extras_mini-os_include_time.h patch-extras_mini-os_lib_sys.c
            patch-extras_mini-os_lock.c patch-stubdom_Makefile
            patch-stubdom_newlib.patch patch-stubdom_vtpmmgr_marshal.h
            patch-stubdom_vtpmmgr_tcg.h patch-stubdom_vtpmmgr_tpmrsa.h
            patch-stubdom_vtpmmgr_vtpm_manager.h
            patch-stubdom_vtpmmgr_vtpmmgr.h patch-tools_Makefile
            patch-tools_Rules.mk patch-tools_configure
            patch-tools_console_daemon_utils.c patch-tools_examples_Makefile
            patch-tools_firmware_etherboot_Makefile
            patch-tools_firmware_hvmloader_Makefile
            patch-tools_hotplug_NetBSD_Makefile
            patch-tools_hotplug_NetBSD_block
            patch-tools_hotplug_NetBSD_vif-bridge
            patch-tools_hotplug_NetBSD_vif-ip
            patch-tools_hotplug_common_Makefile
            patch-tools_include_xen-sys_NetBSD_gntdev.h
            patch-tools_libs_call_netbsd.c patch-tools_libs_call_private.h
            patch-tools_libs_evtchn_netbsd.c
            patch-tools_libs_foreignmemory_compat.c
            patch-tools_libs_foreignmemory_netbsd.c
            patch-tools_libs_foreignmemory_private.h patch-tools_libxl_Makefile
            patch-tools_libxl_libxl__create.c patch-tools_libxl_libxl_event.c
            patch-tools_libxl_libxl_internal.h patch-tools_libxl_libxl_uuid.c
            patch-tools_libxl_xl__cmdtable.c patch-tools_libxl_xl_cmdimpl.c
            patch-tools_ocaml_common.make patch-tools_ocaml_xenstored_Makefile
            patch-tools_ocaml_xenstored_define.ml
            patch-tools_ocaml_xenstored_utils.ml patch-tools_pygrub_Makefile
            patch-tools_qemu-xen-traditional_Makefile
            patch-tools_qemu-xen-traditional_block-raw-posix.c
            patch-tools_qemu-xen-traditional_configure
            patch-tools_qemu-xen-traditional_hw_e1000.c
            patch-tools_qemu-xen-traditional_hw_ide.c
            patch-tools_qemu-xen-traditional_hw_pass-through.c
            patch-tools_qemu-xen-traditional_hw_pass-through.h
            patch-tools_qemu-xen-traditional_hw_piix4acpi.c
            patch-tools_qemu-xen-traditional_hw_pt-graphics.c
            patch-tools_qemu-xen-traditional_hw_pt-msi.c
            patch-tools_qemu-xen-traditional_hw_pt-msi.h
            patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak
            patch-tools_qemu-xen-traditional_net.c
            patch-tools_qemu-xen-traditional_xen-hooks.mak
            patch-tools_qemu-xen_audio_audio.c patch-tools_qemu-xen_configure
            patch-tools_qemu-xen_qemu-doc.texi patch-tools_qemu-xen_xen-hvm.c
            patch-tools_xenpaging_xenpaging.c patch-tools_xenstore_xc.c
            patch-tools_xentrace_xentrace.c

Log Message:
Add xenkerne48 and xentools48, version 4.8.0.
This includes stub domains support, but it should be considered
experimental at this time. Stub domains hangs with serial ports,
or more more than one virual disk (multiple virtual ethernet have not been
tested).


To generate a diff of this commit:
cvs rdiff -u -r1.692 -r1.693 pkgsrc/sysutils/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/xenkernel48/DESCR \
    pkgsrc/sysutils/xenkernel48/MESSAGE pkgsrc/sysutils/xenkernel48/Makefile \
    pkgsrc/sysutils/xenkernel48/PLIST pkgsrc/sysutils/xenkernel48/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/xenkernel48/patches/patch-Config.mk \
    pkgsrc/sysutils/xenkernel48/patches/patch-xen_Makefile \
    pkgsrc/sysutils/xenkernel48/patches/patch-xen_Rules.mk \
    pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_Rules.mk \
    pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_boot_build32.mk \
    pkgsrc/sysutils/xenkernel48/patches/patch-xen_tools_symbols.c
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/xentools48/DESCR \
    pkgsrc/sysutils/xentools48/MESSAGE \
    pkgsrc/sysutils/xentools48/MESSAGE.NetBSD \
    pkgsrc/sysutils/xentools48/Makefile pkgsrc/sysutils/xentools48/PLIST \
    pkgsrc/sysutils/xentools48/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/xentools48/files/blk_netbsd.c \
    pkgsrc/sysutils/xentools48/files/blktapctrl_netbsd.c \
    pkgsrc/sysutils/xentools48/files/locking.sh \
    pkgsrc/sysutils/xentools48/files/xen-watchdog.sh \
    pkgsrc/sysutils/xentools48/files/xencommons.sh \
    pkgsrc/sysutils/xentools48/files/xendomains.sh
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_core_settings.c \
    pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_net_fcels.c \
    pkgsrc/sysutils/xentools48/patches/patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h \
    pkgsrc/sysutils/xentools48/patches/patch-._stubdom_vtpmmgr_tpm2_marshal.h \
    pkgsrc/sysutils/xentools48/patches/patch-Config.mk \
    pkgsrc/sysutils/xentools48/patches/patch-Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-XSA-211-1 \
    pkgsrc/sysutils/xentools48/patches/patch-XSA-211-2 \
    pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.cfg.pod.5.in \
    pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.conf.pod.5 \
    pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.pod.1.in \
    pkgsrc/sysutils/xentools48/patches/patch-docs_man_xlcpupool.cfg.pod.5 \
    pkgsrc/sysutils/xentools48/patches/patch-docs_misc_xl-disk-configuration.txt \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_Config.mk \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_arch_x86_arch.mk \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_fcntl.h \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_time.h \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lib_sys.c \
    pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lock.c \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_newlib.patch \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_marshal.h \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tcg.h \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tpmrsa.h \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpm_manager.h \
    pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpmmgr.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_Rules.mk \
    pkgsrc/sysutils/xentools48/patches/patch-tools_configure \
    pkgsrc/sysutils/xentools48/patches/patch-tools_console_daemon_utils.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_examples_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_etherboot_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_hvmloader_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_block \
    pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-bridge \
    pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-ip \
    pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_common_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_include_xen-sys_NetBSD_gntdev.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_netbsd.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_private.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_evtchn_netbsd.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_compat.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_netbsd.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_private.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl__create.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_event.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_internal.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_uuid.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl__cmdtable.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl_cmdimpl.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_common.make \
    pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_define.ml \
    pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_utils.ml \
    pkgsrc/sysutils/xentools48/patches/patch-tools_pygrub_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_Makefile \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_block-raw-posix.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_configure \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_e1000.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_ide.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_piix4acpi.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-graphics.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.h \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_net.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_xen-hooks.mak \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_audio_audio.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_configure \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_qemu-doc.texi \
    pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_xen-hvm.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_xenpaging_xenpaging.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_xenstore_xc.c \
    pkgsrc/sysutils/xentools48/patches/patch-tools_xentrace_xentrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/sysutils/Makefile
diff -u pkgsrc/sysutils/Makefile:1.692 pkgsrc/sysutils/Makefile:1.693
--- pkgsrc/sysutils/Makefile:1.692      Sat Mar  4 19:10:32 2017
+++ pkgsrc/sysutils/Makefile    Thu Mar 30 09:15:09 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.692 2017/03/04 19:10:32 bsiegert Exp $
+# $NetBSD: Makefile,v 1.693 2017/03/30 09:15:09 bouyer Exp $
 #
 
 COMMENT=       System utilities
@@ -651,10 +651,12 @@ SUBDIR+=  xe-guest-utilities
 SUBDIR+=       xenkernel42
 SUBDIR+=       xenkernel45
 SUBDIR+=       xenkernel46
+SUBDIR+=       xenkernel48
 SUBDIR+=       xenstoretools
 SUBDIR+=       xentools42
 SUBDIR+=       xentools45
 SUBDIR+=       xentools46
+SUBDIR+=       xentools48
 SUBDIR+=       xenvstat
 SUBDIR+=       xfburn
 SUBDIR+=       xfce4-appfinder

Added files:

Index: pkgsrc/sysutils/xenkernel48/DESCR
diff -u /dev/null pkgsrc/sysutils/xenkernel48/DESCR:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/DESCR   Thu Mar 30 09:15:09 2017
@@ -0,0 +1,14 @@
+Xen is a hypervisor which supports running multiple guest operating
+systems on a single machine. Guest OSes (also called "domains")
+can be either paravirtualised (i.e. make hypercalls in order to
+access hardware), run in HVM (Hardware Virtualisation Mode) where
+they will be presented with virtual devices, or a combination where
+they use hypercalls to access hardware but manage memory themselves.
+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.
+
+This package contains the 4.8 Xen kernel itself.  PCI passthrough is
+not supported.  PAE is mandatory; on i386 one must use XEN3PAE_DOM[0U].
Index: pkgsrc/sysutils/xenkernel48/MESSAGE
diff -u /dev/null pkgsrc/sysutils/xenkernel48/MESSAGE:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/MESSAGE Thu Mar 30 09:15:09 2017
@@ -0,0 +1,7 @@
+===========================================================================
+$NetBSD: MESSAGE,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+The Xen hypervisor is installed under the following locations:
+       ${XENKERNELDIR}/xen.gz          (standard hypervisor)
+       ${XENKERNELDIR}/xen-debug.gz    (debug hypervisor)
+===========================================================================
Index: pkgsrc/sysutils/xenkernel48/Makefile
diff -u /dev/null pkgsrc/sysutils/xenkernel48/Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/Makefile        Thu Mar 30 09:15:09 2017
@@ -0,0 +1,68 @@
+# $NetBSD: Makefile,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+VERSION=       4.8.0
+DISTNAME=      xen-${VERSION}
+PKGNAME=       xenkernel48-${VERSION}
+#PKGREVISION=  4
+CATEGORIES=    sysutils
+MASTER_SITES=  http://bits.xensource.com/oss-xen/release/${VERSION}/
+DIST_SUBDIR=   xen48
+
+MAINTAINER=    bouyer%NetBSD.org@localhost
+HOMEPAGE=      http://xenproject.org/
+COMMENT=       Xen 4.8.x Kernel
+
+LICENSE=       gnu-gpl-v2
+
+ONLY_FOR_PLATFORM=     Linux-2.6*-x86_64
+ONLY_FOR_PLATFORM+=    NetBSD-[5-9].*-x86_64
+
+NO_CONFIGURE=  yes
+USE_TOOLS+=    gmake
+
+PYTHON_FOR_BUILD_ONLY=         YES
+PYTHON_VERSIONS_INCOMPATIBLE=  34 35 36
+
+MAKE_ENV+=     OCAML_TOOLS=no
+
+INSTALLATION_DIRS=     xen48-kernel
+XENKERNELDIR=          ${PREFIX}/${INSTALLATION_DIRS}
+
+MESSAGE_SUBST+=                XENKERNELDIR=${XENKERNELDIR}
+
+.include "../../mk/compiler.mk"
+.if !empty(PKGSRC_COMPILER:Mclang)
+EXTRA_CFLAGS+= -Qunused-arguments -no-integrated-as -Wno-error=format \
+               -Wno-error=parentheses-equality -Wno-error=enum-conversion \
+               -Wno-error=unused-function -Wno-error=unused-const-variable \
+               -Wno-error=ignored-attributes -Wno-error=constant-conversion \
+               -Wno-error=address-of-packed-member \
+               -Wno-error=initializer-overrides \
+               -Wno-error=tautological-compare
+.endif
+EXTRA_CFLAGS+=  -falign-functions=16
+
+MAKE_ENV+=     EXTRA_CFLAGS=${EXTRA_CFLAGS:Q}
+
+do-build:
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} build-xen
+       ${CP} ${WRKSRC}/xen/xen.gz ${WRKDIR}/xen.gz
+       cd ${WRKSRC} && ${MAKE_PROGRAM} clean
+       echo "CONFIG_DEBUG=y" >> ${WRKSRC}/xen/.config
+       echo "# CONFIG_CRASH_DEBUG is not set" >> ${WRKSRC}/xen/.config
+       echo "# CONFIG_FRAME_POINTER is not set" >> ${WRKSRC}/xen/.config
+       echo "# CONFIG_GCOV is not set" >> ${WRKSRC}/xen/.config
+       echo "# CONFIG_LOCK_PROFILE is not set" >> ${WRKSRC}/xen/.config
+       echo "# CONFIG_PERF_COUNTERS is not set" >> ${WRKSRC}/xen/.config
+       echo "CONFIG_VERBOSE_DEBUG=y" >> ${WRKSRC}/xen/.config
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} build-xen
+       ${CP} ${WRKSRC}/xen/xen.gz ${WRKDIR}/xen-debug.gz
+
+do-install:
+       ${INSTALL_DATA} ${WRKDIR}/xen.gz \
+           ${DESTDIR}${XENKERNELDIR}/xen.gz
+       ${INSTALL_DATA} ${WRKDIR}/xen-debug.gz \
+           ${DESTDIR}${XENKERNELDIR}/xen-debug.gz
+
+.include "../../lang/python/application.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/sysutils/xenkernel48/PLIST
diff -u /dev/null pkgsrc/sysutils/xenkernel48/PLIST:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/PLIST   Thu Mar 30 09:15:09 2017
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+xen48-kernel/xen-debug.gz
+xen48-kernel/xen.gz
Index: pkgsrc/sysutils/xenkernel48/distinfo
diff -u /dev/null pkgsrc/sysutils/xenkernel48/distinfo:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/distinfo        Thu Mar 30 09:15:09 2017
@@ -0,0 +1,12 @@
+$NetBSD: distinfo,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+SHA1 (xen48/xen-4.8.0.tar.gz) = c2403899b13e1e8b8da391aceecbfc932d583a88
+RMD160 (xen48/xen-4.8.0.tar.gz) = b79b1e2587caa9c6fe68d2996a4fd42f95c1fe7b
+SHA512 (xen48/xen-4.8.0.tar.gz) = 70b95553f9813573b12e52999a4df8701dec430f23c36a8dc70d25a46bb4bc9234e5b7feb74a04062af4c8d6b6bcfe947d90b2b172416206812e54bac9797454
+Size (xen48/xen-4.8.0.tar.gz) = 22499917 bytes
+SHA1 (patch-Config.mk) = abf55aa58792315e758ee3785a763cfa8c2da68f
+SHA1 (patch-xen_Makefile) = be3f4577a205b23187b91319f91c50720919f70b
+SHA1 (patch-xen_Rules.mk) = 5f33a667bae67c85d997a968c0f8b014b707d13c
+SHA1 (patch-xen_arch_x86_Rules.mk) = e2d148fb308c37c047ca41a678471217b6166977
+SHA1 (patch-xen_arch_x86_boot_build32.mk) = 7fa0d64e88e3be0330dac9a2ddc8b0114fd7d4a5
+SHA1 (patch-xen_tools_symbols.c) = fdc7e4aa7b8db0854987c9d0e60c254bb9f5af4e

Index: pkgsrc/sysutils/xenkernel48/patches/patch-Config.mk
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-Config.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-Config.mk Thu Mar 30 09:15:09 2017
@@ -0,0 +1,14 @@
+$NetBSD: patch-Config.mk,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+--- Config.mk.orig     2016-12-05 13:03:27.000000000 +0100
++++ Config.mk  2017-03-21 17:03:57.000000000 +0100
+@@ -36,6 +36,9 @@
+ # Tools to run on system hosting the build
+ HOSTCFLAGS  = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
+ HOSTCFLAGS += -fno-strict-aliasing
++HOSTCFLAGS += ${EXTRA_CFLAGS}
++CFLAGS     += ${EXTRA_CFLAGS}
++
+ 
+ DISTDIR     ?= $(XEN_ROOT)/dist
+ DESTDIR     ?= /
Index: pkgsrc/sysutils/xenkernel48/patches/patch-xen_Makefile
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-xen_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-xen_Makefile      Thu Mar 30 09:15:09 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-xen_Makefile,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+--- xen/Makefile.orig  2016-02-09 14:44:19.000000000 +0000
++++ xen/Makefile
+@@ -135,7 +135,7 @@ include/xen/compile.h: include/xen/compi
+           -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
+           -e 's/@@domain@@/$(XEN_DOMAIN)/g' \
+           -e 's/@@hostname@@/$(XEN_BUILD_HOST)/g' \
+-          -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) --version 2>&1 | head -1)!g' \
++          -e 's!@@compiler@@!$(shell $(CC) $(EXTRA_CFLAGS) $(CFLAGS) --version 2>&1 | head -1)!g' \
+           -e 's/@@version@@/$(XEN_VERSION)/g' \
+           -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
+           -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
Index: pkgsrc/sysutils/xenkernel48/patches/patch-xen_Rules.mk
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-xen_Rules.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-xen_Rules.mk      Thu Mar 30 09:15:09 2017
@@ -0,0 +1,14 @@
+$NetBSD: patch-xen_Rules.mk,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+--- xen/Rules.mk.orig  2017-03-21 18:32:41.000000000 +0100
++++ xen/Rules.mk       2017-03-21 18:33:07.000000000 +0100
+@@ -5,6 +5,9 @@
+ #
+ lto           ?= n
+ 
++#reset cflags. Why is it needed in pkgsrc ?
++CFLAGS=
++
+ -include $(BASEDIR)/include/config/auto.conf
+ 
+ include $(XEN_ROOT)/Config.mk
Index: pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_Rules.mk
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_Rules.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_Rules.mk     Thu Mar 30 09:15:09 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-xen_arch_x86_Rules.mk,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+--- ./xen/arch/x86/Rules.mk.orig       2016-12-05 13:03:27.000000000 +0100
++++ ./xen/arch/x86/Rules.mk    2017-03-21 16:59:28.000000000 +0100
+@@ -5,6 +5,7 @@
+ CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
+ CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
+ CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))'
++CFLAGS += $(EXTRA_CFLAGS)
+ 
+ # Prevent floating-point variables from creeping into Xen.
+ CFLAGS += -msoft-float
Index: pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_boot_build32.mk
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_boot_build32.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-xen_arch_x86_boot_build32.mk      Thu Mar 30 09:15:09 2017
@@ -0,0 +1,15 @@
+$NetBSD: patch-xen_arch_x86_boot_build32.mk,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+linux's toolchain doesn't generate a .eh_frame section but NetBSD does.
+remove it.
+
+--- xen/arch/x86/boot/build32.mk.orig  2017-03-24 16:06:14.000000000 +0100
++++ xen/arch/x86/boot/build32.mk       2017-03-24 16:06:37.000000000 +0100
+@@ -24,7 +24,7 @@
+                               exit $$(expr $$idx + 1);; \
+                       esac; \
+               done
+-      $(OBJCOPY) -O binary -R .got.plt $< $@
++      $(OBJCOPY) -O binary -R .got.plt -R .eh_frame $< $@
+ 
+ %.lnk: %.o
+       $(LD) $(LDFLAGS_DIRECT) -N -T build32.lds -o $@ $<
Index: pkgsrc/sysutils/xenkernel48/patches/patch-xen_tools_symbols.c
diff -u /dev/null pkgsrc/sysutils/xenkernel48/patches/patch-xen_tools_symbols.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xenkernel48/patches/patch-xen_tools_symbols.c       Thu Mar 30 09:15:09 2017
@@ -0,0 +1,19 @@
+$NetBSD: patch-xen_tools_symbols.c,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+fix "error: array subscript has type 'char'"
+
+--- xen/tools/symbols.c.orig   2017-03-21 17:37:05.000000000 +0100
++++ xen/tools/symbols.c        2017-03-21 17:37:53.000000000 +0100
+@@ -173,11 +173,11 @@
+       /* include the type field in the symbol name, so that it gets
+        * compressed together */
+       s->len = strlen(str) + 1;
+-      if (islower(stype) && filename)
++      if (islower((uint8_t)stype) && filename)
+               s->len += strlen(filename) + 1;
+       s->sym = malloc(s->len + 1);
+       sym = SYMBOL_NAME(s);
+-      if (islower(stype) && filename) {
++      if (islower((uint8_t)stype) && filename) {
+               sym = stpcpy(sym, filename);
+               *sym++ = '#';
+       }

Index: pkgsrc/sysutils/xentools48/DESCR
diff -u /dev/null pkgsrc/sysutils/xentools48/DESCR:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/DESCR    Thu Mar 30 09:15:09 2017
@@ -0,0 +1,5 @@
+The Xen virtual machine monitor allows running several virtual machines
+on a single physical machine.  The xentools48 package contains the
+tools to create, destroy and control the virtual machines.
+
+This package contains the tools for Xen 4.8.x
Index: pkgsrc/sysutils/xentools48/MESSAGE
diff -u /dev/null pkgsrc/sysutils/xentools48/MESSAGE:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/MESSAGE  Thu Mar 30 09:15:09 2017
@@ -0,0 +1,11 @@
+===========================================================================
+$NetBSD: MESSAGE,v 1.1 2017/03/30 09:15:09 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.
+
+===========================================================================
Index: pkgsrc/sysutils/xentools48/MESSAGE.NetBSD
diff -u /dev/null pkgsrc/sysutils/xentools48/MESSAGE.NetBSD:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/MESSAGE.NetBSD   Thu Mar 30 09:15:09 2017
@@ -0,0 +1,17 @@
+===========================================================================
+$NetBSD: MESSAGE.NetBSD,v 1.1 2017/03/30 09:15:09 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
+
+===========================================================================
Index: pkgsrc/sysutils/xentools48/Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/Makefile Thu Mar 30 09:15:09 2017
@@ -0,0 +1,307 @@
+# $NetBSD: Makefile,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+#
+VERSION=       4.8.0
+VERSION_IPXE=  827dd1bfee67daa683935ce65316f7e0f057fe1c
+DIST_IPXE=     ipxe-git-${VERSION_IPXE}.tar.gz
+DIST_NEWLIB=   newlib-1.16.0.tar.gz
+DIST_LWIP=     lwip-1.3.0.tar.gz
+DIST_GRUB=     grub-0.97.tar.gz
+DIST_GMP=      gmp-4.3.2.tar.bz2
+DIST_OCAML=    ocaml-3.11.0.tar.gz
+DIST_POLARSSL= polarssl-1.1.4-gpl.tgz
+DIST_TPMEMU=   tpm_emulator-0.7.4.tar.gz
+DIST_ZLIB=     zlib-1.2.3.tar.gz
+DIST_LIBPCI=   pciutils-2.2.9.tar.bz2
+
+DIST_SUBDIR=           xen48
+DISTNAME=              xen-${VERSION}
+PKGNAME=               xentools48-${VERSION}
+#PKGREVISION=          2
+CATEGORIES=            sysutils
+MASTER_SITES=          http://bits.xensource.com/oss-xen/release/${VERSION}/
+
+DISTFILES=             ${DISTNAME}.tar.gz
+
+XEN_EXTFILES=          http://xenbits.xensource.com/xen-extfiles/
+DISTFILES+=                    ${DIST_IPXE}
+SITES.${DIST_IPXE} +=          ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_NEWLIB}
+SITES.${DIST_NEWLIB} +=                ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_LWIP}
+SITES.${DIST_LWIP} +=          ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_GRUB}
+SITES.${DIST_GRUB} +=          ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_GMP}
+SITES.${DIST_GMP} +=           ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_OCAML}
+SITES.${DIST_OCAML} +=         http://caml.inria.fr/pub/distrib/ocaml-3.11/
+
+DISTFILES+=                    ${DIST_POLARSSL}
+SITES.${DIST_POLARSSL} +=      ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_TPMEMU}
+SITES.${DIST_TPMEMU} +=                ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_ZLIB}
+SITES.${DIST_ZLIB} +=          ${XEN_EXTFILES}
+
+DISTFILES+=                    ${DIST_LIBPCI}
+SITES.${DIST_LIBPCI} +=                ${XEN_EXTFILES}
+
+MAINTAINER=            bouyer%NetBSD.org@localhost
+HOMEPAGE=              http://xenproject.org/
+COMMENT=               Userland Tools for Xen 4.8.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>=0:../../devel/py-curses
+
+PKG_SYSCONFSUBDIR=     xen
+
+ONLY_FOR_PLATFORM=     Linux-2.6*-x86_64
+ONLY_FOR_PLATFORM+=    NetBSD-[5-9].*-x86_64
+
+CONFLICTS+=            libxen-[0-9]*
+CONFLICTS+=            xentools20-[0-9]*
+CONFLICTS+=            xentools3-[0-9]*
+CONFLICTS+=            xenstoretools-[0-9]*
+
+CHECK_PORTABILITY_SKIP=        tools/examples/* \
+                       tools/qemu-xen/scripts/qemu-binfmt-conf.sh
+
+EGDIR=                 ${PREFIX}/share/examples/xen
+MESSAGE_SUBST+=                EGDIR=${EGDIR}
+
+USE_TOOLS+=            pod2man gmake pkg-config makeinfo perl bash cmake
+USE_LANGUAGES=         c
+
+GNU_CONFIGURE=         YES
+#CONFIGURE_ARGS+=      --enable-xenapi
+CONFIGURE_ARGS+=       --disable-seabios
+
+CONFIGURE_ARGS+=       --sysconfdir=${PKG_SYSCONFBASE}
+
+MAKE_ENV+=             PREFIX=${prefix:Q} WRKSRC=${WRKSRC}
+MAKE_ENV+=             XEN_EXAMPLES_DIR=${EGDIR}
+MAKE_ENV+=             MV=${MV:Q} PYTHON=${PYTHONBIN:Q} SED=${SED:Q}
+MAKE_ENV+=             V=YES
+MAKE_ENV+=             NO_WERROR=1
+
+PYTHON_VERSIONS_INCOMPATIBLE=  34 35 36
+
+PY_PATCHPLIST=         yes
+REPLACE_PYTHON+=       tools/misc/xen-bugtool tools/misc/xen-ringwatch
+REPLACE_PYTHON+=       tools/misc/xencons
+REPLACE_PYTHON+=       tools/misc/xenpvnetboot tools/misc/xensymoops
+REPLACE_PYTHON+=       tools/python/scripts/convert-legacy-stream
+REPLACE_PYTHON+=       tools/python/scripts/verify-stream-v2
+REPLACE_PYTHON+=       tools/xenmon/xenmon.py
+
+REPLACE_BASH+=         stubdom/stubdom-dm
+
+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=  tools/Makefile \
+                       tools/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+=     tools/ocaml/xenstored/define.ml
+SUBST_FILES.conf+=     tools/libxl/xl_cmdtable.c
+SUBST_FILES.conf+=     docs/misc/xl-disk-configuration.txt
+SUBST_SED.conf=                -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g"
+
+XEND_SCRIPTS=          block vif-bridge vif-ip qemu-ifup hotplugpath.sh locking.sh
+
+SUBST_CLASSES.NetBSD+= proc
+SUBST_STAGE.proc=      pre-configure
+SUBST_FILES.proc+=     tools/ocaml/xenstored/define.ml
+SUBST_SED.proc=                -e "s|/proc|/kern|g"
+
+OPSYSVARS+=            PROCPATH
+PROCPATH.NetBSD=       /kern
+PROCPATH.*=            /proc
+
+.include "../../mk/bsd.prefs.mk"
+
+SUBST_CLASSES+=                procdev
+SUBST_STAGE.procdev=   pre-configure
+SUBST_FILES.procdev=   tools/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}
+
+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
+       ${CP} -f ${FILESDIR}/locking.sh  ${WRKSRC}/tools/hotplug/NetBSD/
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xenstore-chmod.pod.1 |\
+           pod2man -n xenstore-chmod >${WRKDIR}/xenstore-chmod.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xenstore-ls.pod.1 |\
+           pod2man -n xenstore-ls >${WRKDIR}/xenstore-ls.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xenstore.pod.1 |\
+           pod2man -n xenstore >${WRKDIR}/xenstore.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xentop.pod.1 |\
+           pod2man -n xentop >${WRKDIR}/xentop.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xentrace.pod.8 |\
+           pod2man -n xentrace >${WRKDIR}/xentrace.8
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xentrace_format.pod.1 |\
+           pod2man -n xenstore_format >${WRKDIR}/xentrace_format.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xl.cfg.pod.5.in |\
+           pod2man -n xl.cfg >${WRKDIR}/xl.cfg.5
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xl.conf.pod.5 |\
+           pod2man -n xl.conf >${WRKDIR}/xl.conf.5
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xl.pod.1.in |\
+           pod2man -n xl >${WRKDIR}/xl.1
+       ${SED} -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g" \
+               ${WRKSRC}/docs/man/xlcpupool.cfg.pod.5 |\
+           pod2man -n xlcpupool.cfg >${WRKDIR}/xlcpupool.cfg.5
+
+INSTALLATION_DIRS=     ${EGDIR} ${PKGMANDIR}/man1 ${PKGMANDIR}/man5
+INSTALLATION_DIRS+=    ${PKGMANDIR}/man8 share/doc/xen
+
+BUILD_DEFS+=           VARBASE
+
+.if (${OPSYS} == "NetBSD")
+TARGET_CC=     ${PREFIX}/gcc48/bin/gcc
+.else
+TARGET_CC=     gcc
+.endif
+
+do-build:
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} build-tools
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} build-stubdom
+
+do-install:
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} DESTDIR=${DESTDIR} install-tools
+       cd ${WRKSRC} && ${BUILD_MAKE_CMD} DESTDIR=${DESTDIR} install-stubdom
+
+post-install:
+       ${INSTALL_MAN} ${WRKDIR}/xenstore-chmod.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xenstore-ls.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xenstore.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xentop.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xentrace.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
+       ${INSTALL_MAN} ${WRKDIR}/xentrace_format.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xl.cfg.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+       ${INSTALL_MAN} ${WRKDIR}/xl.conf.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+       ${INSTALL_MAN} ${WRKDIR}/xl.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+       ${INSTALL_MAN} ${WRKDIR}/xlcpupool.cfg.5 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/channel.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/console.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/dump-core-format.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xen-command-line.markdown ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xenmon.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xenstore-paths.markdown ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xenstore.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xl-disk-configuration.txt ${DESTDIR}${PREFIX}/share/doc/xen
+       ${INSTALL_DATA} ${WRKSRC}/docs/misc/xl-network-configuration.markdown ${DESTDIR}${PREFIX}/share/doc/xen
+
+.if (${OPSYS} == "NetBSD" && \
+    (empty(OS_VERSION:M6.99.[3-9]?) && empty(OS_VERSION:M[7-9].*)))
+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 \
+               -Wno-error=enum-conversion
+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} TARGET_CC=${TARGET_CC}
+
+.include "../../lang/python/application.mk"
+.include "../../lang/python/extension.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 "../../devel/argp/buildlink3.mk"
+.include "../../security/libgcrypt/buildlink3.mk"
+.include "../../x11/pixman/buildlink3.mk"
+.if (${OPSYS} == "NetBSD")
+.include "../../lang/gcc48/buildlink3.mk"
+.endif
+
+.include "../../mk/curses.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/sysutils/xentools48/PLIST
diff -u /dev/null pkgsrc/sysutils/xentools48/PLIST:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/PLIST    Thu Mar 30 09:15:09 2017
@@ -0,0 +1,486 @@
+@comment $NetBSD: PLIST,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+${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
+${PYSITELIB}/xen/migration/__init__.py
+${PYSITELIB}/xen/migration/__init__.pyc
+${PYSITELIB}/xen/migration/legacy.py
+${PYSITELIB}/xen/migration/legacy.pyc
+${PYSITELIB}/xen/migration/libxc.py
+${PYSITELIB}/xen/migration/libxc.pyc
+${PYSITELIB}/xen/migration/libxl.py
+${PYSITELIB}/xen/migration/libxl.pyc
+${PYSITELIB}/xen/migration/public.py
+${PYSITELIB}/xen/migration/public.pyc
+${PYSITELIB}/xen/migration/tests.py
+${PYSITELIB}/xen/migration/tests.pyc
+${PYSITELIB}/xen/migration/verify.py
+${PYSITELIB}/xen/migration/verify.pyc
+${PYSITELIB}/xen/migration/xl.py
+${PYSITELIB}/xen/migration/xl.pyc
+bin/pygrub
+bin/qemu-img-xen
+bin/xen-cpuid
+bin/xen-detect
+bin/xenalyze
+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_format
+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/libxlutil.h
+include/xen/COPYING
+include/xen/arch-arm.h
+include/xen/arch-arm/hvm/save.h
+include/xen/arch-x86/cpufeatureset.h
+include/xen/arch-x86/cpuid.h
+include/xen/arch-x86/hvm/save.h
+include/xen/arch-x86/hvm/start_info.h
+include/xen/arch-x86/pmu.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/errno.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_vcpu.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/memory.h
+include/xen/nmi.h
+include/xen/physdev.h
+include/xen/platform.h
+include/xen/pmu.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/vm_event.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/xencall.h
+include/xenctrl.h
+include/xenctrl_compat.h
+include/xenevtchn.h
+include/xenforeignmemory.h
+include/xengnttab.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/libxencall.a
+lib/libxencall.so
+lib/libxencall.so.1
+lib/libxencall.so.1.0
+lib/libxenctrl.a
+lib/libxenctrl.so
+lib/libxenctrl.so.4.8
+lib/libxenctrl.so.4.8.0
+lib/libxenevtchn.a
+lib/libxenevtchn.so
+lib/libxenevtchn.so.1
+lib/libxenevtchn.so.1.0
+lib/libxenforeignmemory.a
+lib/libxenforeignmemory.so
+lib/libxenforeignmemory.so.1
+lib/libxenforeignmemory.so.1.0
+lib/libxengnttab.a
+lib/libxengnttab.so
+lib/libxengnttab.so.1
+lib/libxengnttab.so.1.1
+lib/libxenguest.a
+lib/libxenguest.so
+lib/libxenguest.so.4.8
+lib/libxenguest.so.4.8.0
+lib/libxenlight.a
+lib/libxenlight.so
+lib/libxenlight.so.4.8
+lib/libxenlight.so.4.8.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/libxentoollog.a
+lib/libxentoollog.so
+lib/libxentoollog.so.1
+lib/libxentoollog.so.1.0
+lib/libxlutil.a
+lib/libxlutil.so
+lib/libxlutil.so.4.8
+lib/libxlutil.so.4.8.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
+lib/python2.7/site-packages/pygrub-0.3-py2.7.egg-info
+lib/python2.7/site-packages/xen-3.0-py2.7.egg-info
+libexec/xen/bin/convert-legacy-stream
+libexec/xen/bin/ivshmem-client
+libexec/xen/bin/ivshmem-server
+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/stubdom-dm
+libexec/xen/bin/stubdompath.sh
+libexec/xen/bin/verify-stream-v2
+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/boot/ioemu-stubdom.gz
+libexec/xen/boot/pv-grub-x86_64.gz
+libexec/xen/boot/vtpm-stubdom.gz
+libexec/xen/boot/vtpmmgr-stubdom.gz
+libexec/xen/boot/xenstore-stubdom.gz
+man/man1/xenstore-chmod.1
+man/man1/xenstore-ls.1
+man/man1/xenstore.1
+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/flask-get-bool
+sbin/flask-getenforce
+sbin/flask-label-pci
+sbin/flask-loadpolicy
+sbin/flask-set-bool
+sbin/flask-setenforce
+sbin/gdbsx
+sbin/kdd
+sbin/oxenstored
+sbin/xen-bugtool
+sbin/xen-hptool
+sbin/xen-hvmcrash
+sbin/xen-hvmctx
+sbin/xen-livepatch
+sbin/xen-lowmemd
+sbin/xen-mfndump
+sbin/xen-ringwatch
+sbin/xen-tmem-list-parse
+sbin/xenbaked
+sbin/xenconsoled
+sbin/xencov
+sbin/xenlockprof
+sbin/xenmon.py
+sbin/xenperf
+sbin/xenpm
+sbin/xenpmd
+sbin/xenstored
+sbin/xentop
+sbin/xentrace
+sbin/xentrace_setmask
+sbin/xentrace_setsize
+sbin/xenwatchdogd
+sbin/xl
+share/doc/xen/channel.txt
+share/doc/xen/console.txt
+share/doc/xen/dump-core-format.txt
+share/doc/xen/xen-command-line.markdown
+share/doc/xen/xenmon.txt
+share/doc/xen/xenstore-paths.markdown
+share/doc/xen/xenstore.txt
+share/doc/xen/xl-disk-configuration.txt
+share/doc/xen/xl-network-configuration.markdown
+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/locking.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/pkgconfig/xenlight.pc
+share/pkgconfig/xlutil.pc
+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-e1000e.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/efi-vmxnet3.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/linuxboot_dma.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/qemu-icon.bmp
+share/qemu-xen/qemu/qemu_logo_no_text.svg
+share/qemu-xen/qemu/s390-ccw.img
+share/qemu-xen/qemu/sgabios.bin
+share/qemu-xen/qemu/slof.bin
+share/qemu-xen/qemu/spapr-rtas.bin
+share/qemu-xen/qemu/trace-events-all
+share/qemu-xen/qemu/u-boot.e500
+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-virtio.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
Index: pkgsrc/sysutils/xentools48/distinfo
diff -u /dev/null pkgsrc/sysutils/xentools48/distinfo:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/distinfo Thu Mar 30 09:15:09 2017
@@ -0,0 +1,124 @@
+$NetBSD: distinfo,v 1.1 2017/03/30 09:15:09 bouyer Exp $
+
+SHA1 (xen48/gmp-4.3.2.tar.bz2) = c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c
+RMD160 (xen48/gmp-4.3.2.tar.bz2) = a8f3f41501ece290c348aeb4444bbea40bc53e71
+SHA512 (xen48/gmp-4.3.2.tar.bz2) = 2e0b0fd23e6f10742a5517981e5171c6e88b0a93c83da701b296f5c0861d72c19782daab589a7eac3f9032152a0fc7eff7f5362db8fccc4859564a9aa82329cf
+Size (xen48/gmp-4.3.2.tar.bz2) = 1897483 bytes
+SHA1 (xen48/grub-0.97.tar.gz) = 2580626c4579bd99336d3af4482c346c95dac4fb
+RMD160 (xen48/grub-0.97.tar.gz) = 7fb5674edf0c950bd38e94f85ff1e2909aa741f0
+SHA512 (xen48/grub-0.97.tar.gz) = c2bc9ffc8583aeae71cee9ddcc4418969768d4e3764d47307da54f93981c0109fb07d84b061b3a3628bd00ba4d14a54742bc04848110eb3ae8ca25dbfbaabadb
+Size (xen48/grub-0.97.tar.gz) = 971783 bytes
+SHA1 (xen48/ipxe-git-827dd1bfee67daa683935ce65316f7e0f057fe1c.tar.gz) = 37270d4d39686e29130c51405dbabf670d37b73d
+RMD160 (xen48/ipxe-git-827dd1bfee67daa683935ce65316f7e0f057fe1c.tar.gz) = f780d33d510a83eda0c06cb9fa4732650e337640
+SHA512 (xen48/ipxe-git-827dd1bfee67daa683935ce65316f7e0f057fe1c.tar.gz) = 
82ba65e1c676d32b29c71e6395c9506cab952c8f8b03f692e2b50133be8f0c0146d0f22c223262d81a4df579986fde5abc6507869f4965be4846297ef7b4b890
+Size (xen48/ipxe-git-827dd1bfee67daa683935ce65316f7e0f057fe1c.tar.gz) = 3656744 bytes
+SHA1 (xen48/lwip-1.3.0.tar.gz) = 241f917ba9dffc614346472e3c5871217ad0a91c
+RMD160 (xen48/lwip-1.3.0.tar.gz) = 72c63bf5e3b29e185c46a5fc116146ea902def83
+SHA512 (xen48/lwip-1.3.0.tar.gz) = 1465b58279af1647f909450e394fe002ca165f0ff4a0254bfa9fe0e64316f50facdde2729d79a4e632565b4500cf4d6c74192ac0dd3bc9fe09129bbd67ba089d
+Size (xen48/lwip-1.3.0.tar.gz) = 398933 bytes
+SHA1 (xen48/newlib-1.16.0.tar.gz) = 841edec33d19a9e549984982fb92445ee967e265
+RMD160 (xen48/newlib-1.16.0.tar.gz) = fa40ff43e858da3093c9f3b5b203724b9b327696
+SHA512 (xen48/newlib-1.16.0.tar.gz) = 40eb96bbc6736a16b6399e0cdb73e853d0d90b685c967e77899183446664d64570277a633fdafdefc351b46ce210a99115769a1d9f47ac749d7e82837d4d1ac3
+Size (xen48/newlib-1.16.0.tar.gz) = 12024353 bytes
+SHA1 (xen48/ocaml-3.11.0.tar.gz) = 4e9cd02f15a2334086c1538d1478ec6a99c911c8
+RMD160 (xen48/ocaml-3.11.0.tar.gz) = 4102d681086eaeb17503f9e2d4ac42a451276889
+SHA512 (xen48/ocaml-3.11.0.tar.gz) = 61cacf14d1d90a11bd0599e7ad323350f3a3f30afb4ef5eaadc2108e5d6007dafbb83e955435ee49eeb0130955215923fa72d4e56196bec2396c166a54641955
+Size (xen48/ocaml-3.11.0.tar.gz) = 2855506 bytes
+SHA1 (xen48/pciutils-2.2.9.tar.bz2) = 2871be0890f0406c7f86fa01646e23935fda789e
+RMD160 (xen48/pciutils-2.2.9.tar.bz2) = 781a3d30c5c429a0d92110a46711144f74acde06
+SHA512 (xen48/pciutils-2.2.9.tar.bz2) = 2b3d98d027e46d8c08037366dde6f0781ca03c610ef2b380984639e4ef39899ed8d8b8e4cd9c9dc54df101279b95879bd66bfd4d04ad07fef41e847ea7ae32b5
+Size (xen48/pciutils-2.2.9.tar.bz2) = 212265 bytes
+SHA1 (xen48/polarssl-1.1.4-gpl.tgz) = 3dd10bd1a8f7f58e0ef8c91cfa5ea7efd5d5f4bc
+RMD160 (xen48/polarssl-1.1.4-gpl.tgz) = da5e218d1462561006841baff747f60bb4655f08
+SHA512 (xen48/polarssl-1.1.4-gpl.tgz) = 88da614e4d3f4409c4fd3bb3e44c7587ba051e3fed4e33d526069a67e8180212e1ea22da984656f50e290049f60ddca65383e5983c0f8884f648d71f698303ad
+Size (xen48/polarssl-1.1.4-gpl.tgz) = 611340 bytes
+SHA1 (xen48/tpm_emulator-0.7.4.tar.gz) = ffa3aafcd833fdcd7483bbdb4ff862f30ffde579
+RMD160 (xen48/tpm_emulator-0.7.4.tar.gz) = ded71632d316126138f2db4a5f2051b2489ae5ff
+SHA512 (xen48/tpm_emulator-0.7.4.tar.gz) = 4928b5b82f57645be9408362706ff2c4d9baa635b21b0d41b1c82930e8c60a759b1ea4fa74d7e6c7cae1b7692d006aa5cb72df0c3b88bf049779aa2b566f9d35
+Size (xen48/tpm_emulator-0.7.4.tar.gz) = 214145 bytes
+SHA1 (xen48/xen-4.8.0.tar.gz) = c2403899b13e1e8b8da391aceecbfc932d583a88
+RMD160 (xen48/xen-4.8.0.tar.gz) = b79b1e2587caa9c6fe68d2996a4fd42f95c1fe7b
+SHA512 (xen48/xen-4.8.0.tar.gz) = 70b95553f9813573b12e52999a4df8701dec430f23c36a8dc70d25a46bb4bc9234e5b7feb74a04062af4c8d6b6bcfe947d90b2b172416206812e54bac9797454
+Size (xen48/xen-4.8.0.tar.gz) = 22499917 bytes
+SHA1 (xen48/zlib-1.2.3.tar.gz) = 60faeaaf250642db5c0ea36cd6dcc9f99c8f3902
+RMD160 (xen48/zlib-1.2.3.tar.gz) = 89a57e336c24f7f6eebda3a1724e14b71187e117
+SHA512 (xen48/zlib-1.2.3.tar.gz) = 021b958fcd0d346c4ba761bcf0cc40f3522de6186cf5a0a6ea34a70504ce9622b1c2626fce40675bc8282cf5f5ade18473656abc38050f72f5d6480507a2106e
+Size (xen48/zlib-1.2.3.tar.gz) = 496597 bytes
+SHA1 (patch-.._ipxe_src_core_settings.c) = 1eab2fbd8b22dde2b8aa830ae7701603486f74e4
+SHA1 (patch-.._ipxe_src_net_fcels.c) = 3b515307d8203b60815ad76bfd2a82289e05ebc5
+SHA1 (patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h) = 65ff526aa26832b930086279ed6c83862040f8ac
+SHA1 (patch-._stubdom_vtpmmgr_tpm2_marshal.h) = 30c747a53e848387e4c8d6f4dcbcab7d1b46ed12
+SHA1 (patch-Config.mk) = 7976ce94c553c2fc6badc6d41e9cb8334fea40c8
+SHA1 (patch-Makefile) = fdcd5fbb22613e55ac1b000a46b1ecbbd99eef59
+SHA1 (patch-XSA-211-1) = df96b8992148e442a887715ccca741b948fbb0f5
+SHA1 (patch-XSA-211-2) = c860da3631c1c7988f9bb150020935859c6b061f
+SHA1 (patch-docs_man_xl.cfg.pod.5.in) = e1ee6f2d48f6ce001c44c7ac688ea179b625b584
+SHA1 (patch-docs_man_xl.conf.pod.5) = d77e3313750db315d540d7713c95cd54d6f02938
+SHA1 (patch-docs_man_xl.pod.1.in) = 9b37ef724f2827bc05110e5456a8668257509cab
+SHA1 (patch-docs_man_xlcpupool.cfg.pod.5) = 3f6db65d95b5fc607c2fa7e2fc975e0ddbfdd5e5
+SHA1 (patch-docs_misc_xl-disk-configuration.txt) = b5c71dab9adc5ab1be38077617a8ea10b59485ec
+SHA1 (patch-extras_mini-os_Config.mk) = cb5cdb32f1b3c55abad702ab6768caf59d886ff2
+SHA1 (patch-extras_mini-os_arch_x86_arch.mk) = 8b4f1fe0e888f5b70408d2cc3a3968ce27eae5dc
+SHA1 (patch-extras_mini-os_include_fcntl.h) = 4ed18497227c8c327ee3db9d793caa4ac6254822
+SHA1 (patch-extras_mini-os_include_time.h) = ab3b0794bf892ce6a036aa889c6852d65b508596
+SHA1 (patch-extras_mini-os_lib_sys.c) = 9dd4bcab9deed5132d0fe88a0fe0d33b3fc7d09c
+SHA1 (patch-extras_mini-os_lock.c) = e28753793dee483c1ffad8ea8ed2706353046b50
+SHA1 (patch-stubdom_Makefile) = 6c52ae9af4003fdc199980b6725265fde5a06545
+SHA1 (patch-stubdom_newlib.patch) = e937cd046db217e45b1de76bd0950f514666bc12
+SHA1 (patch-stubdom_vtpmmgr_marshal.h) = 63bb39894e3c6b81b699966ddfa19cb779e916fc
+SHA1 (patch-stubdom_vtpmmgr_tcg.h) = 19e3bd41d58740392f0c0ec1c8d4dee7222b8ab4
+SHA1 (patch-stubdom_vtpmmgr_tpmrsa.h) = a3b169567e1ce3d0cebda125af3fe4f0c748c79d
+SHA1 (patch-stubdom_vtpmmgr_vtpm_manager.h) = 5d11489708f268609ea98a4cbb8b568da4ad8fdf
+SHA1 (patch-stubdom_vtpmmgr_vtpmmgr.h) = 2915a89cb9a80d8c57f314c33c4e4f74ba3b1a39
+SHA1 (patch-tools_Makefile) = 4277125963bf7521cc0f682bb48dd21b69998f3e
+SHA1 (patch-tools_Rules.mk) = 8ff6318747e3ddf703cb9b43b6405c7b0f22ee5c
+SHA1 (patch-tools_configure) = b7b26dec49388f543f42dcb389113d6a2ed96e1b
+SHA1 (patch-tools_console_daemon_utils.c) = 1c954e1edadad2607f7b87eaf2d6285be7f968ff
+SHA1 (patch-tools_examples_Makefile) = fe258fc26e4507ca2fb4363c5e2197ee06e89d64
+SHA1 (patch-tools_firmware_etherboot_Makefile) = 82aa5cb09a9654e27c4686a02a3eb1123a594342
+SHA1 (patch-tools_firmware_hvmloader_Makefile) = 02cac5e9314c4c71105f15a3c1c303c573d6583a
+SHA1 (patch-tools_hotplug_NetBSD_Makefile) = 8a2c8a9b1d3a59792a831f292131c8dfe755e20e
+SHA1 (patch-tools_hotplug_NetBSD_block) = 535ecef7cc0431a14515387e47aadea5dec79569
+SHA1 (patch-tools_hotplug_NetBSD_vif-bridge) = 6d5288c9c47fe81b388ea73f9a71ca3975df36c2
+SHA1 (patch-tools_hotplug_NetBSD_vif-ip) = cb8fd1150f6ac24fa853444618437f7d984b4282
+SHA1 (patch-tools_hotplug_common_Makefile) = 71059eddc2d7183b8b43aa976d9ae5f3a1fd75df
+SHA1 (patch-tools_include_xen-sys_NetBSD_gntdev.h) = ce4f7160e92d23afa029c9548cead180fe980ff4
+SHA1 (patch-tools_libs_call_netbsd.c) = c5e166212b0069220d9155636b41028f0f7f9e9e
+SHA1 (patch-tools_libs_call_private.h) = caeaf937ae379836c3187bee97ac0b986af53f9f
+SHA1 (patch-tools_libs_evtchn_netbsd.c) = 1abb0f128ab0702b606e22f199d297d1e9c0aae5
+SHA1 (patch-tools_libs_foreignmemory_compat.c) = d90307702b10badb8101684c38e1a32b5bba786f
+SHA1 (patch-tools_libs_foreignmemory_netbsd.c) = ac278e3b7e1077272130bf2b83ef613472ae19ea
+SHA1 (patch-tools_libs_foreignmemory_private.h) = ed97af7fef60ba8752625b19f4e7027a5bc7ac54
+SHA1 (patch-tools_libxl_Makefile) = 6ae383af726e2525c74f5d58b1a8893e55694217
+SHA1 (patch-tools_libxl_libxl__create.c) = 8d4984705fff4a3907cc2a436115c400ef732141
+SHA1 (patch-tools_libxl_libxl_event.c) = 8147122d03102eccc45c48a7d6ca1aa5d6286040
+SHA1 (patch-tools_libxl_libxl_internal.h) = 613edc0fa055b23f5dc2a2448456d3d6005337fe
+SHA1 (patch-tools_libxl_libxl_uuid.c) = 1eb8c027dbeb7e67df7475ee6e4d87220140c65b
+SHA1 (patch-tools_libxl_xl__cmdtable.c) = 073c08795af8ec828c60864a788c32e9cca31547
+SHA1 (patch-tools_libxl_xl_cmdimpl.c) = d43beffad3c6da70cb69b2b5d3cf0b48f614e2a6
+SHA1 (patch-tools_ocaml_common.make) = 423d241ec7dc93faf4ec0bf15f9d3c1f34f42646
+SHA1 (patch-tools_ocaml_xenstored_Makefile) = b267702cf4090c7b45bba530e60327fced24e3e5
+SHA1 (patch-tools_ocaml_xenstored_define.ml) = 1f12a8a853b847b80e2c3bb5919ed2410a70092f
+SHA1 (patch-tools_ocaml_xenstored_utils.ml) = 560b26b6d5030838721ddb4e3d819766c3db0349
+SHA1 (patch-tools_pygrub_Makefile) = 662d296b0687e73ef459714e1276b067ad8f4de9
+SHA1 (patch-tools_qemu-xen-traditional_Makefile) = 5fbb55bf84f9856043be301d5d06530190fe9a60
+SHA1 (patch-tools_qemu-xen-traditional_block-raw-posix.c) = eb3efea4b0c7fd744f627f1926fca737ba826b99
+SHA1 (patch-tools_qemu-xen-traditional_configure) = 6a42dcac010f90439a347c0f6e886b07185cb19a
+SHA1 (patch-tools_qemu-xen-traditional_hw_e1000.c) = ec86584529cc743ea27768ad1fab523ee9fb6bea
+SHA1 (patch-tools_qemu-xen-traditional_hw_ide.c) = b541546390c6d142bc6079dbd51cfd65b5223e9e
+SHA1 (patch-tools_qemu-xen-traditional_hw_pass-through.c) = 45848fb5038bdd6def218b35dd0a6496a14102f1
+SHA1 (patch-tools_qemu-xen-traditional_hw_pass-through.h) = 6edb7a9a03d99b84801bf595c4d68acbc361bb4b
+SHA1 (patch-tools_qemu-xen-traditional_hw_piix4acpi.c) = 280265db035e239b173efd9d63b629201d2c0cfa
+SHA1 (patch-tools_qemu-xen-traditional_hw_pt-graphics.c) = b9c18042f40ccacb3f24ab0f1e3c6e1a5bf5521a
+SHA1 (patch-tools_qemu-xen-traditional_hw_pt-msi.c) = a953380dbc3e64528c39e26d2c45c0cbd3e4d738
+SHA1 (patch-tools_qemu-xen-traditional_hw_pt-msi.h) = 787447cc24518fe5ae16942d72d3038db612419d
+SHA1 (patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak) = 3fdfbb7c9c2243a4cf5dabc5a6dd13c12f9d5850
+SHA1 (patch-tools_qemu-xen-traditional_net.c) = 0999993172070db5dc8d7c7daaa4999a3edaadb8
+SHA1 (patch-tools_qemu-xen-traditional_xen-hooks.mak) = d4264675ffaa2065afa820cfd306c09390989126
+SHA1 (patch-tools_qemu-xen_audio_audio.c) = a7f47ff0350900bcb99b5515eeee162144a98cf8
+SHA1 (patch-tools_qemu-xen_configure) = 89694a58aaaece945d793572530179aaed58bfb1
+SHA1 (patch-tools_qemu-xen_qemu-doc.texi) = e72d480ec29829055f01226eaf020d4cbd100d5d
+SHA1 (patch-tools_qemu-xen_xen-hvm.c) = 8faeba31a6f6452d50437a4564b32eb0f8965333
+SHA1 (patch-tools_xenpaging_xenpaging.c) = 0a154b97f1f452a5f80f7c9a835a1f216f12f7e1
+SHA1 (patch-tools_xenstore_xc.c) = cf49b65cba064667e13bb041d1f0099c76ab6a40
+SHA1 (patch-tools_xentrace_xentrace.c) = f964c7555f454358a39f28a2e75db8ee100a4243

Index: pkgsrc/sysutils/xentools48/files/blk_netbsd.c
diff -u /dev/null pkgsrc/sysutils/xentools48/files/blk_netbsd.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/blk_netbsd.c       Thu Mar 30 09:15:09 2017
@@ -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;
+}
Index: pkgsrc/sysutils/xentools48/files/blktapctrl_netbsd.c
diff -u /dev/null pkgsrc/sysutils/xentools48/files/blktapctrl_netbsd.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/blktapctrl_netbsd.c        Thu Mar 30 09:15:09 2017
@@ -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;
+}
Index: pkgsrc/sysutils/xentools48/files/locking.sh
diff -u /dev/null pkgsrc/sysutils/xentools48/files/locking.sh:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/locking.sh Thu Mar 30 09:15:09 2017
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (c) 2016, Christoph Badura.  All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+LOCK_BASEDIR="$XEN_LOCK_DIR/xen-hotplug"
+
+_lockfd=9
+_have_lock=0   # lock not taken yet.
+
+SHLOCK="shlock ${_shlock_debug-}"
+
+_lock_set_vars() {
+       _lockfile="$LOCK_BASEDIR/$1.lock"
+       _lockfifo="$LOCK_BASEDIR/$1.fifo"
+}
+
+_lock_init() {
+       mkdir -p "$LOCK_BASEDIR" 2>/dev/null || true
+       mkfifo $_lockfifo 2>/dev/null || true
+}
+
+#
+# use a named pipe as condition variable
+# opening for read-only blocks when there's no writer.
+# opening for read-write never blocks but unblocks any waiting readers.
+# 
+_lock_wait_cv() {
+       eval "exec $_lockfd<  $_lockfifo ; exec $_lockfd<&-"
+}
+_lock_signal_cv() {
+       eval "exec $_lockfd<> $_lockfifo ; exec $_lockfd<&-"
+}
+
+claim_lock() {
+       _lock_set_vars $1
+       _lock_init
+       until $SHLOCK -f $_lockfile -p $$; do
+               _lock_wait_cv
+       done
+       _have_lock=1
+       # be sure to release the lock when the shell exits
+       trap "release_lock $1" 0 1 2 15
+}
+
+release_lock() {
+       _lock_set_vars $1
+       [ "$_have_lock" != 0 -a -f $_lockfile ] && rm $_lockfile
+       _have_lock=0
+       _lock_signal_cv;
+}
Index: pkgsrc/sysutils/xentools48/files/xen-watchdog.sh
diff -u /dev/null pkgsrc/sysutils/xentools48/files/xen-watchdog.sh:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/xen-watchdog.sh    Thu Mar 30 09:15:09 2017
@@ -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"
Index: pkgsrc/sysutils/xentools48/files/xencommons.sh
diff -u /dev/null pkgsrc/sysutils/xentools48/files/xencommons.sh:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/xencommons.sh      Thu Mar 30 09:15:09 2017
@@ -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
+LIBEXEC_BIN=@PREFIX@/libexec/xen/bin
+
+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, domid and JSON config...\n"
+        ${LIBEXEC_BIN}/xen-init-dom0
+
+       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"
Index: pkgsrc/sysutils/xentools48/files/xendomains.sh
diff -u /dev/null pkgsrc/sysutils/xentools48/files/xendomains.sh:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/files/xendomains.sh      Thu Mar 30 09:15:09 2017
@@ -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"

Index: pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_core_settings.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_core_settings.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_core_settings.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,34 @@
+$NetBSD: patch-.._ipxe_src_core_settings.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- ../ipxe/src/core/settings.c.orig   2016-08-31 18:23:42.000000000 +0200
++++ ../ipxe/src/core/settings.c        2017-03-24 19:44:07.000000000 +0100
+@@ -304,10 +304,12 @@
+  */
+ struct settings * autovivify_child_settings ( struct settings *parent,
+                                             const char *name ) {
++      size_t nlen = strlen(name) + 1;
+       struct {
+               struct autovivified_settings autovivified;
+-              char name[ strlen ( name ) + 1 /* NUL */ ];
++              char name[];
+       } *new_child;
++      size_t tlen = sizeof(*new_child) + nlen;
+       struct settings *settings;
+ 
+       /* Find target parent settings block */
+@@ -318,13 +320,13 @@
+               return settings;
+ 
+       /* Create new generic settings block */
+-      new_child = zalloc ( sizeof ( *new_child ) );
++      new_child = zalloc ( tlen );
+       if ( ! new_child ) {
+               DBGC ( parent, "Settings %p could not create child %s\n",
+                      parent, name );
+               return NULL;
+       }
+-      memcpy ( new_child->name, name, sizeof ( new_child->name ) );
++      memcpy ( new_child->name, name, nlen );
+       ref_init ( &new_child->autovivified.refcnt,
+                  autovivified_settings_free );
+       generic_settings_init ( &new_child->autovivified.generic,
Index: pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_net_fcels.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_net_fcels.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-.._ipxe_src_net_fcels.c    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,124 @@
+$NetBSD: patch-.._ipxe_src_net_fcels.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- ../ipxe/src/net/fcels.c.orig       2015-01-25 20:27:57.000000000 +0000
++++ ../ipxe/src/net/fcels.c
+@@ -946,8 +946,11 @@ int fc_els_prli_tx ( struct fc_els *els,
+                    struct fc_els_prli_descriptor *descriptor, void *param ) {
+       struct {
+               struct fc_prli_frame frame;
+-              uint8_t param[descriptor->param_len];
+-      } __attribute__ (( packed )) prli;
++              uint8_t param[];
++      } __attribute__ (( packed )) *prli;
++      size_t plen = sizeof(*prli) + descriptor->param_len;
++      uint8_t prli_buf[plen];
++      prli = (void *)prli_buf;
+       struct fc_ulp *ulp;
+       int rc;
+ 
+@@ -960,22 +963,22 @@ int fc_els_prli_tx ( struct fc_els *els,
+       }
+ 
+       /* Build frame for transmission */
+-      memset ( &prli, 0, sizeof ( prli ) );
+-      prli.frame.command = fc_els_tx_command ( els, FC_ELS_PRLI );
+-      prli.frame.page_len =
+-              ( sizeof ( prli.frame.page ) + sizeof ( prli.param ) );
+-      prli.frame.len = htons ( sizeof ( prli ) );
+-      prli.frame.page.type = descriptor->type;
++      memset ( prli, 0, plen );
++      prli->frame.command = fc_els_tx_command ( els, FC_ELS_PRLI );
++      prli->frame.page_len =
++              ( sizeof ( prli->frame.page ) + descriptor->param_len );
++      prli->frame.len = htons ( plen );
++      prli->frame.page.type = descriptor->type;
+       if ( fc_els_is_request ( els ) ) {
+-              prli.frame.page.flags |= htons ( FC_PRLI_ESTABLISH );
++              prli->frame.page.flags |= htons ( FC_PRLI_ESTABLISH );
+       } else if ( fc_link_ok ( &ulp->link ) ) {
+-              prli.frame.page.flags |= htons ( FC_PRLI_ESTABLISH |
++              prli->frame.page.flags |= htons ( FC_PRLI_ESTABLISH |
+                                                   FC_PRLI_RESPONSE_SUCCESS );
+       }
+-      memcpy ( &prli.param, param, sizeof ( prli.param ) );
++      memcpy ( &prli->param, param, descriptor->param_len );
+ 
+       /* Transmit frame */
+-      if ( ( rc = fc_els_tx ( els, &prli, sizeof ( prli ) ) ) != 0 )
++      if ( ( rc = fc_els_tx ( els, prli, plen ) ) != 0 )
+               goto err_tx;
+ 
+       /* Drop temporary reference to ULP */
+@@ -1003,13 +1006,14 @@ int fc_els_prli_rx ( struct fc_els *els,
+                    void *data, size_t len ) {
+       struct {
+               struct fc_prli_frame frame;
+-              uint8_t param[descriptor->param_len];
++              uint8_t param[];
+       } __attribute__ (( packed )) *prli = data;
++      size_t plen = sizeof(*prli) + descriptor->param_len;
+       struct fc_ulp *ulp;
+       int rc;
+ 
+       /* Sanity check */
+-      if ( len < sizeof ( *prli ) ) {
++      if ( len < plen ) {
+               DBGC ( els, FCELS_FMT " received underlength frame:\n",
+                      FCELS_ARGS ( els ) );
+               DBGC_HDA ( els, 0, data, len );
+@@ -1018,7 +1022,7 @@ int fc_els_prli_rx ( struct fc_els *els,
+       }
+ 
+       DBGC ( els, FCELS_FMT " has parameters:\n", FCELS_ARGS ( els ) );
+-      DBGC_HDA ( els, 0, prli->param, sizeof ( prli->param ) );
++      DBGC_HDA ( els, 0, prli->param, descriptor->param_len );
+ 
+       /* Get ULP */
+       ulp = fc_ulp_get_port_id_type ( els->port, &els->peer_port_id,
+@@ -1039,7 +1043,7 @@ int fc_els_prli_rx ( struct fc_els *els,
+       /* Log in ULP, if applicable */
+       if ( prli->frame.page.flags & htons ( FC_PRLI_ESTABLISH ) ) {
+               if ( ( rc = fc_ulp_login ( ulp, prli->param,
+-                                         sizeof ( prli->param ),
++                                         descriptor->param_len,
+                                          fc_els_is_request ( els ) ) ) != 0 ){
+                       DBGC ( els, FCELS_FMT " could not log in ULP: %s\n",
+                              FCELS_ARGS ( els ), strerror ( rc ) );
+@@ -1089,15 +1093,16 @@ int fc_els_prli_detect ( struct fc_els *
+                        const void *data, size_t len ) {
+       const struct {
+               struct fc_prli_frame frame;
+-              uint8_t param[descriptor->param_len];
++              uint8_t param[];
+       } __attribute__ (( packed )) *prli = data;
++      size_t plen = sizeof(*prli) + descriptor->param_len;
+ 
+       /* Check for PRLI */
+       if ( prli->frame.command != FC_ELS_PRLI )
+               return -EINVAL;
+ 
+       /* Check for sufficient length to contain service parameter page */
+-      if ( len < sizeof ( *prli ) )
++      if ( len < plen )
+               return -EINVAL;
+ 
+       /* Check for upper-layer protocol type */
+@@ -1252,15 +1257,16 @@ static int fc_els_echo_rx_request ( stru
+                                   size_t len ) {
+       struct {
+               struct fc_echo_frame_header echo;
+-              char payload[ len - sizeof ( struct fc_echo_frame_header ) ];
++              char payload[];
+       } *echo = data;
++      size_t plen = suzeif(*echo) + len - sizeof ( struct fc_echo_frame_header );
+       int rc;
+ 
+       DBGC ( els, FCELS_FMT "\n", FCELS_ARGS ( els ) );
+ 
+       /* Transmit response */
+       echo->echo.command = FC_ELS_LS_ACC;
+-      if ( ( rc = fc_els_tx ( els, echo, sizeof ( *echo ) ) ) != 0 )
++      if ( ( rc = fc_els_tx ( els, echo, plen ) ) != 0 )
+               return rc;
+ 
+       /* Nothing to do */
Index: pkgsrc/sysutils/xentools48/patches/patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,16 @@
+$NetBSD: patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- ../newlib-1.16.0/newlib/libc/include/sys/_types.h.orig     2017-03-28 15:10:39.000000000 +0200
++++ ../newlib-1.16.0/newlib/libc/include/sys/_types.h  2017-03-28 15:10:56.000000000 +0200
+@@ -52,12 +52,8 @@
+ #endif
+ 
+ #ifndef __ssize_t_defined
+-#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
+-typedef int _ssize_t;
+-#else
+ typedef long _ssize_t;
+ #endif
+-#endif
+ 
+ #define __need_wint_t
+ #include <stddef.h>
Index: pkgsrc/sysutils/xentools48/patches/patch-._stubdom_vtpmmgr_tpm2_marshal.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-._stubdom_vtpmmgr_tpm2_marshal.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-._stubdom_vtpmmgr_tpm2_marshal.h   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,491 @@
+$NetBSD: patch-._stubdom_vtpmmgr_tpm2_marshal.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- ./stubdom/vtpmmgr/tpm2_marshal.h.orig      2017-03-28 16:08:46.000000000 +0200
++++ ./stubdom/vtpmmgr/tpm2_marshal.h   2017-03-28 16:08:56.000000000 +0200
+@@ -52,7 +52,7 @@
+ #define pack_TPM_BUFFER(ptr, buf, size) pack_BUFFER(ptr, buf, size)
+ #define unpack_TPM_BUFFER(ptr, buf, size) unpack_BUFFER(ptr, buf, size)
+ 
+-inline BYTE* pack_BYTE_ARRAY(BYTE* ptr, const BYTE* array, UINT32 size)
++static inline BYTE* pack_BYTE_ARRAY(BYTE* ptr, const BYTE* array, UINT32 size)
+ {
+     int i;
+     for (i = 0; i < size; i++)
+@@ -60,22 +60,22 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMA_SESSION(BYTE* ptr, const TPMA_SESSION *attr)
++static inline BYTE* pack_TPMA_SESSION(BYTE* ptr, const TPMA_SESSION *attr)
+ {
+     return pack_BYTE(ptr, (BYTE)(*attr));
+ }
+ 
+-inline BYTE* unpack_TPMA_SESSION(BYTE* ptr, TPMA_SESSION *attr)
++static inline BYTE* unpack_TPMA_SESSION(BYTE* ptr, TPMA_SESSION *attr)
+ {
+     return unpack_BYTE(ptr, (BYTE *)attr);
+ }
+ 
+-inline BYTE* pack_TPMI_ALG_HASH(BYTE* ptr, const TPMI_ALG_HASH *hash)
++static inline BYTE* pack_TPMI_ALG_HASH(BYTE* ptr, const TPMI_ALG_HASH *hash)
+ {
+     return pack_UINT16(ptr, *hash);
+ }
+ 
+-inline BYTE* unpack_TPMI_ALG_HASH(BYTE *ptr, TPMI_ALG_HASH *hash)
++static inline BYTE* unpack_TPMI_ALG_HASH(BYTE *ptr, TPMI_ALG_HASH *hash)
+ {
+     return unpack_UINT16(ptr, hash);
+ }
+@@ -125,21 +125,21 @@
+ #define pack_TPMI_RH_LOCKOUT(ptr, l)            pack_TPM2_HANDLE(ptr, l)
+ #define unpack_TPMI_RH_LOCKOUT(ptr, l)          unpack_TPM2_HANDLE(ptr, l)
+ 
+-inline BYTE* pack_TPM2B_DIGEST(BYTE* ptr, const TPM2B_DIGEST *digest)
++static inline BYTE* pack_TPM2B_DIGEST(BYTE* ptr, const TPM2B_DIGEST *digest)
+ {
+     ptr = pack_UINT16(ptr, digest->size);
+     ptr = pack_BUFFER(ptr, digest->buffer, digest->size);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2B_DIGEST(BYTE* ptr, TPM2B_DIGEST *digest)
++static inline BYTE* unpack_TPM2B_DIGEST(BYTE* ptr, TPM2B_DIGEST *digest)
+ {
+     ptr = unpack_UINT16(ptr, &digest->size);
+     ptr = unpack_BUFFER(ptr, digest->buffer, digest->size);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMT_TK_CREATION(BYTE* ptr,const TPMT_TK_CREATION *ticket )
++static inline BYTE* pack_TPMT_TK_CREATION(BYTE* ptr,const TPMT_TK_CREATION *ticket )
+ {
+     ptr = pack_TPM_ST(ptr , &ticket->tag);
+     ptr = pack_TPMI_RH_HIERACHY(ptr , &ticket->hierarchy);
+@@ -147,7 +147,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMT_TK_CREATION(BYTE* ptr, TPMT_TK_CREATION *ticket )
++static inline BYTE* unpack_TPMT_TK_CREATION(BYTE* ptr, TPMT_TK_CREATION *ticket )
+ {
+     ptr = unpack_TPM_ST(ptr, &ticket->tag);
+     ptr = unpack_TPMI_RH_HIERACHY(ptr, &ticket->hierarchy);
+@@ -155,70 +155,70 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2B_NAME(BYTE* ptr,const TPM2B_NAME *name )
++static inline BYTE* pack_TPM2B_NAME(BYTE* ptr,const TPM2B_NAME *name )
+ {
+     ptr = pack_UINT16(ptr, name->size);
+     ptr = pack_TPM_BUFFER(ptr, name->name, name->size);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2B_NAME(BYTE* ptr, TPM2B_NAME *name)
++static inline BYTE* unpack_TPM2B_NAME(BYTE* ptr, TPM2B_NAME *name)
+ {
+     ptr = unpack_UINT16(ptr, &name->size);
+     ptr = unpack_TPM_BUFFER(ptr, name->name, name->size);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2B_NONCE(BYTE* ptr, const TPM2B_NONCE *nonce)
++static inline BYTE* pack_TPM2B_NONCE(BYTE* ptr, const TPM2B_NONCE *nonce)
+ {
+     return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)nonce);
+ }
+ 
+ #define unpack_TPM2B_NONCE(ptr, nonce)  unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)nonce)
+ 
+-inline BYTE* pack_TPM2B_AUTH(BYTE* ptr, const TPM2B_AUTH *auth)
++static inline BYTE* pack_TPM2B_AUTH(BYTE* ptr, const TPM2B_AUTH *auth)
+ {
+     return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)auth);
+ }
+ 
+ #define unpack_TPM2B_AUTH(ptr, auth)    unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)auth)
+ 
+-inline BYTE* pack_TPM2B_DATA(BYTE* ptr, const TPM2B_DATA *data)
++static inline BYTE* pack_TPM2B_DATA(BYTE* ptr, const TPM2B_DATA *data)
+ {
+     return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)data);
+ }
+ 
+ #define unpack_TPM2B_DATA(ptr, data)    unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)data)
+ 
+-inline BYTE* pack_TPM2B_SENSITIVE_DATA(BYTE* ptr, const TPM2B_SENSITIVE_DATA *data)
++static inline BYTE* pack_TPM2B_SENSITIVE_DATA(BYTE* ptr, const TPM2B_SENSITIVE_DATA *data)
+ {
+     return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)data);
+ }
+ 
+ #define unpack_TPM2B_SENSITIVE_DATA(ptr, data)  unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)data)
+ 
+-inline BYTE* pack_TPM2B_PUBLIC_KEY_RSA(BYTE* ptr, const TPM2B_PUBLIC_KEY_RSA *rsa)
++static inline BYTE* pack_TPM2B_PUBLIC_KEY_RSA(BYTE* ptr, const TPM2B_PUBLIC_KEY_RSA *rsa)
+ {
+     return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)rsa);
+ }
+ 
+ #define unpack_TPM2B_PUBLIC_KEY_RSA(ptr, rsa)   unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)rsa)
+ 
+-inline BYTE* pack_TPM2B_PRIVATE(BYTE* ptr, const TPM2B_PRIVATE *Private)
++static inline BYTE* pack_TPM2B_PRIVATE(BYTE* ptr, const TPM2B_PRIVATE *Private)
+ {
+     ptr = pack_UINT16(ptr, Private->size);
+     ptr = pack_TPM_BUFFER(ptr, Private->buffer, Private->size);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2B_PRIVATE(BYTE* ptr, TPM2B_PRIVATE *Private)
++static inline BYTE* unpack_TPM2B_PRIVATE(BYTE* ptr, TPM2B_PRIVATE *Private)
+ {
+     ptr = unpack_UINT16(ptr, &Private->size);
+     ptr = unpack_BUFFER(ptr, Private->buffer, Private->size);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, const TPMS_PCR_SELECTION *sel, UINT32 count)
++static inline BYTE* pack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, const TPMS_PCR_SELECTION *sel, UINT32 count)
+ {
+     int i;
+     for (i = 0; i < count; i++) {
+@@ -229,7 +229,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, TPMS_PCR_SELECTION *sel, UINT32 count)
++static inline BYTE* unpack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, TPMS_PCR_SELECTION *sel, UINT32 count)
+ {
+     int i;
+     for (i = 0; i < count; i++) {
+@@ -240,21 +240,21 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPML_PCR_SELECTION(BYTE* ptr, const TPML_PCR_SELECTION *sel)
++static inline BYTE* pack_TPML_PCR_SELECTION(BYTE* ptr, const TPML_PCR_SELECTION *sel)
+ {
+     ptr = pack_UINT32(ptr, sel->count);
+     ptr = pack_TPMS_PCR_SELECTION_ARRAY(ptr, sel->pcrSelections, sel->count);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPML_PCR_SELECTION(BYTE* ptr, TPML_PCR_SELECTION *sel)
++static inline BYTE* unpack_TPML_PCR_SELECTION(BYTE* ptr, TPML_PCR_SELECTION *sel)
+ {
+     ptr = unpack_UINT32(ptr, &sel->count);
+     ptr = unpack_TPMS_PCR_SELECTION_ARRAY(ptr, sel->pcrSelections, sel->count);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPML_DIGEST(BYTE* ptr,TPML_DIGEST *digest)
++static inline BYTE* unpack_TPML_DIGEST(BYTE* ptr,TPML_DIGEST *digest)
+ {
+     int i;
+     ptr = unpack_UINT32(ptr, &digest->count);
+@@ -265,7 +265,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_CREATION_DATA(BYTE* ptr,const TPMS_CREATION_DATA *data)
++static inline BYTE* pack_TPMS_CREATION_DATA(BYTE* ptr,const TPMS_CREATION_DATA *data)
+ {
+     ptr = pack_TPML_PCR_SELECTION(ptr, &data->pcrSelect);
+     ptr = pack_TPM2B_DIGEST(ptr, &data->pcrDigest);
+@@ -276,7 +276,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMS_CREATION_DATA(BYTE* ptr, TPMS_CREATION_DATA *data)
++static inline BYTE* unpack_TPMS_CREATION_DATA(BYTE* ptr, TPMS_CREATION_DATA *data)
+ {
+     ptr = unpack_TPML_PCR_SELECTION(ptr, &data->pcrSelect);
+     ptr = unpack_TPM2B_DIGEST(ptr, &data->pcrDigest);
+@@ -288,28 +288,28 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2B_CREATION_DATA(BYTE* ptr, const TPM2B_CREATION_DATA *data )
++static inline BYTE* pack_TPM2B_CREATION_DATA(BYTE* ptr, const TPM2B_CREATION_DATA *data )
+ {
+     ptr = pack_UINT16(ptr, data->size);
+     ptr = pack_TPMS_CREATION_DATA(ptr, &data->creationData);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2B_CREATION_DATA(BYTE* ptr, TPM2B_CREATION_DATA * data)
++static inline BYTE* unpack_TPM2B_CREATION_DATA(BYTE* ptr, TPM2B_CREATION_DATA * data)
+ {
+     ptr = unpack_UINT16(ptr, &data->size);
+     ptr = unpack_TPMS_CREATION_DATA(ptr, &data->creationData);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_SENSITIVE_CREATE(BYTE* ptr, const TPMS_SENSITIVE_CREATE *create)
++static inline BYTE* pack_TPMS_SENSITIVE_CREATE(BYTE* ptr, const TPMS_SENSITIVE_CREATE *create)
+ {
+     ptr = pack_TPM2B_AUTH(ptr, &create->userAuth);
+     ptr = pack_TPM2B_SENSITIVE_DATA(ptr, &create->data);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2B_SENSITIVE_CREATE(BYTE* ptr, const TPM2B_SENSITIVE_CREATE *create)
++static inline BYTE* pack_TPM2B_SENSITIVE_CREATE(BYTE* ptr, const TPM2B_SENSITIVE_CREATE *create)
+ {
+     BYTE* sizePtr = ptr;
+     ptr += 2;
+@@ -318,7 +318,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMU_SYM_MODE(BYTE* ptr, const TPMU_SYM_MODE *p,
++static inline BYTE* pack_TPMU_SYM_MODE(BYTE* ptr, const TPMU_SYM_MODE *p,
+                                 const TPMI_ALG_SYM_OBJECT *sel)
+ {
+     switch(*sel) {
+@@ -336,7 +336,7 @@
+     }
+     return ptr;
+ }
+-inline BYTE* unpack_TPMU_SYM_MODE(BYTE* ptr, TPMU_SYM_MODE *p,
++static inline BYTE* unpack_TPMU_SYM_MODE(BYTE* ptr, TPMU_SYM_MODE *p,
+                                   const TPMI_ALG_SYM_OBJECT *sel)
+ {
+     switch(*sel) {
+@@ -355,7 +355,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMU_SYM_KEY_BITS(BYTE* ptr, const TPMU_SYM_KEY_BITS *p,
++static inline BYTE* pack_TPMU_SYM_KEY_BITS(BYTE* ptr, const TPMU_SYM_KEY_BITS *p,
+                                     const TPMI_ALG_SYM_OBJECT *sel)
+ {
+     switch(*sel) {
+@@ -376,7 +376,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMU_SYM_KEY_BITS(BYTE* ptr, TPMU_SYM_KEY_BITS *p,
++static inline BYTE* unpack_TPMU_SYM_KEY_BITS(BYTE* ptr, TPMU_SYM_KEY_BITS *p,
+                                       const TPMI_ALG_SYM_OBJECT *sel)
+ {
+     switch(*sel) {
+@@ -397,7 +397,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMT_SYM_DEF_OBJECT(BYTE* ptr, const TPMT_SYM_DEF_OBJECT *p)
++static inline BYTE* pack_TPMT_SYM_DEF_OBJECT(BYTE* ptr, const TPMT_SYM_DEF_OBJECT *p)
+ {
+     ptr = pack_TPMI_ALG_SYM_OBJECT(ptr, &p->algorithm);
+     ptr = pack_TPMU_SYM_KEY_BITS(ptr, &p->keyBits, &p->algorithm);
+@@ -405,7 +405,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMT_SYM_DEF_OBJECT(BYTE *ptr, TPMT_SYM_DEF_OBJECT *p)
++static inline BYTE* unpack_TPMT_SYM_DEF_OBJECT(BYTE *ptr, TPMT_SYM_DEF_OBJECT *p)
+ {
+     ptr = unpack_TPMI_ALG_SYM_OBJECT(ptr, &p->algorithm);
+     ptr = unpack_TPMU_SYM_KEY_BITS(ptr, &p->keyBits, &p->algorithm);
+@@ -416,7 +416,7 @@
+ #define pack_TPMS_SCHEME_OAEP(p, t)     pack_TPMI_ALG_HASH(p, &((t)->hashAlg))
+ #define unpack_TPMS_SCHEME_OAEP(p, t)   unpack_TPMI_ALG_HASH(p, &((t)->hashAlg))
+ 
+-inline BYTE* pack_TPMU_ASYM_SCHEME(BYTE *ptr, const TPMU_ASYM_SCHEME *p,
++static inline BYTE* pack_TPMU_ASYM_SCHEME(BYTE *ptr, const TPMU_ASYM_SCHEME *p,
+                                    const TPMI_ALG_RSA_SCHEME *s)
+ {
+     switch(*s) {
+@@ -438,7 +438,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMU_ASYM_SCHEME(BYTE *ptr, TPMU_ASYM_SCHEME *p,
++static inline BYTE* unpack_TPMU_ASYM_SCHEME(BYTE *ptr, TPMU_ASYM_SCHEME *p,
+                                      const TPMI_ALG_RSA_SCHEME *s)
+ {
+     switch(*s) {
+@@ -462,28 +462,28 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMT_RSA_SCHEME(BYTE* ptr, const TPMT_RSA_SCHEME *p)
++static inline BYTE* pack_TPMT_RSA_SCHEME(BYTE* ptr, const TPMT_RSA_SCHEME *p)
+ {
+     ptr = pack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme);
+     ptr = pack_TPMU_ASYM_SCHEME(ptr, &p->details, &p->scheme);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMT_RSA_SCHEME(BYTE* ptr, TPMT_RSA_SCHEME *p)
++static inline BYTE* unpack_TPMT_RSA_SCHEME(BYTE* ptr, TPMT_RSA_SCHEME *p)
+ {
+     ptr = unpack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme);
+     ptr = unpack_TPMU_ASYM_SCHEME(ptr, &p->details, &p->scheme);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMT_RSA_DECRYPT(BYTE* ptr, const TPMT_RSA_DECRYPT *p)
++static inline BYTE* pack_TPMT_RSA_DECRYPT(BYTE* ptr, const TPMT_RSA_DECRYPT *p)
+ {
+     ptr = pack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme);
+     ptr = pack_TPMU_ASYM_SCHEME(ptr, &p->details, &p->scheme);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_RSA_PARMS(BYTE* ptr, const TPMS_RSA_PARMS *p)
++static inline BYTE* pack_TPMS_RSA_PARMS(BYTE* ptr, const TPMS_RSA_PARMS *p)
+ {
+     ptr = pack_TPMT_SYM_DEF_OBJECT(ptr, &p->symmetric);
+     ptr = pack_TPMT_RSA_SCHEME(ptr, &p->scheme);
+@@ -492,7 +492,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMS_RSA_PARMS(BYTE *ptr, TPMS_RSA_PARMS *p)
++static inline BYTE* unpack_TPMS_RSA_PARMS(BYTE *ptr, TPMS_RSA_PARMS *p)
+ {
+     ptr = unpack_TPMT_SYM_DEF_OBJECT(ptr, &p->symmetric);
+     ptr = unpack_TPMT_RSA_SCHEME(ptr, &p->scheme);
+@@ -501,7 +501,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMU_PUBLIC_PARMS(BYTE* ptr, const TPMU_PUBLIC_PARMS *param,
++static inline BYTE* pack_TPMU_PUBLIC_PARMS(BYTE* ptr, const TPMU_PUBLIC_PARMS *param,
+                                     const TPMI_ALG_PUBLIC *selector)
+ {
+     switch(*selector) {
+@@ -518,7 +518,7 @@
+     return NULL;
+ }
+ 
+-inline BYTE* unpack_TPMU_PUBLIC_PARMS(BYTE* ptr, TPMU_PUBLIC_PARMS *param,
++static inline BYTE* unpack_TPMU_PUBLIC_PARMS(BYTE* ptr, TPMU_PUBLIC_PARMS *param,
+                                       const TPMI_ALG_PUBLIC *selector)
+ {
+     switch(*selector) {
+@@ -535,19 +535,19 @@
+     return NULL;
+ }
+ 
+-inline BYTE* pack_TPMS_ECC_POINT(BYTE* ptr, const TPMS_ECC_POINT *point)
++static inline BYTE* pack_TPMS_ECC_POINT(BYTE* ptr, const TPMS_ECC_POINT *point)
+ {
+     assert(false);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMS_ECC_POINT(BYTE* ptr, TPMS_ECC_POINT *point)
++static inline BYTE* unpack_TPMS_ECC_POINT(BYTE* ptr, TPMS_ECC_POINT *point)
+ {
+     assert(false);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMU_PUBLIC_ID(BYTE* ptr, const TPMU_PUBLIC_ID *id,
++static inline BYTE* pack_TPMU_PUBLIC_ID(BYTE* ptr, const TPMU_PUBLIC_ID *id,
+                                  const TPMI_ALG_PUBLIC *selector)
+ {
+     switch (*selector) {
+@@ -564,7 +564,7 @@
+     return NULL;
+ }
+ 
+-inline BYTE* unpack_TPMU_PUBLIC_ID(BYTE* ptr, TPMU_PUBLIC_ID *id, TPMI_ALG_PUBLIC *selector)
++static inline BYTE* unpack_TPMU_PUBLIC_ID(BYTE* ptr, TPMU_PUBLIC_ID *id, TPMI_ALG_PUBLIC *selector)
+ {
+     switch (*selector) {
+     case TPM2_ALG_KEYEDHASH:
+@@ -580,7 +580,7 @@
+     return NULL;
+ }
+ 
+-inline BYTE* pack_TPMT_PUBLIC(BYTE* ptr, const TPMT_PUBLIC *public)
++static inline BYTE* pack_TPMT_PUBLIC(BYTE* ptr, const TPMT_PUBLIC *public)
+ {
+     ptr = pack_TPMI_ALG_PUBLIC(ptr, &public->type);
+     ptr = pack_TPMI_ALG_HASH(ptr, &public->nameAlg);
+@@ -591,7 +591,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPMT_PUBLIC(BYTE* ptr, TPMT_PUBLIC *public)
++static inline BYTE* unpack_TPMT_PUBLIC(BYTE* ptr, TPMT_PUBLIC *public)
+ {
+     ptr = unpack_TPMI_ALG_PUBLIC(ptr, &public->type);
+     ptr = unpack_TPMI_ALG_HASH(ptr, &public->nameAlg);
+@@ -602,7 +602,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2B_PUBLIC(BYTE* ptr, const TPM2B_PUBLIC *public)
++static inline BYTE* pack_TPM2B_PUBLIC(BYTE* ptr, const TPM2B_PUBLIC *public)
+ {
+     BYTE *sizePtr = ptr;
+     ptr += 2;
+@@ -611,14 +611,14 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2B_PUBLIC(BYTE* ptr, TPM2B_PUBLIC *public)
++static inline BYTE* unpack_TPM2B_PUBLIC(BYTE* ptr, TPM2B_PUBLIC *public)
+ {
+     ptr = unpack_UINT16(ptr, &public->size);
+     ptr = unpack_TPMT_PUBLIC(ptr, &public->publicArea);
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_PCR_SELECTION(BYTE* ptr, const TPMS_PCR_SELECTION *selection)
++static inline BYTE* pack_TPMS_PCR_SELECTION(BYTE* ptr, const TPMS_PCR_SELECTION *selection)
+ {
+     ptr = pack_TPMI_ALG_HASH(ptr, &selection->hash);
+     ptr = pack_BYTE(ptr, selection->sizeofSelect);
+@@ -626,7 +626,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPMS_PCR_SELECTION_Array(BYTE* ptr, const TPMS_PCR_SELECTION *selections,
++static inline BYTE* pack_TPMS_PCR_SELECTION_Array(BYTE* ptr, const TPMS_PCR_SELECTION *selections,
+                                            const UINT32 cnt)
+ {
+     int i;
+@@ -635,7 +635,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM_AuthArea(BYTE* ptr, const TPM_AuthArea *auth)
++static inline BYTE* pack_TPM_AuthArea(BYTE* ptr, const TPM_AuthArea *auth)
+ {
+     BYTE* sizePtr = ptr;
+     ptr += sizeof(UINT32);
+@@ -647,7 +647,7 @@
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM_AuthArea(BYTE* ptr, TPM_AuthArea *auth)
++static inline BYTE* unpack_TPM_AuthArea(BYTE* ptr, TPM_AuthArea *auth)
+ {
+     ptr = unpack_UINT32(ptr, &auth->size);
+     ptr = unpack_TPM_RH(ptr, &auth->sessionHandle);
+@@ -657,14 +657,14 @@
+     return ptr;
+ }
+ 
+-inline BYTE* pack_TPM2_RSA_KEY(BYTE* ptr, const TPM2_RSA_KEY *key)
++static inline BYTE* pack_TPM2_RSA_KEY(BYTE* ptr, const TPM2_RSA_KEY *key)
+ {
+     ptr = pack_TPM2B_PRIVATE(ptr, &key->Private);
+     ptr = pack_TPM2B_PUBLIC(ptr, &key->Public);
+     return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM2_RSA_KEY(BYTE* ptr, TPM2_RSA_KEY *key)
++static inline BYTE* unpack_TPM2_RSA_KEY(BYTE* ptr, TPM2_RSA_KEY *key)
+ {
+     ptr = unpack_TPM2B_PRIVATE(ptr, &key->Private);
+     ptr = unpack_TPM2B_PUBLIC(ptr, &key->Public);
Index: pkgsrc/sysutils/xentools48/patches/patch-Config.mk
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-Config.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-Config.mk  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-Config.mk,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- Config.mk.orig     2016-12-05 13:03:27.000000000 +0100
++++ Config.mk  2017-03-24 17:33:17.000000000 +0100
+@@ -35,7 +35,7 @@
+ 
+ # Tools to run on system hosting the build
+ HOSTCFLAGS  = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
+-HOSTCFLAGS += -fno-strict-aliasing
++HOSTCFLAGS += -fno-strict-aliasing ${EXTRA_HOSTCFLAGS}
+ 
+ DISTDIR     ?= $(XEN_ROOT)/dist
+ DESTDIR     ?= /
+@@ -221,6 +221,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)
Index: pkgsrc/sysutils/xentools48/patches/patch-Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-Makefile   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,29 @@
+$NetBSD: patch-Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- Makefile.orig      2017-03-29 10:48:50.000000000 +0200
++++ Makefile   2017-03-29 10:49:33.000000000 +0200
+@@ -56,9 +56,9 @@
+ .PHONY: build-stubdom
+ build-stubdom: mini-os-dir
+       $(MAKE) -C stubdom build
+-ifeq (x86_64,$(XEN_TARGET_ARCH))
+-      XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
+-endif
++#ifeq (x86_64,$(XEN_TARGET_ARCH))
++#     XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
++#endif
+ 
+ .PHONY: build-docs
+ build-docs:
+@@ -103,9 +103,9 @@
+ .PHONY: install-stubdom
+ install-stubdom: install-tools mini-os-dir
+       $(MAKE) -C stubdom install
+-ifeq (x86_64,$(XEN_TARGET_ARCH))
+-      XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
+-endif
++#ifeq (x86_64,$(XEN_TARGET_ARCH))
++#     XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
++#endif
+ 
+ .PHONY: tools/firmware/seabios-dir-force-update
+ tools/firmware/seabios-dir-force-update:
Index: pkgsrc/sysutils/xentools48/patches/patch-XSA-211-1
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-XSA-211-1:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-XSA-211-1  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,266 @@
+$NetBSD: patch-XSA-211-1,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+From 7563ddb0bd67e7e54568e017cb7d4f7f556587fc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel%redhat.com@localhost>
+Date: Tue, 14 Feb 2017 19:09:59 +0100
+Subject: [PATCH] cirrus/vnc: zap bitblit support from console code.
+
+There is a special code path (dpy_gfx_copy) to allow graphic emulation
+notify user interface code about bitblit operations carryed out by
+guests.  It is supported by cirrus and vnc server.  The intended purpose
+is to optimize display scrolls and just send over the scroll op instead
+of a full display update.
+
+This is rarely used these days though because modern guests simply don't
+use the cirrus blitter any more.  Any linux guest using the cirrus drm
+driver doesn't.  Any windows guest newer than winxp doesn't ship with a
+cirrus driver any more and thus uses the cirrus as simple framebuffer.
+
+So this code tends to bitrot and bugs can go unnoticed for a long time.
+See for example commit "3e10c3e vnc: fix qemu crash because of SIGSEGV"
+which fixes a bug lingering in the code for almost a year, added by
+commit "c7628bf vnc: only alloc server surface with clients connected".
+
+Also the vnc server will throttle the frame rate in case it figures the
+network can't keep up (send buffers are full).  This doesn't work with
+dpy_gfx_copy, for any copy operation sent to the vnc client we have to
+send all outstanding updates beforehand, otherwise the vnc client might
+run the client side blit on outdated data and thereby corrupt the
+display.  So this dpy_gfx_copy "optimization" might even make things
+worse on slow network links.
+
+Lets kill it once for all.
+
+Signed-off-by: Gerd Hoffmann <kraxel%redhat.com@localhost>
+---
+ hw/display/cirrus_vga.c | 12 ++-----
+ include/ui/console.h    |  7 ----
+ ui/console.c            | 28 ---------------
+ ui/vnc.c                | 96 -------------------------------------------------
+ 4 files changed, 3 insertions(+), 140 deletions(-)
+
+diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
+index 9a4e90a..2966125 100644
+--- tools/qemu-xen/hw/display/cirrus_vga.c.orig
++++ tools/qemu-xen/hw/display/cirrus_vga.c
+@@ -760,11 +760,6 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
+         }
+     }
+ 
+-    /* we have to flush all pending changes so that the copy
+-       is generated at the appropriate moment in time */
+-    if (notify)
+-        graphic_hw_update(s->vga.con);
+-
+     (*s->cirrus_rop) (s, s->vga.vram_ptr +
+                     (s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
+                     s->vga.vram_ptr +
+@@ -773,10 +768,9 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
+                     s->cirrus_blt_width, s->cirrus_blt_height);
+ 
+     if (notify) {
+-        qemu_console_copy(s->vga.con,
+-                        sx, sy, dx, dy,
+-                        s->cirrus_blt_width / depth,
+-                        s->cirrus_blt_height);
++        dpy_gfx_update(s->vga.con, dx, dy,
++                       s->cirrus_blt_width / depth,
++                       s->cirrus_blt_height);
+     }
+ 
+     /* we don't have to notify the display that this portion has
+diff --git a/include/ui/console.h b/include/ui/console.h
+index 2703a3a..67927ed 100644
+--- tools/qemu-xen/include/ui/console.h.orig
++++ tools/qemu-xen/include/ui/console.h
+@@ -189,9 +189,6 @@ typedef struct DisplayChangeListenerOps {
+                            int x, int y, int w, int h);
+     void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
+                            struct DisplaySurface *new_surface);
+-    void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
+-                         int src_x, int src_y,
+-                         int dst_x, int dst_y, int w, int h);
+     bool (*dpy_gfx_check_format)(DisplayChangeListener *dcl,
+                                  pixman_format_code_t format);
+ 
+@@ -273,8 +270,6 @@ int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info);
+ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);
+ void dpy_gfx_replace_surface(QemuConsole *con,
+                              DisplaySurface *surface);
+-void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
+-                  int dst_x, int dst_y, int w, int h);
+ void dpy_text_cursor(QemuConsole *con, int x, int y);
+ void dpy_text_update(QemuConsole *con, int x, int y, int w, int h);
+ void dpy_text_resize(QemuConsole *con, int w, int h);
+@@ -398,8 +393,6 @@ void text_consoles_set_display(DisplayState *ds);
+ void console_select(unsigned int index);
+ void console_color_init(DisplayState *ds);
+ void qemu_console_resize(QemuConsole *con, int width, int height);
+-void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
+-                       int dst_x, int dst_y, int w, int h);
+ DisplaySurface *qemu_console_surface(QemuConsole *con);
+ 
+ /* console-gl.c */
+diff --git a/ui/console.c b/ui/console.c
+index c24bfe4..ece0c04 100644
+--- tools/qemu-xen/ui/console.c.orig
++++ tools/qemu-xen/ui/console.c
+@@ -1558,27 +1558,6 @@ static void dpy_refresh(DisplayState *s)
+     }
+ }
+ 
+-void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
+-                  int dst_x, int dst_y, int w, int h)
+-{
+-    DisplayState *s = con->ds;
+-    DisplayChangeListener *dcl;
+-
+-    if (!qemu_console_is_visible(con)) {
+-        return;
+-    }
+-    QLIST_FOREACH(dcl, &s->listeners, next) {
+-        if (con != (dcl->con ? dcl->con : active_console)) {
+-            continue;
+-        }
+-        if (dcl->ops->dpy_gfx_copy) {
+-            dcl->ops->dpy_gfx_copy(dcl, src_x, src_y, dst_x, dst_y, w, h);
+-        } else { /* TODO */
+-            dcl->ops->dpy_gfx_update(dcl, dst_x, dst_y, w, h);
+-        }
+-    }
+-}
+-
+ void dpy_text_cursor(QemuConsole *con, int x, int y)
+ {
+     DisplayState *s = con->ds;
+@@ -2104,13 +2083,6 @@ void qemu_console_resize(QemuConsole *s, int width, int height)
+     dpy_gfx_replace_surface(s, surface);
+ }
+ 
+-void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
+-                       int dst_x, int dst_y, int w, int h)
+-{
+-    assert(con->console_type == GRAPHIC_CONSOLE);
+-    dpy_gfx_copy(con, src_x, src_y, dst_x, dst_y, w, h);
+-}
+-
+ DisplaySurface *qemu_console_surface(QemuConsole *console)
+ {
+     return console->surface;
+diff --git a/ui/vnc.c b/ui/vnc.c
+index d1087c9..b45bb2c 100644
+--- tools/qemu-xen/ui/vnc.c.orig
++++ tools/qemu-xen/ui/vnc.c
+@@ -872,101 +872,6 @@ int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
+     return n;
+ }
+ 
+-static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
+-{
+-    /* send bitblit op to the vnc client */
+-    vnc_lock_output(vs);
+-    vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
+-    vnc_write_u8(vs, 0);
+-    vnc_write_u16(vs, 1); /* number of rects */
+-    vnc_framebuffer_update(vs, dst_x, dst_y, w, h, VNC_ENCODING_COPYRECT);
+-    vnc_write_u16(vs, src_x);
+-    vnc_write_u16(vs, src_y);
+-    vnc_unlock_output(vs);
+-    vnc_flush(vs);
+-}
+-
+-static void vnc_dpy_copy(DisplayChangeListener *dcl,
+-                         int src_x, int src_y,
+-                         int dst_x, int dst_y, int w, int h)
+-{
+-    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
+-    VncState *vs, *vn;
+-    uint8_t *src_row;
+-    uint8_t *dst_row;
+-    int i, x, y, pitch, inc, w_lim, s;
+-    int cmp_bytes;
+-
+-    if (!vd->server) {
+-        /* no client connected */
+-        return;
+-    }
+-
+-    vnc_refresh_server_surface(vd);
+-    QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {
+-        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
+-            vs->force_update = 1;
+-            vnc_update_client(vs, 1, true);
+-            /* vs might be free()ed here */
+-        }
+-    }
+-
+-    /* do bitblit op on the local surface too */
+-    pitch = vnc_server_fb_stride(vd);
+-    src_row = vnc_server_fb_ptr(vd, src_x, src_y);
+-    dst_row = vnc_server_fb_ptr(vd, dst_x, dst_y);
+-    y = dst_y;
+-    inc = 1;
+-    if (dst_y > src_y) {
+-        /* copy backwards */
+-        src_row += pitch * (h-1);
+-        dst_row += pitch * (h-1);
+-        pitch = -pitch;
+-        y = dst_y + h - 1;
+-        inc = -1;
+-    }
+-    w_lim = w - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % VNC_DIRTY_PIXELS_PER_BIT));
+-    if (w_lim < 0) {
+-        w_lim = w;
+-    } else {
+-        w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT);
+-    }
+-    for (i = 0; i < h; i++) {
+-        for (x = 0; x <= w_lim;
+-                x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {
+-            if (x == w_lim) {
+-                if ((s = w - w_lim) == 0)
+-                    break;
+-            } else if (!x) {
+-                s = (VNC_DIRTY_PIXELS_PER_BIT -
+-                    (dst_x % VNC_DIRTY_PIXELS_PER_BIT));
+-                s = MIN(s, w_lim);
+-            } else {
+-                s = VNC_DIRTY_PIXELS_PER_BIT;
+-            }
+-            cmp_bytes = s * VNC_SERVER_FB_BYTES;
+-            if (memcmp(src_row, dst_row, cmp_bytes) == 0)
+-                continue;
+-            memmove(dst_row, src_row, cmp_bytes);
+-            QTAILQ_FOREACH(vs, &vd->clients, next) {
+-                if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
+-                    set_bit(((x + dst_x) / VNC_DIRTY_PIXELS_PER_BIT),
+-                            vs->dirty[y]);
+-                }
+-            }
+-        }
+-        src_row += pitch - w * VNC_SERVER_FB_BYTES;
+-        dst_row += pitch - w * VNC_SERVER_FB_BYTES;
+-        y += inc;
+-    }
+-
+-    QTAILQ_FOREACH(vs, &vd->clients, next) {
+-        if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
+-            vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);
+-        }
+-    }
+-}
+-
+ static void vnc_mouse_set(DisplayChangeListener *dcl,
+                           int x, int y, int visible)
+ {
+@@ -3119,7 +3024,6 @@ static gboolean vnc_listen_io(QIOChannel *ioc,
+ static const DisplayChangeListenerOps dcl_ops = {
+     .dpy_name             = "vnc",
+     .dpy_refresh          = vnc_refresh,
+-    .dpy_gfx_copy         = vnc_dpy_copy,
+     .dpy_gfx_update       = vnc_dpy_update,
+     .dpy_gfx_switch       = vnc_dpy_switch,
+     .dpy_gfx_check_format = qemu_pixman_check_format,
+-- 
+2.1.4
+
Index: pkgsrc/sysutils/xentools48/patches/patch-XSA-211-2
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-XSA-211-2:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-XSA-211-2  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,227 @@
+$NetBSD: patch-XSA-211-2,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+From 29e67cfd46b4d06ca1bb75558e227ec34a6af35f Mon Sep 17 00:00:00 2001
+From: Ian Jackson <ian.jackson%eu.citrix.com@localhost>
+Date: Thu, 9 Mar 2017 11:14:55 +0000
+Subject: [PATCH] cirrus/vnc: zap drop bitblit support from console code.
+
+From: Gerd Hoffmann <kraxel%redhat.com@localhost>
+
+There is a special code path (dpy_gfx_copy) to allow graphic emulation
+notify user interface code about bitblit operations carryed out by
+guests.  It is supported by cirrus and vnc server.  The intended purpose
+is to optimize display scrolls and just send over the scroll op instead
+of a full display update.
+
+This is rarely used these days though because modern guests simply don't
+use the cirrus blitter any more.  Any linux guest using the cirrus drm
+driver doesn't.  Any windows guest newer than winxp doesn't ship with a
+cirrus driver any more and thus uses the cirrus as simple framebuffer.
+
+So this code tends to bitrot and bugs can go unnoticed for a long time.
+See for example commit "3e10c3e vnc: fix qemu crash because of SIGSEGV"
+which fixes a bug lingering in the code for almost a year, added by
+commit "c7628bf vnc: only alloc server surface with clients connected".
+
+Also the vnc server will throttle the frame rate in case it figures the
+network can't keep up (send buffers are full).  This doesn't work with
+dpy_gfx_copy, for any copy operation sent to the vnc client we have to
+send all outstanding updates beforehand, otherwise the vnc client might
+run the client side blit on outdated data and thereby corrupt the
+display.  So this dpy_gfx_copy "optimization" might even make things
+worse on slow network links.
+
+Lets kill it once for all.
+
+Signed-off-by: Gerd Hoffmann <kraxel%redhat.com@localhost>
+
+These changes (dropping dpy_copy and all its references and
+implementations) reimplemented for qemu-xen-traditional.
+
+This is XSA-211.
+
+Signed-off-by: Ian Jackson <ian.jackson%eu.citrix.com@localhost>
+---
+ console.c       |  8 --------
+ console.h       | 16 ----------------
+ hw/cirrus_vga.c | 15 +++++----------
+ hw/vmware_vga.c |  1 +
+ vnc.c           | 35 -----------------------------------
+ 5 files changed, 6 insertions(+), 69 deletions(-)
+
+diff --git a/console.c b/console.c
+index d4f1ad0..e61b53b 100644
+--- tools/qemu-xen-traditional/console.c.orig
++++ tools/qemu-xen-traditional/console.c
+@@ -1399,14 +1399,6 @@ void qemu_console_resize(DisplayState *ds, int width, int height)
+     }
+ }
+ 
+-void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
+-                int dst_x, int dst_y, int w, int h)
+-{
+-    if (is_graphic_console()) {
+-        dpy_copy(ds, src_x, src_y, dst_x, dst_y, w, h);
+-    }
+-}
+-
+ PixelFormat qemu_different_endianness_pixelformat(int bpp)
+ {
+     PixelFormat pf;
+diff --git a/console.h b/console.h
+index 14b42f3..8306cc4 100644
+--- tools/qemu-xen-traditional/console.h.orig
++++ tools/qemu-xen-traditional/console.h
+@@ -98,8 +98,6 @@ struct DisplayChangeListener {
+     void (*dpy_resize)(struct DisplayState *s);
+     void (*dpy_setdata)(struct DisplayState *s);
+     void (*dpy_refresh)(struct DisplayState *s);
+-    void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y,
+-                     int dst_x, int dst_y, int w, int h);
+     void (*dpy_fill)(struct DisplayState *s, int x, int y,
+                      int w, int h, uint32_t c);
+     void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
+@@ -211,18 +209,6 @@ static inline void dpy_refresh(DisplayState *s)
+     }
+ }
+ 
+-static inline void dpy_copy(struct DisplayState *s, int src_x, int src_y,
+-                             int dst_x, int dst_y, int w, int h) {
+-    struct DisplayChangeListener *dcl = s->listeners;
+-    while (dcl != NULL) {
+-        if (dcl->dpy_copy)
+-            dcl->dpy_copy(s, src_x, src_y, dst_x, dst_y, w, h);
+-        else /* TODO */
+-            dcl->dpy_update(s, dst_x, dst_y, w, h);
+-        dcl = dcl->next;
+-    }
+-}
+-
+ static inline void dpy_fill(struct DisplayState *s, int x, int y,
+                              int w, int h, uint32_t c) {
+     struct DisplayChangeListener *dcl = s->listeners;
+@@ -297,8 +283,6 @@ void text_consoles_set_display(DisplayState *ds);
+ void console_select(unsigned int index);
+ void console_color_init(DisplayState *ds);
+ void qemu_console_resize(DisplayState *ds, int width, int height);
+-void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
+-                int dst_x, int dst_y, int w, int h);
+ 
+ /* sdl.c */
+ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame, int opengl_enabled);
+diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
+index 06b4a3b..4e85b90 100644
+--- tools/qemu-xen-traditional/hw/cirrus_vga.c.orig
++++ tools/qemu-xen-traditional/hw/cirrus_vga.c
+@@ -793,11 +793,6 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
+         }
+     }
+ 
+-    /* we have to flush all pending changes so that the copy
+-       is generated at the appropriate moment in time */
+-    if (notify)
+-      vga_hw_update();
+-
+     (*s->cirrus_rop) (s, s->vram_ptr +
+                     (s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
+                     s->vram_ptr +
+@@ -806,13 +801,13 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
+                     s->cirrus_blt_width, s->cirrus_blt_height);
+ 
+     if (notify)
+-      qemu_console_copy(s->ds,
+-                        sx, sy, dx, dy,
+-                        s->cirrus_blt_width / depth,
+-                        s->cirrus_blt_height);
++      dpy_update(s->ds,
++                   dx, dy,
++                   s->cirrus_blt_width / depth,
++                   s->cirrus_blt_height);
+ 
+     /* we don't have to notify the display that this portion has
+-       changed since qemu_console_copy implies this */
++       changed since dpy_update implies this */
+ 
+     cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
+                               s->cirrus_blt_dstpitch, s->cirrus_blt_width,
+diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
+index d1cba28..c38e43c 100644
+--- tools/qemu-xen-traditional/hw/vmware_vga.c.orig
++++ tools/qemu-xen-traditional/hw/vmware_vga.c
+@@ -383,6 +383,7 @@ static inline void vmsvga_copy_rect(struct vmsvga_state_s *s,
+ 
+ # ifdef DIRECT_VRAM
+     if (s->ds->dpy_copy)
++#  error This configuration is not supported.  See XSA-211.
+         qemu_console_copy(s->ds, x0, y0, x1, y1, w, h);
+     else
+ # endif
+diff --git a/vnc.c b/vnc.c
+index 61d1555..0e61197 100644
+--- tools/qemu-xen-traditional/vnc.c.orig
++++ tools/qemu-xen-traditional/vnc.c
+@@ -572,36 +572,6 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
+           send_framebuffer_update_raw(vs, x, y, w, h);
+ }
+ 
+-static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
+-{
+-    VncState *vs = ds->opaque;
+-    int updating_client = 1;
+-
+-    if (!vs->update_requested ||
+-        src_x < vs->visible_x || src_y < vs->visible_y ||
+-      dst_x < vs->visible_x || dst_y < vs->visible_y ||
+-      (src_x + w) > (vs->visible_x + vs->visible_w) ||
+-      (src_y + h) > (vs->visible_y + vs->visible_h) ||
+-      (dst_x + w) > (vs->visible_x + vs->visible_w) ||
+-      (dst_y + h) > (vs->visible_y + vs->visible_h))
+-      updating_client = 0;
+-
+-    if (updating_client)
+-        _vnc_update_client(vs);
+-
+-    if (updating_client && vs->csock != -1 && !vs->has_update) {
+-      vnc_write_u8(vs, 0);  /* msg id */
+-      vnc_write_u8(vs, 0);
+-      vnc_write_u16(vs, 1); /* number of rects */
+-      vnc_framebuffer_update(vs, dst_x, dst_y, w, h, 1);
+-      vnc_write_u16(vs, src_x);
+-      vnc_write_u16(vs, src_y);
+-      vnc_flush(vs);
+-        vs->update_requested--;
+-    } else
+-      framebuffer_set_updated(vs, dst_x, dst_y, w, h);
+-}
+-
+ static int find_update_height(VncState *vs, int y, int maxy, int last_x, int x)
+ {
+     int h;
+@@ -1543,16 +1513,12 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
+     vs->has_pointer_type_change = 0;
+     vs->has_WMVi = 0;
+     vs->absolute = -1;
+-    dcl->dpy_copy = NULL;
+ 
+     for (i = n_encodings - 1; i >= 0; i--) {
+       switch (encodings[i]) {
+       case 0: /* Raw */
+           vs->has_hextile = 0;
+           break;
+-      case 1: /* CopyRect */
+-          dcl->dpy_copy = vnc_copy;
+-          break;
+       case 5: /* Hextile */
+           vs->has_hextile = 1;
+           break;
+@@ -2459,7 +2425,6 @@ static void vnc_listen_read(void *opaque)
+       vs->has_resize = 0;
+       vs->has_hextile = 0;
+         vs->update_requested = 0;
+-      dcl->dpy_copy = NULL;
+       vnc_timer_init(vs);
+     }
+ }
+-- 
+2.1.4
+
Index: pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.cfg.pod.5.in
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.cfg.pod.5.in:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.cfg.pod.5.in   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,29 @@
+$NetBSD: patch-docs_man_xl.cfg.pod.5.in,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- docs/man/xl.cfg.pod.5.in.orig      2017-03-24 17:42:46.000000000 +0100
++++ docs/man/xl.cfg.pod.5.in   2017-03-24 17:43:19.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
+@@ -2040,7 +2040,7 @@
+ 
+ =head1 FILES
+ 
+-F</etc/xen/NAME.cfg>
++F<@XENDCONFDIR@/NAME.cfg>
+ F<@XEN_DUMP_DIR@/NAME>
+ 
+ =head1 BUGS
Index: pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.conf.pod.5
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.conf.pod.5:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.conf.pod.5     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,37 @@
+$NetBSD: patch-docs_man_xl.conf.pod.5,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- docs/man/xl.conf.pod.5.orig        2016-12-05 13:03:27.000000000 +0100
++++ docs/man/xl.conf.pod.5     2017-03-24 17:37:53.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,13 +109,13 @@
+ 
+ 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<colo.default.proxyscript="PATH">
+ 
+ Configures the default script used by COLO to setup colo-proxy.
+ 
+-Default: C</etc/xen/scripts/colo-proxy-setup>
++Default: C<@XENDCONFDIR@/scripts/colo-proxy-setup>
+ 
+ =item B<output_format="json|sxp">
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.pod.1.in
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.pod.1.in:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-docs_man_xl.pod.1.in       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,44 @@
+$NetBSD: patch-docs_man_xl.pod.1.in,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- docs/man/xl.pod.1.in.orig  2017-03-24 17:39:08.000000000 +0100
++++ docs/man/xl.pod.1.in       2017-03-24 17:40:12.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>
+ 
+@@ -175,7 +175,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>
+@@ -528,7 +528,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>
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-docs_man_xlcpupool.cfg.pod.5
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-docs_man_xlcpupool.cfg.pod.5:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-docs_man_xlcpupool.cfg.pod.5       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,28 @@
+$NetBSD: patch-docs_man_xlcpupool.cfg.pod.5,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- docs/man/xlcpupool.cfg.pod.5.orig  2017-03-24 17:41:23.000000000 +0100
++++ docs/man/xlcpupool.cfg.pod.5       2017-03-24 17:41:50.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
+@@ -117,7 +117,7 @@
+ 
+ =head1 FILES
+ 
+-F</etc/xen/CPUPOOL.cfg>
++F<@XENDCONFDIR@/CPUPOOL.cfg>
+ 
+ =head1 BUGS
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-docs_misc_xl-disk-configuration.txt
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-docs_misc_xl-disk-configuration.txt:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-docs_misc_xl-disk-configuration.txt        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-docs_misc_xl-disk-configuration.txt,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- docs/misc/xl-disk-configuration.txt.orig   2015-11-03 10:11:18.000000000 +0100
++++ docs/misc/xl-disk-configuration.txt        2016-03-29 22:48:24.000000000 +0200
+@@ -173,7 +173,7 @@
+ 
+ Specifies that <target> is not a normal host path, but rather
+ information to be interpreted by the executable program <script>,
+-(looked for in /etc/xen/scripts, if it doesn't contain a slash).
++(looked for in @XENDCONFDIR@/scripts, if it doesn't contain a slash).
+ 
+ These scripts are normally called "block-<script>".
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_Config.mk
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_Config.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_Config.mk   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,17 @@
+--- extras/mini-os/Config.mk.orig      2017-03-27 19:37:46.000000000 +0200
++++ extras/mini-os/Config.mk   2017-03-27 19:38:46.000000000 +0200
+@@ -106,13 +106,7 @@
+ # Set tools
+ AS         = $(CROSS_COMPILE)as
+ LD         = $(CROSS_COMPILE)ld
+-ifeq ($(clang),y)
+-CC         = $(CROSS_COMPILE)clang
+-LD_LTO     = $(CROSS_COMPILE)llvm-ld
+-else
+-CC         = $(CROSS_COMPILE)gcc
+-LD_LTO     = $(CROSS_COMPILE)ld
+-endif
++CC         = $(TARGET_CC)
+ CPP        = $(CC) -E
+ AR         = $(CROSS_COMPILE)ar
+ RANLIB     = $(CROSS_COMPILE)ranlib
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_arch_x86_arch.mk
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_arch_x86_arch.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_arch_x86_arch.mk    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-extras_mini-os_arch_x86_arch.mk,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- extras/mini-os/arch/x86/arch.mk.orig       2017-03-27 16:41:50.000000000 +0200
++++ extras/mini-os/arch/x86/arch.mk    2017-03-27 16:43:37.000000000 +0200
+@@ -7,7 +7,7 @@
+ 
+ ifeq ($(MINIOS_TARGET_ARCH),x86_32)
+ ARCH_CFLAGS  := -m32 -march=i686
+-ARCH_LDFLAGS := -m elf_i386
++ARCH_LDFLAGS := -Wl,-melf_i386
+ ARCH_ASFLAGS := -m32
+ EXTRA_INC += $(TARGET_ARCH_FAM)/$(MINIOS_TARGET_ARCH)
+ EXTRA_SRC += arch/$(EXTRA_INC)
+@@ -17,7 +17,7 @@
+ ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks
+ ARCH_CFLAGS += -fno-asynchronous-unwind-tables
+ ARCH_ASFLAGS := -m64
+-ARCH_LDFLAGS := -m elf_x86_64
++ARCH_LDFLAGS := -Wl,-melf_x86_64
+ EXTRA_INC += $(TARGET_ARCH_FAM)/$(MINIOS_TARGET_ARCH)
+ EXTRA_SRC += arch/$(EXTRA_INC)
+ endif
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_fcntl.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_fcntl.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_fcntl.h     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-extras_mini-os_include_fcntl.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- extras/mini-os/include/fcntl.h.orig        2017-03-28 19:38:01.000000000 +0200
++++ extras/mini-os/include/fcntl.h     2017-03-28 19:38:12.000000000 +0200
+@@ -93,7 +93,7 @@
+ 
+ #endif
+ 
+-int open(const char *path, int flags, ...) asm("open64");
++int open(const char *path, int flags, ...);
+ int fcntl(int fd, int cmd, ...);
+ 
+ #endif
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_time.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_time.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_include_time.h      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-extras_mini-os_include_time.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- extras/mini-os/include/time.h.orig 2016-09-28 13:09:38.000000000 +0200
++++ extras/mini-os/include/time.h      2017-03-28 20:00:33.000000000 +0200
+@@ -48,7 +48,7 @@
+ 
+ #include <sys/time.h>
+ 
+-#ifdef HAVE_LIBC
++#if defined(HAVE_LIBC) && defined(NEED_TIME_H)
+ #include_next <time.h>
+ #endif
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lib_sys.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lib_sys.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lib_sys.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,15 @@
+--- extras/mini-os/lib//sys.c.orig     2017-03-28 13:14:26.000000000 +0200
++++ extras/mini-os/lib//sys.c  2017-03-28 13:14:39.000000000 +0200
+@@ -18,6 +18,12 @@
+ #define DEBUG(fmt,...)
+ #endif
+ 
++void __enable_execute_stack (void *);
++void
++__enable_execute_stack (void *addr __attribute__((__unused__)))
++{
++}
++
+ #ifdef HAVE_LIBC
+ #include <os.h>
+ #include <console.h>
Index: pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lock.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lock.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-extras_mini-os_lock.c      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,11 @@
+--- extras/mini-os/lock.c.orig 2017-03-28 12:14:33.000000000 +0200
++++ extras/mini-os/lock.c      2017-03-28 12:14:43.000000000 +0200
+@@ -4,7 +4,7 @@
+  * Samuel Thibault <Samuel.Thibault%eu.citrix.net@localhost>, July 20008
+  */
+ 
+-#ifdef HAVE_LIBC
++#if 0 /* def HAVE_LIBC */
+ 
+ #include <sys/lock.h>
+ #include <sched.h>
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_Makefile   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,296 @@
+$NetBSD: patch-stubdom_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/Makefile.orig      2016-12-05 13:03:27.000000000 +0100
++++ stubdom/Makefile   2017-03-29 09:58:39.000000000 +0200
+@@ -6,8 +6,6 @@
+ 
+ export stubdom=y
+ export debug=y
+-# Moved from config/StdGNU.mk
+-CFLAGS += -O1 -fno-omit-frame-pointer
+ 
+ ifeq (,$(findstring clean,$(MAKECMDGOALS)))
+   ifeq ($(wildcard $(MINI_OS)/Config.mk),)
+@@ -24,27 +22,27 @@
+ endif
+ 
+ ifeq ($(GNU_TARGET_ARCH), i686)
+-TARGET_CFLAGS=
++TARGET_CFLAGS=-O1 -fno-omit-frame-pointer
+ NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
+ STUBDOM_SUPPORTED=1
++MINIOS_TARGET_ARCH:=x86
+ endif
+ ifeq ($(GNU_TARGET_ARCH), x86_64)
+ TARGET_CFLAGS=-mno-red-zone
+ NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
+ STUBDOM_SUPPORTED=1
++MINIOS_TARGET_ARCH:=x86
+ endif
+ 
+ CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
+ CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
+ 
+ # Disable PIE/SSP if GCC supports them. They can break us.
+-TARGET_CFLAGS += $(CFLAGS)
+-TARGET_CPPFLAGS += $(CPPFLAGS)
+-$(call cc-options-add,TARGET_CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
++$(call cc-options-add,TARGET_CFLAGS,TARGET_CC,$(EMBEDDED_EXTRA_CFLAGS))
+ 
+ # Do not use host headers and libs
+-GCC_INSTALL = $(shell LANG=C gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
+-TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
++GCC_INSTALL = $(shell LANG=C ${TARGET_CC} -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
++TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __NetBSD__ -U __sun__
+ TARGET_CPPFLAGS += -nostdinc
+ TARGET_CPPFLAGS += -isystem $(MINI_OS)/include/posix
+ TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
+@@ -74,11 +72,8 @@
+ # Cross-newlib
+ ##############
+ 
+-newlib-$(NEWLIB_VERSION).tar.gz:
+-      $(FETCHER) $@ $(NEWLIB_URL)/$@
+-
+-newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
+-      tar xzf $<
++newlib-$(NEWLIB_VERSION): 
++      cp -r ${WRKSRC}/../newlib-$(NEWLIB_VERSION) .
+       patch -d $@ -p0 < newlib.patch
+       patch -d $@ -p0 < newlib-chk.patch
+       patch -d $@ -p1 < newlib-stdint-size_max-fix-from-1.17.0.patch
+@@ -92,7 +87,7 @@
+ $(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
+       mkdir -p newlib-$(XEN_TARGET_ARCH)
+       ( cd newlib-$(XEN_TARGET_ARCH) && \
+-        CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure 
--prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
++        CFLAGS_FOR_BUILD="$(CFLAGS)" CFLAGS="" CC_FOR_TARGET="$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS) -isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH)" 
AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf 
--enable-newlib-io-long-long --disable-multilib && \
+         $(MAKE) DESTDIR= && \
+         $(MAKE) DESTDIR= install )
+ 
+@@ -100,19 +95,15 @@
+ # Cross-zlib
+ ############
+ 
+-zlib-$(ZLIB_VERSION).tar.gz:
+-      $(FETCHER) $@ $(ZLIB_URL)/$@
+-
+-zlib-$(XEN_TARGET_ARCH): zlib-$(ZLIB_VERSION).tar.gz 
+-      tar xzf $<
+-      mv zlib-$(ZLIB_VERSION) $@
++zlib-$(XEN_TARGET_ARCH): 
++      cp -r ${WRKSRC}/../zlib-$(ZLIB_VERSION) $@
+ 
+ ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
+ .PHONY: cross-zlib
+ cross-zlib: $(ZLIB_STAMPFILE)
+ $(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
+       ( cd $< && \
+-        CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
++        CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(TARGET_CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
+         $(MAKE) DESTDIR= libz.a && \
+         $(MAKE) DESTDIR= install )
+ 
+@@ -120,12 +111,8 @@
+ # Cross-libpci
+ ##############
+ 
+-pciutils-$(LIBPCI_VERSION).tar.bz2:
+-      $(FETCHER) $@ $(LIBPCI_URL)/$@
+-
+-pciutils-$(XEN_TARGET_ARCH): pciutils-$(LIBPCI_VERSION).tar.bz2
+-      tar xjf $<
+-      mv pciutils-$(LIBPCI_VERSION) $@
++pciutils-$(XEN_TARGET_ARCH): 
++      cp -r ${WRKSRC}/../pciutils-$(LIBPCI_VERSION) $@
+       patch -d $@ -p1 < pciutils.patch
+       touch $@
+ 
+@@ -138,7 +125,7 @@
+         chmod u+w lib/config.h && \
+         echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
+         ln -sf ../../libpci.config.mak lib/config.mk && \
+-        $(MAKE) DESTDIR= CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(call realpath,$(MINI_OS)/include)" lib/libpci.a && \
++        $(MAKE) DESTDIR= CC="$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -isystem $(call realpath,$(MINI_OS)/include) -isystem $(call realpath,$(MINI_OS)/include/$(MINIOS_TARGET_ARCH)) 
-isystem $(call realpath,$(MINI_OS)/include/$(MINIOS_TARGET_ARCH)/$(XEN_TARGET_ARCH))" CPPFLAGS="" CFLAGS="" lib/libpci.a && \
+         $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
+         $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
+         $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
+@@ -148,12 +135,8 @@
+ # lwIP
+ ######
+ 
+-lwip-$(LWIP_VERSION).tar.gz:
+-      $(FETCHER) $@ $(LWIP_URL)/$@
+-
+-lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
+-      tar xzf $<
+-      mv lwip $@
++lwip-$(XEN_TARGET_ARCH): 
++      cp -r ${WRKSRC}/../lwip $@
+       patch -d $@ -p0 < lwip.patch-cvs
+       patch -d $@ -p0 < lwip.dhcp_create_request-hwaddr_len.patch
+       touch $@
+@@ -161,19 +144,14 @@
+ #############
+ # cross-gmp
+ #############
+-gmp-$(GMP_VERSION).tar.bz2:
+-      $(FETCHER) $@ $(GMP_URL)/$@
+-
+ .PHONY: cross-gmp
+ ifeq ($(XEN_TARGET_ARCH), x86_32)
+    GMPEXT=ABI=32
+ endif
+-gmp-$(XEN_TARGET_ARCH): gmp-$(GMP_VERSION).tar.bz2 $(NEWLIB_STAMPFILE)
+-      tar xjf $<
+-      rm $@ -rf || :
+-      mv gmp-$(GMP_VERSION) $@
++gmp-$(XEN_TARGET_ARCH): $(NEWLIB_STAMPFILE)
++      cp -r ${WRKSRC}/../gmp-$(GMP_VERSION) $@
+       #patch -d $@ -p0 < gmp.patch
+-      cd $@; CPPFLAGS="-isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include $(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" CC=$(CC) $(GMPEXT) ./configure --disable-shared --enable-static 
--disable-fft --without-readline --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --libdir=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib --build=`gcc -dumpmachine` 
--host=$(GNU_TARGET_ARCH)-xen-elf
++      cd $@; CPPFLAGS="-isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include $(TARGET_CPPFLAGS) -isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH) -isystem $(MINI_OS)/include" 
CFLAGS="$(TARGET_CFLAGS)" CC=$(TARGET_CC) $(GMPEXT) ./configure --disable-shared --enable-static --disable-fft --without-readline --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf 
--libdir=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib --build=`${TARGET_CC} -dumpmachine` --host=$(GNU_TARGET_ARCH)-xen-elf
+       sed -i 's/#define HAVE_OBSTACK_VPRINTF 1/\/\/#define HAVE_OBSTACK_VPRINTF 1/' $@/config.h
+       touch $@
+ 
+@@ -187,12 +165,8 @@
+ #############
+ # cross-polarssl
+ #############
+-polarssl-$(POLARSSL_VERSION)-gpl.tgz:
+-      $(FETCHER) $@ $(POLARSSL_URL)/$@
+-
+-polarssl-$(XEN_TARGET_ARCH): polarssl-$(POLARSSL_VERSION)-gpl.tgz
+-      tar xzf $<
+-      mv polarssl-$(POLARSSL_VERSION) $@
++polarssl-$(XEN_TARGET_ARCH): 
++      cp -r ${WRKSRC}/../polarssl-$(POLARSSL_VERSION) $@
+       patch -d $@ -p1 < polarssl.patch
+       touch $@
+ 
+@@ -200,7 +174,7 @@
+ cross-polarssl: $(POLARSSL_STAMPFILE)
+ $(POLARSSL_STAMPFILE): polarssl-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) lwip-$(XEN_TARGET_ARCH)
+        ( cd $</library && \
+-         make CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I $(realpath $(MINI_OS)/include)" && \
++         $(MAKE) CFLAGS="" CC="$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I../include" && \
+          mkdir -p $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include && \
+          cp -r ../include/* $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include && \
+          mkdir -p $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib && \
+@@ -209,13 +183,10 @@
+ #############
+ # cross-tpmemu
+ #############
+-tpm_emulator-$(TPMEMU_VERSION).tar.gz:
+-      $(FETCHER) $@ $(TPMEMU_URL)/$@
+-
+-tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz
++VTPM_CPPFLAGS=$(TARGET_CPPFLAGS) -isystem $(MINI_OS)/include -isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH)/$(XEN_TARGET_ARCH) -isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH)
++tpm_emulator-$(XEN_TARGET_ARCH): 
+       @if [ ! -f "$(CMAKE)" ]; then echo "cmake not installed! Install it and then rerun ./configure!"; false; fi
+-      tar xzf $<
+-      mv tpm_emulator-$(TPMEMU_VERSION) $@
++      cp -r ${WRKSRC}/../tpm_emulator-$(TPMEMU_VERSION) $@
+       patch -d $@ -p1 < tpmemu-$(TPMEMU_VERSION).patch;
+       patch -d $@ -p1 < vtpm-bufsize.patch
+       patch -d $@ -p1 < vtpm-locality.patch
+@@ -224,7 +195,7 @@
+       patch -d $@ -p1 < vtpm-deepquote-anyloc.patch
+       patch -d $@ -p1 < vtpm-cmake-Wextra.patch
+       mkdir $@/build
+-      cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
++      cd $@/build; CC=${TARGET_CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=gnu99 -DTPM_NO_EXTERN $(VTPM_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
+       touch $@
+ 
+ TPMEMU_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libtpm.a
+@@ -243,11 +214,8 @@
+ CAMLLIB = $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ocaml
+ OCAML_STAMPFILE=$(CAMLLIB)/.dirstamp
+ 
+-ocaml-$(OCAML_VERSION).tar.gz:
+-      $(FETCHER) $@ $(OCAML_URL)/$@
+-
+-ocaml-$(XEN_TARGET_ARCH)/.dirstamp: ocaml-$(OCAML_VERSION).tar.gz ocaml.patch
+-      tar xzf $<
++ocaml-$(XEN_TARGET_ARCH)/.dirstamp: ocaml.patch
++      cp -r ${WRKSRC}/../ocaml-$(OCAML_VERSION) .
+       cd ocaml-$(OCAML_VERSION) && patch -p0 < ../ocaml.patch
+       rm -rf ocaml-$(XEN_TARGET_ARCH)
+       mv ocaml-$(OCAML_VERSION) ocaml-$(XEN_TARGET_ARCH)
+@@ -260,7 +228,7 @@
+ $(OCAML_STAMPFILE): ocaml-$(XEN_TARGET_ARCH)/.dirstamp
+       cd ocaml-$(XEN_TARGET_ARCH) &&  ./configure -prefix $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf \
+               -no-pthread -no-shared-libs -no-tk -no-curses \
+-              -cc "$(CC) -U_FORTIFY_SOURCE -fno-stack-protector -mno-red-zone"
++              -cc "$(TARGET_CC) -U_FORTIFY_SOURCE -fno-stack-protector -mno-red-zone"
+       $(foreach i,$(MINIOS_HASNOT),sed -i 's,^\(#define HAS_$(i)\),//\1,' ocaml-$(XEN_TARGET_ARCH)/config/s.h ; )
+       $(MAKE) DESTDIR= -C ocaml-$(XEN_TARGET_ARCH) world
+       $(MAKE) DESTDIR= -C ocaml-$(XEN_TARGET_ARCH) opt
+@@ -374,7 +342,7 @@
+ .PHONY: libxentoollog
+ libxentoollog: libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a
+ libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
+-      CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog
++      CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" EXTRA_HOSTCFLAGS="" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog
+ 
+ #######
+ # libxenevtchn
+@@ -436,11 +404,12 @@
+         ( $(buildmakevars2shellvars); \
+           cd ioemu ; \
+           LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) \
+-          TARGET_CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat ioemu-minios-config.mk)" \
++          TARGET_CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat ioemu-minios-config.mk) -DNEED_TIME_H -isystem $(MINI_OS)/include -isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH)/$(XEN_TARGET_ARCH) 
-isystem $(MINI_OS)/include/$(MINIOS_TARGET_ARCH)" \
+           TARGET_CFLAGS="$(TARGET_CFLAGS)" \
+           TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
++          CPPFLAGS="" CFLAGS="" \
+           $(QEMU_ROOT)/xen-setup-stubdom )
+-      $(MAKE) DESTDIR= -C ioemu -f $(QEMU_ROOT)/Makefile
++      CPPFLAGS="" CFLAGS="" $(MAKE) DESTDIR= -C ioemu -f $(QEMU_ROOT)/Makefile
+ 
+ ######
+ # caml
+@@ -473,7 +442,7 @@
+ 
+ .PHONY: vtpm
+ vtpm: cross-polarssl cross-tpmemu vtpm-minios-config.mk
+-      XEN_TARGET_ARCH="$(XEN_TARGET_ARCH)" CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat vtpm-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
++      XEN_TARGET_ARCH="$(XEN_TARGET_ARCH)" CPPFLAGS="$(VTPM_CPPFLAGS) $(shell cat vtpm-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS) -std=gnu99" $(MAKE) -C $@
+ 
+ ######
+ # VTPMMGR
+@@ -484,18 +453,14 @@
+ 
+ .PHONY: vtpmmgr
+ vtpmmgr: cross-polarssl vtpmmgr-minios-config.mk
+-      XEN_TARGET_ARCH="$(XEN_TARGET_ARCH)" CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat vtpmmgr-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
++      XEN_TARGET_ARCH="$(XEN_TARGET_ARCH)" CPPFLAGS="$(VTPM_CPPFLAGS) $(shell cat vtpmmgr-minios-config.mk) -DHAVE_LIBC" CFLAGS="$(TARGET_CFLAGS) -std=gnu99" $(MAKE) -C $@
+ 
+ ######
+ # Grub
+ ######
+ 
+-grub-$(GRUB_VERSION).tar.gz:
+-      $(FETCHER) $@ $(GRUB_URL)/$@
+-
+-grub-upstream: grub-$(GRUB_VERSION).tar.gz
+-      tar xzf $<
+-      mv grub-$(GRUB_VERSION) $@
++grub-upstream: 
++      cp -r ${WRKSRC}/../grub-$(GRUB_VERSION) $@
+       for i in grub.patches/* ; do \
+               patch -d $@ -p1 < $$i || exit 1; \
+       done
+@@ -538,11 +503,11 @@
+ 
+ .PHONY: vtpm-stubdom
+ vtpm-stubdom: mini-os-$(XEN_TARGET_ARCH)-vtpm vtpm
+-      DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpm/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
APP_OBJS="$(CURDIR)/vtpm/vtpm.a" APP_LDLIBS="-ltpm -ltpm_crypto -lgmp -lpolarssl"
++      DEF_CPPFLAGS="$(VTPM_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpm/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
APP_OBJS="$(CURDIR)/vtpm/vtpm.a" APP_LDLIBS="-ltpm -ltpm_crypto -lgmp -lpolarssl"
+ 
+ .PHONY: vtpmmgr-stubdom
+ vtpmmgr-stubdom: mini-os-$(XEN_TARGET_ARCH)-vtpmmgr vtpmmgr
+-      DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpmmgr/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
APP_OBJS="$(CURDIR)/vtpmmgr/vtpmmgr.a" APP_LDLIBS="-lm -lpolarssl"
++      DEF_CPPFLAGS="$(VTPM_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpmmgr/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
APP_OBJS="$(CURDIR)/vtpmmgr/vtpmmgr.a" APP_LDLIBS="-lm -lpolarssl"
+ 
+ .PHONY: pv-grub
+ pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_newlib.patch
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_newlib.patch:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_newlib.patch       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,26 @@
+$NetBSD: patch-stubdom_newlib.patch,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- stubdom/newlib.patch.orig  2016-12-05 13:03:27.000000000 +0100
++++ stubdom/newlib.patch       2017-03-28 13:34:23.000000000 +0200
+@@ -663,21 +663,6 @@
+  extern int _fcntl _PARAMS ((int, int, ...));
+  #ifdef __LARGE64_FILES
+  extern int _open64 _PARAMS ((const char *, int, ...));
+---- ./newlib/libc/include/sys/unistd.h.orig   2008-08-07 15:09:36.449280000 +0100
+-+++ ./newlib/libc/include/sys/unistd.h        2008-08-07 15:09:51.210370000 +0100
+-@@ -101,7 +101,11 @@
+- int     _EXFUN(link, (const char *__path1, const char *__path2 ));
+- int  _EXFUN(nice, (int __nice_value ));
+- #if !defined(__INSIDE_CYGWIN__)
+--off_t   _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
+-+off_t   _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ))
+-+#ifdef __MINIOS__
+-+    asm("lseek64")
+-+#endif
+-+    ;
+- #endif
+- #if defined(__SPU__)
+- #define F_ULOCK      0
+ --- ./newlib/libc/include/sys/stat.h.orig     2008-08-07 16:08:50.495116000 +0100
+ +++ ./newlib/libc/include/sys/stat.h  2008-08-07 16:10:21.799753000 +0100
+ @@ -49,6 +49,9 @@
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_marshal.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_marshal.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_marshal.h  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,587 @@
+$NetBSD: patch-stubdom_vtpmmgr_marshal.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/vtpmmgr/marshal.h.orig     2017-03-28 16:07:11.000000000 +0200
++++ stubdom/vtpmmgr/marshal.h  2017-03-28 16:08:28.000000000 +0200
+@@ -47,17 +47,17 @@
+       UNPACK_ALLOC
+ } UnpackPtr;
+ 
+-inline BYTE* pack_BYTE(BYTE* ptr, BYTE t) {
++static inline BYTE* pack_BYTE(BYTE* ptr, BYTE t) {
+       ptr[0] = t;
+       return ++ptr;
+ }
+ 
+-inline BYTE* unpack_BYTE(BYTE* ptr, BYTE* t) {
++static inline BYTE* unpack_BYTE(BYTE* ptr, BYTE* t) {
+       t[0] = ptr[0];
+       return ++ptr;
+ }
+ 
+-inline int unpack3_BYTE(BYTE* ptr, UINT32* pos, UINT32 max, BYTE *t)
++static inline int unpack3_BYTE(BYTE* ptr, UINT32* pos, UINT32 max, BYTE *t)
+ {
+       if (*pos + 1 > max)
+               return TPM_SIZE;
+@@ -72,19 +72,19 @@
+ #define unpack3_BOOL(p, x, m, t) unpack3_BYTE(p, x, m, t)
+ #define sizeof_BOOL(t) 1
+ 
+-inline BYTE* pack_UINT16(void* ptr, UINT16 t) {
++static inline BYTE* pack_UINT16(void* ptr, UINT16 t) {
+       UINT16* p = ptr;
+       *p = cpu_to_be16(t);
+       return ptr + sizeof(UINT16);
+ }
+ 
+-inline BYTE* unpack_UINT16(void* ptr, UINT16* t) {
++static inline BYTE* unpack_UINT16(void* ptr, UINT16* t) {
+       UINT16* p = ptr;
+       *t = be16_to_cpu(*p);
+       return ptr + sizeof(UINT16);
+ }
+ 
+-inline int unpack3_UINT16(BYTE* ptr, UINT32* pos, UINT32 max, UINT16 *t)
++static inline int unpack3_UINT16(BYTE* ptr, UINT32* pos, UINT32 max, UINT16 *t)
+ {
+       if (*pos + 2 > max)
+               return TPM_SIZE;
+@@ -93,19 +93,19 @@
+       return 0;
+ }
+ 
+-inline BYTE* pack_UINT32(void* ptr, UINT32 t) {
++static inline BYTE* pack_UINT32(void* ptr, UINT32 t) {
+       UINT32* p = ptr;
+       *p = cpu_to_be32(t);
+       return ptr + sizeof(UINT32);
+ }
+ 
+-inline BYTE* unpack_UINT32(void* ptr, UINT32* t) {
++static inline BYTE* unpack_UINT32(void* ptr, UINT32* t) {
+       UINT32* p = ptr;
+       *t = be32_to_cpu(*p);
+       return ptr + sizeof(UINT32);
+ }
+ 
+-inline int unpack3_UINT32(BYTE* ptr, UINT32* pos, UINT32 max, UINT32 *t)
++static inline int unpack3_UINT32(BYTE* ptr, UINT32* pos, UINT32 max, UINT32 *t)
+ {
+       if (*pos + 4 > max)
+               return TPM_SIZE;
+@@ -236,17 +236,17 @@
+ #define sizeof_TCS_KEY_HANDLE(t) sizeof_UINT32(t)
+ 
+ 
+-inline BYTE* pack_BUFFER(BYTE* ptr, const BYTE* buf, UINT32 size) {
++static inline BYTE* pack_BUFFER(BYTE* ptr, const BYTE* buf, UINT32 size) {
+       memcpy(ptr, buf, size);
+       return ptr + size;
+ }
+ 
+-inline BYTE* unpack_BUFFER(BYTE* ptr, BYTE* buf, UINT32 size) {
++static inline BYTE* unpack_BUFFER(BYTE* ptr, BYTE* buf, UINT32 size) {
+       memcpy(buf, ptr, size);
+       return ptr + size;
+ }
+ 
+-inline int unpack3_BUFFER(BYTE* ptr, UINT32* pos, UINT32 max, BYTE* buf, UINT32 size) {
++static inline int unpack3_BUFFER(BYTE* ptr, UINT32* pos, UINT32 max, BYTE* buf, UINT32 size) {
+       if (*pos + size > max)
+               return TPM_SIZE;
+       memcpy(buf, ptr + *pos, size);
+@@ -256,12 +256,12 @@
+ 
+ #define sizeof_BUFFER(b, s) s
+ 
+-inline BYTE* unpack_ALIAS(BYTE* ptr, BYTE** buf, UINT32 size) {
++static inline BYTE* unpack_ALIAS(BYTE* ptr, BYTE** buf, UINT32 size) {
+       *buf = ptr;
+       return ptr + size;
+ }
+ 
+-inline BYTE* unpack_ALLOC(BYTE* ptr, BYTE** buf, UINT32 size) {
++static inline BYTE* unpack_ALLOC(BYTE* ptr, BYTE** buf, UINT32 size) {
+       if(size) {
+               *buf = malloc(size);
+               memcpy(*buf, ptr, size);
+@@ -271,7 +271,7 @@
+       return ptr + size;
+ }
+ 
+-inline BYTE* unpack_PTR(BYTE* ptr, BYTE** buf, UINT32 size, UnpackPtr alloc) {
++static inline BYTE* unpack_PTR(BYTE* ptr, BYTE** buf, UINT32 size, UnpackPtr alloc) {
+       if(alloc == UNPACK_ALLOC) {
+               return unpack_ALLOC(ptr, buf, size);
+       } else {
+@@ -279,7 +279,7 @@
+       }
+ }
+ 
+-inline int unpack3_PTR(BYTE* ptr, UINT32* pos, UINT32 max, BYTE** buf, UINT32 size, UnpackPtr alloc) {
++static inline int unpack3_PTR(BYTE* ptr, UINT32* pos, UINT32 max, BYTE** buf, UINT32 size, UnpackPtr alloc) {
+       if (size > max || *pos + size > max)
+               return TPM_SIZE;
+       if (alloc == UNPACK_ALLOC) {
+@@ -292,15 +292,15 @@
+ }
+ #define unpack3_VPTR(ptr, pos, max, buf, size, alloc) unpack3_PTR(ptr, pos, max, (void*)(buf), size, alloc)
+ 
+-inline BYTE* pack_TPM_AUTHDATA(BYTE* ptr, const TPM_AUTHDATA* d) {
++static inline BYTE* pack_TPM_AUTHDATA(BYTE* ptr, const TPM_AUTHDATA* d) {
+       return pack_BUFFER(ptr, *d, TPM_DIGEST_SIZE);
+ }
+ 
+-inline BYTE* unpack_TPM_AUTHDATA(BYTE* ptr, TPM_AUTHDATA* d) {
++static inline BYTE* unpack_TPM_AUTHDATA(BYTE* ptr, TPM_AUTHDATA* d) {
+       return unpack_BUFFER(ptr, *d, TPM_DIGEST_SIZE);
+ }
+ 
+-inline int unpack3_TPM_AUTHDATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTHDATA* d) {
++static inline int unpack3_TPM_AUTHDATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTHDATA* d) {
+       return unpack3_BUFFER(ptr, pos, len, *d, TPM_DIGEST_SIZE);
+ }
+ 
+@@ -325,7 +325,7 @@
+ #define sizeof_TPM_TAG(t) sizeof_UINT16(t)
+ #define sizeof_TPM_STRUCTURE_TAG(t) sizeof_UINT16(t)
+ 
+-inline BYTE* pack_TPM_VERSION(BYTE* ptr, const TPM_VERSION* t) {
++static inline BYTE* pack_TPM_VERSION(BYTE* ptr, const TPM_VERSION* t) {
+       ptr[0] = t->major;
+       ptr[1] = t->minor;
+       ptr[2] = t->revMajor;
+@@ -333,7 +333,7 @@
+       return ptr + 4;
+ }
+ 
+-inline BYTE* unpack_TPM_VERSION(BYTE* ptr, TPM_VERSION* t) {
++static inline BYTE* unpack_TPM_VERSION(BYTE* ptr, TPM_VERSION* t) {
+       t->major = ptr[0];
+       t->minor = ptr[1];
+       t->revMajor = ptr[2];
+@@ -341,7 +341,7 @@
+       return ptr + 4;
+ }
+ 
+-inline int unpack3_TPM_VERSION(BYTE* ptr, UINT32 *pos, UINT32 max, TPM_VERSION* t) {
++static inline int unpack3_TPM_VERSION(BYTE* ptr, UINT32 *pos, UINT32 max, TPM_VERSION* t) {
+       if (*pos + 4 > max)
+               return TPM_SIZE;
+       ptr += *pos;
+@@ -355,7 +355,7 @@
+ 
+ #define sizeof_TPM_VERSION(x) 4
+ 
+-inline BYTE* pack_TPM_CAP_VERSION_INFO(BYTE* ptr, const TPM_CAP_VERSION_INFO* v) {
++static inline BYTE* pack_TPM_CAP_VERSION_INFO(BYTE* ptr, const TPM_CAP_VERSION_INFO* v) {
+       ptr = pack_TPM_STRUCTURE_TAG(ptr, v->tag);
+       ptr = pack_TPM_VERSION(ptr, &v->version);
+       ptr = pack_UINT16(ptr, v->specLevel);
+@@ -366,7 +366,7 @@
+       return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM_CAP_VERSION_INFO(BYTE* ptr, TPM_CAP_VERSION_INFO* v, UnpackPtr alloc) {
++static inline BYTE* unpack_TPM_CAP_VERSION_INFO(BYTE* ptr, TPM_CAP_VERSION_INFO* v, UnpackPtr alloc) {
+       ptr = unpack_TPM_STRUCTURE_TAG(ptr, &v->tag);
+       ptr = unpack_TPM_VERSION(ptr, &v->version);
+       ptr = unpack_UINT16(ptr, &v->specLevel);
+@@ -377,15 +377,15 @@
+       return ptr;
+ }
+ 
+-inline BYTE* pack_TPM_DIGEST(BYTE* ptr, const TPM_DIGEST* d) {
++static inline BYTE* pack_TPM_DIGEST(BYTE* ptr, const TPM_DIGEST* d) {
+       return pack_BUFFER(ptr, d->digest, TPM_DIGEST_SIZE);
+ }
+ 
+-inline BYTE* unpack_TPM_DIGEST(BYTE* ptr, TPM_DIGEST* d) {
++static inline BYTE* unpack_TPM_DIGEST(BYTE* ptr, TPM_DIGEST* d) {
+       return unpack_BUFFER(ptr, d->digest, TPM_DIGEST_SIZE);
+ }
+ 
+-inline int unpack3_TPM_DIGEST(BYTE* ptr, UINT32* pos, UINT32 max, TPM_DIGEST* d) {
++static inline int unpack3_TPM_DIGEST(BYTE* ptr, UINT32* pos, UINT32 max, TPM_DIGEST* d) {
+       return unpack3_BUFFER(ptr, pos, max, d->digest, TPM_DIGEST_SIZE);
+ }
+ 
+@@ -409,72 +409,72 @@
+ #define pack_TPM_CHOSENID_HASH(ptr, d) pack_TPM_DIGEST(ptr, d)
+ #define unpack_TPM_CHOSENID_HASH(ptr, d) unpack_TPM_DIGEST(ptr, d)
+ 
+-inline BYTE* pack_TPM_NONCE(BYTE* ptr, const TPM_NONCE* n) {
++static inline BYTE* pack_TPM_NONCE(BYTE* ptr, const TPM_NONCE* n) {
+       return pack_BUFFER(ptr, n->nonce, TPM_DIGEST_SIZE);
+ }
+ 
+-inline BYTE* unpack_TPM_NONCE(BYTE* ptr, TPM_NONCE* n) {
++static inline BYTE* unpack_TPM_NONCE(BYTE* ptr, TPM_NONCE* n) {
+       return unpack_BUFFER(ptr, n->nonce, TPM_DIGEST_SIZE);
+ }
+ 
+ #define sizeof_TPM_NONCE(x) TPM_DIGEST_SIZE
+ 
+-inline int unpack3_TPM_NONCE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_NONCE* n) {
++static inline int unpack3_TPM_NONCE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_NONCE* n) {
+       return unpack3_BUFFER(ptr, pos, max, n->nonce, TPM_DIGEST_SIZE);
+ }
+ 
+-inline BYTE* pack_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, const TPM_SYMMETRIC_KEY_PARMS* k) {
++static inline BYTE* pack_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, const TPM_SYMMETRIC_KEY_PARMS* k) {
+       ptr = pack_UINT32(ptr, k->keyLength);
+       ptr = pack_UINT32(ptr, k->blockSize);
+       ptr = pack_UINT32(ptr, k->ivSize);
+       return pack_BUFFER(ptr, k->IV, k->ivSize);
+ }
+ 
+-inline BYTE* pack_TPM_SYMMETRIC_KEY(BYTE* ptr, const TPM_SYMMETRIC_KEY* k) {
++static inline BYTE* pack_TPM_SYMMETRIC_KEY(BYTE* ptr, const TPM_SYMMETRIC_KEY* k) {
+       ptr = pack_UINT32(ptr, k->algId);
+       ptr = pack_UINT16(ptr, k->encScheme);
+       ptr = pack_UINT16(ptr, k->size);
+       return pack_BUFFER(ptr, k->data, k->size);
+ }
+ 
+-inline int unpack3_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY_PARMS* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY_PARMS* k, UnpackPtr alloc) {
+       return unpack3_UINT32(ptr, pos, max, &k->keyLength) ||
+               unpack3_UINT32(ptr, pos, max, &k->blockSize) ||
+               unpack3_UINT32(ptr, pos, max, &k->ivSize) ||
+               unpack3_PTR(ptr, pos, max, &k->IV, k->ivSize, alloc);
+ }
+ 
+-inline int sizeof_TPM_SYMMETRIC_KEY_PARMS(const TPM_SYMMETRIC_KEY_PARMS* k) {
++static inline int sizeof_TPM_SYMMETRIC_KEY_PARMS(const TPM_SYMMETRIC_KEY_PARMS* k) {
+       return 12 + k->ivSize;
+ }
+ 
+-inline int unpack3_TPM_SYMMETRIC_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_SYMMETRIC_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY* k, UnpackPtr alloc) {
+       return unpack3_UINT32(ptr, pos, max, &k->algId) ||
+               unpack3_UINT16(ptr, pos, max, &k->encScheme) ||
+               unpack3_UINT16(ptr, pos, max, &k->size) ||
+               unpack3_PTR(ptr, pos, max, &k->data, k->size, alloc);
+ }
+ 
+-inline BYTE* pack_TPM_RSA_KEY_PARMS(BYTE* ptr, const TPM_RSA_KEY_PARMS* k) {
++static inline BYTE* pack_TPM_RSA_KEY_PARMS(BYTE* ptr, const TPM_RSA_KEY_PARMS* k) {
+       ptr = pack_UINT32(ptr, k->keyLength);
+       ptr = pack_UINT32(ptr, k->numPrimes);
+       ptr = pack_UINT32(ptr, k->exponentSize);
+       return pack_BUFFER(ptr, k->exponent, k->exponentSize);
+ }
+ 
+-inline int unpack3_TPM_RSA_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_RSA_KEY_PARMS* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_RSA_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_RSA_KEY_PARMS* k, UnpackPtr alloc) {
+       return unpack3_UINT32(ptr, pos, max, &k->keyLength) ||
+               unpack3_UINT32(ptr, pos, max, &k->numPrimes) ||
+               unpack3_UINT32(ptr, pos, max, &k->exponentSize) ||
+               unpack3_PTR(ptr, pos, max, &k->exponent, k->exponentSize, alloc);
+ }
+ 
+-inline int sizeof_TPM_RSA_KEY_PARMS(const TPM_RSA_KEY_PARMS* k) {
++static inline int sizeof_TPM_RSA_KEY_PARMS(const TPM_RSA_KEY_PARMS* k) {
+       return 12 + k->exponentSize;
+ }
+ 
+ 
+-inline BYTE* pack_TPM_KEY_PARMS(BYTE* ptr, const TPM_KEY_PARMS* k) {
++static inline BYTE* pack_TPM_KEY_PARMS(BYTE* ptr, const TPM_KEY_PARMS* k) {
+       ptr = pack_TPM_ALGORITHM_ID(ptr, k->algorithmID);
+       ptr = pack_TPM_ENC_SCHEME(ptr, k->encScheme);
+       ptr = pack_TPM_SIG_SCHEME(ptr, k->sigScheme);
+@@ -493,7 +493,7 @@
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 len, TPM_KEY_PARMS* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 len, TPM_KEY_PARMS* k, UnpackPtr alloc) {
+       int rc = unpack3_TPM_ALGORITHM_ID(ptr, pos, len, &k->algorithmID) ||
+               unpack3_TPM_ENC_SCHEME(ptr, pos, len, &k->encScheme) ||
+               unpack3_TPM_SIG_SCHEME(ptr, pos, len, &k->sigScheme) ||
+@@ -511,7 +511,7 @@
+       return TPM_FAIL;
+ }
+ 
+-inline int sizeof_TPM_KEY_PARMS(const TPM_KEY_PARMS* k) {
++static inline int sizeof_TPM_KEY_PARMS(const TPM_KEY_PARMS* k) {
+       int rc = 0;
+       rc += sizeof_TPM_ALGORITHM_ID(&k->algorithmID);
+       rc += sizeof_TPM_ENC_SCHEME(&k->encScheme);
+@@ -532,66 +532,66 @@
+       return rc;
+ }
+ 
+-inline BYTE* pack_TPM_STORE_PUBKEY(BYTE* ptr, const TPM_STORE_PUBKEY* k) {
++static inline BYTE* pack_TPM_STORE_PUBKEY(BYTE* ptr, const TPM_STORE_PUBKEY* k) {
+       ptr = pack_UINT32(ptr, k->keyLength);
+       ptr = pack_BUFFER(ptr, k->key, k->keyLength);
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_STORE_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_STORE_PUBKEY* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_STORE_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_STORE_PUBKEY* k, UnpackPtr alloc) {
+       return unpack3_UINT32(ptr, pos, max, &k->keyLength) ||
+               unpack3_PTR(ptr, pos, max, &k->key, k->keyLength, alloc);
+ }
+ 
+-inline int sizeof_TPM_STORE_PUBKEY(const TPM_STORE_PUBKEY* k) {
++static inline int sizeof_TPM_STORE_PUBKEY(const TPM_STORE_PUBKEY* k) {
+       return 4 + k->keyLength;
+ }
+ 
+-inline BYTE* pack_TPM_PUBKEY(BYTE* ptr, const TPM_PUBKEY* k) {
++static inline BYTE* pack_TPM_PUBKEY(BYTE* ptr, const TPM_PUBKEY* k) {
+       ptr = pack_TPM_KEY_PARMS(ptr, &k->algorithmParms);
+       return pack_TPM_STORE_PUBKEY(ptr, &k->pubKey);
+ }
+ 
+-inline int unpack3_TPM_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 len, TPM_PUBKEY* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 len, TPM_PUBKEY* k, UnpackPtr alloc) {
+       return unpack3_TPM_KEY_PARMS(ptr, pos, len, &k->algorithmParms, alloc) ||
+               unpack3_TPM_STORE_PUBKEY(ptr, pos, len, &k->pubKey, alloc);
+ }
+ 
+-inline BYTE* pack_TPM_PCR_SELECTION(BYTE* ptr, const TPM_PCR_SELECTION* p) {
++static inline BYTE* pack_TPM_PCR_SELECTION(BYTE* ptr, const TPM_PCR_SELECTION* p) {
+       ptr = pack_UINT16(ptr, p->sizeOfSelect);
+       ptr = pack_BUFFER(ptr, p->pcrSelect, p->sizeOfSelect);
+       return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM_PCR_SELECTION(BYTE* ptr, TPM_PCR_SELECTION* p, UnpackPtr alloc) {
++static inline BYTE* unpack_TPM_PCR_SELECTION(BYTE* ptr, TPM_PCR_SELECTION* p, UnpackPtr alloc) {
+       ptr = unpack_UINT16(ptr, &p->sizeOfSelect);
+       ptr = unpack_PTR(ptr, &p->pcrSelect, p->sizeOfSelect, alloc);
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_PCR_SELECTION(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_SELECTION* p, UnpackPtr alloc) {
++static inline int unpack3_TPM_PCR_SELECTION(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_SELECTION* p, UnpackPtr alloc) {
+       return unpack3_UINT16(ptr, pos, max, &p->sizeOfSelect) ||
+               unpack3_PTR(ptr, pos, max, &p->pcrSelect, p->sizeOfSelect, alloc);
+ }
+ 
+-inline int sizeof_TPM_PCR_SELECTION(const TPM_PCR_SELECTION* p) {
++static inline int sizeof_TPM_PCR_SELECTION(const TPM_PCR_SELECTION* p) {
+       return 2 + p->sizeOfSelect;
+ }
+ 
+-inline BYTE* pack_TPM_PCR_INFO(BYTE* ptr, const TPM_PCR_INFO* p) {
++static inline BYTE* pack_TPM_PCR_INFO(BYTE* ptr, const TPM_PCR_INFO* p) {
+       ptr = pack_TPM_PCR_SELECTION(ptr, &p->pcrSelection);
+       ptr = pack_TPM_COMPOSITE_HASH(ptr, &p->digestAtRelease);
+       ptr = pack_TPM_COMPOSITE_HASH(ptr, &p->digestAtCreation);
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_PCR_INFO(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO* p, UnpackPtr alloc) {
++static inline int unpack3_TPM_PCR_INFO(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO* p, UnpackPtr alloc) {
+       return unpack3_TPM_PCR_SELECTION(ptr, pos, max, &p->pcrSelection, alloc) ||
+               unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtRelease) ||
+               unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtCreation);
+ }
+ 
+-inline int sizeof_TPM_PCR_INFO(const TPM_PCR_INFO* p) {
++static inline int sizeof_TPM_PCR_INFO(const TPM_PCR_INFO* p) {
+       int rc = 0;
+       rc += sizeof_TPM_PCR_SELECTION(&p->pcrSelection);
+       rc += sizeof_TPM_COMPOSITE_HASH(&p->digestAtRelease);
+@@ -599,7 +599,7 @@
+       return rc;
+ }
+ 
+-inline BYTE* pack_TPM_PCR_INFO_LONG(BYTE* ptr, const TPM_PCR_INFO_LONG* p) {
++static inline BYTE* pack_TPM_PCR_INFO_LONG(BYTE* ptr, const TPM_PCR_INFO_LONG* p) {
+       ptr = pack_TPM_STRUCTURE_TAG(ptr, p->tag);
+       ptr = pack_TPM_LOCALITY_SELECTION(ptr, p->localityAtCreation);
+       ptr = pack_TPM_LOCALITY_SELECTION(ptr, p->localityAtRelease);
+@@ -610,7 +610,7 @@
+       return ptr;
+ }
+ 
+-inline int sizeof_TPM_PCR_INFO_LONG(const TPM_PCR_INFO_LONG* p) {
++static inline int sizeof_TPM_PCR_INFO_LONG(const TPM_PCR_INFO_LONG* p) {
+       int rc = 0;
+       rc += sizeof_TPM_STRUCTURE_TAG(p->tag);
+       rc += sizeof_TPM_LOCALITY_SELECTION(p->localityAtCreation);
+@@ -622,7 +622,7 @@
+       return rc;
+ }
+ 
+-inline int unpack3_TPM_PCR_INFO_LONG(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO_LONG* p, UnpackPtr alloc) {
++static inline int unpack3_TPM_PCR_INFO_LONG(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO_LONG* p, UnpackPtr alloc) {
+       return unpack3_TPM_STRUCTURE_TAG(ptr, pos, max, &p->tag) ||
+               unpack3_TPM_LOCALITY_SELECTION(ptr, pos, max,
+                                              &p->localityAtCreation) ||
+@@ -637,20 +637,20 @@
+               unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtRelease);
+ }
+ 
+-inline BYTE* pack_TPM_PCR_COMPOSITE(BYTE* ptr, const TPM_PCR_COMPOSITE* p) {
++static inline BYTE* pack_TPM_PCR_COMPOSITE(BYTE* ptr, const TPM_PCR_COMPOSITE* p) {
+       ptr = pack_TPM_PCR_SELECTION(ptr, &p->select);
+       ptr = pack_UINT32(ptr, p->valueSize);
+       ptr = pack_BUFFER(ptr, (const BYTE*)p->pcrValue, p->valueSize);
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_PCR_COMPOSITE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_COMPOSITE* p, UnpackPtr alloc) {
++static inline int unpack3_TPM_PCR_COMPOSITE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_COMPOSITE* p, UnpackPtr alloc) {
+       return unpack3_TPM_PCR_SELECTION(ptr, pos, max, &p->select, alloc) ||
+               unpack3_UINT32(ptr, pos, max, &p->valueSize) ||
+               unpack3_PTR(ptr, pos, max, (BYTE**)&p->pcrValue, p->valueSize, alloc);
+ }
+ 
+-inline BYTE* pack_TPM_KEY(BYTE* ptr, const TPM_KEY* k) {
++static inline BYTE* pack_TPM_KEY(BYTE* ptr, const TPM_KEY* k) {
+       ptr = pack_TPM_VERSION(ptr, &k->ver);
+       ptr = pack_TPM_KEY_USAGE(ptr, k->keyUsage);
+       ptr = pack_TPM_KEY_FLAGS(ptr, k->keyFlags);
+@@ -665,7 +665,7 @@
+       return pack_BUFFER(ptr, k->encData, k->encDataSize);
+ }
+ 
+-inline int unpack3_TPM_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_KEY* k, UnpackPtr alloc) {
++static inline int unpack3_TPM_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_KEY* k, UnpackPtr alloc) {
+       int rc = unpack3_TPM_VERSION(ptr, pos, max, &k->ver) ||
+               unpack3_TPM_KEY_USAGE(ptr, pos, max, &k->keyUsage) ||
+               unpack3_TPM_KEY_FLAGS(ptr, pos, max, &k->keyFlags) ||
+@@ -682,7 +682,7 @@
+               unpack3_PTR(ptr, pos, max, &k->encData, k->encDataSize, alloc);
+ }
+ 
+-inline int sizeof_TPM_KEY(const TPM_KEY* k) {
++static inline int sizeof_TPM_KEY(const TPM_KEY* k) {
+       int rc = 0;
+       rc += sizeof_TPM_VERSION(&k->ver);
+       rc += sizeof_TPM_KEY_USAGE(k->keyUsage);
+@@ -699,19 +699,19 @@
+       return rc;
+ }
+ 
+-inline BYTE* pack_TPM_BOUND_DATA(BYTE* ptr, const TPM_BOUND_DATA* b, UINT32 payloadSize) {
++static inline BYTE* pack_TPM_BOUND_DATA(BYTE* ptr, const TPM_BOUND_DATA* b, UINT32 payloadSize) {
+       ptr = pack_TPM_VERSION(ptr, &b->ver);
+       ptr = pack_TPM_PAYLOAD_TYPE(ptr, b->payload);
+       return pack_BUFFER(ptr, b->payloadData, payloadSize);
+ }
+ 
+-inline BYTE* unpack_TPM_BOUND_DATA(BYTE* ptr, TPM_BOUND_DATA* b, UINT32 payloadSize, UnpackPtr alloc) {
++static inline BYTE* unpack_TPM_BOUND_DATA(BYTE* ptr, TPM_BOUND_DATA* b, UINT32 payloadSize, UnpackPtr alloc) {
+       ptr = unpack_TPM_VERSION(ptr, &b->ver);
+       ptr = unpack_TPM_PAYLOAD_TYPE(ptr, &b->payload);
+       return unpack_PTR(ptr, &b->payloadData, payloadSize, alloc);
+ }
+ 
+-inline BYTE* pack_TPM_STORED_DATA(BYTE* ptr, const TPM_STORED_DATA* d) {
++static inline BYTE* pack_TPM_STORED_DATA(BYTE* ptr, const TPM_STORED_DATA* d) {
+       ptr = pack_TPM_VERSION(ptr, &d->ver);
+       ptr = pack_UINT32(ptr, d->sealInfoSize);
+       if(d->sealInfoSize) {
+@@ -722,7 +722,7 @@
+       return ptr;
+ }
+ 
+-inline int sizeof_TPM_STORED_DATA(const TPM_STORED_DATA* d) {
++static inline int sizeof_TPM_STORED_DATA(const TPM_STORED_DATA* d) {
+       int rv = sizeof_TPM_VERSION(&d->ver) + sizeof_UINT32(d->sealInfoSize);
+       if (d->sealInfoSize) {
+               rv += sizeof_TPM_PCR_INFO(&d->sealInfo);
+@@ -732,7 +732,7 @@
+       return rv;
+ }
+ 
+-inline int unpack3_TPM_STORED_DATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA* d, UnpackPtr alloc) {
++static inline int unpack3_TPM_STORED_DATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA* d, UnpackPtr alloc) {
+       int rc = unpack3_TPM_VERSION(ptr, pos, len, &d->ver) ||
+               unpack3_UINT32(ptr, pos, len, &d->sealInfoSize);
+       if (rc)
+@@ -746,7 +746,7 @@
+       return rc;
+ }
+ 
+-inline BYTE* pack_TPM_STORED_DATA12(BYTE* ptr, const TPM_STORED_DATA12* d) {
++static inline BYTE* pack_TPM_STORED_DATA12(BYTE* ptr, const TPM_STORED_DATA12* d) {
+       ptr = pack_TPM_STRUCTURE_TAG(ptr, d->tag);
+       ptr = pack_TPM_ENTITY_TYPE(ptr, d->et);
+       ptr = pack_UINT32(ptr, d->sealInfoLongSize);
+@@ -758,7 +758,7 @@
+       return ptr;
+ }
+ 
+-inline int sizeof_TPM_STORED_DATA12(const TPM_STORED_DATA12* d) {
++static inline int sizeof_TPM_STORED_DATA12(const TPM_STORED_DATA12* d) {
+       int rv = sizeof_TPM_STRUCTURE_TAG(&d->ver) +
+                sizeof_TPM_ENTITY_TYPE(&d->et) +
+                sizeof_UINT32(d->sealInfoLongSize);
+@@ -770,7 +770,7 @@
+       return rv;
+ }
+ 
+-inline int unpack3_TPM_STORED_DATA12(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA12* d, UnpackPtr alloc) {
++static inline int unpack3_TPM_STORED_DATA12(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA12* d, UnpackPtr alloc) {
+       int rc = unpack3_TPM_STRUCTURE_TAG(ptr, pos, len, &d->tag) ||
+               unpack3_TPM_ENTITY_TYPE(ptr, pos, len, &d->et) ||
+               unpack3_UINT32(ptr, pos, len, &d->sealInfoLongSize);
+@@ -786,7 +786,7 @@
+       return rc;
+ }
+ 
+-inline BYTE* pack_TPM_AUTH_SESSION(BYTE* ptr, const TPM_AUTH_SESSION* auth) {
++static inline BYTE* pack_TPM_AUTH_SESSION(BYTE* ptr, const TPM_AUTH_SESSION* auth) {
+       ptr = pack_TPM_AUTH_HANDLE(ptr, auth->AuthHandle);
+       ptr = pack_TPM_NONCE(ptr, &auth->NonceOdd);
+       ptr = pack_BOOL(ptr, auth->fContinueAuthSession);
+@@ -794,21 +794,21 @@
+       return ptr;
+ }
+ 
+-inline BYTE* unpack_TPM_AUTH_SESSION(BYTE* ptr, TPM_AUTH_SESSION* auth) {
++static inline BYTE* unpack_TPM_AUTH_SESSION(BYTE* ptr, TPM_AUTH_SESSION* auth) {
+       ptr = unpack_TPM_NONCE(ptr, &auth->NonceEven);
+       ptr = unpack_BOOL(ptr, &auth->fContinueAuthSession);
+       ptr = unpack_TPM_AUTHDATA(ptr, &auth->HMAC);
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_AUTH_SESSION(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTH_SESSION* auth) {
++static inline int unpack3_TPM_AUTH_SESSION(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTH_SESSION* auth) {
+       return unpack3_TPM_NONCE(ptr, pos, len, &auth->NonceEven) ||
+               unpack3_BOOL(ptr, pos, len, &auth->fContinueAuthSession) ||
+               unpack3_TPM_AUTHDATA(ptr, pos, len, &auth->HMAC);
+ }
+ 
+ 
+-inline int sizeof_TPM_AUTH_SESSION(const TPM_AUTH_SESSION* auth) {
++static inline int sizeof_TPM_AUTH_SESSION(const TPM_AUTH_SESSION* auth) {
+       int rv = 0;
+       rv += sizeof_TPM_AUTH_HANDLE(auth->AuthHandle);
+       rv += sizeof_TPM_NONCE(&auth->NonceOdd);
+@@ -817,7 +817,7 @@
+       return rv;
+ }
+ 
+-inline BYTE* pack_TPM_RQU_HEADER(BYTE* ptr,
++static inline BYTE* pack_TPM_RQU_HEADER(BYTE* ptr,
+               TPM_TAG tag,
+               UINT32 size,
+               TPM_COMMAND_CODE ord) {
+@@ -826,7 +826,7 @@
+       return pack_UINT32(ptr, ord);
+ }
+ 
+-inline BYTE* unpack_TPM_RQU_HEADER(BYTE* ptr,
++static inline BYTE* unpack_TPM_RQU_HEADER(BYTE* ptr,
+               TPM_TAG* tag,
+               UINT32* size,
+               TPM_COMMAND_CODE* ord) {
+@@ -836,7 +836,7 @@
+       return ptr;
+ }
+ 
+-inline int unpack3_TPM_RQU_HEADER(BYTE* ptr, UINT32* pos, UINT32 max,
++static inline int unpack3_TPM_RQU_HEADER(BYTE* ptr, UINT32* pos, UINT32 max,
+               TPM_TAG* tag, UINT32* size, TPM_COMMAND_CODE* ord) {
+       return
+               unpack3_UINT16(ptr, pos, max, tag) ||
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tcg.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tcg.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tcg.h      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,129 @@
+$NetBSD: patch-stubdom_vtpmmgr_tcg.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/vtpmmgr/tcg.h.orig 2017-03-28 16:00:31.000000000 +0200
++++ stubdom/vtpmmgr/tcg.h      2017-03-28 16:01:01.000000000 +0200
+@@ -461,7 +461,7 @@
+    BYTE* vendorSpecific;
+ } TPM_CAP_VERSION_INFO;
+ 
+-inline void free_TPM_CAP_VERSION_INFO(TPM_CAP_VERSION_INFO* v) {
++static inline void free_TPM_CAP_VERSION_INFO(TPM_CAP_VERSION_INFO* v) {
+    free(v->vendorSpecific);
+    v->vendorSpecific = NULL;
+ }
+@@ -494,7 +494,7 @@
+    BYTE* data;
+ } TPM_SYMMETRIC_KEY;
+ 
+-inline void free_TPM_SYMMETRIC_KEY_PARMS(TPM_SYMMETRIC_KEY_PARMS* p) {
++static inline void free_TPM_SYMMETRIC_KEY_PARMS(TPM_SYMMETRIC_KEY_PARMS* p) {
+    free(p->IV);
+    p->IV = NULL;
+ }
+@@ -510,7 +510,7 @@
+ 
+ #define TPM_RSA_KEY_PARMS_INIT { 0, 0, 0, NULL }
+ 
+-inline void free_TPM_RSA_KEY_PARMS(TPM_RSA_KEY_PARMS* p) {
++static inline void free_TPM_RSA_KEY_PARMS(TPM_RSA_KEY_PARMS* p) {
+    free(p->exponent);
+    p->exponent = NULL;
+ }
+@@ -528,7 +528,7 @@
+ 
+ #define TPM_KEY_PARMS_INIT { 0, 0, 0, 0 }
+ 
+-inline void free_TPM_KEY_PARMS(TPM_KEY_PARMS* p) {
++static inline void free_TPM_KEY_PARMS(TPM_KEY_PARMS* p) {
+    if(p->parmSize) {
+       switch(p->algorithmID) {
+          case TPM_ALG_RSA:
+@@ -550,7 +550,7 @@
+ 
+ #define TPM_STORE_PUBKEY_INIT { 0, NULL }
+ 
+-inline void free_TPM_STORE_PUBKEY(TPM_STORE_PUBKEY* p) {
++static inline void free_TPM_STORE_PUBKEY(TPM_STORE_PUBKEY* p) {
+    free(p->key);
+    p->key = NULL;
+ }
+@@ -562,7 +562,7 @@
+ 
+ #define TPM_PUBKEY_INIT { TPM_KEY_PARMS_INIT, TPM_STORE_PUBKEY_INIT }
+ 
+-inline void free_TPM_PUBKEY(TPM_PUBKEY* k) {
++static inline void free_TPM_PUBKEY(TPM_PUBKEY* k) {
+    free_TPM_KEY_PARMS(&k->algorithmParms);
+    free_TPM_STORE_PUBKEY(&k->pubKey);
+ }
+@@ -574,7 +574,7 @@
+ 
+ #define TPM_PCR_SELECTION_INIT { 0, NULL }
+ 
+-inline void free_TPM_PCR_SELECTION(TPM_PCR_SELECTION* p) {
++static inline void free_TPM_PCR_SELECTION(TPM_PCR_SELECTION* p) {
+    free(p->pcrSelect);
+    p->pcrSelect = NULL;
+ }
+@@ -594,7 +594,7 @@
+ #define TPM_PCR_INFO_LONG_INIT { 0, 0, 0, TPM_PCR_SELECTION_INIT, \
+                                  TPM_PCR_SELECTION_INIT }
+ 
+-inline void free_TPM_PCR_INFO_LONG(TPM_PCR_INFO_LONG* p) {
++static inline void free_TPM_PCR_INFO_LONG(TPM_PCR_INFO_LONG* p) {
+    free_TPM_PCR_SELECTION(&p->creationPCRSelection);
+    free_TPM_PCR_SELECTION(&p->releasePCRSelection);
+ }
+@@ -607,7 +607,7 @@
+ 
+ #define TPM_PCR_INFO_INIT { TPM_PCR_SELECTION_INIT }
+ 
+-inline void free_TPM_PCR_INFO(TPM_PCR_INFO* p) {
++static inline void free_TPM_PCR_INFO(TPM_PCR_INFO* p) {
+    free_TPM_PCR_SELECTION(&p->pcrSelection);
+ }
+ 
+@@ -619,7 +619,7 @@
+ 
+ #define TPM_PCR_COMPOSITE_INIT { TPM_PCR_SELECTION_INIT, 0, NULL }
+ 
+-inline void free_TPM_PCR_COMPOSITE(TPM_PCR_COMPOSITE* p) {
++static inline void free_TPM_PCR_COMPOSITE(TPM_PCR_COMPOSITE* p) {
+    free_TPM_PCR_SELECTION(&p->select);
+    free(p->pcrValue);
+    p->pcrValue = NULL;
+@@ -643,7 +643,7 @@
+    .pubKey = TPM_STORE_PUBKEY_INIT, \
+    .encDataSize = 0, .encData = NULL }
+ 
+-inline void free_TPM_KEY(TPM_KEY* k) {
++static inline void free_TPM_KEY(TPM_KEY* k) {
+    if(k->PCRInfoSize) {
+       free_TPM_PCR_INFO(&k->PCRInfo);
+    }
+@@ -660,7 +660,7 @@
+ 
+ #define TPM_BOUND_DATA_INIT { .payloadData = NULL }
+ 
+-inline void free_TPM_BOUND_DATA(TPM_BOUND_DATA* d) {
++static inline void free_TPM_BOUND_DATA(TPM_BOUND_DATA* d) {
+    free(d->payloadData);
+    d->payloadData = NULL;
+ }
+@@ -676,7 +676,7 @@
+ #define TPM_STORED_DATA_INIT { .sealInfoSize = 0, sealInfo = TPM_PCR_INFO_INIT,\
+    .encDataSize = 0, .encData = NULL }
+ 
+-inline void free_TPM_STORED_DATA(TPM_STORED_DATA* d) {
++static inline void free_TPM_STORED_DATA(TPM_STORED_DATA* d) {
+    if(d->sealInfoSize) {
+       free_TPM_PCR_INFO(&d->sealInfo);
+    }
+@@ -696,7 +696,7 @@
+ #define TPM_STORED_DATA12_INIT { .sealInfoLongSize = 0, \
+    sealInfoLong = TPM_PCR_INFO_INIT, .encDataSize = 0, .encData = NULL }
+ 
+-inline void free_TPM_STORED_DATA12(TPM_STORED_DATA12* d) {
++static inline void free_TPM_STORED_DATA12(TPM_STORED_DATA12* d) {
+    if(d->sealInfoLongSize) {
+       free_TPM_PCR_INFO_LONG(&d->sealInfoLong);
+    }
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tpmrsa.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tpmrsa.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_tpmrsa.h   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-stubdom_vtpmmgr_tpmrsa.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/vtpmmgr/tpmrsa.h.orig      2017-03-28 16:12:14.000000000 +0200
++++ stubdom/vtpmmgr/tpmrsa.h   2017-03-28 16:12:26.000000000 +0200
+@@ -62,7 +62,7 @@
+       unsigned char *output );
+ 
+ /* free tpmrsa key */
+-inline void tpmrsa_free( tpmrsa_context *ctx ) {
++static inline void tpmrsa_free( tpmrsa_context *ctx ) {
+    mpi_free( &ctx->RN ); mpi_free( &ctx->E  ); mpi_free( &ctx->N  );
+ }
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpm_manager.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpm_manager.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpm_manager.h     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-stubdom_vtpmmgr_vtpm_manager.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/vtpmmgr/vtpm_manager.h.orig        2017-03-28 15:33:35.000000000 +0200
++++ stubdom/vtpmmgr/vtpm_manager.h     2017-03-28 15:33:55.000000000 +0200
+@@ -54,7 +54,7 @@
+ 
+ //************************ Command Codes ****************************
+ #define VTPM_ORD_BASE       0x0000
+-#define TPM_VENDOR_COMMAND  0x02000000 // TPM Main, part 2, section 17.
++#define TPM_VENDOR_COMMAND  0x20000000 // TPM Main, part 2, section 17.
+ #define VTPM_PRIV_BASE      (VTPM_ORD_BASE | TPM_VENDOR_COMMAND)
+ 
+ /*
Index: pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpmmgr.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpmmgr.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-stubdom_vtpmmgr_vtpmmgr.h  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-stubdom_vtpmmgr_vtpmmgr.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- stubdom/vtpmmgr/vtpmmgr.h.orig     2017-03-28 16:13:43.000000000 +0200
++++ stubdom/vtpmmgr/vtpmmgr.h  2017-03-28 16:13:51.000000000 +0200
+@@ -101,7 +101,7 @@
+ 
+ TPM_RESULT vtpmmgr_handle_cmd(struct tpm_opaque *opq, tpmcmd_t* tpmcmd);
+ 
+-inline TPM_RESULT vtpmmgr_rand(unsigned char* bytes, size_t num_bytes) {
++static inline TPM_RESULT vtpmmgr_rand(unsigned char* bytes, size_t num_bytes) {
+    return ctr_drbg_random(&vtpm_globals.ctr_drbg, bytes, num_bytes) == 0 ? 0 : TPM_FAIL;
+ }
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_Makefile     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,39 @@
+$NetBSD: patch-tools_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/Makefile.orig        2016-12-05 13:03:27.000000000 +0100
++++ tools/Makefile     2017-03-24 20:07:16.000000000 +0100
+@@ -18,7 +18,7 @@
+ SUBDIRS-y += xenstat
+ SUBDIRS-$(CONFIG_Linux) += memshr 
+ SUBDIRS-$(CONFIG_BLKTAP2) += blktap2
+-SUBDIRS-$(CONFIG_NetBSD) += xenbackendd
++#XXX SUBDIRS-$(CONFIG_NetBSD) += xenbackendd
+ SUBDIRS-y += libfsimage
+ SUBDIRS-$(CONFIG_Linux) += libvchan
+ 
+@@ -34,7 +34,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))
+@@ -275,11 +275,11 @@
+               -L$(XEN_ROOT)/tools/libs/evtchn \
+               -L$(XEN_ROOT)/tools/libs/gnttab \
+               -L$(XEN_ROOT)/tools/libs/foreignmemory \
+-              -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \
+-              -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/evtchn \
+-              -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \
+-              -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \
+-              -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \
++              -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/toollog \
++              -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/evtchn \
++              -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/gnttab \
++              -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/call \
++              -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/foreignmemory \
+               $(QEMU_UPSTREAM_RPATH)" \
+               --bindir=$(LIBEXEC_BIN) \
+               --datadir=$(SHAREDIR)/qemu-xen \
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_Rules.mk
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_Rules.mk:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_Rules.mk     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,91 @@
+$NetBSD: patch-tools_Rules.mk,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/Rules.mk.orig        2016-12-05 13:03:27.000000000 +0100
++++ tools/Rules.mk     2017-03-24 17:48:17.000000000 +0100
+@@ -84,57 +84,57 @@
+ CFLAGS_libxentoollog = -I$(XEN_LIBXENTOOLLOG)/include $(CFLAGS_xeninclude)
+ SHDEPS_libxentoollog =
+ LDLIBS_libxentoollog = $(XEN_LIBXENTOOLLOG)/libxentoollog$(libextension)
+-SHLIB_libxentoollog  = -Wl,-rpath-link=$(XEN_LIBXENTOOLLOG)
++SHLIB_libxentoollog  = -Wl,-rpath-link,$(XEN_LIBXENTOOLLOG)
+ 
+ CFLAGS_libxenevtchn = -I$(XEN_LIBXENEVTCHN)/include $(CFLAGS_xeninclude)
+ SHDEPS_libxenevtchn =
+ LDLIBS_libxenevtchn = $(XEN_LIBXENEVTCHN)/libxenevtchn$(libextension)
+-SHLIB_libxenevtchn  = -Wl,-rpath-link=$(XEN_LIBXENEVTCHN)
++SHLIB_libxenevtchn  = -Wl,-rpath-link,$(XEN_LIBXENEVTCHN)
+ 
+ CFLAGS_libxengnttab = -I$(XEN_LIBXENGNTTAB)/include $(CFLAGS_xeninclude)
+ SHDEPS_libxengnttab = $(SHLIB_libxentoollog)
+ LDLIBS_libxengnttab = $(SHDEPS_libxengnttab) $(XEN_LIBXENGNTTAB)/libxengnttab$(libextension)
+-SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link=$(XEN_LIBXENGNTTAB)
++SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link,$(XEN_LIBXENGNTTAB)
+ 
+ # xengntshr_* interfaces are actually part of libxengnttab.so
+ CFLAGS_libxengntshr = -I$(XEN_LIBXENGNTTAB)/include $(CFLAGS_xeninclude)
+ LDLIBS_libxengntshr = $(XEN_LIBXENGNTTAB)/libxengnttab$(libextension)
+-SHLIB_libxengntshr  = -Wl,-rpath-link=$(XEN_LIBXENGNTTAB)
++SHLIB_libxengntshr  = -Wl,-rpath-link,$(XEN_LIBXENGNTTAB)
+ 
+ CFLAGS_libxencall = -I$(XEN_LIBXENCALL)/include $(CFLAGS_xeninclude)
+ LDLIBS_libxencall = $(XEN_LIBXENCALL)/libxencall$(libextension)
+-SHLIB_libxencall  = -Wl,-rpath-link=$(XEN_LIBXENCALL)
++SHLIB_libxencall  = -Wl,-rpath-link,$(XEN_LIBXENCALL)
+ 
+ CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xeninclude)
+ LDLIBS_libxenforeignmemory = $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension)
+-SHLIB_libxenforeignmemory  = -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY)
++SHLIB_libxenforeignmemory  = -Wl,-rpath-link,$(XEN_LIBXENFOREIGNMEMORY)
+ 
+ # code which compiles against libxenctrl get __XEN_TOOLS__ and
+ # therefore sees the unstable hypercall interfaces.
+ CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
+ SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory)
+ LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension)
+-SHLIB_libxenctrl  = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC)
++SHLIB_libxenctrl  = $(SHDEPS_libxenctrl) -Wl,-rpath-link,$(XEN_LIBXC)
+ 
+ CFLAGS_libxenguest = -I$(XEN_LIBXC)/include $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude)
+ SHDEPS_libxenguest = $(SHLIB_libxenevtchn)
+ LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_LIBXC)/libxenguest$(libextension)
+-SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_LIBXC)
++SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link,$(XEN_LIBXC)
+ 
+ CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
+ SHDEPS_libxenstore =
+ LDLIBS_libxenstore = $(SHDEPS_libxenguest) $(XEN_XENSTORE)/libxenstore$(libextension)
+-SHLIB_libxenstore  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_XENSTORE)
++SHLIB_libxenstore  = $(SHDEPS_libxenguest) -Wl,-rpath-link,$(XEN_XENSTORE)
+ 
+ CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
+ SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
+ LDLIBS_libxenstat  = $(SHDEPS_libxenstat) $(XEN_LIBXENSTAT)/libxenstat$(libextension)
+-SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_LIBXENSTAT)
++SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link,$(XEN_LIBXENSTAT)
+ 
+ CFLAGS_libxenvchan = -I$(XEN_LIBVCHAN)
+ SHDEPS_libxenvchan = $(SHLIB_libxentoollog) $(SHLIB_libxenstore) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr)
+ LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libextension)
+-SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
++SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link,$(XEN_LIBVCHAN)
+ 
+ ifeq ($(debug),y)
+ # Disable optimizations and enable debugging information for macros
+@@ -151,7 +151,7 @@
+ CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include $(CFLAGS_xeninclude)
+ SHDEPS_libblktapctl =
+ LDLIBS_libblktapctl = $(SHDEPS_libblktapctl) $(XEN_BLKTAP2)/control/libblktapctl$(libextension)
+-SHLIB_libblktapctl  = $(SHDEPS_libblktapctl) -Wl,-rpath-link=$(XEN_BLKTAP2)/control
++SHLIB_libblktapctl  = $(SHDEPS_libblktapctl) -Wl,-rpath-link,$(XEN_BLKTAP2)/control
+ else
+ CFLAGS_libblktapctl =
+ SHDEPS_libblktapctl =
+@@ -162,7 +162,7 @@
+ CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
+ SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl)
+ LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_XENLIGHT)/libxenlight$(libextension)
+-SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_XENLIGHT)
++SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link,$(XEN_XENLIGHT)
+ 
+ CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_configure
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_configure:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_configure    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,39 @@
+$NetBSD: patch-tools_configure,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/configure.orig       2016-12-05 13:03:27.000000000 +0100
++++ tools/configure    2017-03-24 18:13:41.000000000 +0100
+@@ -2408,7 +2408,7 @@
+ 
+ 
+ 
+-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons 
hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain 
hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain 
libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf"
++ac_config_files="$ac_config_files ../config/Tools.mk ../config/Paths.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons 
hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain 
hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain 
libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf"
+ 
+ ac_config_headers="$ac_config_headers config.h"
+ 
+@@ -3844,7 +3844,7 @@
+ 
+ if test "x$sysconfdir" = 'x${prefix}/etc' ; then
+     case "$host_os" in
+-         *freebsd*)
++         *freebsd*|*netbsd*)
+          sysconfdir=$prefix/etc
+          ;;
+          *solaris*)
+@@ -3962,7 +3962,7 @@
+ 
+ case "$host_os" in
+ *freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+-*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
++*netbsd*) XEN_LOCK_DIR=$localstatedir/run ;;
+ *) XEN_LOCK_DIR=$localstatedir/lock ;;
+ esac
+ 
+@@ -10386,6 +10386,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/FreeBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xendriverdomain" ;;
+     "hotplug/Linux/init.d/sysconfig.xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/sysconfig.xencommons" ;;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_console_daemon_utils.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_console_daemon_utils.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_console_daemon_utils.c       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-tools_console_daemon_utils.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/console/daemon/utils.c.orig  2015-06-22 13:41:35.000000000 +0000
++++ tools/console/daemon/utils.c
+@@ -113,13 +113,15 @@ bool xen_setup(void)
+       xs = xs_daemon_open();
+       if (xs == NULL) {
+               dolog(LOG_ERR,
+-                    "Failed to contact xenstore (%m).  Is it running?");
++                    "Failed to contact xenstore (%s).  Is it running?",
++                    strerror(errno));
+               goto out;
+       }
+ 
+       xc = xc_interface_open(0,0,0);
+       if (!xc) {
+-              dolog(LOG_ERR, "Failed to contact hypervisor (%m)");
++              dolog(LOG_ERR, "Failed to contact hypervisor (%s)",
++                    strerror(errno));
+               goto out;
+       }
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_examples_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_examples_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_examples_Makefile    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-tools_examples_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/examples/Makefile.orig       2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_etherboot_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_etherboot_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_etherboot_Makefile  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,26 @@
+$NetBSD: patch-tools_firmware_etherboot_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/firmware/etherboot/Makefile.orig     2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_hvmloader_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_hvmloader_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_firmware_hvmloader_Makefile  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_firmware_hvmloader_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/firmware/hvmloader/Makefile.orig     2016-12-05 13:03:27.000000000 +0100
++++ tools/firmware/hvmloader/Makefile  2017-03-24 18:14:34.000000000 +0100
+@@ -26,7 +26,7 @@
+ # SMBIOS spec requires format mm/dd/yyyy
+ SMBIOS_REL_DATE ?= $(shell date +%m/%d/%Y)
+ 
+-CFLAGS += $(CFLAGS_xeninclude)
++CFLAGS += $(CFLAGS_xeninclude) $(EXTRA_CFLAGS)
+ 
+ # We mustn't use tools-only public interfaces.
+ CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_Makefile      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,52 @@
+$NetBSD: patch-tools_hotplug_NetBSD_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/hotplug/NetBSD/Makefile.orig 2016-02-09 14:44:19.000000000 +0000
++++ tools/hotplug/NetBSD/Makefile
+@@ -3,12 +3,13 @@ include $(XEN_ROOT)/tools/Rules.mk
+ 
+ # Xen script dir and scripts to go there.
+ XEN_SCRIPTS =
++XEN_SCRIPTS += locking.sh
+ XEN_SCRIPTS += block
+ XEN_SCRIPTS += vif-bridge
+ XEN_SCRIPTS += vif-ip
+ 
+ XEN_SCRIPT_DATA =
+-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
++#XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
+ 
+ .PHONY: all
+ all:
+@@ -21,10 +22,11 @@ install: install-scripts install-rcd
+ 
+ .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 +35,12 @@ install-scripts:
+ 
+ .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:
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_block
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_block:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_block Thu Mar 30 09:15:10 2017
@@ -0,0 +1,37 @@
+$NetBSD: patch-tools_hotplug_NetBSD_block,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/hotplug/NetBSD/block.orig    2016-02-09 14:44:19.000000000 +0000
++++ tools/hotplug/NetBSD/block
+@@ -6,6 +6,7 @@
+ 
+ DIR=$(dirname "$0")
+ . "${DIR}/hotplugpath.sh"
++. "${DIR}/locking.sh"
+ 
+ PATH=${bindir}:${sbindir}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin
+ export PATH
+@@ -62,6 +63,7 @@ case $xstatus in
+                       available_disks="$available_disks $disk"
+                       eval $disk=free
+               done
++              claim_lock block
+               # Mark the used vnd(4) devices as ``used''.
+               for disk in `sysctl hw.disknames`; do
+                       case $disk in
+@@ -77,6 +79,7 @@ case $xstatus in
+                               break   
+                       fi
+               done
++              release_lock block
+               if [ x$device = x ] ; then
+                       error "no available vnd device"
+               fi
+@@ -86,7 +89,7 @@ case $xstatus in
+               device=$xparams
+               ;;
+       esac
+-      physical_device=$(stat -f '%r' "$device")
++      physical_device=$(stat -L -f '%r' "$device")
+       xenstore-write $xpath/physical-device $physical_device
+       xenstore-write $xpath/hotplug-status connected
+       exit 0
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-bridge
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-bridge:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-bridge    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,16 @@
+$NetBSD: patch-tools_hotplug_NetBSD_vif-bridge,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/hotplug/NetBSD/vif-bridge.orig       2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-ip
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-ip:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_NetBSD_vif-ip        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,15 @@
+$NetBSD: patch-tools_hotplug_NetBSD_vif-ip,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/hotplug/NetBSD/vif-ip.orig   2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_common_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_common_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_hotplug_common_Makefile      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,24 @@
+$NetBSD: patch-tools_hotplug_common_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/hotplug/common/Makefile.orig 2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_include_xen-sys_NetBSD_gntdev.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_include_xen-sys_NetBSD_gntdev.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_include_xen-sys_NetBSD_gntdev.h      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,110 @@
+$NetBSD: patch-tools_include_xen-sys_NetBSD_gntdev.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/include/xen-sys/NetBSD/gntdev.h.orig 2015-01-19 13:16:37.000000000 +0100
++++ tools/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__ */
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_netbsd.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_netbsd.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_netbsd.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,55 @@
+$NetBSD: patch-tools_libs_call_netbsd.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/call/netbsd.c.orig      2017-03-24 18:29:45.000000000 +0100
++++ tools/libs/call/netbsd.c   2017-03-24 18:34:05.000000000 +0100
+@@ -19,12 +19,14 @@
+  * Split from xc_netbsd.c
+  */
+ 
+-#include "xc_private.h"
+ 
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <malloc.h>
++#include <errno.h>
+ #include <sys/mman.h>
++#include <sys/ioctl.h>
++#include "private.h"
+ 
+ int osdep_xencall_open(xencall_handle *xcall)
+ {
+@@ -69,12 +71,13 @@
+     return close(fd);
+ }
+ 
+-void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages)
++void *osdep_alloc_pages(xencall_handle *xcall, size_t npages)
+ {
+-    size_t size = npages * XC_PAGE_SIZE;
++    size_t size = npages * PAGE_SIZE;
+     void *p;
++    int ret;
+ 
+-    ret = posix_memalign(&p, XC_PAGE_SIZE, size);
++    ret = posix_memalign(&p, PAGE_SIZE, size);
+     if ( ret != 0 || !p )
+         return NULL;
+ 
+@@ -86,14 +89,13 @@
+     return p;
+ }
+ 
+-void osdep_free_hypercall_buffer(xencall_handle *xcall, void *ptr,
+-                                 size_t npages)
++void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
+ {
+-    (void) munlock(ptr, npages * XC_PAGE_SIZE);
++    (void) munlock(ptr, npages * PAGE_SIZE);
+     free(ptr);
+ }
+ 
+-int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
++int osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
+ {
+     int fd = xcall->fd;
+     int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_private.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_private.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_call_private.h  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,16 @@
+$NetBSD: patch-tools_libs_call_private.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/call/private.h.orig     2017-03-28 10:42:37.000000000 +0200
++++ tools/libs/call/private.h  2017-03-28 10:43:04.000000000 +0200
+@@ -11,8 +11,10 @@
+ #ifndef PAGE_SHIFT /* Mini-os, Yukk */
+ #define PAGE_SHIFT           12
+ #endif
+-#ifndef __MINIOS__ /* Yukk */
++#ifndef PAGE_SIZE
+ #define PAGE_SIZE            (1UL << PAGE_SHIFT)
++#endif
++#ifndef PAGE_MASK
+ #define PAGE_MASK            (~(PAGE_SIZE-1))
+ #endif
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_evtchn_netbsd.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_evtchn_netbsd.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_evtchn_netbsd.c Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-tools_libs_evtchn_netbsd.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/evtchn/netbsd.c.orig    2017-03-24 18:23:27.000000000 +0100
++++ tools/libs/evtchn/netbsd.c 2017-03-24 18:23:40.000000000 +0100
+@@ -124,7 +124,7 @@
+     int fd = xce->fd;
+     evtchn_port_t port;
+ 
+-    if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
++    if ( read(fd, (char *)&port, sizeof(port)) == -1 )
+         return -1;
+ 
+     return port;
+@@ -133,7 +133,7 @@
+ int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port)
+ {
+     int fd = xce->fd;
+-    return write_exact(fd, (char *)&port, sizeof(port));
++    return write(fd, (char *)&port, sizeof(port));
+ }
+ 
+ /*
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_compat.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_compat.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_compat.c  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,14 @@
+$NetBSD: patch-tools_libs_foreignmemory_compat.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/foreignmemory/compat.c.orig     2017-03-24 18:42:26.000000000 +0100
++++ tools/libs/foreignmemory/compat.c  2017-03-24 18:41:44.000000000 +0100
+@@ -20,6 +20,9 @@
+ #endif
+ 
+ #include "private.h"
++#include <stdlib.h>
++#include <errno.h>
++#include <string.h>
+ 
+ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
+                                  uint32_t dom, int prot, size_t num,
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_netbsd.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_netbsd.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_netbsd.c  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,48 @@
+$NetBSD: patch-tools_libs_foreignmemory_netbsd.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/foreignmemory/netbsd.c.orig     2017-03-24 18:51:51.000000000 +0100
++++ tools/libs/foreignmemory/netbsd.c  2017-03-24 18:55:36.000000000 +0100
+@@ -19,7 +19,9 @@
+ 
+ #include <unistd.h>
+ #include <fcntl.h>
++#include <errno.h>
+ #include <sys/mman.h>
++#include <sys/ioctl.h>
+ 
+ #include "private.h"
+ 
+@@ -66,13 +68,13 @@
+     return close(fd);
+ }
+ 
+-void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,
++void *osdep_map_foreign_batch(xenforeignmemory_handle *fmem, uint32_t dom,
+                               int prot, xen_pfn_t *arr, int num)
+ {
+     int fd = fmem->fd;
+     privcmd_mmapbatch_t ioctlx;
+     void *addr;
+-    addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
++    addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
+     if ( addr == MAP_FAILED ) {
+         PERROR("osdep_map_foreign_batch: mmap failed");
+         return NULL;
+@@ -86,7 +88,7 @@
+     {
+         int saved_errno = errno;
+         PERROR("osdep_map_foreign_batch: ioctl failed");
+-        (void)munmap(addr, num*XC_PAGE_SIZE);
++        (void)munmap(addr, num*PAGE_SIZE);
+         errno = saved_errno;
+         return NULL;
+     }
+@@ -97,7 +99,7 @@
+ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+                                  void *addr, size_t num)
+ {
+-    return munmap(addr, num*XC_PAGE_SIZE);
++    return munmap(addr, num*PAGE_SIZE);
+ }
+ 
+ /*
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_private.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_private.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libs_foreignmemory_private.h Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_libs_foreignmemory_private.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libs/foreignmemory/private.h.orig    2017-03-24 18:38:28.000000000 +0100
++++ tools/libs/foreignmemory/private.h 2017-03-24 18:52:19.000000000 +0100
+@@ -34,7 +34,7 @@
+ 
+ #if defined(__NetBSD__) || defined(__sun__)
+ /* Strictly compat for those two only only */
+-void *compat_mapforeign_batch(xenforeignmem_handle *fmem, uint32_t dom,
++void *osdep_map_foreign_batch(xenforeignmemory_handle *fmem, uint32_t dom,
+                               int prot, xen_pfn_t *arr, int num);
+ #endif
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_Makefile       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-tools_libxl_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libxl/Makefile.orig  2016-12-05 13:03:27.000000000 +0100
++++ tools/libxl/Makefile       2017-03-24 18:00:08.000000000 +0100
+@@ -306,7 +306,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_DIR) $(DESTDIR)$(PKG_INSTALLDIR)
+       $(INSTALL_PROG) xl $(DESTDIR)$(sbindir)
+@@ -320,7 +320,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 libxlutil.h $(DESTDIR)$(includedir)
+-      $(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
++      $(INSTALL_DATA) bash-completion $(DESTDIR)$(XEN_EXAMPLES_DIR)/xl.sh
+       $(INSTALL_DATA) xenlight.pc $(DESTDIR)$(PKG_INSTALLDIR)
+       $(INSTALL_DATA) xlutil.pc $(DESTDIR)$(PKG_INSTALLDIR)
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl__create.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl__create.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl__create.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,40 @@
+$NetBSD: patch-tools_libxl_libxl__create.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libxl/libxl_create.c.orig    2016-12-05 13:03:27.000000000 +0100
++++ tools/libxl/libxl_create.c 2017-03-24 18:03:19.000000000 +0100
+@@ -451,7 +451,7 @@
+         vments[2] = "image/ostype";
+         vments[3] = "hvm";
+         vments[4] = "start_time";
+-        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++        vments[5] = GCSPRINTF("%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+ 
+         localents = libxl__calloc(gc, 9, sizeof(char *));
+         i = 0;
+@@ -488,7 +488,7 @@
+         vments[i++] = "image/kernel";
+         vments[i++] = (char *) state->pv_kernel.path;
+         vments[i++] = "start_time";
+-        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++        vments[i++] = GCSPRINTF("%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;
+@@ -1161,7 +1161,7 @@
+         vments[2] = "image/ostype";
+         vments[3] = "hvm";
+         vments[4] = "start_time";
+-        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++        vments[5] = GCSPRINTF("%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 *));
+@@ -1171,7 +1171,7 @@
+         vments[i++] = "image/kernel";
+         vments[i++] = (char *) state->pv_kernel.path;
+         vments[i++] = "start_time";
+-        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
++        vments[i++] = GCSPRINTF("%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;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_event.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_event.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_event.c  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,24 @@
+$NetBSD: patch-tools_libxl_libxl_event.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+The SIGCHLD handler just writes to a pipe where the reader is the
+same process. The idea is that this will cause poll(2) in the main
+thread to exit with the reaper pipe readable, and do child cleanup here.
+
+Unfortunably, is the child also has a write pipe back to the
+parent (as e.g. with pygrub), the loop in afterpoll_internal() may see the
+POLLHUP event on this pipe before the POLLIN even on the reaper pipe, and
+this will be considered as an error (from e.g. pygrub).
+
+work around by filtering POLLHUP events here
+
+--- tools/libxl/libxl_event.c.orig     2016-12-20 16:01:30.000000000 +0100
++++ tools/libxl/libxl_event.c  2016-12-20 17:28:52.000000000 +0100
+@@ -1261,7 +1261,7 @@
+ 
+             revents = afterpoll_check_fd(poller,fds,nfds,
+                                          efd->fd,efd->events);
+-            if (revents)
++            if (revents & ~POLLHUP)
+                 goto found_fd_event;
+         }
+         /* no ordinary fd events, then */
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_internal.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_internal.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_internal.h       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,23 @@
+$NetBSD: patch-tools_libxl_libxl_internal.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+bump some timeouts to more reasonable values. 40s is not enough
+if there is lots of them (e.g lots of network interfaces) and they
+need to be serialized.
+
+--- tools/libxl/libxl_internal.h.orig  2016-12-05 13:03:27.000000000 +0100
++++ tools/libxl/libxl_internal.h       2017-03-24 18:07:05.000000000 +0100
+@@ -88,11 +88,11 @@
+ #include "_libxl_types_internal_json.h"
+ 
+ #define LIBXL_INIT_TIMEOUT 10
+-#define LIBXL_DESTROY_TIMEOUT 10
+-#define LIBXL_HOTPLUG_TIMEOUT 40
++#define LIBXL_DESTROY_TIMEOUT 120
++#define LIBXL_HOTPLUG_TIMEOUT 120
+ /* QEMU may be slow to load and start due to a bug in Linux where the I/O
+  * subsystem sometime produce high latency under load. */
+-#define LIBXL_DEVICE_MODEL_START_TIMEOUT 60
++#define LIBXL_DEVICE_MODEL_START_TIMEOUT 120
+ #define LIBXL_DEVICE_MODEL_SAVE_FILE XEN_LIB_DIR "/qemu-save" /* .$domid */
+ #define LIBXL_DEVICE_MODEL_RESTORE_FILE XEN_LIB_DIR "/qemu-resume" /* .$domid */
+ #define LIBXL_STUBDOM_START_TIMEOUT 30
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_uuid.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_uuid.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_libxl_uuid.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,22 @@
+$NetBSD: patch-tools_libxl_libxl_uuid.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libxl/libxl_uuid.c.orig      2016-12-05 13:03:27.000000000 +0100
++++ tools/libxl/libxl_uuid.c   2017-03-24 18:15:58.000000000 +0100
+@@ -82,7 +82,7 @@
+     uuid_enc_be(uuid->uuid, &nat_uuid);
+ }
+ 
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in)
+ {
+     uint32_t status;
+@@ -120,7 +120,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)
+ {
+     uuid_t nat_uuid1, nat_uuid2;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl__cmdtable.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl__cmdtable.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl__cmdtable.c Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_libxl_xl__cmdtable.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/libxl/xl_cmdtable.c.orig     2015-11-03 09:11:18.000000000 +0000
++++ tools/libxl/xl_cmdtable.c
+@@ -507,7 +507,7 @@ struct cmd_spec cmd_table[] = {
+       "-e                      Do not wait in the background (on <host>) for the death\n"
+       "                        of the domain.\n"
+       "-N <netbufscript>       Use netbufscript to setup network buffering instead of the\n"
+-      "                        default script (/etc/xen/scripts/remus-netbuf-setup).\n"
++      "                        default script (@XENDCONFDIR@/scripts/remus-netbuf-setup).\n"
+       "-F                      Enable unsafe configurations [-b|-n|-d flags]. Use this option\n"
+       "                        with caution as failover may not work as intended.\n"
+       "-b                      Replicate memory checkpoints to /dev/null (blackhole).\n"
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl_cmdimpl.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl_cmdimpl.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_libxl_xl_cmdimpl.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,49 @@
+$NetBSD: patch-tools_libxl_xl_cmdimpl.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+avoid shadowing a global on netbsd-6.
+
+--- tools/libxl/xl_cmdimpl.c.orig      2017-03-21 23:27:46.000000000 +0100
++++ tools/libxl/xl_cmdimpl.c   2017-03-21 23:28:17.000000000 +0100
+@@ -473,7 +473,7 @@
+     flush_stream(fh);
+ }
+ 
+-static int do_daemonize(char *name, const char *pidfile)
++static int do_daemonize(char *name, const char *l_pidfile)
+ {
+     char *fullname;
+     pid_t child1;
+@@ -505,8 +505,8 @@
+ 
+     CHK_SYSCALL(daemon(0, 1));
+ 
+-    if (pidfile) {
+-        int fd = open(pidfile, O_RDWR | O_CREAT, S_IRUSR|S_IWUSR);
++    if (l_pidfile) {
++        int fd = open(l_pidfile, O_RDWR | O_CREAT, S_IRUSR|S_IWUSR);
+         char *pid = NULL;
+ 
+         if (fd == -1) {
+@@ -8076,7 +8076,7 @@
+ int main_devd(int argc, char **argv)
+ {
+     int ret = 0, opt = 0, daemonize = 1;
+-    const char *pidfile = NULL;
++    const char *l_pidfile = NULL;
+     static const struct option opts[] = {
+         {"pidfile", 1, 0, 'p'},
+         COMMON_LONG_OPTS,
+@@ -8088,12 +8088,12 @@
+         daemonize = 0;
+         break;
+     case 'p':
+-        pidfile = optarg;
++        l_pidfile = optarg;
+         break;
+     }
+ 
+     if (daemonize) {
+-        ret = do_daemonize("xldevd", pidfile);
++        ret = do_daemonize("xldevd", l_pidfile);
+         if (ret) {
+             ret = (ret == 1) ? 0 : ret;
+             goto out;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_common.make
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_common.make:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_common.make    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_ocaml_common.make,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/ocaml/common.make.orig       2015-01-12 17:53:24.000000000 +0100
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_Makefile     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-tools_ocaml_xenstored_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/ocaml/xenstored/Makefile.orig        2016-02-09 14:44:19.000000000 +0000
++++ tools/ocaml/xenstored/Makefile
+@@ -1,6 +1,7 @@
+ XEN_ROOT = $(CURDIR)/../../..
+ OCAML_TOPLEVEL = $(CURDIR)/..
+ include $(OCAML_TOPLEVEL)/common.make
++XEN_CONFIG_DIR=${XEN_EXAMPLES_DIR}
+ 
+ # Include configure output (config.h)
+ CFLAGS += -include $(XEN_ROOT)/tools/config.h
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_define.ml
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_define.ml:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_define.ml    Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_ocaml_xenstored_define.ml,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/ocaml/xenstored/define.ml.orig       2016-12-05 13:03:27.000000000 +0100
++++ tools/ocaml/xenstored/define.ml    2017-03-24 17:29:24.000000000 +0100
+@@ -17,7 +17,7 @@
+ let xenstored_major = 1
+ let xenstored_minor = 0
+ 
+-let xenstored_proc_kva = "/proc/xen/xsd_kva"
++let xenstored_proc_kva = "@PROCDEV@/xen/xsd_kva"
+ let xenstored_proc_port = "/proc/xen/xsd_port"
+ 
+ let xs_daemon_socket = Paths.xen_run_stored ^ "/socket"
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_utils.ml
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_utils.ml:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_ocaml_xenstored_utils.ml     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_ocaml_xenstored_utils.ml,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/ocaml/xenstored/utils.ml.orig        2016-12-05 13:03:27.000000000 +0100
++++ tools/ocaml/xenstored/utils.ml     2017-03-24 17:31:22.000000000 +0100
+@@ -87,7 +87,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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_pygrub_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_pygrub_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_pygrub_Makefile      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_pygrub_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/pygrub/Makefile.orig 2016-02-09 14:44:19.000000000 +0000
++++ tools/pygrub/Makefile
+@@ -17,7 +17,7 @@ install: all
+               --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
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_Makefile
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_Makefile:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_Makefile        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,84 @@
+$NetBSD: patch-tools_qemu-xen-traditional_Makefile,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/Makefile.orig   2014-10-06 17:50:24.000000000 +0200
++++ tools/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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_block-raw-posix.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_block-raw-posix.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_block-raw-posix.c       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,62 @@
+$NetBSD: patch-tools_qemu-xen-traditional_block-raw-posix.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+- if given a block device, use the character device instead.
+
+--- tools/qemu-xen-traditional/block-raw-posix.c.orig  2014-10-06 17:50:24.000000000 +0200
++++ tools/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();
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_configure
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_configure:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_configure       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,41 @@
+$NetBSD: patch-tools_qemu-xen-traditional_configure,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/configure.orig  2014-10-06 17:50:24.000000000 +0200
++++ tools/qemu-xen-traditional/configure       2015-01-20 22:58:07.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
+@@ -1493,7 +1495,9 @@
+ # XXX: suppress that
+ if [ "$bsd" = "yes" ] ; then
+   echo "#define O_LARGEFILE 0" >> $config_h
++  echo "#ifndef MAP_ANONYMOUS" >> $config_h
+   echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
++  echo "#endif" >> $config_h
+   echo "#define _BSD 1" >> $config_h
+ fi
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_e1000.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_e1000.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_e1000.c      Thu Mar 30 09:15:10 2017
@@ -0,0 +1,34 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_e1000.c,v 1.1 2017/03/30 09:15:10 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
+
+--- tools/qemu-xen-traditional/hw/e1000.c.orig 2014-10-06 17:50:24.000000000 +0200
++++ tools/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;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_ide.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_ide.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_ide.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,37 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_ide.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/ide.c.orig   2014-01-09 13:44:42.000000000 +0100
++++ tools/qemu-xen-traditional/hw/ide.c        2015-06-11 16:15:49.000000000 +0200
+@@ -757,10 +757,15 @@
+     put_le16(p + 58, oldsize >> 16);
+     if (s->mult_sectors)
+         put_le16(p + 59, 0x100 | s->mult_sectors);
+-    put_le16(p + 60, s->nb_sectors);
+-    put_le16(p + 61, s->nb_sectors >> 16);
++    if (s->nb_sectors > 0x10000000)
++      oldsize = 0x10000000; /* report only 128GB */
++    else
++      oldsize =  s->nb_sectors;
++    put_le16(p + 60, oldsize);
++    put_le16(p + 61, oldsize >> 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 +817,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 */
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.c       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_pass-through.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/pass-through.c.orig  2014-10-06 17:50:24.000000000 +0200
++++ tools/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"
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pass-through.h       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,18 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_pass-through.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/pass-through.h.orig  2014-10-06 17:50:24.000000000 +0200
++++ tools/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"
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_piix4acpi.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_piix4acpi.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_piix4acpi.c  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,17 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_piix4acpi.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/piix4acpi.c.orig     2014-10-06 17:50:24.000000000 +0200
++++ tools/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)
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-graphics.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-graphics.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-graphics.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_pt-graphics.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/pt-graphics.c.orig   2015-01-19 16:14:46.000000000 +0100
++++ tools/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>
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.c     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,15 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_pt-msi.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/pt-msi.c.orig        2014-10-06 17:50:24.000000000 +0200
++++ tools/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;
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.h
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.h:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_hw_pt-msi.h     Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-tools_qemu-xen-traditional_hw_pt-msi.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/hw/pt-msi.h.orig        2014-10-06 17:50:24.000000000 +0200
++++ tools/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 */
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-tools_qemu-xen-traditional_i386-dm_hookstarget.mak,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen-traditional/i386-dm/hookstarget.mak.orig    2014-10-06 17:50:24.000000000 +0200
++++ tools/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"
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_net.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_net.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_net.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,46 @@
+$NetBSD: patch-tools_qemu-xen-traditional_net.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+--- tools/qemu-xen-traditional/net.c.orig      2016-11-29 17:36:38.000000000 +0100
++++ tools/qemu-xen-traditional/net.c   2017-03-29 18:16:54.000000000 +0200
+@@ -990,6 +990,7 @@
+ #define DEFAULT_NETWORK_DOWN_SCRIPT ""
+ #endif
+ 
++#if !defined(CONFIG_STUBDOM)
+ static int launch_script(const char *setup_script, const char *ifname,
+                          const char *script_arg, int fd)
+ {
+@@ -1028,6 +1029,7 @@
+         }
+     return 0;
+ }
++#endif
+ 
+ static int net_tap_init(VLANState *vlan, const char *model,
+                         const char *name, const char *ifname1,
+@@ -1048,12 +1050,14 @@
+ 
+     if (!setup_script || !strcmp(setup_script, "no"))
+         setup_script = "";
++#if !defined(CONFIG_STUBDOM)
+     if (setup_script[0] != '\0') {
+       if (launch_script(setup_script, ifname, script_arg, fd)) {
+           close(fd);
+           return -1;
+       }
+     }
++#endif
+     s = net_tap_fd_init(vlan, model, name, fd);
+     if (!s)
+         return -1;
+@@ -1965,9 +1969,11 @@
+             if (vc->fd_read == tap_receive) {
+                 TAPState *s = vc->opaque;
+ 
++#ifndef CONFIG_STUBDOM
+                 if (s->down_script[0])
+                     launch_script(s->down_script, s->down_script_arg,
+                                 s->script_arg, s->fd);
++#endif
+             }
+ #if defined(CONFIG_VDE)
+             if (vc->fd_read == vde_from_qemu) {
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_xen-hooks.mak
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_xen-hooks.mak:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen-traditional_xen-hooks.mak   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,47 @@
+$NetBSD: patch-tools_qemu-xen-traditional_xen-hooks.mak,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+enable PCI passthrough when pciutils is present
+
+--- tools/qemu-xen-traditional/xen-hooks.mak.orig      2016-11-29 17:36:38.000000000 +0100
++++ tools/qemu-xen-traditional/xen-hooks.mak   2017-03-24 20:09:07.000000000 +0100
+@@ -25,9 +25,9 @@
+ LIBS += -L$(XEN_ROOT)/tools/libs/gnttab -lxengnttab
+ LIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl -lxenguest
+ LIBS += -L$(XEN_ROOT)/tools/xenstore -lxenstore
+-LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog
+-LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call
+-LIBS += -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory
++LIBS += -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/toollog
++LIBS += -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/call
++LIBS += -Wl,-rpath-link,$(XEN_ROOT)/tools/libs/foreignmemory
+ 
+ LDFLAGS := $(CFLAGS) $(LDFLAGS)
+ 
+@@ -68,17 +68,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
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_audio_audio.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_audio_audio.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_audio_audio.c       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,12 @@
+$NetBSD: patch-tools_qemu-xen_audio_audio.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen/audio/audio.c.orig  2016-11-24 13:24:26.000000000 +0100
++++ tools/qemu-xen/audio/audio.c       2017-03-24 18:11:17.000000000 +0100
+@@ -1156,6 +1156,7 @@
+         return 0;
+     }
+ 
++#undef read
+     return sw->hw->pcm_ops->read(sw, buf, size);
+ }
+ 
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_configure
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_configure:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_configure   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,14 @@
+$NetBSD: patch-tools_qemu-xen_configure,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+-lrt is needed for shm_open()
+
+--- tools/qemu-xen/configure.orig      2017-03-26 22:27:41.000000000 +0200
++++ tools/qemu-xen/configure   2017-03-26 22:27:46.000000000 +0200
+@@ -594,6 +594,7 @@
+   audio_drv_list="oss"
+   audio_possible_drivers="oss sdl"
+   oss_lib="-lossaudio"
++  LIBS="-lrt $LIBS"
+   HOST_VARIANT_DIR="netbsd"
+ ;;
+ OpenBSD)
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_qemu-doc.texi
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_qemu-doc.texi:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_qemu-doc.texi       Thu Mar 30 09:15:10 2017
@@ -0,0 +1,15 @@
+$NetBSD: patch-tools_qemu-xen_qemu-doc.texi,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+Avoid encoding issues in pod2man.
+
+--- tools/qemu-xen/qemu-doc.texi.orig  2014-12-02 11:41:02.000000000 +0100
++++ tools/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.
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_xen-hvm.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_xen-hvm.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_qemu-xen_xen-hvm.c   Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_qemu-xen_xen-hvm.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/qemu-xen/xen-hvm.c.orig      2016-01-06 16:42:43.000000000 +0000
++++ tools/qemu-xen/xen-hvm.c
+@@ -612,7 +612,7 @@ static void xen_sync_dirty_bitmap(XenIOS
+     for (i = 0; i < ARRAY_SIZE(bitmap); i++) {
+         unsigned long map = bitmap[i];
+         while (map != 0) {
+-            j = ctzl(map);
++            j = __builtin_ctzl(map);
+             map &= ~(1ul << j);
+             memory_region_set_dirty(framebuffer,
+                                     (i * width + j) * TARGET_PAGE_SIZE,
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_xenpaging_xenpaging.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_xenpaging_xenpaging.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_xenpaging_xenpaging.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,18 @@
+$NetBSD: patch-tools_xenpaging_xenpaging.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/xenpaging/xenpaging.c.orig   2016-06-20 12:08:22.000000000 +0000
++++ tools/xenpaging/xenpaging.c
+@@ -182,10 +182,11 @@ static int xenpaging_get_tot_pages(struc
+ static void *init_page(void)
+ {
+     void *buffer;
++    int rc;
+ 
+     /* Allocated page memory */
+-    errno = posix_memalign(&buffer, PAGE_SIZE, PAGE_SIZE);
+-    if ( errno != 0 )
++    rc = posix_memalign(&buffer, PAGE_SIZE, PAGE_SIZE);
++    if ( rc != 0 )
+         return NULL;
+ 
+     /* Lock buffer in memory so it can't be paged out */
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_xenstore_xc.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_xenstore_xc.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_xenstore_xc.c        Thu Mar 30 09:15:10 2017
@@ -0,0 +1,18 @@
+$NetBSD: patch-tools_xenstore_xc.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/xenstore/xs.c.orig   2015-01-19 15:40:00.000000000 +0100
++++ tools/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);
Index: pkgsrc/sysutils/xentools48/patches/patch-tools_xentrace_xentrace.c
diff -u /dev/null pkgsrc/sysutils/xentools48/patches/patch-tools_xentrace_xentrace.c:1.1
--- /dev/null   Thu Mar 30 09:15:10 2017
+++ pkgsrc/sysutils/xentools48/patches/patch-tools_xentrace_xentrace.c  Thu Mar 30 09:15:10 2017
@@ -0,0 +1,13 @@
+$NetBSD: patch-tools_xentrace_xentrace.c,v 1.1 2017/03/30 09:15:10 bouyer Exp $
+
+--- tools/xentrace/xentrace.c.orig     2016-02-09 14:44:19.000000000 +0000
++++ tools/xentrace/xentrace.c
+@@ -945,7 +945,7 @@ static int parse_cpumask_range(const cha
+ {
+     unsigned int a, b;
+     int nmaskbits;
+-    char c;
++    unsigned char c;
+     int in_range;
+     const char *s;
+ 



Home | Main Index | Thread Index | Old Index