summaryrefslogtreecommitdiff
path: root/sysutils/xentools30
diff options
context:
space:
mode:
authorbouyer <bouyer>2006-07-02 16:49:31 +0000
committerbouyer <bouyer>2006-07-02 16:49:31 +0000
commit63e7b912b019ff7d1192749be29b0460e6f1cb3f (patch)
tree4850e54bb846e0d77b4122192180459ec0d1bdc6 /sysutils/xentools30
parent9d9d170b758564a893664a624c42ff558d464b02 (diff)
downloadpkgsrc-63e7b912b019ff7d1192749be29b0460e6f1cb3f.tar.gz
Initial import of a packages for Xen 3.0 domain0 tools.
Diffstat (limited to 'sysutils/xentools30')
-rw-r--r--sysutils/xentools30/DESCR5
-rw-r--r--sysutils/xentools30/MESSAGE.NetBSD17
-rw-r--r--sysutils/xentools30/Makefile177
-rw-r--r--sysutils/xentools30/PLIST262
-rw-r--r--sysutils/xentools30/distinfo64
-rw-r--r--sysutils/xentools30/files/block-nbsd88
-rw-r--r--sysutils/xentools30/files/vif-bridge-nbsd35
-rw-r--r--sysutils/xentools30/files/xenbackendd.c319
-rw-r--r--sysutils/xentools30/files/xenbackendd.sh17
-rw-r--r--sysutils/xentools30/files/xend.sh29
-rw-r--r--sysutils/xentools30/files/xendomains.sh134
-rw-r--r--sysutils/xentools30/files/xenio.h105
-rw-r--r--sysutils/xentools30/files/xenio3.h89
-rw-r--r--sysutils/xentools30/patches/patch-aa45
-rw-r--r--sysutils/xentools30/patches/patch-ab28
-rw-r--r--sysutils/xentools30/patches/patch-ac22
-rw-r--r--sysutils/xentools30/patches/patch-ad13
-rw-r--r--sysutils/xentools30/patches/patch-ae10
-rw-r--r--sysutils/xentools30/patches/patch-af10
-rw-r--r--sysutils/xentools30/patches/patch-ag10
-rw-r--r--sysutils/xentools30/patches/patch-ai10
-rw-r--r--sysutils/xentools30/patches/patch-aj17
-rw-r--r--sysutils/xentools30/patches/patch-ak10
-rw-r--r--sysutils/xentools30/patches/patch-al26
-rw-r--r--sysutils/xentools30/patches/patch-am79
-rw-r--r--sysutils/xentools30/patches/patch-an24
-rw-r--r--sysutils/xentools30/patches/patch-ao22
-rw-r--r--sysutils/xentools30/patches/patch-ap27
-rw-r--r--sysutils/xentools30/patches/patch-aq40
-rw-r--r--sysutils/xentools30/patches/patch-ar13
-rw-r--r--sysutils/xentools30/patches/patch-as46
-rw-r--r--sysutils/xentools30/patches/patch-at22
-rw-r--r--sysutils/xentools30/patches/patch-au32
-rw-r--r--sysutils/xentools30/patches/patch-av16
-rw-r--r--sysutils/xentools30/patches/patch-aw47
-rw-r--r--sysutils/xentools30/patches/patch-ax18
-rw-r--r--sysutils/xentools30/patches/patch-ay13
-rw-r--r--sysutils/xentools30/patches/patch-az14
-rw-r--r--sysutils/xentools30/patches/patch-ba17
-rw-r--r--sysutils/xentools30/patches/patch-bb24
-rw-r--r--sysutils/xentools30/patches/patch-bc22
-rw-r--r--sysutils/xentools30/patches/patch-bd40
-rw-r--r--sysutils/xentools30/patches/patch-be56
-rw-r--r--sysutils/xentools30/patches/patch-bf127
-rw-r--r--sysutils/xentools30/patches/patch-bg16
-rw-r--r--sysutils/xentools30/patches/patch-bh13
-rw-r--r--sysutils/xentools30/patches/patch-bi13
-rw-r--r--sysutils/xentools30/patches/patch-bj16
-rw-r--r--sysutils/xentools30/patches/patch-bk13
-rw-r--r--sysutils/xentools30/patches/patch-bl13
-rw-r--r--sysutils/xentools30/patches/patch-bm20
-rw-r--r--sysutils/xentools30/patches/patch-bn18
-rw-r--r--sysutils/xentools30/patches/patch-bo25
-rw-r--r--sysutils/xentools30/patches/patch-bp19
-rw-r--r--sysutils/xentools30/patches/patch-bq62
-rw-r--r--sysutils/xentools30/patches/patch-br15
-rw-r--r--sysutils/xentools30/patches/patch-bs74
-rw-r--r--sysutils/xentools30/patches/patch-bt91
-rw-r--r--sysutils/xentools30/patches/patch-bu32
-rw-r--r--sysutils/xentools30/patches/patch-bv30
-rw-r--r--sysutils/xentools30/patches/patch-bw15
-rw-r--r--sysutils/xentools30/patches/patch-bx16
-rw-r--r--sysutils/xentools30/patches/patch-by39
-rw-r--r--sysutils/xentools30/patches/patch-bz14
-rw-r--r--sysutils/xentools30/patches/patch-ca14
-rw-r--r--sysutils/xentools30/patches/patch-cb12
-rw-r--r--sysutils/xentools30/patches/patch-cc23
-rw-r--r--sysutils/xentools30/patches/patch-cd15
-rw-r--r--sysutils/xentools30/patches/patch-ce13
-rw-r--r--sysutils/xentools30/patches/patch-cf17
-rw-r--r--sysutils/xentools30/patches/patch-cg22
-rw-r--r--sysutils/xentools30/patches/patch-ch21
72 files changed, 2932 insertions, 0 deletions
diff --git a/sysutils/xentools30/DESCR b/sysutils/xentools30/DESCR
new file mode 100644
index 00000000000..a687436b5b0
--- /dev/null
+++ b/sysutils/xentools30/DESCR
@@ -0,0 +1,5 @@
+The Xen virtual machine monitor allows running several virtual machines
+on a single physical machine. The xentools30 package contains the
+tools to create, destroy and control the virtual machines.
+
+The xentools30 package contains the tools for Xen 3.0
diff --git a/sysutils/xentools30/MESSAGE.NetBSD b/sysutils/xentools30/MESSAGE.NetBSD
new file mode 100644
index 00000000000..6bfd90aeccd
--- /dev/null
+++ b/sysutils/xentools30/MESSAGE.NetBSD
@@ -0,0 +1,17 @@
+===========================================================================
+$NetBSD: MESSAGE.NetBSD,v 1.1.1.1 2006/07/02 16:49:31 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}/xmexample[0-9]*
+
+Please also refer to the the "NetBSD/xen How-To" for more information on
+creating a Xen setup:
+
+ http://www.NetBSD.org/Ports/xen/howto.html
+
+===========================================================================
diff --git a/sysutils/xentools30/Makefile b/sysutils/xentools30/Makefile
new file mode 100644
index 00000000000..de4b0a5d710
--- /dev/null
+++ b/sysutils/xentools30/Makefile
@@ -0,0 +1,177 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+#
+
+DISTNAME= xen-3.0.2-2-src
+PKGNAME= xentools30-3.0.2.2
+CATEGORIES= sysutils
+MASTER_SITES= http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= bouyer@NetBSD.org
+HOMEPAGE= http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
+COMMENT= Userland Tools for Xen
+
+#DEPENDS+= ${PYPKGPREFIX}-twisted-[0-9]*:../../net/py-twisted
+
+PKG_SYSCONFSUBDIR= xen
+
+ONLY_FOR_PLATFORM= Linux-2.[46]*-i386 NetBSD-*-i386
+
+CONFLICTS+= libxen-[0-9]*
+CONFLICTS+= xentools20-[0-9]*
+
+WRKSRC= ${WRKDIR}/xen-3.0.2-2/tools
+
+EGDIR= ${PREFIX}/share/examples/xen
+MESSAGE_SUBST= EGDIR=${EGDIR}
+
+USE_TOOLS+= gmake
+MAKE_ENV+= EGDIR=${EGDIR:Q}
+MAKE_ENV+= MV=${MV:Q} PYTHON=${PYTHONBIN:Q} SED=${SED:Q}
+MAKE_ENV+= XEN_TARGET_ARCH="x86_32"
+MAKE_ENV+= XEN_NO_IOEMU=yes
+PYTHON_VERSIONS_ACCEPTED= 24 23 22
+PY_PATCHPLIST= yes
+PYTHON_PATCH_SCRIPTS= ioemu/keymaps/convert-map
+PYTHON_PATCH_SCRIPTS+= misc/xm
+PYTHON_PATCH_SCRIPTS+= misc/netfix
+PYTHON_PATCH_SCRIPTS+= misc/xen-bugtool
+PYTHON_PATCH_SCRIPTS+= misc/xencons
+PYTHON_PATCH_SCRIPTS+= misc/xend
+PYTHON_PATCH_SCRIPTS+= misc/xensymoops
+PYTHON_PATCH_SCRIPTS+= pygrub/src/fsys/ext2/test.py
+PYTHON_PATCH_SCRIPTS+= pygrub/src/pygrub
+PYTHON_PATCH_SCRIPTS+= python/xen/util/bugtool.py
+PYTHON_PATCH_SCRIPTS+= python/xen/xend/sxp.py
+PYTHON_PATCH_SCRIPTS+= python/xen/xend/XendClient.py
+PYTHON_PATCH_SCRIPTS+= python/test.py
+PYTHON_PATCH_SCRIPTS+= security/python/xensec_gen/cgi-bin/policylabel.cgi
+PYTHON_PATCH_SCRIPTS+= security/python/xensec_gen/cgi-bin/policy.cgi
+PYTHON_PATCH_SCRIPTS+= security/python/xensec_gen/main.py
+PYTHON_PATCH_SCRIPTS+= security/python/setup.py
+PYTHON_PATCH_SCRIPTS+= security/xensec_gen.py
+PYTHON_PATCH_SCRIPTS+= xenmon/xenmon.py
+PYTHON_PATCH_SCRIPTS+= xentrace/xentrace_format
+
+SUBST_CLASSES+= paths
+SUBST_STAGE.paths= pre-configure
+SUBST_FILES.paths= ioemu/vl.c
+SUBST_SED.paths= -e "s|/usr/sbin|${PREFIX}/sbin|g"
+SUBST_MESSAGE.paths= Fixing hardcoded paths.
+
+SUBST_CLASSES+= pathsvar
+SUBST_STAGE.pathsvar= pre-configure
+SUBST_FILES.pathsvar= debugger/pdb/xcs.ml \
+ examples/init.d/sysconfig.xendomains \
+ examples/xend-config.sxp \
+ python/xen/xend/server/relocate.py \
+ python/xen/xend/XendRoot.py \
+ security/Makefile security/python/xensec_gen/main.py \
+ xenstore/Makefile xenstore/xs_lib.c
+SUBST_SED.pathsvar= -e "s|/var/lib|${VARBASE}/run|g"
+
+SUBST_CLASSES+= py
+SUBST_STAGE.py= pre-configure
+SUBST_FILES.py= pygrub/Makefile
+SUBST_FILES.py+= python/Makefile
+SUBST_FILES.py+= security/Makefile
+SUBST_SED.py= -e "s,python,${PYTHONBIN},g"
+
+SUBST_CLASSES+= conf
+SUBST_STAGE.conf= pre-configure
+SUBST_FILES.conf= ioemu/configure
+SUBST_FILES.conf+= ioemu/vl.c
+SUBST_FILES.conf+= python/xen/xend/XendRoot.py
+SUBST_FILES.conf+= python/xen/xm/tests/test_create.py
+SUBST_FILES.conf+= python/xen/xm/create.py
+SUBST_FILES.conf+= security/example.txt
+SUBST_FILES.conf+= security/getlabel.sh
+SUBST_FILES.conf+= security/labelfuncs.sh
+SUBST_FILES.conf+= security/secpol_xml2bin.h
+SUBST_FILES.conf+= security/setlabel.sh
+SUBST_SED.conf= -e "s,@XENDCONFDIR@,${PKG_SYSCONFDIR},g"
+
+SUBST_CLASSES+= prefix
+SUBST_STAGE.prefix= pre-configure
+SUBST_FILES.prefix= python/xen/util/auxbin.py
+SUBST_SED.prefix= -e "s,@PREFIX@,${PREFIX},g"
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${OPSYS} == "NetBSD"
+SUBST_CLASSES+= proc
+SUBST_STAGE.proc= pre-configure
+SUBST_FILES.proc= libxc/xc_misc.c
+SUBST_FILES.proc+= python/xen/xend/XendVnet.py
+SUBST_FILES.proc+= python/xen/xend/balloon.py
+SUBST_FILES.proc+= security/get_decision.c
+SUBST_FILES.proc+= security/secpol_tool.c
+SUBST_FILES.proc+= xenmon/xenbaked.c
+SUBST_FILES.proc+= xenstat/libxenstat/src/xen-interface.c
+SUBST_FILES.proc+= xenstore/xenstored_proc.h
+SUBST_FILES.proc+= xenstore/xs_lib.c
+SUBST_FILES.proc+= xentrace/xentrace.c
+SUBST_SED.proc= -e "s|/proc|/kern|g"
+PROCPATH= /kern
+.else
+PROCPATH= /proc
+.endif
+
+RCD_SCRIPTS= xend xenbackendd xendomains
+FILES_SUBST+= RCD_INTERPRETER=${PYTHONBIN:Q}
+FILES_SUBST+= PROCPATH=${PROCPATH:Q}
+FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
+
+XEND_SCRIPTS= block vif-bridge
+
+CONF_FILES= ${EGDIR}/xend-config.sxp \
+ ${PKG_SYSCONFDIR}/xend-config.sxp
+.for s in ${XEND_SCRIPTS}
+CONF_FILES_PERMS+= ${EGDIR}/${s} ${PKG_SYSCONFDIR}/scripts/${s} \
+ ${ROOT_USER} ${ROOT_GROUP} 0755
+.endfor
+
+OWN_DIRS= ${PKG_SYSCONFDIR}/scripts
+
+pre-build:
+ ${MKDIR} ${WRKSRC}/libxc/xen/NetBSD
+ ${TEST} -f ${WRKSRC}/libxc/xen/NetBSD/xenio.h || ${CP} ${FILESDIR}/xenio.h ${WRKSRC}/libxc/xen/NetBSD
+ ${TEST} -f ${WRKSRC}/libxc/xen/NetBSD/xenio3.h || ${CP} ${FILESDIR}/xenio3.h ${WRKSRC}/libxc/xen/NetBSD
+
+.if ${OPSYS} == "NetBSD"
+post-build:
+ cd ${FILESDIR}; for src in *-nbsd; do \
+ dst="$${src%-nbsd}"; \
+ ${SED} -e "s|@PKG_SYSCONFDIR@|${PKG_SYSCONFDIR}|g" \
+ -e "s|@PREFIX@|${PREFIX}|g" \
+ $$src > ${WRKSRC}/examples/$$dst; \
+ done
+ ${CC} ${CFLAGS} ${LDFLAGS} \
+ -DVBD_SCRIPT=\"${PKG_SYSCONFDIR}/scripts/block\" \
+ -DLOG_FILE=\"${VARBASE}/log/xenbackendd.log\" \
+ -DPID_FILE=\"${VARBASE}/run/xenbackendd.pid\" \
+ -o ${WRKDIR}/xenbackendd.bin ${FILESDIR}/xenbackendd.c \
+ -I${WRKSRC}/libxc -L${WRKSRC}/libxc \
+ -I${WRKSRC}/xenstore -L${WRKSRC}/xenstore \
+ -lxenctrl -lxenstore
+
+.endif
+
+post-install:
+ ${INSTALL_PROGRAM} ${WRKDIR}/xenbackendd.bin ${PREFIX}/sbin/xenbackendd
+ ${INSTALL_DATA_DIR} ${EGDIR}
+ for f in xend-config.sxp xmexample1 xmexample2 xmexample3; do \
+ ${INSTALL_DATA} ${WRKSRC}/examples/$$f ${EGDIR}/$$f; \
+ done
+.for s in ${XEND_SCRIPTS}
+ ${INSTALL_SCRIPT} ${WRKSRC}/examples/${s} ${EGDIR}/${s}
+.endfor
+ ${RM} -rf ${PREFIX}/lib/xen
+
+.include "../../lang/python/application.mk"
+.include "../../lang/python/extension.mk"
+#.include "../../devel/zlib/buildlink3.mk"
+#.include "../../www/curl/buildlink3.mk"
+.include "../../devel/ncurses/buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/xentools30/PLIST b/sysutils/xentools30/PLIST
new file mode 100644
index 00000000000..881ebf83737
--- /dev/null
+++ b/sysutils/xentools30/PLIST
@@ -0,0 +1,262 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+bin/cpuperf-perfcntr
+bin/cpuperf-xen
+bin/xc_restore
+bin/xc_save
+bin/xc_shadow
+bin/xencons
+bin/xenconsole
+bin/xenperf
+bin/xenstore-control
+bin/xenstore-exists
+bin/xenstore-list
+bin/xenstore-ls
+bin/xenstore-read
+bin/xenstore-rm
+bin/xenstore-write
+include/xenctrl.h
+include/xenguest.h
+include/xs.h
+include/xs_lib.h
+lib/libxenctrl.a
+lib/libxenctrl.so
+lib/libxenctrl.so.3.0
+lib/libxenctrl.so.3.0.0
+lib/libxenguest.a
+lib/libxenguest.so
+lib/libxenguest.so.3.0
+lib/libxenguest.so.3.0.0
+lib/libxenstore.so
+man/man1/xentop.1
+${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/sv/CreateDomain.py
+${PYSITELIB}/xen/sv/CreateDomain.pyc
+${PYSITELIB}/xen/sv/DomInfo.py
+${PYSITELIB}/xen/sv/DomInfo.pyc
+${PYSITELIB}/xen/sv/GenTabbed.py
+${PYSITELIB}/xen/sv/GenTabbed.pyc
+${PYSITELIB}/xen/sv/HTMLBase.py
+${PYSITELIB}/xen/sv/HTMLBase.pyc
+${PYSITELIB}/xen/sv/Main.py
+${PYSITELIB}/xen/sv/Main.pyc
+${PYSITELIB}/xen/sv/NodeInfo.py
+${PYSITELIB}/xen/sv/NodeInfo.pyc
+${PYSITELIB}/xen/sv/RestoreDomain.py
+${PYSITELIB}/xen/sv/RestoreDomain.pyc
+${PYSITELIB}/xen/sv/Wizard.py
+${PYSITELIB}/xen/sv/Wizard.pyc
+${PYSITELIB}/xen/sv/__init__.py
+${PYSITELIB}/xen/sv/__init__.pyc
+${PYSITELIB}/xen/sv/util.py
+${PYSITELIB}/xen/sv/util.pyc
+${PYSITELIB}/xen/util/Brctl.py
+${PYSITELIB}/xen/util/Brctl.pyc
+${PYSITELIB}/xen/util/__init__.py
+${PYSITELIB}/xen/util/__init__.pyc
+${PYSITELIB}/xen/util/asserts.py
+${PYSITELIB}/xen/util/asserts.pyc
+${PYSITELIB}/xen/util/auxbin.py
+${PYSITELIB}/xen/util/auxbin.pyc
+${PYSITELIB}/xen/util/blkif.py
+${PYSITELIB}/xen/util/blkif.pyc
+${PYSITELIB}/xen/util/bugtool.py
+${PYSITELIB}/xen/util/bugtool.pyc
+${PYSITELIB}/xen/util/diagnose.py
+${PYSITELIB}/xen/util/diagnose.pyc
+${PYSITELIB}/xen/util/ip.py
+${PYSITELIB}/xen/util/ip.pyc
+${PYSITELIB}/xen/util/mac.py
+${PYSITELIB}/xen/util/mac.pyc
+${PYSITELIB}/xen/util/pci.py
+${PYSITELIB}/xen/util/pci.pyc
+${PYSITELIB}/xen/util/xmlrpclib2.py
+${PYSITELIB}/xen/util/xmlrpclib2.pyc
+${PYSITELIB}/xen/util/xpopen.py
+${PYSITELIB}/xen/util/xpopen.pyc
+${PYSITELIB}/xen/web/SrvBase.py
+${PYSITELIB}/xen/web/SrvBase.pyc
+${PYSITELIB}/xen/web/SrvDir.py
+${PYSITELIB}/xen/web/SrvDir.pyc
+${PYSITELIB}/xen/web/__init__.py
+${PYSITELIB}/xen/web/__init__.pyc
+${PYSITELIB}/xen/web/connection.py
+${PYSITELIB}/xen/web/connection.pyc
+${PYSITELIB}/xen/web/http.py
+${PYSITELIB}/xen/web/http.pyc
+${PYSITELIB}/xen/web/httpserver.py
+${PYSITELIB}/xen/web/httpserver.pyc
+${PYSITELIB}/xen/web/protocol.py
+${PYSITELIB}/xen/web/protocol.pyc
+${PYSITELIB}/xen/web/resource.py
+${PYSITELIB}/xen/web/resource.pyc
+${PYSITELIB}/xen/web/static.py
+${PYSITELIB}/xen/web/static.pyc
+${PYSITELIB}/xen/web/tcp.py
+${PYSITELIB}/xen/web/tcp.pyc
+${PYSITELIB}/xen/web/unix.py
+${PYSITELIB}/xen/web/unix.pyc
+${PYSITELIB}/xen/xend/Args.py
+${PYSITELIB}/xen/xend/Args.pyc
+${PYSITELIB}/xen/xend/PrettyPrint.py
+${PYSITELIB}/xen/xend/PrettyPrint.pyc
+${PYSITELIB}/xen/xend/Vifctl.py
+${PYSITELIB}/xen/xend/Vifctl.pyc
+${PYSITELIB}/xen/xend/XendBootloader.py
+${PYSITELIB}/xen/xend/XendBootloader.pyc
+${PYSITELIB}/xen/xend/XendCheckpoint.py
+${PYSITELIB}/xen/xend/XendCheckpoint.pyc
+${PYSITELIB}/xen/xend/XendClient.py
+${PYSITELIB}/xen/xend/XendClient.pyc
+${PYSITELIB}/xen/xend/XendDmesg.py
+${PYSITELIB}/xen/xend/XendDmesg.pyc
+${PYSITELIB}/xen/xend/XendDomain.py
+${PYSITELIB}/xen/xend/XendDomain.pyc
+${PYSITELIB}/xen/xend/XendDomainInfo.py
+${PYSITELIB}/xen/xend/XendDomainInfo.pyc
+${PYSITELIB}/xen/xend/XendError.py
+${PYSITELIB}/xen/xend/XendError.pyc
+${PYSITELIB}/xen/xend/XendLogging.py
+${PYSITELIB}/xen/xend/XendLogging.pyc
+${PYSITELIB}/xen/xend/XendNode.py
+${PYSITELIB}/xen/xend/XendNode.pyc
+${PYSITELIB}/xen/xend/XendProtocol.py
+${PYSITELIB}/xen/xend/XendProtocol.pyc
+${PYSITELIB}/xen/xend/XendRoot.py
+${PYSITELIB}/xen/xend/XendRoot.pyc
+${PYSITELIB}/xen/xend/XendVnet.py
+${PYSITELIB}/xen/xend/XendVnet.pyc
+${PYSITELIB}/xen/xend/__init__.py
+${PYSITELIB}/xen/xend/__init__.pyc
+${PYSITELIB}/xen/xend/balloon.py
+${PYSITELIB}/xen/xend/balloon.pyc
+${PYSITELIB}/xen/xend/encode.py
+${PYSITELIB}/xen/xend/encode.pyc
+${PYSITELIB}/xen/xend/image.py
+${PYSITELIB}/xen/xend/image.pyc
+${PYSITELIB}/xen/xend/server/DevController.py
+${PYSITELIB}/xen/xend/server/DevController.pyc
+${PYSITELIB}/xen/xend/server/XMLRPCServer.py
+${PYSITELIB}/xen/xend/server/XMLRPCServer.pyc
+${PYSITELIB}/xen/xend/server/SrvDaemon.py
+${PYSITELIB}/xen/xend/server/SrvDaemon.pyc
+${PYSITELIB}/xen/xend/server/SrvDmesg.py
+${PYSITELIB}/xen/xend/server/SrvDmesg.pyc
+${PYSITELIB}/xen/xend/server/SrvDomain.py
+${PYSITELIB}/xen/xend/server/SrvDomain.pyc
+${PYSITELIB}/xen/xend/server/SrvDomainDir.py
+${PYSITELIB}/xen/xend/server/SrvDomainDir.pyc
+${PYSITELIB}/xen/xend/server/SrvNode.py
+${PYSITELIB}/xen/xend/server/SrvNode.pyc
+${PYSITELIB}/xen/xend/server/SrvRoot.py
+${PYSITELIB}/xen/xend/server/SrvRoot.pyc
+${PYSITELIB}/xen/xend/server/SrvServer.py
+${PYSITELIB}/xen/xend/server/SrvServer.pyc
+${PYSITELIB}/xen/xend/server/SrvVnetDir.py
+${PYSITELIB}/xen/xend/server/SrvVnetDir.pyc
+${PYSITELIB}/xen/xend/server/SrvXendLog.py
+${PYSITELIB}/xen/xend/server/SrvXendLog.pyc
+${PYSITELIB}/xen/xend/server/__init__.py
+${PYSITELIB}/xen/xend/server/__init__.pyc
+${PYSITELIB}/xen/xend/server/blkif.py
+${PYSITELIB}/xen/xend/server/blkif.pyc
+${PYSITELIB}/xen/xend/server/iopif.py
+${PYSITELIB}/xen/xend/server/iopif.pyc
+${PYSITELIB}/xen/xend/server/irqif.py
+${PYSITELIB}/xen/xend/server/irqif.pyc
+${PYSITELIB}/xen/xend/server/netif.py
+${PYSITELIB}/xen/xend/server/netif.pyc
+${PYSITELIB}/xen/xend/server/params.py
+${PYSITELIB}/xen/xend/server/params.pyc
+${PYSITELIB}/xen/xend/server/pciif.py
+${PYSITELIB}/xen/xend/server/pciif.pyc
+${PYSITELIB}/xen/xend/server/relocate.py
+${PYSITELIB}/xen/xend/server/relocate.pyc
+${PYSITELIB}/xen/xend/server/tests/__init__.py
+${PYSITELIB}/xen/xend/server/tests/__init__.pyc
+${PYSITELIB}/xen/xend/server/tests/test_controllers.py
+${PYSITELIB}/xen/xend/server/tests/test_controllers.pyc
+${PYSITELIB}/xen/xend/server/tpmif.py
+${PYSITELIB}/xen/xend/server/tpmif.pyc
+${PYSITELIB}/xen/xend/server/usbif.py
+${PYSITELIB}/xen/xend/server/usbif.pyc
+${PYSITELIB}/xen/xend/sxp.py
+${PYSITELIB}/xen/xend/sxp.pyc
+${PYSITELIB}/xen/xend/tests/__init__.py
+${PYSITELIB}/xen/xend/tests/__init__.pyc
+${PYSITELIB}/xen/xend/tests/test_sxp.py
+${PYSITELIB}/xen/xend/tests/test_sxp.pyc
+${PYSITELIB}/xen/xend/tests/test_uuid.py
+${PYSITELIB}/xen/xend/tests/test_uuid.pyc
+${PYSITELIB}/xen/xend/uuid.py
+${PYSITELIB}/xen/xend/uuid.pyc
+${PYSITELIB}/xen/xend/xenstore/__init__.py
+${PYSITELIB}/xen/xend/xenstore/__init__.pyc
+${PYSITELIB}/xen/xend/xenstore/tests/__init__.py
+${PYSITELIB}/xen/xend/xenstore/tests/__init__.pyc
+${PYSITELIB}/xen/xend/xenstore/tests/stress_xs.py
+${PYSITELIB}/xen/xend/xenstore/tests/stress_xs.pyc
+${PYSITELIB}/xen/xend/xenstore/xstransact.py
+${PYSITELIB}/xen/xend/xenstore/xstransact.pyc
+${PYSITELIB}/xen/xend/xenstore/xsutil.py
+${PYSITELIB}/xen/xend/xenstore/xsutil.pyc
+${PYSITELIB}/xen/xend/xenstore/xswatch.py
+${PYSITELIB}/xen/xend/xenstore/xswatch.pyc
+${PYSITELIB}/xen/xm/__init__.py
+${PYSITELIB}/xen/xm/__init__.pyc
+${PYSITELIB}/xen/xm/console.py
+${PYSITELIB}/xen/xm/console.pyc
+${PYSITELIB}/xen/xm/create.py
+${PYSITELIB}/xen/xm/create.pyc
+${PYSITELIB}/xen/xm/help.py
+${PYSITELIB}/xen/xm/help.pyc
+${PYSITELIB}/xen/xm/main.py
+${PYSITELIB}/xen/xm/main.pyc
+${PYSITELIB}/xen/xm/migrate.py
+${PYSITELIB}/xen/xm/migrate.pyc
+${PYSITELIB}/xen/xm/opts.py
+${PYSITELIB}/xen/xm/opts.pyc
+${PYSITELIB}/xen/xm/shutdown.py
+${PYSITELIB}/xen/xm/shutdown.pyc
+${PYSITELIB}/xen/xm/sysrq.py
+${PYSITELIB}/xen/xm/sysrq.pyc
+${PYSITELIB}/xen/xm/tests/__init__.py
+${PYSITELIB}/xen/xm/tests/__init__.pyc
+${PYSITELIB}/xen/xm/tests/test_create.py
+${PYSITELIB}/xen/xm/tests/test_create.pyc
+sbin/netfix
+sbin/xen-bugtool
+sbin/xenbackendd
+sbin/xenconsoled
+sbin/xend
+sbin/xenperf
+sbin/xenstored
+sbin/xentop
+sbin/xm
+share/examples/rc.d/xend
+share/examples/rc.d/xenbackendd
+share/examples/rc.d/xendomains
+share/examples/xen/block
+share/examples/xen/vif-bridge
+share/examples/xen/xend-config.sxp
+share/examples/xen/xmexample1
+share/examples/xen/xmexample2
+share/examples/xen/xmexample3
+@dirrm share/examples/xen
+@dirrm ${PYSITELIB}/xen/xm/tests
+@dirrm ${PYSITELIB}/xen/xm
+@dirrm ${PYSITELIB}/xen/xend/xenstore/tests
+@dirrm ${PYSITELIB}/xen/xend/xenstore
+@dirrm ${PYSITELIB}/xen/xend/tests
+@dirrm ${PYSITELIB}/xen/xend/server/tests
+@dirrm ${PYSITELIB}/xen/xend/server
+@dirrm ${PYSITELIB}/xen/xend
+@dirrm ${PYSITELIB}/xen/web
+@dirrm ${PYSITELIB}/xen/util
+@dirrm ${PYSITELIB}/xen/sv
+@dirrm ${PYSITELIB}/xen/lowlevel
+@dirrm ${PYSITELIB}/xen
diff --git a/sysutils/xentools30/distinfo b/sysutils/xentools30/distinfo
new file mode 100644
index 00000000000..f9804770692
--- /dev/null
+++ b/sysutils/xentools30/distinfo
@@ -0,0 +1,64 @@
+$NetBSD: distinfo,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+SHA1 (xen-3.0.2-2-src.tgz) = 6042611bfc65ce30dc4c56485e9ddc0661d0639b
+RMD160 (xen-3.0.2-2-src.tgz) = 81be04ca7e235874ab099043ac5d924856ea3206
+Size (xen-3.0.2-2-src.tgz) = 4937486 bytes
+SHA1 (patch-aa) = aeb2d9f4b7a2e0c20f85b2a628c09347a03cd661
+SHA1 (patch-ab) = aa92cd8b2b4f4ca4e97241cf6b3e5ba6abdaefaa
+SHA1 (patch-ac) = 0991e75091e5ef85c1e26e6db0a40f6c462322d3
+SHA1 (patch-ad) = 5bcd9f360174bf0c79a64c5c0a9d25650f593591
+SHA1 (patch-ae) = b3c831640fad08ee73a0e63095c6ba2f65f8eed0
+SHA1 (patch-af) = e328cd97dfd01a17fd9b66b841287acb60d7d984
+SHA1 (patch-ag) = 8e11f49bb5c3ac65d5eafc60b9580ed81374d1d4
+SHA1 (patch-ai) = 70cf2681659832ec93d5e4bdb8cb3a94a0c21991
+SHA1 (patch-aj) = db206e84b9bd1d7cf0b4d724dafe3be836590a2c
+SHA1 (patch-ak) = fdbb19ea18399c565687cf7deeafcc351a9eb992
+SHA1 (patch-al) = 026efc19c922e7112182ba96d735df7b75d1134a
+SHA1 (patch-am) = e4678aa131d2971a6d807443347d512b73f77be8
+SHA1 (patch-an) = 71eff89959784370caea701e937f9b3267f26da5
+SHA1 (patch-ao) = c1697a6110d70fd120fd7bddfe8260ffb614fef9
+SHA1 (patch-ap) = fcd55f9e35517f3ba325e0d196bfa20a4007561b
+SHA1 (patch-aq) = 9f6a9ee40292661b2658435a849bc58bd0402d63
+SHA1 (patch-ar) = 43a4dae33a99132df3b1be1d91012d621b1a4170
+SHA1 (patch-as) = dd5ca155328e10cc565a852fec7db26ec157785a
+SHA1 (patch-at) = 19b1ea80068e1f543dc710a6006444029794a148
+SHA1 (patch-au) = a992f922bdd2966c42e71202bb0499b2fbaec5c9
+SHA1 (patch-av) = feb46154a7ff886a480f4089304c29189e4e5f15
+SHA1 (patch-aw) = 92107acf79bcd65330f279d409e8318f7f2f88c5
+SHA1 (patch-ax) = bba82ce8f8dcae534241525711ad24c7828cb64c
+SHA1 (patch-ay) = d731e9b53a4d4e47bf254d35578cf0267f124b8d
+SHA1 (patch-az) = 5bb357f715f1244b080929cd8bec3bd3b9993cc8
+SHA1 (patch-ba) = e82485eecbc1d7686193df960f136b7357f7a26a
+SHA1 (patch-bb) = 1ed5c183165683cb790da0011edaf80fa396496e
+SHA1 (patch-bc) = fbe49ba2f56c030ca4ebbb687ef6591d511651a1
+SHA1 (patch-bd) = af02f54fcade81d269e5ca57976309c9689e0964
+SHA1 (patch-be) = 6754b24adfebdea9c28389eb6a07fe3166515597
+SHA1 (patch-bf) = 56ae1ad68a97dde03485ea5fff22244836297941
+SHA1 (patch-bg) = 0d2e2685f4a087ed15ebd28b52dda72636358f7b
+SHA1 (patch-bh) = 17a94cff5b54c93c0f881a86b9776c88c4265cdd
+SHA1 (patch-bi) = 96f6e3ee65a1f5768586c2940896425044098bd6
+SHA1 (patch-bj) = 9df77974f9d036682ee579f4686686e6d83ee12f
+SHA1 (patch-bk) = 894cc935df346a10906b1a1595aa88084eb6c13f
+SHA1 (patch-bl) = 050f6a2c7c85c151156529aedaa4409c2ba9332f
+SHA1 (patch-bm) = a067747f79217200fb6e9b015371d66950067d20
+SHA1 (patch-bn) = c3a3e047183f3749c5c57d930ee9dd36d7e2c815
+SHA1 (patch-bo) = 97d2856032df83e2d42b8be020dd9573bf67eedf
+SHA1 (patch-bp) = 1d9791314f346a3503df82272e6ea3c5095c4ca7
+SHA1 (patch-bq) = 227429f42f75f38a6f210346f7690ddfcae55e0f
+SHA1 (patch-br) = 5027d715695623a7f50cad6cfac47850134cac77
+SHA1 (patch-bs) = a7834c8fb2ed1f3a8881574658436607d756c939
+SHA1 (patch-bt) = 69b74c8bc9e6ca936b9a72c6662696e6034f1ceb
+SHA1 (patch-bu) = 0e6bd9edf9cbc67d4b936a7661c71b47a8c792ec
+SHA1 (patch-bv) = 197887df84a0ac3d32f4de007da7b9d50339b97c
+SHA1 (patch-bw) = 551e5bcc4dd24c32f3ff717fe673e88f0bfc77e6
+SHA1 (patch-bx) = 2a6cdb8031cde2751a85fa80428f6844d9bbd25d
+SHA1 (patch-by) = 295d65fd562f6b73ea33134ab478c74a0c653e78
+SHA1 (patch-bz) = e633fcafd903f393ad4637910dba7cbaf544bdfb
+SHA1 (patch-ca) = 83b5b070feeeefa297231880387fc5791c4d7cea
+SHA1 (patch-cb) = 2b758bb5f0b6cc2d22bc2ef1f42e17e3a5909dc0
+SHA1 (patch-cc) = 3121541fb0cc2b881a04f75da8d27862f4290bbb
+SHA1 (patch-cd) = 16a673525f889d33e63f2fdc4e88a1419dddfe52
+SHA1 (patch-ce) = d4351bab7e2349565e9ffb55dc241fce652a2bf9
+SHA1 (patch-cf) = 7a28c13bb36877bdfc4c1212da968c165369769a
+SHA1 (patch-cg) = 93cc78ef8a075a3e9934bccd218681d289ce5c92
+SHA1 (patch-ch) = 23e553d0e4493d180d3974fe740326953f06a2b4
diff --git a/sysutils/xentools30/files/block-nbsd b/sysutils/xentools30/files/block-nbsd
new file mode 100644
index 00000000000..f8d334247ba
--- /dev/null
+++ b/sysutils/xentools30/files/block-nbsd
@@ -0,0 +1,88 @@
+#!/bin/sh -e
+
+# $NetBSD: block-nbsd,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+# Called by xenbackendd
+# Usage: block xsdir_backend_path state
+
+PATH=/bin:/usr/bin:@PREFIX@/bin:/sbin:/usr/sbin:@PREFIX@/sbin
+export PATH
+
+error() {
+ echo "$@" >&2
+ xenstore_write $xpath/hotplug-status error
+ exit 1
+}
+
+
+xpath=$1
+xstatus=$2
+xtype=$(xenstore-read "$xpath/type")
+xparams=$(xenstore-read "$xpath/params")
+
+case $xstatus in
+6)
+ # device removed
+ case $xtype in
+ file)
+ vnd=$(xenstore-read "$xpath/vnd" || echo none)
+ if [ $vnd != none ]; then
+ vnconfig -u $vnd
+ fi
+ ;;
+ phy)
+ ;;
+ *)
+ echo "unknown type $xtype" >&2
+ ;;
+ esac
+ xenstore-rm $xpath
+ exit 0
+ ;;
+2)
+ case $xtype in
+ file)
+ # Store the list of available vnd(4) devices in
+ #``available_disks'', and mark them as ``free''.
+ list=`ls -1 /dev/vnd[0-9]*d | sed "s,/dev/vnd,,;s,d,," | sort -n`
+ for i in $list; do
+ disk="vnd$i"
+ available_disks="$available_disks $disk"
+ eval $disk=free
+ done
+ # Mark the used vnd(4) devices as ``used''.
+ for disk in `sysctl hw.disknames`; do
+ case $disk in
+ vnd[0-9]*) eval $disk=used ;;
+ esac
+ done
+ # Configure the first free vnd(4) device.
+ for disk in $available_disks; do
+ eval status=\$$disk
+ if [ "$status" = "free" ] && \
+ vnconfig /dev/${disk}d $xparams >/dev/null; then
+ device=/dev/${disk}d
+ echo vnconfig /dev/${disk}d $xparams
+ break
+ fi
+ done
+ if [ x$device = x ] ; then
+ error "no available vnd device"
+ fi
+ echo xenstore-write $xpath/vnd $device
+ xenstore-write $xpath/vnd $device
+ ;;
+ phy)
+ device=$xparams
+ ;;
+ esac
+ physical_device=$(stat -f '%r' "$device")
+ echo xenstore-write $xpath/physical-device $physical_device
+ xenstore-write $xpath/physical-device $physical_device
+ echo xenstore-write $xpath/hotplug-status connected
+ xenstore-write $xpath/hotplug-status connected
+ exit 0
+ ;;
+*)
+ exit 0
+ ;;
+esac
diff --git a/sysutils/xentools30/files/vif-bridge-nbsd b/sysutils/xentools30/files/vif-bridge-nbsd
new file mode 100644
index 00000000000..602ecec180c
--- /dev/null
+++ b/sysutils/xentools30/files/vif-bridge-nbsd
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+# $NetBSD: vif-bridge-nbsd,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+# Called by xenbackendd
+# Usage: vif-bridge xsdir_backend_path state
+
+PATH=/bin:/usr/bin:@PREFIX@/bin:/sbin:/usr/sbin:@PREFIX@/sbin
+export PATH
+
+xpath=$1
+xstatus=$2
+
+case $xstatus in
+6)
+ # device removed
+ xenstore-rm $xpath
+ exit 0
+ ;;
+2)
+ xbridge=$(xenstore-read "$xpath/bridge")
+ xfid=$(xenstore-read "$xpath/frontend-id")
+ xhandle=$(xenstore-read "$xpath/handle")
+ iface=xvif$xfid.$xhandle
+ echo ifconfig $iface up
+ ifconfig $iface up
+ brconfig $xbridge add $iface
+ echo brconfig $xbridge add $iface
+ xenstore-write $xpath/hotplug-status connected
+ echo xenstore-write $xpath/hotplug-status connected
+ exit 0
+ ;;
+*)
+ exit 0
+ ;;
+esac
diff --git a/sysutils/xentools30/files/xenbackendd.c b/sysutils/xentools30/files/xenbackendd.c
new file mode 100644
index 00000000000..d9eda55f70c
--- /dev/null
+++ b/sysutils/xentools30/files/xenbackendd.c
@@ -0,0 +1,319 @@
+/* $NetBSD: xenbackendd.c,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $ */
+/*
+ * Copyright (C) 2006 Manuel bouyer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <stdbool.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <string.h>
+#include <syslog.h>
+#include <stdarg.h>
+
+#include <xenctrl.h>
+#include <xs.h>
+
+#define DEVTYPE_UNKNOWN 0
+#define DEVTYPE_VIF 1
+#define DEVTYPE_VBD 2
+
+#define DOMAIN_PATH "/local/domain/0"
+
+#ifndef VBD_SCRIPT
+#define VBD_SCRIPT "/usr/pkg/etc/xen/scripts/block"
+#endif
+#ifndef LOG_FILE
+#define LOG_FILE "/var/log/xenbackendd.log"
+#endif
+#ifndef PID_FILE
+#define PID_FILE "/var/run/xenbackendd.pid"
+#endif
+
+
+struct xs_handle *xs;
+int xc;
+
+int xen_setup(void);
+void dolog(int, const char *, ...);
+void dodebug(const char *, ...);
+void doexec(const char *, const char *, const char *);
+void usage(void);
+
+int fflag = 0;
+int dflag = 0;
+
+const char *vbd_script = NULL;
+const char *log_file = NULL;
+const char *pidfile = NULL;
+int
+main(int argc, char * const argv[])
+{
+ char **vec;
+ unsigned int num;
+ int i;
+ char *s;
+ int state;
+ char *sstate;
+ char *p;
+ char buf[80];
+ int type = DEVTYPE_UNKNOWN;
+ extern char *optarg;
+ extern int optind;
+ int ch;
+ int debug_fd;
+ FILE *pidfile_f;
+
+ while ((ch = getopt(argc, argv, "dfl:p:s:")) != -1) {
+ switch (ch) {
+ case 'd':
+ dflag = 1;
+ break;
+ case 'f':
+ fflag = 1;
+ break;
+ case 'l':
+ log_file = optarg;
+ break;
+ case 'p':
+ pidfile = pidfile;
+ case 's':
+ vbd_script = optarg;
+ break;
+ default:
+ usage();
+ }
+ }
+
+ if (vbd_script == NULL)
+ vbd_script = VBD_SCRIPT;
+ if (pidfile == NULL)
+ pidfile = PID_FILE;
+ if (log_file == NULL)
+ log_file = LOG_FILE;
+
+ openlog("xenbackendd", LOG_PID | LOG_NDELAY, LOG_DAEMON);
+
+ if (fflag == 0) {
+ /* open log file */
+ debug_fd = open(log_file, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ if (debug_fd == -1) {
+ dolog(LOG_ERR, "can't open %s: %s",
+ log_file, strerror(errno));
+ exit(1);
+ }
+ }
+
+ if (fflag == 0) {
+ /* daemonize */
+ pidfile_f = fopen(pidfile, "w");
+ if (pidfile_f == NULL) {
+ dolog(LOG_ERR, "can't open %s: %s",
+ pidfile, strerror(errno));
+ exit(1);
+ }
+ if (daemon(0, 0) < 0) {
+ dolog(LOG_ERR, "can't daemonize: %s",
+ strerror(errno));
+ exit(1);
+ }
+ fprintf(pidfile_f, "%d\n", (int)getpid());
+ fclose(pidfile_f);
+ /* retirect stderr to log file */
+ if (dup2(debug_fd, STDERR_FILENO) < 0) {
+ dolog(LOG_ERR, "can't redirect stderr to %s: %s\n",
+ log_file, strerror(errno));
+ exit(1);
+ }
+ /* also redirect stdout if we're in debug mode */
+ if (dflag) {
+ if (dup2(debug_fd, STDOUT_FILENO) < 0) {
+ dolog(LOG_ERR,
+ "can't redirect stdout to %s: %s\n",
+ log_file, strerror(errno));
+ exit(1);
+ }
+ }
+ close(debug_fd);
+ debug_fd = -1;
+ }
+
+ if (xen_setup() < 0) {
+ exit(1);
+ }
+
+ while (1) {
+ vec = xs_read_watch(xs, &num);
+ if (!vec) {
+ dolog(LOG_ERR, "xs_read_watch: NULL\n");
+ continue;
+ }
+ if (strlen(vec[XS_WATCH_PATH]) < sizeof("state"))
+ goto next1;
+ /* find last component of path, check if it's "state" */
+ p = &vec[XS_WATCH_PATH][
+ strlen(vec[XS_WATCH_PATH]) - sizeof("state")];
+ if (p[0] != '/')
+ goto next1;
+ p[0] = '\0';
+ p++;
+ if (strcmp(p, "state") != 0)
+ goto next1;
+ snprintf(buf, sizeof(buf), "%s/state", vec[XS_WATCH_PATH]);
+ sstate = xs_read(xs, XBT_NULL, buf, 0);
+ if (sstate == NULL) {
+ dolog(LOG_ERR,
+ "Failed to read %s (%s)", buf, strerror(errno));
+ goto next1;
+ }
+ state = atoi(sstate);
+ snprintf(buf, sizeof(buf), "%s/hotplug-status",
+ vec[XS_WATCH_PATH]);
+ s = xs_read(xs, XBT_NULL, buf, 0);
+ if (s != NULL && state != 6 /* XenbusStateClosed */)
+ goto next2;
+ if (strncmp(vec[XS_WATCH_PATH],
+ DOMAIN_PATH "/backend/vif",
+ strlen(DOMAIN_PATH "/backend/vif")) == 0)
+ type = DEVTYPE_VIF;
+ if (strncmp(vec[XS_WATCH_PATH],
+ DOMAIN_PATH "/backend/vbd",
+ strlen(DOMAIN_PATH "/backend/vbd")) == 0)
+ type = DEVTYPE_VBD;
+ switch(type) {
+ case DEVTYPE_VIF:
+ if (s)
+ free(s);
+ snprintf(buf, sizeof(buf), "%s/script",
+ vec[XS_WATCH_PATH]);
+ s = xs_read(xs, XBT_NULL, buf, 0);
+ if (s == NULL) {
+ dolog(LOG_ERR,
+ "Failed to read %s (%s)", buf,
+ strerror(errno));
+ goto next2;
+ }
+ doexec(s, vec[XS_WATCH_PATH], sstate);
+ break;
+ case DEVTYPE_VBD:
+ doexec(vbd_script, vec[XS_WATCH_PATH], sstate);
+ break;
+ default:
+ break;
+ }
+next2:
+ if (s)
+ free(s);
+ free(sstate);
+next1:
+ free(vec);
+ }
+}
+
+void
+dolog(int pri, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ va_start(ap, fmt);
+ vsyslog(pri, fmt, ap);
+ va_end(ap);
+}
+
+void
+dodebug(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (dflag == 0)
+ return;
+ va_start(ap, fmt);
+ vfprintf(stdout, fmt, ap);
+ va_end(ap);
+ printf("\n");
+ fflush(stdout);
+}
+
+int
+xen_setup(void)
+{
+
+ xs = xs_daemon_open();
+ if (xs == NULL) {
+ dolog(LOG_ERR,
+ "Failed to contact xenstore (%s). Is it running?",
+ strerror(errno));
+ goto out;
+ }
+
+ xc = xc_interface_open();
+ if (xc == -1) {
+ dolog(LOG_ERR, "Failed to contact hypervisor (%s)",
+ strerror(errno));
+ goto out;
+ }
+ if (!xs_watch(xs, DOMAIN_PATH, "backend")) {
+ dolog(LOG_ERR, "xenstore watch on backend fails.");
+ goto out;
+ }
+ return 0;
+ out:
+ if (xs)
+ xs_daemon_close(xs);
+ if (xc != -1)
+ xc_interface_close(xc);
+ return -1;
+}
+
+void
+doexec(const char *cmd, const char *arg1, const char *arg2)
+{
+ dodebug("exec %s %s %s", cmd, arg1, arg2);
+ switch(vfork()) {
+ case -1:
+ dolog(LOG_ERR, "can't vfork: %s", strerror(errno));
+ break;
+ case 0:
+ execl(cmd, cmd, arg1, arg2, NULL);
+ dolog(LOG_ERR, "can't exec %s: %s", cmd, strerror(errno));
+ exit(1);
+ break;
+ default:
+ wait(NULL);
+ break;
+ }
+}
+
+void
+usage()
+{
+ fprintf(stderr, "usage: %s [-d] [-f] [-l log_file] [-p pif_file] [-s vbd_script]\n",
+ getprogname());
+ exit(1);
+}
diff --git a/sysutils/xentools30/files/xenbackendd.sh b/sysutils/xentools30/files/xenbackendd.sh
new file mode 100644
index 00000000000..adb27fa08f8
--- /dev/null
+++ b/sysutils/xentools30/files/xenbackendd.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $NetBSD: xenbackendd.sh,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+#
+
+# PROVIDE: xenbackendd
+# REQUIRE: xend
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="xenbackendd"
+rcvar=$name
+command="@PREFIX@/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/sysutils/xentools30/files/xend.sh b/sysutils/xentools30/files/xend.sh
new file mode 100644
index 00000000000..868b807edd5
--- /dev/null
+++ b/sysutils/xentools30/files/xend.sh
@@ -0,0 +1,29 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: xend.sh,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+#
+# PROVIDE: xend
+# REQUIRE: disks network
+
+. /etc/rc.subr
+
+name="xend"
+rcvar=$name
+command="@PREFIX@/sbin/xend"
+command_interpreter="@RCD_INTERPRETER@"
+start_cmd="@ECHO@ Starting ${name}. && PATH=${PATH}:@PREFIX@/sbin ${command} start"
+start_precmd="xen_precmd"
+privcmd_path="@PROCPATH@/xen/privcmd"
+
+xen_precmd()
+{
+ if [ ! -f ${privcmd_path} ]; then
+ @ECHO@ "${name}: Cannot find ${privcmd_path}!"
+ exit 1
+ fi
+ mkdir -p /var/run/xend || exit 1
+ mkdir -p /var/run/xenstored || exit 1
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/sysutils/xentools30/files/xendomains.sh b/sysutils/xentools30/files/xendomains.sh
new file mode 100644
index 00000000000..c3f35bb88db
--- /dev/null
+++ b/sysutils/xentools30/files/xendomains.sh
@@ -0,0 +1,134 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: xendomains.sh,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+#
+# PROVIDE: xendomains
+# REQUIRE: xenbackendd
+# 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/xm"
+start_cmd="xendomains_start"
+stop_cmd="xendomains_stop"
+list_cmd="xendomains_list"
+extra_commands="list"
+privcmd_path="@PROCPATH@/xen/privcmd"
+
+xendomains_start()
+{
+ [ -n "$xendomains" ] || return
+
+ if [ ! -f ${privcmd_path} ]; then
+ echo "${name}: Cannot find ${privcmd_path}!"
+ exit 1
+ fi
+
+ 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
+ $cmdline || echo "Pre-hook \`\`$cmdline'' failed... skipping $domain."
+ continue
+ 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 --halt $domain
+ done
+ while [ $timeout -gt 0 ]; do
+ livedomains=$(xendomains_list)
+ [ -n "$livedomains" ] || break
+ timeout=$((timeout - 10))
+ sleep 10
+ done
+ livedomains=$(xendomains_list)
+ if [ -n "$livedomains" ]; then
+ echo "Failed to stop: $livedomains"
+ else
+ echo "All domains stopped."
+ fi
+
+ # Finish off by running the post-hook script if it's present.
+ for domain in $xendomains; do
+ case "$domain" in
+ "") continue ;;
+ esac
+ if [ -n "${xendomains_posthook}" ]; then
+ cmdline=`printf "${xendomains_posthook}" $domain`
+ cmd="${cmdline%% *}"
+ if [ -x "$cmd" ]; then
+ $cmdline || echo "Post-hook \`\`$cmdline'' failed."
+ fi
+ fi
+ done
+}
+
+load_rc_config $name
+
+: ${xendomains_config="@PKG_SYSCONFDIR@/%s"}
+: ${xendomains_prehook="@PKG_SYSCONFDIR@/%s-pre"}
+: ${xendomains_posthook="@PKG_SYSCONFDIR@/%s-post"}
+
+run_rc_command "$1"
diff --git a/sysutils/xentools30/files/xenio.h b/sysutils/xentools30/files/xenio.h
new file mode 100644
index 00000000000..b4514a1831b
--- /dev/null
+++ b/sysutils/xentools30/files/xenio.h
@@ -0,0 +1,105 @@
+/* NetBSD: xenio.h,v 1.3 2005/05/24 12:07:12 yamt Exp $ */
+
+/******************************************************************************
+ * privcmd.h
+ *
+ * Copyright (c) 2003-2004, K A Fraser
+ *
+ * This file may be 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 __PRIVCMD_H__
+#define __PRIVCMD_H__
+
+/* Interface to /proc/xen/privcmd */
+
+typedef struct privcmd_hypercall
+{
+ unsigned long op;
+ unsigned long arg[5];
+} privcmd_hypercall_t;
+
+typedef struct privcmd_mmap_entry {
+ unsigned long va;
+ unsigned long mfn;
+ unsigned long npages;
+} privcmd_mmap_entry_t;
+
+typedef struct privcmd_mmap {
+ int num;
+ domid_t dom; /* target domain */
+ privcmd_mmap_entry_t *entry;
+} privcmd_mmap_t;
+
+typedef struct privcmd_mmapbatch {
+ int num; /* number of pages to populate */
+ domid_t dom; /* target domain */
+ unsigned long addr; /* virtual address */
+ unsigned long *arr; /* array of mfns - top nibble set on err */
+} privcmd_mmapbatch_t;
+
+typedef struct privcmd_blkmsg
+{
+ unsigned long op;
+ void *buf;
+ int buf_size;
+} privcmd_blkmsg_t;
+
+/*
+ * @cmd: IOCTL_PRIVCMD_HYPERCALL
+ * @arg: &privcmd_hypercall_t
+ * Return: Value returned from execution of the specified hypercall.
+ */
+#define IOCTL_PRIVCMD_HYPERCALL \
+ _IOWR('P', 0, privcmd_hypercall_t)
+
+#if defined(_KERNEL)
+/* compat */
+#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN_OLD \
+ _IO('P', 1)
+#endif /* defined(_KERNEL) */
+
+#define IOCTL_PRIVCMD_MMAP \
+ _IOW('P', 2, privcmd_mmap_t)
+#define IOCTL_PRIVCMD_MMAPBATCH \
+ _IOW('P', 3, privcmd_mmapbatch_t)
+#define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
+ _IOR('P', 4, unsigned long)
+
+/*
+ * @cmd: IOCTL_PRIVCMD_INITDOMAIN_EVTCHN
+ * @arg: n/a
+ * Return: Port associated with domain-controller end of control event channel
+ * for the initial domain.
+ */
+#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN \
+ _IOR('P', 5, int)
+
+/* Interface to /dev/xenevt */
+/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
+#define EVTCHN_RESET _IO('E', 1)
+/* EVTCHN_BIND: Bind to the specified event-channel port. */
+#define EVTCHN_BIND _IOW('E', 2, unsigned long)
+/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
+#define EVTCHN_UNBIND _IOW('E', 3, unsigned long)
+
+#endif /* __PRIVCMD_H__ */
diff --git a/sysutils/xentools30/files/xenio3.h b/sysutils/xentools30/files/xenio3.h
new file mode 100644
index 00000000000..2c74ae376e6
--- /dev/null
+++ b/sysutils/xentools30/files/xenio3.h
@@ -0,0 +1,89 @@
+/* $NetBSD: xenio3.h,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $ */
+/******************************************************************************
+ * evtchn.h
+ *
+ * Interface to /dev/xen/evtchn.
+ *
+ * Copyright (c) 2003-2005, K A Fraser
+ *
+ * This file may be 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 __LINUX_PUBLIC_EVTCHN_H__
+#define __LINUX_PUBLIC_EVTCHN_H__
+
+/*
+ * Bind a fresh port to VIRQ @virq.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_VIRQ \
+ _IOWR('E', 4, struct ioctl_evtchn_bind_virq)
+struct ioctl_evtchn_bind_virq {
+ unsigned int virq;
+ unsigned int port;
+};
+
+/*
+ * Bind a fresh port to remote <@remote_domain, @remote_port>.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_INTERDOMAIN \
+ _IOWR('E', 5, struct ioctl_evtchn_bind_interdomain)
+struct ioctl_evtchn_bind_interdomain {
+ unsigned int remote_domain, remote_port;
+ unsigned int port;
+};
+
+/*
+ * Allocate a fresh port for binding to @remote_domain.
+ * Return allocated port.
+ */
+#define IOCTL_EVTCHN_BIND_UNBOUND_PORT \
+ _IOWR('E', 6, struct ioctl_evtchn_bind_unbound_port)
+struct ioctl_evtchn_bind_unbound_port {
+ unsigned int remote_domain;
+ unsigned int port;
+};
+
+/*
+ * Unbind previously allocated @port.
+ */
+#define IOCTL_EVTCHN_UNBIND \
+ _IOW('E', 7, struct ioctl_evtchn_unbind)
+struct ioctl_evtchn_unbind {
+ unsigned int port;
+};
+
+/*
+ * Send event to previously allocated @port.
+ */
+#define IOCTL_EVTCHN_NOTIFY \
+ _IOW('E', 8, struct ioctl_evtchn_notify)
+struct ioctl_evtchn_notify {
+ unsigned int port;
+};
+
+/* Clear and reinitialise the event buffer. Clear error condition. */
+#define IOCTL_EVTCHN_RESET \
+ _IO('E', 9)
+
+#endif /* __LINUX_PUBLIC_EVTCHN_H__ */
diff --git a/sysutils/xentools30/patches/patch-aa b/sysutils/xentools30/patches/patch-aa
new file mode 100644
index 00000000000..23a901a32ee
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-aa
@@ -0,0 +1,45 @@
+$NetBSD: patch-aa,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- Makefile.orig 2006-01-31 17:09:20.000000000 +0100
++++ Makefile
+@@ -5,23 +5,18 @@ SUBDIRS :=
+ SUBDIRS += libxc
+ SUBDIRS += xenstore
+ SUBDIRS += misc
+-SUBDIRS += examples
+-SUBDIRS += xentrace
+ SUBDIRS += xcutils
+ SUBDIRS += firmware
+ SUBDIRS += security
+ SUBDIRS += console
+-SUBDIRS += xenmon
+-SUBDIRS += guest-headers
+ ifeq ($(VTPM_TOOLS),y)
+ SUBDIRS += vtpm_manager
+ SUBDIRS += vtpm
+ endif
+ SUBDIRS += xenstat
+ # These don't cross-compile
+ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
+ SUBDIRS += python
+-SUBDIRS += pygrub
+ endif
+
+ .PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean
+@@ -45,15 +39,13 @@ clean: check_clean
+ $(MAKE) ioemuclean
+
+ check:
+- $(MAKE) -C check
+
+ check_clean:
+- $(MAKE) -C check clean
+
+ ifndef XEN_NO_IOEMU
+ ioemu ioemuinstall ioemuclean:
+ [ -f ioemu/config-host.h ] || \
+- (cd ioemu; ./configure --prefix=usr)
++ (cd ioemu; ./configure --prefix=$(PREFIX))
+ $(MAKE) -C ioemu $(patsubst ioemu%,%,$@)
+ else
+ ioemu ioemuinstall ioemuclean:
diff --git a/sysutils/xentools30/patches/patch-ab b/sysutils/xentools30/patches/patch-ab
new file mode 100644
index 00000000000..309cb61cc4a
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ab
@@ -0,0 +1,28 @@
+$NetBSD: patch-ab,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- blktap/Makefile.orig 2006-01-31 17:09:20.000000000 +0100
++++ blktap/Makefile
+@@ -48,10 +48,10 @@ all: mk-symlinks libblktap.so #blkdump
+ done
+
+ install: all
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/include
+- $(INSTALL_PROG) $(LIB) $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_PROG) blktaplib.h $(DESTDIR)/usr/include
++ $(BSD_INSTALL_LIB_DIR) $(PREFIX)/lib
++ $(BSD_INSTALL_DATA_DIR) $(PREFIX)/include
++ $(BSD_INSTALL_LIB) $(LIB) $(PREFIX)/lib
++ $(BSD_INSTALL_DATA) blktaplib.h $(PREFIX)/include
+ #$(INSTALL_PROG) $(IBINS) $(DESTDIR)$(BLKTAP_INSTALL_DIR)
+ @set -e; for subdir in $(SUBDIRS); do \
+ $(MAKE) -C $$subdir $@; \
+@@ -80,7 +80,7 @@ libblktap.so: $(OBJS)
+ ln -sf libblktap.so.$(MAJOR) $@
+
+ blkdump: libblktap.so
+- $(CC) $(CFLAGS) -o blkdump -L$(XEN_LIBXC) -L. \
++ $(CC) $(CFLAGS) -o blkdump $(LDFLAGS) -L$(XEN_LIBXC) -L. \
+ -l blktap blkdump.c
+
+ .PHONY: TAGS clean install mk-symlinks rpm
diff --git a/sysutils/xentools30/patches/patch-ac b/sysutils/xentools30/patches/patch-ac
new file mode 100644
index 00000000000..93c9bf17e1d
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ac
@@ -0,0 +1,22 @@
+$NetBSD: patch-ac,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- blktap/parallax/Makefile.orig 2006-04-10 00:05:52.000000000 +0200
++++ blktap/parallax/Makefile 2006-05-05 21:42:19.000000000 +0200
+@@ -1,7 +1,7 @@
+ XEN_ROOT = ../../..
+ include $(XEN_ROOT)/tools/Rules.mk
+
+-PARALLAX_INSTALL_DIR = /usr/sbin
++PARALLAX_INSTALL_DIR = $(PREFIX)/sbin
+
+ INSTALL = install
+ INSTALL_PROG = $(INSTALL) -m0755
+@@ -46,7 +46,7 @@
+ all: $(VDI_TOOLS) parallax blockstored
+
+ install: all
+- $(INSTALL_PROG) $(IBINS) $(DESTDIR)$(PARALLAX_INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM) $(IBINS) $(PARALLAX_INSTALL_DIR)
+
+ clean:
+ rm -rf *.o *~ $(DEPS) xen TAGS $(VDI_TOOLS) parallax vdi_unittest
diff --git a/sysutils/xentools30/patches/patch-ad b/sysutils/xentools30/patches/patch-ad
new file mode 100644
index 00000000000..0a4c3412ce7
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ad
@@ -0,0 +1,13 @@
+$NetBSD: patch-ad,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- blktap/ublkback/Makefile.orig 2006-01-31 17:09:20.000000000 +0100
++++ blktap/ublkback/Makefile
+@@ -29,7 +29,7 @@ all: $(IBIN)
+ LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
+
+ install:
+- $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM) $(IBIN) $(PREFIX)/sbin
+ clean:
+ rm -rf *.o*~ $(DEPS) xen TAGS $(IBIN)
+
diff --git a/sysutils/xentools30/patches/patch-ae b/sysutils/xentools30/patches/patch-ae
new file mode 100644
index 00000000000..e05fc4a68ee
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ae
@@ -0,0 +1,10 @@
+$NetBSD: patch-ae,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/check_brctl.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/check_brctl
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+ # CHECK-INSTALL
+
+ function error {
diff --git a/sysutils/xentools30/patches/patch-af b/sysutils/xentools30/patches/patch-af
new file mode 100644
index 00000000000..c8026c23eff
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-af
@@ -0,0 +1,10 @@
+$NetBSD: patch-af,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/check_hotplug.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/check_hotplug
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+ # CHECK-INSTALL
+
+ function error {
diff --git a/sysutils/xentools30/patches/patch-ag b/sysutils/xentools30/patches/patch-ag
new file mode 100644
index 00000000000..c8ea2faca7e
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ag
@@ -0,0 +1,10 @@
+$NetBSD: patch-ag,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/check_iproute.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/check_iproute
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+ # CHECK-INSTALL
+
+ function error {
diff --git a/sysutils/xentools30/patches/patch-ai b/sysutils/xentools30/patches/patch-ai
new file mode 100644
index 00000000000..b71fcc4cce1
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ai
@@ -0,0 +1,10 @@
+$NetBSD: patch-ai,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/check_zlib_devel.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/check_zlib_devel
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+ # CHECK-BUILD
+
+ function error {
diff --git a/sysutils/xentools30/patches/patch-aj b/sysutils/xentools30/patches/patch-aj
new file mode 100644
index 00000000000..b4fd832f59a
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-aj
@@ -0,0 +1,17 @@
+$NetBSD: patch-aj,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/check_zlib_lib.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/check_zlib_lib
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+ # CHECK-BUILD CHECK-INSTALL
+
+ function error {
+@@ -7,5 +7,6 @@ function error {
+ exit 1
+ }
+
++exit 0
+ set -e
+ ldconfig -p | grep -q libz.so || error
diff --git a/sysutils/xentools30/patches/patch-ak b/sysutils/xentools30/patches/patch-ak
new file mode 100644
index 00000000000..eb8f82b3238
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ak
@@ -0,0 +1,10 @@
+$NetBSD: patch-ak,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- check/chk.orig 2006-01-31 17:09:20.000000000 +0100
++++ check/chk
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/ksh
+
+ function usage {
+ echo "Usage:"
diff --git a/sysutils/xentools30/patches/patch-al b/sysutils/xentools30/patches/patch-al
new file mode 100644
index 00000000000..152170de457
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-al
@@ -0,0 +1,26 @@
+$NetBSD: patch-al,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- console/Makefile.orig 2006-01-31 17:09:20.000000000 +0100
++++ console/Makefile
+@@ -23,15 +23,15 @@ clean:
+ $(RM) client/*.o daemon/*.o
+
+ xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
+- $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
++ $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
+ -lxenctrl -lxenstore
+
+ xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
+- $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
++ $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
+ -lxenctrl -lxenstore
+
+ install: $(BIN)
+- $(INSTALL_DIR) -p $(DESTDIR)/$(DAEMON_INSTALL_DIR)
+- $(INSTALL_PROG) xenconsoled $(DESTDIR)/$(DAEMON_INSTALL_DIR)
+- $(INSTALL_DIR) -p $(DESTDIR)/$(CLIENT_INSTALL_DIR)
+- $(INSTALL_PROG) xenconsole $(DESTDIR)/$(CLIENT_INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) xenconsoled $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) xenconsole $(PREFIX)/bin
diff --git a/sysutils/xentools30/patches/patch-am b/sysutils/xentools30/patches/patch-am
new file mode 100644
index 00000000000..dffebf0a94c
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-am
@@ -0,0 +1,79 @@
+$NetBSD: patch-am,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- console/daemon/io.c.orig 2006-04-13 19:48:38.000000000 +0200
++++ console/daemon/io.c 2006-05-07 23:26:36.000000000 +0200
+@@ -24,7 +24,11 @@
+ #include "io.h"
+ #include <xenctrl.h>
+ #include <xs.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio3.h>
++#else
+ #include <xen/linux/evtchn.h>
++#endif
+ #include <xen/io/console.h>
+
+ #include <malloc.h>
+@@ -155,22 +159,26 @@
+ int master;
+ bool success;
+
+- if ((master = getpt()) == -1 ||
+- grantpt(master) == -1 || unlockpt(master) == -1) {
+- dolog(LOG_ERR, "Failed to create tty for domain-%d",
+- dom->domid);
+- master = -1;
+- } else {
++ if ((master = posix_openpt(O_RDWR)) == -1) {
++ dolog(LOG_ERR, "Failed to create tty for domain-%d: %s",
++ dom->domid, strerror(errno));
++ return -1;
++ }
++ if (grantpt(master) == -1) {
++ dolog(LOG_ERR, "Failed to grant tty for domain-%d: %s",
++ dom->domid, strerror(errno));
++ goto out;
++ }
++ if (unlockpt(master) == -1) {
++ dolog(LOG_ERR, "Failed to unlock tty for domain-%d: %s",
++ dom->domid, strerror(errno));
++ goto out;
++ }
++ {
+ const char *slave = ptsname(master);
+- struct termios term;
+ char *data;
+ unsigned int len;
+
+- if (tcgetattr(master, &term) != -1) {
+- cfmakeraw(&term);
+- tcsetattr(master, TCSAFLUSH, &term);
+- }
+-
+ success = asprintf(&path, "%s/limit", dom->conspath) != -1;
+ if (!success)
+ goto out;
+@@ -263,7 +271,11 @@
+
+ /* Opening evtchn independently for each console is a bit
+ * wasteful, but that's how the code is structured... */
++#ifdef __NetBSD__
++ dom->evtchn_fd = open("/dev/xenevt", O_RDWR);
++#else
+ dom->evtchn_fd = open("/dev/xen/evtchn", O_RDWR);
++#endif
+ if (dom->evtchn_fd == -1) {
+ err = errno;
+ goto out;
+@@ -278,7 +290,11 @@
+ dom->evtchn_fd = -1;
+ goto out;
+ }
++#ifdef __NetBSD__
++ dom->local_port = bind.port;
++#else
+ dom->local_port = rc;
++#endif
+
+ if (dom->tty_fd == -1) {
+ dom->tty_fd = domain_create_tty(dom);
diff --git a/sysutils/xentools30/patches/patch-an b/sysutils/xentools30/patches/patch-an
new file mode 100644
index 00000000000..f7a54659cfc
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-an
@@ -0,0 +1,24 @@
+$NetBSD: patch-an,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- firmware/Makefile.orig 2006-04-10 00:05:53.000000000 +0200
++++ firmware/Makefile 2006-05-05 21:45:41.000000000 +0200
+@@ -4,7 +4,7 @@
+ # hvmloader is a 32-bit protected mode binary.
+ # It belongs in /usr/lib, not /usr/lib64.
+ TARGET := hvmloader/hvmloader
+-INSTALL_DIR := $(DESTDIR)/usr/lib/xen/boot
++INSTALL_DIR := $(PREFIX)/lib/xen/boot
+
+ SUBDIRS :=
+ SUBDIRS += rombios
+@@ -29,8 +29,8 @@
+
+
+ install: all
+- [ -d $(INSTALL_DIR) ] || install -d -m0755 $(INSTALL_DIR)
+- [ ! -e $(TARGET) ] || install -m0644 $(TARGET) $(INSTALL_DIR)
++# $(BSD_INSTALL_DATA_DIR) $(INSTALL_DIR)
++# $(BSD_INSTALL_DATA) $(TARGET) $(INSTALL_DIR)
+
+ clean:
+ @set -e; for subdir in $(SUBDIRS); do \
diff --git a/sysutils/xentools30/patches/patch-ao b/sysutils/xentools30/patches/patch-ao
new file mode 100644
index 00000000000..865023640e0
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ao
@@ -0,0 +1,22 @@
+$NetBSD: patch-ao,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- ioemu/configure.orig 2006-01-31 17:09:20.000000000 +0100
++++ ioemu/configure
+@@ -230,7 +230,7 @@ fi
+
+ if test -z "$vnc"; then
+
+-if libvncserver-config --version >& /dev/null; then
++if libvncserver-config --version > /dev/null 2>&1; then
+ vnc=yes
+ else
+ vnc=no
+@@ -341,7 +341,7 @@ mandir="$installroot/$prefix/share/man"
+ datadir="$installroot/$prefix/share/xen/qemu"
+ docdir="$installroot/$prefix/share/doc/qemu"
+ bindir="$installroot/$prefix/bin"
+-configdir="$installroot/etc/xen"
++configdir="@XENDCONFDIR@"
+ fi
+
+ echo "Install prefix $prefix"
diff --git a/sysutils/xentools30/patches/patch-ap b/sysutils/xentools30/patches/patch-ap
new file mode 100644
index 00000000000..a809ec21c74
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ap
@@ -0,0 +1,27 @@
+$NetBSD: patch-ap,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- ioemu/target-i386-dm/Makefile.orig 2006-04-10 00:05:53.000000000 +0200
++++ ioemu/target-i386-dm/Makefile 2006-05-05 21:46:45.000000000 +0200
+@@ -4,7 +4,7 @@
+ XEN_ROOT=../../..
+ include $(XEN_ROOT)/tools/Rules.mk
+
+-INSTALL_DIR := $(DESTDIR)/usr/$(LIBDIR)/xen/bin
++INSTALL_DIR := $(PREFIX)/libexec
+ TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
+ VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
+ DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
+@@ -389,11 +389,8 @@
+ distclean: clean
+
+ install: all
+- if [ ! -d $(INSTALL_DIR) ];then mkdir -p $(INSTALL_DIR);fi
+- if [ ! -d $(DESTDIR)$(configdir) ];then mkdir -p $(DESTDIR)$(configdir);fi
+- install -m 755 -s $(PROGS) "$(INSTALL_DIR)"
+- install -m 755 qemu-dm.debug "$(INSTALL_DIR)"
+- install -m 755 qemu-ifup "$(DESTDIR)$(configdir)"
++ $(BSD_INSTALL_PROGRAM_DIR) $(INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM) $(PROGS) $(INSTALL_DIR)
+ ifneq ($(wildcard .depend),)
+ include .depend
+ endif
diff --git a/sysutils/xentools30/patches/patch-aq b/sysutils/xentools30/patches/patch-aq
new file mode 100644
index 00000000000..2d4c1e45333
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-aq
@@ -0,0 +1,40 @@
+$NetBSD: patch-aq,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- ioemu/target-i386-dm/helper2.c.orig 2006-04-10 00:05:53.000000000 +0200
++++ ioemu/target-i386-dm/helper2.c 2006-05-05 21:48:14.000000000 +0200
+@@ -51,7 +51,11 @@
+
+ #include <xenctrl.h>
+ #include <xen/hvm/ioreq.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio3.h>
++#else
+ #include <xen/linux/evtchn.h>
++#endif
+
+ #include "cpu.h"
+ #include "exec-all.h"
+@@ -508,7 +512,11 @@
+ return NULL;
+
+ //use nonblock reading not polling, may change in future.
++#ifdef __NetBSD__
++ evtchn_fd = open("/dev/xenevt", O_RDWR|O_NONBLOCK);
++#else
+ evtchn_fd = open("/dev/xen/evtchn", O_RDWR|O_NONBLOCK);
++#endif
+ if (evtchn_fd == -1) {
+ fprintf(logfile, "open evtchn device error %d\n", errno);
+ return NULL;
+@@ -523,7 +531,11 @@
+ fprintf(logfile, "bind interdomain ioctl error %d\n", errno);
+ return NULL;
+ }
++#ifdef __NetBSD__
++ shared_page->vcpu_iodata[i].dm_eport = bind.port;
++#else
+ shared_page->vcpu_iodata[i].dm_eport = rc;
++#endif
+ }
+
+ return env;
diff --git a/sysutils/xentools30/patches/patch-ar b/sysutils/xentools30/patches/patch-ar
new file mode 100644
index 00000000000..9c6d70a1b71
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ar
@@ -0,0 +1,13 @@
+$NetBSD: patch-ar,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- ioemu/vl.c.orig 2006-01-31 17:09:21.000000000 +0100
++++ ioemu/vl.c
+@@ -81,7 +81,7 @@
+
+ //#define DO_TB_FLUSH
+
+-#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
++#define DEFAULT_NETWORK_SCRIPT "@XENDCONFDIR@/qemu-ifup"
+
+ #if !defined(CONFIG_SOFTMMU)
+ #define PHYS_RAM_MAX_SIZE (256 * 1024 * 1024)
diff --git a/sysutils/xentools30/patches/patch-as b/sysutils/xentools30/patches/patch-as
new file mode 100644
index 00000000000..303e5801d8c
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-as
@@ -0,0 +1,46 @@
+$NetBSD: patch-as,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- libxc/Makefile.orig 2006-04-10 00:05:53.000000000 +0200
++++ libxc/Makefile 2006-05-05 21:49:12.000000000 +0200
+@@ -22,8 +22,6 @@
+ SRCS += xc_tbuf.c
+
+ ifeq ($(patsubst x86%,x86,$(XEN_TARGET_ARCH)),x86)
+-SRCS += xc_ptrace.c
+-SRCS += xc_ptrace_core.c
+ SRCS += xc_pagetab.c
+ endif
+
+@@ -80,19 +78,19 @@
+ fi
+
+ install: build
+- [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
+- [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
+- $(INSTALL_PROG) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DATA) libxenctrl.a $(DESTDIR)/usr/$(LIBDIR)
+- ln -sf libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxenctrl.so.$(MAJOR)
+- ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenctrl.so
+- $(INSTALL_DATA) xenctrl.h $(DESTDIR)/usr/include
+-
+- $(INSTALL_PROG) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DATA) libxenguest.a $(DESTDIR)/usr/$(LIBDIR)
+- ln -sf libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so.$(MAJOR)
+- ln -sf libxenguest.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so
+- $(INSTALL_DATA) xenguest.h $(DESTDIR)/usr/include
++ $(BSD_INSTALL_LIB_DIR) $(PREFIX)/lib
++ $(BSD_INSTALL_DATA_DIR) $(PREFIX)/include
++ $(BSD_INSTALL_LIB) libxenctrl.so.$(MAJOR).$(MINOR) $(PREFIX)/lib
++ $(BSD_INSTALL_LIB) libxenctrl.a $(PREFIX)/lib
++ ln -sf libxenctrl.so.$(MAJOR).$(MINOR) $(PREFIX)/lib/libxenctrl.so.$(MAJOR)
++ ln -sf libxenctrl.so.$(MAJOR) $(PREFIX)/lib/libxenctrl.so
++ $(BSD_INSTALL_DATA) xenctrl.h $(PREFIX)/include
++
++ $(BSD_INSTALL_LIB) libxenguest.so.$(MAJOR).$(MINOR) $(PREFIX)/lib
++ $(BSD_INSTALL_LIB) libxenguest.a $(PREFIX)/lib
++ ln -sf libxenguest.so.$(MAJOR).$(MINOR) $(PREFIX)/lib/libxenguest.so.$(MAJOR)
++ ln -sf libxenguest.so.$(MAJOR) $(PREFIX)/lib/libxenguest.so
++ $(BSD_INSTALL_DATA) xenguest.h $(PREFIX)/include
+
+ .PHONY: TAGS clean rpm install all
+
diff --git a/sysutils/xentools30/patches/patch-at b/sysutils/xentools30/patches/patch-at
new file mode 100644
index 00000000000..efcd921f67f
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-at
@@ -0,0 +1,22 @@
+$NetBSD: patch-at,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- libxc/xc_private.c.orig 2006-01-31 17:09:21.000000000 +0100
++++ libxc/xc_private.c
+@@ -13,7 +13,7 @@ void *xc_map_foreign_batch(int xc_handle
+ {
+ privcmd_mmapbatch_t ioctlx;
+ void *addr;
+- addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
++ addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
+ if ( addr == MAP_FAILED )
+ return NULL;
+
+@@ -42,7 +42,7 @@ void *xc_map_foreign_range(int xc_handle
+ privcmd_mmap_t ioctlx;
+ privcmd_mmap_entry_t entry;
+ void *addr;
+- addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
++ addr = mmap(NULL, size, prot, MAP_ANON | MAP_SHARED, -1, 0);
+ if ( addr == MAP_FAILED )
+ return NULL;
+
diff --git a/sysutils/xentools30/patches/patch-au b/sysutils/xentools30/patches/patch-au
new file mode 100644
index 00000000000..f437ffc93d1
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-au
@@ -0,0 +1,32 @@
+$NetBSD: patch-au,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- libxc/xc_private.h.orig 2006-04-13 19:48:38.000000000 +0200
++++ libxc/xc_private.h 2006-05-07 20:33:41.000000000 +0200
+@@ -15,7 +15,11 @@
+
+ #include "xenctrl.h"
+
+-#include <xen/linux/privcmd.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio.h>
++#else
++include <xen/linux/privcmd.h>
++#endif
+
+ /* valgrind cannot see when a hypercall has filled in some values. For this
+ reason, we must zero the privcmd_hypercall_t or dom0_op_t instance before a
+@@ -66,9 +70,13 @@
+ static inline int do_xen_hypercall(int xc_handle,
+ privcmd_hypercall_t *hypercall)
+ {
+- return do_privcmd(xc_handle,
++ int err = do_privcmd(xc_handle,
+ IOCTL_PRIVCMD_HYPERCALL,
+ (unsigned long)hypercall);
++ if (err == 0)
++ return 0;
++ else
++ return -errno;
+ }
+
+ static inline int do_xen_version(int xc_handle, int cmd, void *dest)
diff --git a/sysutils/xentools30/patches/patch-av b/sysutils/xentools30/patches/patch-av
new file mode 100644
index 00000000000..b1ec0102de0
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-av
@@ -0,0 +1,16 @@
+$NetBSD: patch-av,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- libxc/xg_private.h.orig 2006-01-31 17:09:21.000000000 +0100
++++ libxc/xg_private.h
+@@ -13,7 +13,11 @@
+ #include "xenctrl.h"
+ #include "xenguest.h"
+
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio.h>
++#else
+ #include <xen/linux/privcmd.h>
++#endif
+ #include <xen/memory.h>
+
+ /* valgrind cannot see when a hypercall has filled in some values. For this
diff --git a/sysutils/xentools30/patches/patch-aw b/sysutils/xentools30/patches/patch-aw
new file mode 100644
index 00000000000..aa03495f009
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-aw
@@ -0,0 +1,47 @@
+$NetBSD: patch-aw,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/Makefile.orig 2006-04-10 00:05:53.000000000 +0200
++++ misc/Makefile 2006-05-05 22:18:12.000000000 +0200
+@@ -15,25 +15,27 @@
+
+ TARGETS = xenperf xc_shadow
+
+-INSTALL_BIN = $(TARGETS) xencons
+-INSTALL_SBIN = netfix xm xen-bugtool xend xenperf
++INSTALL_BIN = $(TARGETS)
++INSTALL_BIN_SCRIPT = xencons
++INSTALL_SBIN = xenperf
++INSTALL_SBIN_SCRIPT = netfix xm xen-bugtool xend
+
+ all: build
+ build: $(TARGETS)
+ $(MAKE) -C miniterm
+ $(MAKE) -C cpuperf
+ ifneq ($(XEN_TARGET_ARCH),ia64)
+- $(MAKE) -C mbootpack
++# $(MAKE) -C mbootpack
+ endif
+- $(MAKE) -C lomount
+
+ install: build
+- [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
+- [ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin
+- $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
+- $(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)/usr/sbin
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) $(INSTALL_BIN) $(PREFIX)/bin
++ $(BSD_INSTALL_SCRIPT) $(INSTALL_BIN_SCRIPT) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) $(INSTALL_SBIN) $(PREFIX)/sbin
++ $(BSD_INSTALL_SCRIPT) $(INSTALL_SBIN_SCRIPT) $(PREFIX)/sbin
+ $(MAKE) -C cpuperf install
+- $(MAKE) -C lomount install
+ # No sense in installing miniterm on the Xen box.
+ # $(MAKE) -C miniterm install
+ # Likewise mbootpack
+@@ -50,4 +52,4 @@
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+ $(TARGETS): %: %.o Makefile
+- $(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -lxenctrl
++ $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -L$(XEN_LIBXC) -lxenctrl
diff --git a/sysutils/xentools30/patches/patch-ax b/sysutils/xentools30/patches/patch-ax
new file mode 100644
index 00000000000..7a9705d6d3e
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ax
@@ -0,0 +1,18 @@
+$NetBSD: patch-ax,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/cpuperf/Makefile.orig 2006-04-14 02:48:38.000000000 +0900
++++ misc/cpuperf/Makefile
+@@ -36,5 +36,5 @@ clean:
+
+ cpuperf-xen: cpuperf.c $(HDRS) Makefile
+- $(CC) $(CFLAGS) -I $(XEN_LIBXC) -L$(XEN_LIBXC) -lxenctrl -DXENO -o $@ $<
++ $(CC) $(CFLAGS) $(LDFLAGS) -I$(XEN_LIBXC) -L$(XEN_LIBXC) -lxenctrl -DXENO -o $@ $<
+
+ cpuperf-perfcntr: cpuperf.c $(HDRS) Makefile
+@@ -42,5 +42,5 @@ cpuperf-perfcntr: cpuperf.c $(HDRS) Make
+
+ install: all
+- $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
++ $(BSD_INSTALL_PROGRAM) $(INSTALL_BIN) $(PREFIX)/bin
+
+
diff --git a/sysutils/xentools30/patches/patch-ay b/sysutils/xentools30/patches/patch-ay
new file mode 100644
index 00000000000..3607e99bfdb
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ay
@@ -0,0 +1,13 @@
+$NetBSD: patch-ay,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/mbootpack/Makefile.orig 2006-01-31 17:09:21.000000000 +0100
++++ misc/mbootpack/Makefile
+@@ -12,7 +12,7 @@ all: build
+ build: mbootpack
+
+ install: build
+- $(INSTALL_PROG) mbootpack $(DESTDIR)/usr/bin
++ $(BSD_INSTALL_PROGRAM) mbootpack $(PREFIX)/bin
+
+ # Tools etc.
+ RM := rm -f
diff --git a/sysutils/xentools30/patches/patch-az b/sysutils/xentools30/patches/patch-az
new file mode 100644
index 00000000000..725eb411387
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-az
@@ -0,0 +1,14 @@
+$NetBSD: patch-az,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/miniterm/Makefile.orig 2006-01-31 17:09:21.000000000 +0100
++++ misc/miniterm/Makefile
+@@ -9,8 +9,7 @@ TARGET = miniterm
+ all: $(TARGET)
+
+ install: all
+- [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
+- $(INSTALL_PROG) $(TARGET) $(DESTDIR)/usr/bin
++ $(BSD_INSTALL_PROGRAM) $(TARGET) $(PREFIX)/bin
+
+ clean:
+ $(RM) *.o $(TARGET) *~
diff --git a/sysutils/xentools30/patches/patch-ba b/sysutils/xentools30/patches/patch-ba
new file mode 100644
index 00000000000..2d035e0681f
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ba
@@ -0,0 +1,17 @@
+$NetBSD: patch-ba,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/Makefile.orig 2006-04-10 00:05:53.000000000 +0200
++++ python/Makefile 2006-05-05 21:50:52.000000000 +0200
+@@ -9,10 +9,10 @@
+
+ ifndef XEN_PYTHON_NATIVE_INSTALL
+ install: all
+- CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --force
++ python setup.py install
+ else
+ install: all
+- CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
++ python setup.py install
+ endif
+
+ test:
diff --git a/sysutils/xentools30/patches/patch-bb b/sysutils/xentools30/patches/patch-bb
new file mode 100644
index 00000000000..289ff787d70
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bb
@@ -0,0 +1,24 @@
+$NetBSD: patch-bb,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/xen/xend/XendRoot.py.orig 2006-01-31 17:09:21.000000000 +0100
++++ python/xen/xend/XendRoot.py
+@@ -40,16 +40,16 @@ class XendRoot:
+ """Root of the management classes."""
+
+ """Default path to the config file."""
+- config_default = "/etc/xen/xend-config.sxp"
++ config_default = "@XENDCONFDIR@/xend-config.sxp"
+
+ """Environment variable used to override config_default."""
+ config_var = "XEND_CONFIG"
+
+ """Where network control scripts live."""
+- network_script_dir = "/etc/xen/scripts"
++ network_script_dir = "@XENDCONFDIR@/scripts"
+
+ """Where block control scripts live."""
+- block_script_dir = "/etc/xen/scripts"
++ block_script_dir = "@XENDCONFDIR@/scripts"
+
+ """Default path to the log file. """
+ logfile_default = "/var/log/xend.log"
diff --git a/sysutils/xentools30/patches/patch-bc b/sysutils/xentools30/patches/patch-bc
new file mode 100644
index 00000000000..71b56a68251
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bc
@@ -0,0 +1,22 @@
+$NetBSD: patch-bc,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/xen/xm/create.py.orig 2006-01-31 17:09:21.000000000 +0100
++++ python/xen/xm/create.py
+@@ -64,7 +64,7 @@ gopts.opt('quiet', short='q',
+ use="Quiet.")
+
+ gopts.opt('path', val='PATH',
+- fn=set_value, default='.:/etc/xen',
++ fn=set_value, default='.:@XENDCONFDIR@',
+ use="""Search path for configuration scripts.
+ The value of PATH is a colon-separated directory list.""")
+
+@@ -279,7 +279,7 @@ gopts.var('vtpm', val="instance=INSTANCE
+ preferred instance number. The hotplug script will determine
+ which instance number will actually be assigned to the domain.
+ The associtation between virtual machine and the TPM instance
+- number can be found in /etc/xen/vtpm.db. Use the backend in the
++ number can be found in @XENDCONFDIR@/vtpm.db. Use the backend in the
+ given domain.""")
+
+ gopts.var('nics', val="NUM",
diff --git a/sysutils/xentools30/patches/patch-bd b/sysutils/xentools30/patches/patch-bd
new file mode 100644
index 00000000000..ab7c9ef894d
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bd
@@ -0,0 +1,40 @@
+$NetBSD: patch-bd,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/xen/xm/tests/test_create.py.orig 2006-01-31 17:09:21.000000000 +0100
++++ python/xen/xm/tests/test_create.py
+@@ -48,7 +48,7 @@ class test_create(unittest.TestCase):
+ 'boot' : 'c',
+ 'dhcp' : 'off',
+ 'interface' : 'eth0',
+- 'path' : '.:/etc/xen',
++ 'path' : '.:@XENDCONFDIR@',
+ 'builder' : 'linux',
+ 'nics' : -1,
+ })
+@@ -97,7 +97,7 @@ on_crash = 'destroy'
+ 'boot' : 'c',
+ 'dhcp' : 'off',
+ 'interface' : 'eth0',
+- 'path' : '.:/etc/xen',
++ 'path' : '.:@XENDCONFDIR@',
+ 'builder' : 'linux',
+ })
+
+@@ -135,7 +135,7 @@ cpu_weight = 0.75
+ 'boot' : 'c',
+ 'dhcp' : 'off',
+ 'interface' : 'eth0',
+- 'path' : '.:/etc/xen',
++ 'path' : '.:@XENDCONFDIR@',
+ 'builder' : 'linux',
+ 'nics' : -1,
+ })
+@@ -187,7 +187,7 @@ ne2000=0
+ 'boot' : 'c',
+ 'dhcp' : 'off',
+ 'interface' : 'eth0',
+- 'path' : '.:/etc/xen',
++ 'path' : '.:@XENDCONFDIR@',
+ })
+
+
diff --git a/sysutils/xentools30/patches/patch-be b/sysutils/xentools30/patches/patch-be
new file mode 100644
index 00000000000..74dca3efd0c
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-be
@@ -0,0 +1,56 @@
+$NetBSD: patch-be,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/Makefile.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/Makefile
+@@ -40,7 +40,7 @@ ACM_NOINST_TOOLS = get_decision
+ ACM_OBJS = $(OBJS_TOOL) $(OBJS_XML2BIN) $(OBJS_GETD)
+ ACM_SCRIPTS = getlabel.sh setlabel.sh updategrub.sh labelfuncs.sh
+
+-ACM_CONFIG_DIR = /etc/xen/acm-security
++ACM_CONFIG_DIR = $(PREFIX)/share/examples/xen/acm-security
+ ACM_POLICY_DIR = $(ACM_CONFIG_DIR)/policies
+ ACM_SCRIPT_DIR = $(ACM_CONFIG_DIR)/scripts
+
+@@ -59,26 +59,26 @@ ifeq ($(ACM_SECURITY),y)
+ all: build
+
+ install: all $(ACM_CONFIG_FILE)
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
+- $(INSTALL_PROG) -p $(ACM_INST_TOOLS) $(DESTDIR)/usr/sbin
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_CONFIG_DIR)
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_POLICY_DIR)
+- $(INSTALL_DATA) -p policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) $(ACM_INST_TOOLS) $(PREFIX)/sbin
++ $(BSD_INSTALL_DATA_DIR) $(ACM_CONFIG_DIR)
++ $(BSD_INSTALL_DATA_DIR) $(ACM_POLICY_DIR)
++ $(BSD_INSTALL_DATA) policies/$(ACM_SCHEMA) $(ACM_POLICY_DIR)
+ for i in $(ACM_EXAMPLES); do \
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_POLICY_DIR)/$$i; \
+- $(INSTALL_DATA) -p policies/$$i/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/$$i; \
+- $(INSTALL_DATA) -p policies/$$i/$$i-$(ACM_LABEL_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/$$i; \
++ $(BSD_INSTALL_DATA_DIR) $(ACM_POLICY_DIR)/$$i; \
++ $(BSD_INSTALL_DATA) policies/$$i/$$i-$(ACM_POLICY_SUFFIX) $(ACM_POLICY_DIR)/$$i; \
++ $(BSD_INSTALL_DATA) policies/$$i/$$i-$(ACM_LABEL_SUFFIX) $(ACM_POLICY_DIR)/$$i; \
+ done
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_SCRIPT_DIR)
+- $(INSTALL_PROG) -p $(ACM_SCRIPTS) $(DESTDIR)$(ACM_SCRIPT_DIR)
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
+- $(INSTALL_DATA) -p $(ACM_INST_HTML) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
+- $(INSTALL_DIR) -p $(DESTDIR)$(ACM_SECGEN_CGIDIR)
+- $(INSTALL_PROG) -p $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
++ $(BSD_INSTALL_SCRIPT_DIR) $(ACM_SCRIPT_DIR)
++ $(BSD_INSTALL_SCRIPT) $(ACM_SCRIPTS) $(ACM_SCRIPT_DIR)
++ $(BSD_INSTALL_DATA_DIR) $(ACM_SECGEN_HTMLDIR)
++ $(BSD_INSTALL_DATA) $(ACM_INST_HTML) $(ACM_SECGEN_HTMLDIR)
++ $(BSD_INSTALL_PROGRAM_DIR) $(ACM_SECGEN_CGIDIR)
++ $(BSD_INSTALL_PROGRAM) $(ACM_INST_CGI) $(ACM_SECGEN_CGIDIR)
+ ifndef XEN_PYTHON_NATIVE_INSTALL
+- python python/setup.py install --home="$(DESTDIR)/usr"
++ python python/setup.py install --home="$(PREFIX)"
+ else
+- python python/setup.py install --root="$(DESTDIR)"
++ python python/setup.py install --root="$(PREFIX)"
+ endif
+ else
+ all:
diff --git a/sysutils/xentools30/patches/patch-bf b/sysutils/xentools30/patches/patch-bf
new file mode 100644
index 00000000000..ca811c04522
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bf
@@ -0,0 +1,127 @@
+$NetBSD: patch-bf,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/example.txt.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/example.txt
+@@ -22,10 +22,10 @@ Other policies work similarly. Feedback
+ Successful execution should print:
+
+ [root@laptopxn security]# xensec_xml2bin chwall_ste
+- Validating label file /etc/xen/acm-security/policies/chwall_ste/chwall_ste-security_label_template.xml...
+- XML Schema /etc/xen/acm-security/policies/security_policy.xsd valid.
+- Validating policy file /etc/xen/acm-security/policies/chwall_ste/chwall_ste-security_policy.xml...
+- XML Schema /etc/xen/acm-security/policies/security_policy.xsd valid.
++ Validating label file @XENDCONFDIR@/acm-security/policies/chwall_ste/chwall_ste-security_label_template.xml...
++ XML Schema @XENDCONFDIR@/acm-security/policies/security_policy.xsd valid.
++ Validating policy file @XENDCONFDIR@/acm-security/policies/chwall_ste/chwall_ste-security_policy.xml...
++ XML Schema @XENDCONFDIR@/acm-security/policies/security_policy.xsd valid.
+ Creating ssid mappings ...
+ Creating label mappings ...
+ Max chwall labels: 7
+@@ -35,14 +35,14 @@ Successful execution should print:
+ Max ste-types: 6
+ Max ste-ssids: 10
+
+-By default, the tool looks in directory /etc/xen/acm-security/policies
++By default, the tool looks in directory @XENDCONFDIR@/acm-security/policies
+ for a directory that matches the policy name (i.e. chwall_ste) to find
+ the label and policy files.
+-The '-d' option can be used to override the /etc/xen/acm-security/policies
++The '-d' option can be used to override the @XENDCONFDIR@/acm-security/policies
+ directory, for example if running the tool in the Xen security tool build
+ directory.
+
+-The default policy directory structure under /etc/xen/acm-security (and
++The default policy directory structure under @XENDCONFDIR@/acm-security (and
+ the Xen security tool build directory - tools/security) looks like:
+
+ policies
+@@ -71,7 +71,7 @@ definitions that group types together an
+ users.
+
+ After executing the above xensec_xml2bin command, you will find 2 new
+-files in the /etc/xen/acm-security/policies/chwall_ste sub-directory:
++files in the @XENDCONFDIR@/acm-security/policies/chwall_ste sub-directory:
+
+ chwall_ste.map ... this file includes the mapping
+ of names from the xml files into their binary code representation.
+@@ -92,11 +92,11 @@ To activate the policy from the command
+ currently established policy is the minimal boot-policy that is
+ hard-coded into the hypervisor):
+
+-# xensec_tool loadpolicy /etc/xen/acm-security/policies/chwall_ste/chwall_ste.bin
++# xensec_tool loadpolicy @XENDCONFDIR@/acm-security/policies/chwall_ste/chwall_ste.bin
+
+ To activate the policy at next reboot:
+
+-# cp /etc/xen/acm-security/policies/chwall_ste/chwall_ste.bin /boot
++# cp @XENDCONFDIR@/acm-security/policies/chwall_ste/chwall_ste.bin /boot
+
+ Add a module line to your /boot/grub/grub.conf Xen entry.
+ My boot entry with chwall_ste enabled looks like this:
+@@ -134,12 +134,12 @@ assign labels to user domains.
+
+ To show available labels for the chwall_ste policy:
+
+-# /etc/xen/acm-security/scripts/setlabel.sh -l
++# @XENDCONFDIR@/acm-security/scripts/setlabel.sh -l
+
+ lists all available labels. For the default chwall_ste it should print
+ the following:
+
+- [root@laptopxn security]# /etc/xen/acm-security/scripts/setlabel.sh -l chwall_ste
++ [root@laptopxn security]# @XENDCONFDIR@/acm-security/scripts/setlabel.sh -l chwall_ste
+ The following labels are available:
+ dom_SystemManagement
+ dom_HomeBanking
+@@ -162,7 +162,7 @@ since only those are used at this time.
+
+ If you would like to assign the dom_HomeBanking label to one of your
+ user domains (which you hopefully keep clean), look at the hypothetical
+-domain configuration contained in /etc/xen/homebanking.xm:
++domain configuration contained in @XENDCONFDIR@/homebanking.xm:
+
+ #------HOMEBANKING---------
+ kernel = "/boot/vmlinuz-2.6.12-xenU"
+@@ -177,7 +177,7 @@ domain configuration contained in /etc/x
+
+ Now we label this domain
+
+-[root@laptopxn security]# /etc/xen/acm-securit/scripts/setlabel.sh /etc/xen/homebanking.xm dom_HomeBanking chwall_ste
++[root@laptopxn security]# @XENDCONFDIR@/acm-securit/scripts/setlabel.sh @XENDCONFDIR@/homebanking.xm dom_HomeBanking chwall_ste
+ Mapped label 'dom_HomeBanking' to ssidref '0x00020002'.
+
+ The domain configuration my look now like:
+@@ -259,14 +259,14 @@ a) the policy definition (types etc.) fi
+ b) the label template definition (labels etc.) file
+
+ If your policy name is "mypolicy", you need to create a
+-subdirectory mypolicy in /etc/xen/acm-security/policies.
++subdirectory mypolicy in @XENDCONFDIR@/acm-security/policies.
+
+ Then you create
+-/etc/xen/acm-security/policies/mypolicy/mypolicy-security_policy.xml and
+-/etc/xen/acm-security/policies/mypolicy/mypolicy-security_label_template.xml.
++@XENDCONFDIR@/acm-security/policies/mypolicy/mypolicy-security_policy.xml and
++@XENDCONFDIR@/acm-security/policies/mypolicy/mypolicy-security_label_template.xml.
+
+ You need to keep to the schema as defined in
+-/etc/xen/acm-security/security_policy.xsd since the translation tool
++@XENDCONFDIR@/acm-security/security_policy.xsd since the translation tool
+ xensec_xml2bin is written against this schema.
+
+ If you keep to the security policy schema, then you can use all the
+@@ -333,7 +333,7 @@ files:
+ the policy name that you choose to use.
+
+ To get a feel for the tool, you could use one of the example policy definition
+- files from /etc/xen/acm-security/policies as input.
++ files from @XENDCONFDIR@/acm-security/policies as input.
+
+
+ Security Policy Labeling:
+@@ -379,4 +379,4 @@ files:
+ naming conventions based on the policy name that you choose to use.
+
+ To get a feel for the tool, you could use one of the example policy definition
+- and label template definition files from /etc/xen/acm-security/policies as input.
++ and label template definition files from @XENDCONFDIR@/acm-security/policies as input.
diff --git a/sysutils/xentools30/patches/patch-bg b/sysutils/xentools30/patches/patch-bg
new file mode 100644
index 00000000000..ef122e42628
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bg
@@ -0,0 +1,16 @@
+$NetBSD: patch-bg,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/get_decision.c.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/get_decision.c
+@@ -30,7 +30,11 @@
+ #include <netinet/in.h>
+ #include <xen/acm.h>
+ #include <xen/acm_ops.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio.h>
++#else
+ #include <xen/linux/privcmd.h>
++#endif
+
+ #define PERROR(_m, _a...) \
+ fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
diff --git a/sysutils/xentools30/patches/patch-bh b/sysutils/xentools30/patches/patch-bh
new file mode 100644
index 00000000000..f53e1f2d544
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bh
@@ -0,0 +1,13 @@
+$NetBSD: patch-bh,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/getlabel.sh.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/getlabel.sh
+@@ -49,7 +49,7 @@ policy name : the name of the policy, i.
+ entry of the running system is tried to be read
+ and the policy name determined from there.
+ policy dir : the directory where the <policy name> policy is located
+- The default location is '/etc/xen/acm-security/policies'
++ The default location is '@XENDCONFDIR@/acm-security/policies'
+ ssidref : an ssidref in hex or decimal format, i.e., '0x00010002'
+ or '65538'
+ domid : id of the domain, i.e., '1'; Use numbers from the 2nd
diff --git a/sysutils/xentools30/patches/patch-bi b/sysutils/xentools30/patches/patch-bi
new file mode 100644
index 00000000000..b68949baddc
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bi
@@ -0,0 +1,13 @@
+$NetBSD: patch-bi,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/labelfuncs.sh.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/labelfuncs.sh
+@@ -18,7 +18,7 @@
+
+
+ #Some global variables for tools using this module
+-ACM_DEFAULT_ROOT="/etc/xen/acm-security"
++ACM_DEFAULT_ROOT="@XENDCONFDIR@/acm-security"
+
+ # Set the policy and policydir variables
+ # Parameters:
diff --git a/sysutils/xentools30/patches/patch-bj b/sysutils/xentools30/patches/patch-bj
new file mode 100644
index 00000000000..d8eaac41790
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bj
@@ -0,0 +1,16 @@
+$NetBSD: patch-bj,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/secpol_tool.c.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/secpol_tool.c
+@@ -36,7 +36,11 @@
+ #include <stdint.h>
+ #include <xen/acm.h>
+ #include <xen/acm_ops.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio.h>
++#else
+ #include <xen/linux/privcmd.h>
++#endif
+
+ #define PERROR(_m, _a...) \
+ fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
diff --git a/sysutils/xentools30/patches/patch-bk b/sysutils/xentools30/patches/patch-bk
new file mode 100644
index 00000000000..2b191ef49fc
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bk
@@ -0,0 +1,13 @@
+$NetBSD: patch-bk,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/secpol_xml2bin.h.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/secpol_xml2bin.h
+@@ -12,7 +12,7 @@
+ * License.
+ *
+ */
+-#define POLICY_DIR "/etc/xen/acm-security/policies/"
++#define POLICY_DIR "@XENDCONFDIR@/acm-security/policies/"
+ #define POLICY_EXTENSION "-security_policy.xml"
+ #define LABEL_EXTENSION "-security_label_template.xml"
+ #define BINARY_EXTENSION ".bin"
diff --git a/sysutils/xentools30/patches/patch-bl b/sysutils/xentools30/patches/patch-bl
new file mode 100644
index 00000000000..4b2a878b4c0
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bl
@@ -0,0 +1,13 @@
+$NetBSD: patch-bl,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- security/setlabel.sh.orig 2006-01-31 17:09:21.000000000 +0100
++++ security/setlabel.sh
+@@ -55,7 +55,7 @@ policy name : the name of the policy, i.
+ If the policy name is omitted, it is attempted
+ to find the current policy's name in grub.conf.
+ policy dir : the directory where the <policy name> policy is located
+- The default location is '/etc/xen/acm-security/policies'
++ The default location is '@XENDCONFDIR@/acm-security/policies'
+ "
+ }
+
diff --git a/sysutils/xentools30/patches/patch-bm b/sysutils/xentools30/patches/patch-bm
new file mode 100644
index 00000000000..9510ed1788d
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bm
@@ -0,0 +1,20 @@
+$NetBSD: patch-bm,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- vnet/libxutil/Makefile.orig 2006-01-31 17:09:21.000000000 +0100
++++ vnet/libxutil/Makefile
+@@ -69,11 +69,10 @@ check-for-zlib:
+ fi
+
+ install: build
+- [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_PROG) libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DATA) libxutil.a $(DESTDIR)/usr/$(LIBDIR)
+- ln -sf libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so.$(MAJOR)
+- ln -sf libxutil.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so
++ $(BSD_INSTALL_LIB) libxutil.so.$(MAJOR).$(MINOR) $(PREFIX)/lib
++ $(BSD_INSTALL_LIB) libxutil.a $(PREFIX)/lib
++ ln -sf libxutil.so.$(MAJOR).$(MINOR) $(PREFIX)/lib/libxutil.so.$(MAJOR)
++ ln -sf libxutil.so.$(MAJOR) $(PREFIX)/lib/libxutil.so
+
+ clean:
+ -@$(RM) *.a *.so* *.o *.opic *.rpm
diff --git a/sysutils/xentools30/patches/patch-bn b/sysutils/xentools30/patches/patch-bn
new file mode 100644
index 00000000000..0b552f254d2
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bn
@@ -0,0 +1,18 @@
+$NetBSD: patch-bn,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- vtpm_manager/manager/Makefile.orig 2006-01-31 17:09:22.000000000 +0100
++++ vtpm_manager/manager/Makefile
+@@ -8,10 +8,10 @@ all: build
+ build: $(BIN)
+
+ install: build
+- if [ ! -d "$(DESTDIR)/var/vtpm/fifos" ]; \
+- then mkdir -p $(DESTDIR)/var/vtpm/fifos; \
++ if [ ! -d "/var/vtpm/fifos" ]; \
++ then mkdir -p /var/vtpm/fifos; \
+ fi
+- $(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM) $(BIN) $(PREFIX)/bin
+
+ clean:
+ rm -f *.a *.so *.o *.rpm $(DEP_FILES)
diff --git a/sysutils/xentools30/patches/patch-bo b/sysutils/xentools30/patches/patch-bo
new file mode 100644
index 00000000000..1566165e487
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bo
@@ -0,0 +1,25 @@
+$NetBSD: patch-bo,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xcutils/Makefile.orig 2006-01-31 17:09:22.000000000 +0100
++++ xcutils/Makefile
+@@ -28,7 +28,7 @@ PROG_DEP = .*.d
+
+ PROGRAMS = xc_restore xc_save
+
+-LDLIBS = -L$(XEN_LIBXC) -lxenguest -lxenctrl
++LDLIBS = $(LDFLAGS) -L$(XEN_LIBXC) -lxenguest -lxenctrl
+
+ .PHONY: all
+ all: build
+@@ -39,9 +39,8 @@ $(PROGRAMS): %: %.o
+
+ .PHONY: install
+ install: build
+- [ -d $(DESTDIR)$(PROGRAMS_INSTALL_DIR) ] || \
+- $(INSTALL_DIR) $(DESTDIR)$(PROGRAMS_INSTALL_DIR)
+- $(INSTALL_PROG) $(PROGRAMS) $(DESTDIR)$(PROGRAMS_INSTALL_DIR)
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) $(PROGRAMS) $(PREFIX)/bin
+
+
+ clean:
diff --git a/sysutils/xentools30/patches/patch-bp b/sysutils/xentools30/patches/patch-bp
new file mode 100644
index 00000000000..648c7b61c96
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bp
@@ -0,0 +1,19 @@
+$NetBSD: patch-bp,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenmon/Makefile.orig 2006-01-31 17:09:22.000000000 +0100
++++ xenmon/Makefile
+@@ -33,10 +33,10 @@ all: build
+ build: $(BIN)
+
+ install: xenbaked setmask
+- [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir)
+- $(INSTALL_PROG) xenbaked $(DESTDIR)$(sbindir)/xenbaked
+- $(INSTALL_PROG) setmask $(DESTDIR)$(sbindir)/setmask
+- $(INSTALL_PROG) xenmon.py $(DESTDIR)$(sbindir)/xenmon.py
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) xenbaked $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) setmask $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) xenmon.py $(PREFIX)/sbin
+
+ clean:
+ rm -f $(BIN)
diff --git a/sysutils/xentools30/patches/patch-bq b/sysutils/xentools30/patches/patch-bq
new file mode 100644
index 00000000000..8090336dcbf
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bq
@@ -0,0 +1,62 @@
+$NetBSD: patch-bq,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstat/libxenstat/src/xen-interface.c.orig 2006-04-13 19:48:39.000000000 +0200
++++ xenstat/libxenstat/src/xen-interface.c 2006-07-01 23:17:50.000000000 +0200
+@@ -23,7 +23,13 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <errno.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio.h>
++#else
++#error linux
+ #include <xen/linux/privcmd.h>
++#endif
+
+ struct xi_handle {
+ int fd;
+@@ -39,9 +45,9 @@
+ if (handle == NULL)
+ return NULL;
+
+- handle->fd = open("/proc/xen/privcmd", O_RDWR);
++ handle->fd = open("/kern/xen/privcmd", O_RDWR);
+ if (handle->fd < 0) {
+- perror("Couldn't open /proc/xen/privcmd");
++ perror("Couldn't open /kern/xen/privcmd");
+ free(handle);
+ return NULL;
+ }
+@@ -78,7 +84,10 @@
+ privcmd.arg[0] = (unsigned long)XENVER_version;
+ privcmd.arg[1] = 0;
+
+- *vnum = ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd);
++ if (ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) == 0)
++ *vnum = 0;
++ else
++ *vnum = -errno;
+ if (*vnum < 0) {
+ perror("Hypercall failed");
+ ret = -1;
+@@ -88,7 +97,8 @@
+ privcmd.arg[0] = (unsigned long)XENVER_extraversion;
+ privcmd.arg[1] = (unsigned long)ver;
+
+- if (ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0) {
++ if (ioctl(handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0 &&
++ errno >= 0) {
+ perror("Hypercall failed");
+ ret = -1;
+ }
+@@ -123,7 +133,8 @@
+ return -1;
+ }
+
+- if (ioctl( handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0) {
++ if (ioctl( handle->fd, IOCTL_PRIVCMD_HYPERCALL, &privcmd) < 0 &&
++ errno >= 0) {
+ perror("Hypercall failed");
+ ret = -1;
+ }
diff --git a/sysutils/xentools30/patches/patch-br b/sysutils/xentools30/patches/patch-br
new file mode 100644
index 00000000000..c2de32eb78a
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-br
@@ -0,0 +1,15 @@
+$NetBSD: patch-br,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstat/xentop/Makefile.orig 2006-01-31 17:09:22.000000000 +0100
++++ xenstat/xentop/Makefile
+@@ -35,8 +35,8 @@ all: xentop
+ xentop: xentop.o
+
+ install: xentop xentop.1
+- $(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop
+- $(INSTALL_DATA) xentop.1 $(DESTDIR)$(man1dir)/xentop.1
++ $(BSD_INSTALL_PROGRAM) xentop $(PREFIX)/sbin
++ $(BSD_INSTALL_DATA) xentop.1 $(PREFIX)/man/man1
+
+ endif
+
diff --git a/sysutils/xentools30/patches/patch-bs b/sysutils/xentools30/patches/patch-bs
new file mode 100644
index 00000000000..0c9cb2a3d99
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bs
@@ -0,0 +1,74 @@
+$NetBSD: patch-bs,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstore/Makefile.orig 2006-04-10 00:05:54.000000000 +0200
++++ xenstore/Makefile 2006-05-05 21:54:15.000000000 +0200
+@@ -30,30 +30,30 @@
+ all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls
+
+ test_interleaved_transactions: test_interleaved_transactions.o
+- $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
++ $(LINK.o) $^ $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -L. -lxenstore -o $@
+
+ testcode: xs_test xenstored_test xs_random
+
+ xenstored: xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o
+- $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -o $@
++ $(LINK.o) $^ $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -lxenctrl -o $@
+
+ $(CLIENTS): xenstore-%: xenstore_%.o libxenstore.so
+- $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
++ $(LINK.o) $< $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -L. -lxenstore -o $@
+
+ $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c
+ $(COMPILE.c) -DCLIENT_$(*F) -o $@ $<
+
+ xenstore-control: xenstore_control.o libxenstore.so
+- $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
++ $(LINK.o) $< $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -L. -lxenstore -o $@
+
+ xenstore-ls: xsls.o libxenstore.so
+- $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
++ $(LINK.o) $< $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -L. -lxenstore -o $@
+
+ xenstored_test: xenstored_core_test.o xenstored_watch_test.o xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o fake_libxc.o utils.o tdb.o
+- $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
++ $(LINK.o) $^ $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -o $@
+
+ xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
+- $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
++ $(LINK.o) $^ $(LOADLIBES) $(LDFLAGS) $(LDLIBS) -o $@
+
+ xs_test xs_random xs_stress xs_crashme: LDFLAGS+=-lpthread
+ xs_test: xs_test.o xs_lib.o utils.o
+@@ -137,19 +137,18 @@
+ cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
+
+ install: all
+- $(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
+- $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/bin
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/include
+- $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
+- $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin
+- $(INSTALL_PROG) xenstore-control $(DESTDIR)/usr/bin
+- $(INSTALL_PROG) xenstore-ls $(DESTDIR)/usr/bin
+- $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DATA) libxenstore.so $(DESTDIR)/usr/$(LIBDIR)
+- $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
+- $(INSTALL_DATA) xs_lib.h $(DESTDIR)/usr/include
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/sbin
++ $(BSD_INSTALL_DATA_DIR) -p $(PREFIX)/include
++ $(BSD_INSTALL_PROGRAM) xenstored $(PREFIX)/sbin
++ $(BSD_INSTALL_PROGRAM) $(CLIENTS) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) xenstore-control $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) xenstore-ls $(PREFIX)/bin
++ $(BSD_INSTALL_LIB_DIR) $(PREFIX)/lib
++ $(BSD_INSTALL_LIB) libxenstore.so $(PREFIX)/lib
++ $(BSD_INSTALL_DATA) xs.h $(PREFIX)/include
++ $(BSD_INSTALL_DATA) xs_lib.h $(PREFIX)/include
++
+
+ -include $(PROG_DEP)
+
diff --git a/sysutils/xentools30/patches/patch-bt b/sysutils/xentools30/patches/patch-bt
new file mode 100644
index 00000000000..d91582cde13
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bt
@@ -0,0 +1,91 @@
+$NetBSD: patch-bt,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstore/xenstored_domain.c.orig 2006-01-31 17:09:22.000000000 +0100
++++ xenstore/xenstored_domain.c
+@@ -18,7 +18,9 @@
+ */
+
+ #include <stdio.h>
++#ifndef __NetBSD__
+ #include <linux/ioctl.h>
++#endif
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+ #include <unistd.h>
+@@ -38,7 +40,11 @@
+ #include "xenstored_test.h"
+
+ #include <xenctrl.h>
++#ifdef __NetBSD__
++#include <xen/NetBSD/xenio3.h>
++#else
+ #include <xen/linux/evtchn.h>
++#endif
+
+ static int *xc_handle;
+ static evtchn_port_t virq_port;
+@@ -283,7 +289,11 @@ static struct domain *new_domain(void *c
+ rc = ioctl(eventchn_fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
+ if (rc == -1)
+ return NULL;
++#ifdef __NetBSD__
++ domain->port = bind.port;
++#else
+ domain->port = rc;
++#endif
+
+ domain->conn = new_connection(writechn, readchn);
+ domain->conn->domain = domain;
+@@ -503,8 +513,11 @@ outfd:
+ }
+
+
+-
++#ifdef __NetBSD__
++#define EVTCHN_DEV_NAME "/dev/xenevt"
++#else
+ #define EVTCHN_DEV_NAME "/dev/xen/evtchn"
++#endif
+ #define EVTCHN_DEV_MAJOR 10
+ #define EVTCHN_DEV_MINOR 201
+
+@@ -512,7 +525,9 @@ outfd:
+ /* Returns the event channel handle. */
+ int domain_init(void)
+ {
++#ifndef __NetBSD__
+ struct stat st;
++#endif
+ struct ioctl_evtchn_bind_virq bind;
+ int rc;
+
+@@ -530,6 +545,9 @@ int domain_init(void)
+ eventchn_fd = fake_open_eventchn();
+ (void)&st;
+ #else
++#ifdef __NetBSD__
++ eventchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
++#else
+ /* Make sure any existing device file links to correct device. */
+ if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
+ (st.st_rdev != makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)))
+@@ -545,6 +563,7 @@ int domain_init(void)
+ goto reopen;
+ return -errno;
+ }
++#endif /* !__NetBSD__ */
+ #endif
+ if (eventchn_fd < 0)
+ barf_perror("Failed to open evtchn device");
+@@ -556,7 +575,11 @@ int domain_init(void)
+ rc = ioctl(eventchn_fd, IOCTL_EVTCHN_BIND_VIRQ, &bind);
+ if (rc == -1)
+ barf_perror("Failed to bind to domain exception virq port");
++#ifdef __NetBSD__
++ virq_port = bind.port;
++#else
+ virq_port = rc;
++#endif
+
+ return eventchn_fd;
+ }
diff --git a/sysutils/xentools30/patches/patch-bu b/sysutils/xentools30/patches/patch-bu
new file mode 100644
index 00000000000..24a97a1d6a5
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bu
@@ -0,0 +1,32 @@
+$NetBSD: patch-bu,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xentrace/Makefile.orig 2006-01-31 17:09:22.000000000 +0100
++++ xentrace/Makefile
+@@ -32,20 +32,15 @@ all: build
+ build: $(BIN) $(LIBBIN)
+
+ install: build
+- [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
+- [ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \
+- $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
+- [ -d $(DESTDIR)/usr/share/man/man1 ] || \
+- $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man1
+- [ -d $(DESTDIR)/usr/share/man/man8 ] || \
+- $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man8
+- $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
+- [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
+- $(INSTALL_DATA) $(MAN1) $(DESTDIR)/usr/share/man/man1
+- $(INSTALL_DATA) $(MAN8) $(DESTDIR)/usr/share/man/man8
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM_DIR) $(PREFIX)/libexec
++ $(BSD_INSTALL_PROGRAM) $(BIN) $(SCRIPTS) $(PREFIX)/bin
++ $(BSD_INSTALL_PROGRAM) $(LIBBIN) $(PREFIX)/libexec
++ $(BSD_INSTALL_DATA) $(MAN1) $(DESTDIR)/man/man1
++ $(BSD_INSTALL_DATA) $(MAN8) $(DESTDIR)/man/man8
+
+ clean:
+ $(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN)
+
+ %: %.c $(HDRS) Makefile
+- $(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -lxenctrl
++ $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -L$(XEN_LIBXC) -lxenctrl
diff --git a/sysutils/xentools30/patches/patch-bv b/sysutils/xentools30/patches/patch-bv
new file mode 100644
index 00000000000..6c1f8a27216
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bv
@@ -0,0 +1,30 @@
+$NetBSD: patch-bv,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- libxc/xenctrl.h.orig 2006-04-10 00:05:53.000000000 +0200
++++ libxc/xenctrl.h 2006-05-05 21:55:22.000000000 +0200
+@@ -10,7 +10,9 @@
+ #define XENCTRL_H
+
+ #include <stdint.h>
++#ifndef __NetBSD__
+ #include <sys/ptrace.h>
++#endif
+ #include <xen/xen.h>
+ #include <xen/dom0_ops.h>
+ #include <xen/version.h>
+@@ -94,6 +96,7 @@
+
+ #define XC_CORE_MAGIC 0xF00FEBED
+
++#ifndef __NetBSD__
+ long xc_ptrace_core(
+ int xc_handle,
+ enum __ptrace_request request,
+@@ -101,6 +104,7 @@
+ long addr,
+ long data,
+ vcpu_guest_context_t *ctxt);
++#endif
+ void * map_domain_va_core(
+ unsigned long domfd,
+ int cpu,
diff --git a/sysutils/xentools30/patches/patch-bw b/sysutils/xentools30/patches/patch-bw
new file mode 100644
index 00000000000..4c2b8fcdb39
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bw
@@ -0,0 +1,15 @@
+$NetBSD: patch-bw,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstore/list.h.orig 2006-01-31 17:09:22.000000000 +0100
++++ xenstore/list.h
+@@ -3,6 +3,10 @@
+ /* Taken from Linux kernel code, but de-kernelized for userspace. */
+ #include <stddef.h>
+
++#undef LIST_HEAD_INIT
++#undef LIST_HEAD
++#undef INIT_LIST_HEAD
++
+ /*
+ * These are non-NULL pointers that will result in page faults
+ * under normal circumstances, used to verify that nobody uses
diff --git a/sysutils/xentools30/patches/patch-bx b/sysutils/xentools30/patches/patch-bx
new file mode 100644
index 00000000000..5bf846badeb
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bx
@@ -0,0 +1,16 @@
+$NetBSD: patch-bx,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstore/xenstored_proc.h.orig 2006-05-06 18:43:30.000000000 +0200
++++ xenstore/xenstored_proc.h 2006-05-06 18:44:08.000000000 +0200
+@@ -20,7 +20,11 @@
+ #ifndef _XENSTORED_PROC_H
+ #define _XENSTORED_PROC_H
+
++#ifdef __NetBSD__
++#define XENSTORED_PROC_KVA "/dev/xsd_kva"
++#else
+ #define XENSTORED_PROC_KVA "/proc/xen/xsd_kva"
++#endif
+ #define XENSTORED_PROC_PORT "/proc/xen/xsd_port"
+
+
diff --git a/sysutils/xentools30/patches/patch-by b/sysutils/xentools30/patches/patch-by
new file mode 100644
index 00000000000..8f4ecf9145c
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-by
@@ -0,0 +1,39 @@
+$NetBSD: patch-by,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/mbootpack/mbootpack.h.orig 2006-01-31 17:09:21.000000000 +0100
++++ misc/mbootpack/mbootpack.h
+@@ -32,7 +32,25 @@
+ #undef NDEBUG
+ #include <stdio.h>
+
+-#include <endian.h>
++#ifdef __NetBSD__
++#include <sys/endian.h>
++#if _BYTE_ORDER == _LITTLE_ENDIAN
++#define eswap(x) (x)
++#else
++#define eswap(x) \
++ ({ \
++ typeof(x) y = (x); \
++ switch(sizeof(y)) \
++ { \
++ case 2: y = bswap_16(y); break; \
++ case 4: y = bswap_32(y); break; \
++ case 8: y = bswap_64(y); break; \
++ } \
++ y; \
++ })
++#endif
++#else /* __NetBSD__ */
++#include </endian.h>
+ #include <byteswap.h>
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define eswap(x) (x)
+@@ -49,6 +67,7 @@
+ y; \
+ })
+ #endif
++#endif /* !__NetBSD */
+
+ /* Flags */
+ extern int quiet;
diff --git a/sysutils/xentools30/patches/patch-bz b/sysutils/xentools30/patches/patch-bz
new file mode 100644
index 00000000000..2757ab69be2
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-bz
@@ -0,0 +1,14 @@
+$NetBSD: patch-bz,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/mbootpack/mbootpack.c.orig 2006-01-31 17:09:21.000000000 +0100
++++ misc/mbootpack/mbootpack.c
+@@ -42,7 +42,9 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/mman.h>
++#ifndef __NetBSD__
+ #include <asm/page.h>
++#endif
+
+ /* From GNU GRUB */
+ #include "mb_header.h"
diff --git a/sysutils/xentools30/patches/patch-ca b/sysutils/xentools30/patches/patch-ca
new file mode 100644
index 00000000000..87478dfa586
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ca
@@ -0,0 +1,14 @@
+$NetBSD: patch-ca,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- misc/mbootpack/buildimage.c.orig 2006-04-15 20:39:39.000000000 +0200
++++ misc/mbootpack/buildimage.c
+@@ -38,7 +38,9 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/mman.h>
++#ifndef __NetBSD__
+ #include <asm/page.h>
++#endif
+
+ #include "mbootpack.h"
+ #include "mb_header.h"
diff --git a/sysutils/xentools30/patches/patch-cb b/sysutils/xentools30/patches/patch-cb
new file mode 100644
index 00000000000..311f33d64b4
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-cb
@@ -0,0 +1,12 @@
+$NetBSD: patch-cb,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- console/daemon/utils.c.orig 2006-01-31 17:09:20.000000000 +0100
++++ console/daemon/utils.c
+@@ -32,6 +32,7 @@
+ #include <sys/socket.h>
+ #include <sys/un.h>
+ #include <string.h>
++#include <signal.h>
+
+ #include "xenctrl.h"
+ #include "utils.h"
diff --git a/sysutils/xentools30/patches/patch-cc b/sysutils/xentools30/patches/patch-cc
new file mode 100644
index 00000000000..88f6a8f5cee
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-cc
@@ -0,0 +1,23 @@
+$NetBSD: patch-cc,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- console/client/main.c.orig 2006-04-13 19:48:38.000000000 +0200
++++ console/client/main.c 2006-05-07 23:19:41.000000000 +0200
+@@ -34,7 +34,10 @@
+ #include <sys/select.h>
+ #include <err.h>
+ #include <errno.h>
++#ifndef __NetBSD__
+ #include <pty.h>
++#endif
++#include <string.h>
+
+ #include "xenctrl.h"
+ #include "xs.h"
+@@ -259,6 +262,7 @@
+ free(str_pty);
+ free(path);
+
++ init_term(spty, &attr);
+ init_term(STDIN_FILENO, &attr);
+ console_loop(xc_handle, domid, spty);
+ restore_term(STDIN_FILENO, &attr);
diff --git a/sysutils/xentools30/patches/patch-cd b/sysutils/xentools30/patches/patch-cd
new file mode 100644
index 00000000000..d93c04db497
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-cd
@@ -0,0 +1,15 @@
+$NetBSD: patch-cd,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/xen/util/auxbin.py.orig 2006-05-07 21:00:00.000000000 +0200
++++ python/xen/util/auxbin.py 2006-05-07 21:01:06.000000000 +0200
+@@ -16,8 +16,8 @@
+ #============================================================================
+
+
+-LIB_BIN_32 = "/usr/lib/xen/bin"
+-LIB_BIN_64 = "/usr/lib64/xen/bin"
++LIB_BIN_32 = "@PREFIX@/bin"
++LIB_BIN_64 = "@PREFIX@/bin"
+
+ ## The architectures on which the LIB_BIN_64 directory is used. This
+ # deliberately excludes ia64.
diff --git a/sysutils/xentools30/patches/patch-ce b/sysutils/xentools30/patches/patch-ce
new file mode 100644
index 00000000000..b5025368caa
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ce
@@ -0,0 +1,13 @@
+$NetBSD: patch-ce,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- python/xen/xend/XendBootloader.py.orig 2006-07-01 21:35:24.000000000 +0200
++++ python/xen/xend/XendBootloader.py 2006-07-01 21:35:57.000000000 +0200
+@@ -38,7 +38,7 @@
+ raise VmError(msg)
+
+ while True:
+- fifo = "/var/lib/xen/xenbl.%s" %(random.randint(0, 32000),)
++ fifo = "/var/run/xend/xenbl.%s" %(random.randint(0, 32000),)
+ if not os.path.exists(fifo):
+ break
+ os.mkfifo(fifo, 0600)
diff --git a/sysutils/xentools30/patches/patch-cf b/sysutils/xentools30/patches/patch-cf
new file mode 100644
index 00000000000..c3648667057
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-cf
@@ -0,0 +1,17 @@
+$NetBSD: patch-cf,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstat/libxenstat/Makefile.orig 2006-07-01 21:47:57.000000000 +0200
++++ xenstat/libxenstat/Makefile 2006-07-01 21:48:21.000000000 +0200
+@@ -84,10 +84,10 @@
+ BINDINGSRC=$(PYSRC) $(PERLSRC)
+
+ # The all-bindings target builds all the language bindings
+-all-bindings: perl-bindings python-bindings
++all-bindings: python-bindings
+
+ # The install-bindings target installs all the language bindings
+-install-bindings: install-perl-bindings install-python-bindings
++install-bindings: install-python-bindings
+
+ $(BINDINGS): $(SHLIB) $(SHLIB_LINKS) src/xenstat.h
+
diff --git a/sysutils/xentools30/patches/patch-cg b/sysutils/xentools30/patches/patch-cg
new file mode 100644
index 00000000000..8354b8c3fea
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-cg
@@ -0,0 +1,22 @@
+$NetBSD: patch-cg,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstat/xentop/xentop.c.orig 2006-04-13 19:48:39.000000000 +0200
++++ xenstat/xentop/xentop.c 2006-07-01 22:12:29.000000000 +0200
+@@ -18,7 +18,8 @@
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+-#include <curses.h>
++#include <ncurses.h>
++#define vw_printw vwprintw
+ #include <ctype.h>
+ #include <errno.h>
+ #include <stdio.h>
+@@ -27,6 +28,7 @@
+ #include <sys/time.h>
+ #include <time.h>
+ #include <unistd.h>
++#include <stdarg.h>
+
+ #include <xenstat.h>
+
diff --git a/sysutils/xentools30/patches/patch-ch b/sysutils/xentools30/patches/patch-ch
new file mode 100644
index 00000000000..aca6107f846
--- /dev/null
+++ b/sysutils/xentools30/patches/patch-ch
@@ -0,0 +1,21 @@
+$NetBSD: patch-ch,v 1.1.1.1 2006/07/02 16:49:31 bouyer Exp $
+
+--- xenstat/libxenstat/src/xenstat.c.orig 2006-04-13 19:48:39.000000000 +0200
++++ xenstat/libxenstat/src/xenstat.c 2006-07-01 23:20:36.000000000 +0200
+@@ -517,6 +517,8 @@
+ /* Collect information about networks */
+ static int xenstat_collect_networks(xenstat_node * node)
+ {
++#ifndef __NetBSD__
++ /* XXX fixme: implement code to get stats from libkvm ! */
+ /* Open and validate /proc/net/dev if we haven't already */
+ if (node->handle->procnetdev == NULL) {
+ char header[sizeof(PROCNETDEV_HEADER)];
+@@ -592,6 +594,7 @@
+ domain->networks[domain->num_networks - 1] = net;
+ }
+
++#endif
+ return 1;
+ }
+