[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH XEN v8 02/29] tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn.
On Fri, 2016-01-15 at 13:22 +0000, Ian Campbell wrote: This is the only patch which changed meaningfully in v9, so I'm just posting it that one below FTR, intra-log is: v9: Refactor over "xenstore: move init-xenstore-domain to ÂÂÂÂtools/helpers" this highlighted that init-xenstore-domain has no ÂÂÂÂneed for LDLIBS_xenevtchn and never did, so that hunk is simply ÂÂÂÂdropped. Only other interesting thing in v9 would have been #05 "tools: Refactor /dev/xen/gnt{dev,shr} wrappers into libxengnttab." which needed some conflict resolution due to "xenstore: move init-xenstore-domain to tools/helpers" but that was all. Ian. 8<------- From f63312c8d92c728ff50ee3e5777c2ef7e59aaf3f Mon Sep 17 00:00:00 2001 From: Ian Campbell <ian.campbell@xxxxxxxxxx> Date: Mon, 1 Jun 2015 16:20:09 +0100 Subject: [PATCH] tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libxenevtchn will provide a stable API and ABI for accessing the evtchn device. The functions are moved into the xenevtchn namespace to make a clean break from libxc and avoid ambiguity regarding which interfaces are stable. All in-tree users are updated to use the new names. Upon request (via #define XC_WANT_COMPAT_EVTCHN_API) libxenctrl will provide a compat API for the old names. This is used by qemu-xen for the time being. qemu-xen-traditional is updated in lockstep. This leaves a few event channel related functions which go via privcmd (EVTCHNOP) rather than ioctls on the /dev/xen/evtchn device in libxenctrl. Specifically: Â- xc_evtchn_alloc_unbound Â- xc_evtchn_reset Â- xc_evtchn_status Note that xc_evtchn_alloc_unbound's functionality is also provided by xenevtchn_bind_unbound_port() (nÃe xc_evtchn_bind_unbound_port) and is probably redundant. These functions do not appear to be needed by qemu-dm, qemu-pv (provision of device model to HVM guests and PV backends respectively) or by libvchan suggesting they are not needed by non-toolstack uses of event channels. QEMU does use these in hw/xenpv/xen_domainbuild.c but that is a "toolstack use". The new library uses a version script to ensure that only expected symbols are exported and to version them such that ABI guarantees can be kept in the future. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- Must be applied with: Â- "qemu-xen-traditional: Use libxenevtchn" and a corresponding ÂÂÂQEMU_TAG update folded here. Â- "mini-os: Include libxenevtchn with libxc"" and a corresponding ÂÂÂbump to MINIOS_UPSTREAM_REVISION folded in here. v2: Update doc at same time ÂÂÂÂRemoved some stray compat thing v3: Moved to tools/libs/evtchn v4: typedef the xenevtchn_handle in xenguest.h instead of #include, to ÂÂÂÂavoid leaking the libxenevtchn namespace into callers who may not ÂÂÂÂwant it. (And also to avoid adding lots of -I to places like ÂÂÂÂstubdom builds) v5: Handle NULL passed to _close() v6: Properly port xen-access to new API (instead of a single function call) v7: Added mk-headers-$(XEN_TARGET_ARCH) build dependency instead of ÂÂÂÂopen coding the recursion. v8: Remove *.so on clean, add distclean target. v9: Refactor over "xenstore: move init-xenstore-domain to ÂÂÂÂtools/helpers" this highlighted that init-xenstore-domain has no ÂÂÂÂneed for LDLIBS_xenevtchn and never did, so that hunk is simply ÂÂÂÂdropped. --- Â.gitignoreÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ1 + Âstubdom/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ17 +- Âtools/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ5 +- Âtools/Rules.mkÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ14 +- Âtools/console/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ2 + Âtools/console/daemon/io.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ43 ++-- Âtools/libs/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ1 + Âtools/libs/evtchn/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ69 +++++++ Âtools/libs/evtchn/core.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ72 +++++++ Âtools/libs/evtchn/freebsd.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 138 +++++++++++++ Âtools/libs/evtchn/include/xenevtchn.hÂÂÂÂÂÂÂÂÂ| 150 ++++++++++++++ Âtools/libs/evtchn/libxenevtchn.mapÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ19 ++ Âtools/libs/evtchn/linux.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 136 +++++++++++++ Âtools/libs/evtchn/minios.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 269 ++++++++++++++++++++++++++ Âtools/libs/evtchn/netbsd.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 147 ++++++++++++++ Âtools/libs/evtchn/private.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ25 +++ Âtools/libs/evtchn/solaris.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 135 +++++++++++++ Âtools/libs/toollog/include/xentoollog.hÂÂÂÂÂÂÂ|ÂÂ10 + Âtools/libs/toollog/xtl_core.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ10 + Âtools/libs/toollog/xtl_logger_stdio.cÂÂÂÂÂÂÂÂÂ|ÂÂ10 + Âtools/libvchan/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ6 +- Âtools/libvchan/init.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ20 +- Âtools/libvchan/io.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ12 +- Âtools/libvchan/libxenvchan.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ3 +- Âtools/libxc/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ8 +- Âtools/libxc/include/xenctrl.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ99 +--------- Âtools/libxc/include/xenctrl_compat.hÂÂÂÂÂÂÂÂÂÂ|ÂÂ48 +++++ Âtools/libxc/include/xenguest.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ14 +- Âtools/libxc/xc_evtchn_compat.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ75 +++++++ Âtools/libxc/xc_freebsd_osdep.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 101 ---------- Âtools/libxc/xc_linux_osdep.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ95 --------- Âtools/libxc/xc_minios.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 221 --------------------- Âtools/libxc/xc_netbsd.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 109 ----------- Âtools/libxc/xc_private.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ40 ---- Âtools/libxc/xc_private.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ7 - Âtools/libxc/xc_solaris.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ97 ---------- Âtools/libxc/xc_suspend.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ18 +- Âtools/libxl/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ5 +- Âtools/libxl/libxl.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ2 +- Âtools/libxl/libxl_dom_suspend.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ4 +- Âtools/libxl/libxl_event.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ14 +- Âtools/libxl/libxl_internal.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ5 +- Âtools/misc/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ7 +- Âtools/misc/xen-hptool.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ13 +- Âtools/misc/xen-lowmemd.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ15 +- Âtools/ocaml/libs/eventchn/MakefileÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ4 +- Âtools/ocaml/libs/eventchn/xeneventchn_stubs.c |ÂÂ20 +- Âtools/python/setup.pyÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ7 +- Âtools/tests/xen-access/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ3 +- Âtools/tests/xen-access/xen-access.cÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ21 +- Âtools/xcutils/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ4 +- Âtools/xenmon/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ2 + Âtools/xenmon/xenbaked.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ13 +- Âtools/xenpaging/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ4 +- Âtools/xenpaging/xenpaging.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ18 +- Âtools/xenpaging/xenpaging.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ3 +- Âtools/xenstore/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ3 +- Âtools/xenstore/xenstored_core.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ6 +- Âtools/xenstore/xenstored_domain.cÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ25 +-- Âtools/xentrace/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ5 +- Âtools/xentrace/xentrace.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ13 +- Â61 files changed, 1538 insertions(+), 924 deletions(-) Âcreate mode 100644 tools/libs/evtchn/Makefile Âcreate mode 100644 tools/libs/evtchn/core.c Âcreate mode 100644 tools/libs/evtchn/freebsd.c Âcreate mode 100644 tools/libs/evtchn/include/xenevtchn.h Âcreate mode 100644 tools/libs/evtchn/libxenevtchn.map Âcreate mode 100644 tools/libs/evtchn/linux.c Âcreate mode 100644 tools/libs/evtchn/minios.c Âcreate mode 100644 tools/libs/evtchn/netbsd.c Âcreate mode 100644 tools/libs/evtchn/private.h Âcreate mode 100644 tools/libs/evtchn/solaris.c Âcreate mode 100644 tools/libxc/include/xenctrl_compat.h Âcreate mode 100644 tools/libxc/xc_evtchn_compat.c diff --git a/.gitignore b/.gitignore index 141c2be..e7af9f7 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ stubdom/ioemu Âstubdom/ioemu/ Âstubdom/libs-* Âstubdom/libxc-* +stubdom/libxenevtchn-* Âstubdom/libxentoollog-* Âstubdom/lwip-* Âstubdom/lwip/ diff --git a/stubdom/Makefile b/stubdom/Makefile index 9c77205..702d66b 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -319,6 +319,12 @@ mk-headers-$(XEN_TARGET_ARCH): $(IOEMU_LINKFARM_TARGET)  ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/include/*.h . && \  ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/*.c . && \  ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/Makefile . ) + mkdir -p libs-$(XEN_TARGET_ARCH)/evtchn/include + [ -h libs-$(XEN_TARGET_ARCH)/evtchn/Makefile ] || ( cd libs-$(XEN_TARGET_ARCH)/evtchn && \ + ÂÂln -sf $(XEN_ROOT)/tools/libs/evtchn/*.h . && \ + ÂÂln -sf $(XEN_ROOT)/tools/libs/evtchn/include/*.h include/ && \ + ÂÂln -sf $(XEN_ROOT)/tools/libs/evtchn/*.c . && \ + ÂÂln -sf $(XEN_ROOT)/tools/libs/evtchn/Makefile . )  mkdir -p libxc-$(XEN_TARGET_ARCH)  [ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \  ÂÂln -sf $(XEN_ROOT)/tools/libxc/*.h . && \ @@ -351,12 +357,21 @@ libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a: mk-headers-$(XEN_TARGET_ARCH) $  CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog  Â####### +# libxenevtchn +####### + +.PHONY: libxenevtchn +libxenevtchn: libs-$(XEN_TARGET_ARCH)/evtchn/libxenevtchn.a +libs-$(XEN_TARGET_ARCH)/evtchn/libxenevtchn.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/evtchn + +####### Â# libxc Â#######  Â.PHONY: libxc Âlibxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a -libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog cross-zlib +libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog libxenevtchn cross-zlib  CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH)   libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a diff --git a/tools/Makefile b/tools/Makefile index ccd0ae7..55b5d44 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -249,8 +249,10 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find  --libdir=$(LIBEXEC_LIB) \  --includedir=$(LIBEXEC_INC) \  --source-path=$$source \ - --extra-cflags="-I$(XEN_ROOT)/tools/include \ + --extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \ + -I$(XEN_ROOT)/tools/include \  -I$(XEN_ROOT)/tools/libs/toollog/include \ + -I$(XEN_ROOT)/tools/libs/evtchn/include \  -I$(XEN_ROOT)/tools/libxc/include \  -I$(XEN_ROOT)/tools/xenstore/include \  -I$(XEN_ROOT)/tools/xenstore/compat/include \ @@ -258,6 +260,7 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find  --extra-ldflags="-L$(XEN_ROOT)/tools/libxc \  -L$(XEN_ROOT)/tools/xenstore \  -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \ + -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/evtchn \  $(QEMU_UPSTREAM_RPATH)" \  --bindir=$(LIBEXEC_BIN) \  --datadir=$(SHAREDIR)/qemu-xen \ diff --git a/tools/Rules.mk b/tools/Rules.mk index 0652e4b..75d02c4 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -11,6 +11,7 @@ INSTALL = $(XEN_ROOT)/tools/cross-install  ÂXEN_INCLUDEÂÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/include ÂXEN_LIBXENTOOLLOGÂÂ= $(XEN_ROOT)/tools/libs/toollog +XEN_LIBXENEVTCHNÂÂÂ= $(XEN_ROOT)/tools/libs/evtchn ÂXEN_LIBXCÂÂÂÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/libxc ÂXEN_XENLIGHTÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/libxl ÂXEN_XENSTOREÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/xenstore @@ -82,13 +83,18 @@ SHDEPS_libxentoollog = ÂLDLIBS_libxentoollog = $(XEN_LIBXENTOOLLOG)/libxentoollog$(libextension) ÂSHLIB_libxentoollogÂÂ= -Wl,-rpath-link=$(XEN_LIBXENTOOLLOG)  +CFLAGS_libxenevtchn = -I$(XEN_LIBXENEVTCHN)/include $(CFLAGS_xeninclude) +SHDEPS_libxenevtchn = +LDLIBS_libxenevtchn = $(XEN_LIBXENEVTCHN)/libxenevtchn$(libextension) +SHLIB_libxenevtchnÂÂ= -Wl,-rpath-link=$(XEN_LIBXENEVTCHN) + ÂCFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_xeninclude) -SHDEPS_libxenctrl = $(SHLIB_libxentoollog) +SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) ÂLDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension) ÂSHLIB_libxenctrlÂÂ= $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC)  -CFLAGS_libxenguest = -I$(XEN_LIBXC)/include $(CFLAGS_xeninclude) -SHDEPS_libxenguest = +CFLAGS_libxenguest = -I$(XEN_LIBXC)/include $(CFLAGS_libxenevtchn) $(CFLAGS_xeninclude) +SHDEPS_libxenguest = $(SHLIB_libxenevtchn) ÂLDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_LIBXC)/libxenguest$(libextension) ÂSHLIB_libxenguestÂÂ= $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_LIBXC)  @@ -103,7 +109,7 @@ LDLIBS_libxenstatÂÂ= $(SHDEPS_libxenstat) $(XEN_LIBXENSTAT)/libxenstat$(libexten ÂSHLIB_libxenstatÂÂÂ= $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_LIBXENSTAT)  ÂCFLAGS_libxenvchan = -I$(XEN_LIBVCHAN) -SHDEPS_libxenvchan = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) +SHDEPS_libxenvchan = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libxenevtchn) ÂLDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libextension) ÂSHLIB_libxenvchanÂÂ= $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)  diff --git a/tools/console/Makefile b/tools/console/Makefile index 77e8f29..4b3a492 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -3,8 +3,10 @@ include $(XEN_ROOT)/tools/Rules.mk  ÂCFLAGSÂÂ+= -Werror  +CFLAGSÂÂ+= $(CFLAGS_libxenevtchn) ÂCFLAGSÂÂ+= $(CFLAGS_libxenctrl) ÂCFLAGSÂÂ+= $(CFLAGS_libxenstore) +LDLIBS += $(LDLIBS_libxenevtchn) ÂLDLIBS += $(LDLIBS_libxenctrl) ÂLDLIBS += $(LDLIBS_libxenstore) ÂLDLIBS += $(SOCKET_LIBS) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index cafc7b7..2f2e9c5 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -21,6 +21,7 @@  Â#include "utils.h" Â#include "io.h" +#include <xenevtchn.h> Â#include <xenstore.h> Â#include <xen/io/console.h> Â#include <xen/grant_table.h> @@ -101,7 +102,7 @@ struct domain {  int ring_ref;  evtchn_port_or_error_t local_port;  evtchn_port_or_error_t remote_port; - xc_evtchn *xce_handle; + xenevtchn_handle *xce_handle;  int xce_pollfd_idx;  struct xencons_interface *interface;  int event_count; @@ -185,7 +186,7 @@ static void buffer_append(struct domain *dom)   xen_mb();  intf->out_cons = cons; - xc_evtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(dom->xce_handle, dom->local_port);   /* Get the data to the logfile as early as possible because if  Â* no one is listening on the console pty then it will fill up @@ -584,22 +585,22 @@ static int domain_create_ring(struct domain *dom)  dom->local_port = -1;  dom->remote_port = -1;  if (dom->xce_handle != NULL) - xc_evtchn_close(dom->xce_handle); + xenevtchn_close(dom->xce_handle);   /* Opening evtchn independently for each console is a bit  Â* wasteful, but that's how the code is structured... */ - dom->xce_handle = xc_evtchn_open(NULL, 0); + dom->xce_handle = xenevtchn_open(NULL, 0);  if (dom->xce_handle == NULL) {  err = errno;  goto out;  }  - rc = xc_evtchn_bind_interdomain(dom->xce_handle, + rc = xenevtchn_bind_interdomain(dom->xce_handle,  dom->domid, remote_port);   if (rc == -1) {  err = errno; - xc_evtchn_close(dom->xce_handle); + xenevtchn_close(dom->xce_handle);  dom->xce_handle = NULL;  goto out;  } @@ -609,7 +610,7 @@ static int domain_create_ring(struct domain *dom)  if (dom->master_fd == -1) {  if (!domain_create_tty(dom)) {  err = errno; - xc_evtchn_close(dom->xce_handle); + xenevtchn_close(dom->xce_handle);  dom->xce_handle = NULL;  dom->local_port = -1;  dom->remote_port = -1; @@ -749,7 +750,7 @@ static void shutdown_domain(struct domain *d)  watch_domain(d, false);  domain_unmap_interface(d);  if (d->xce_handle != NULL) - xc_evtchn_close(d->xce_handle); + xenevtchn_close(d->xce_handle);  d->xce_handle = NULL; Â}  @@ -839,7 +840,7 @@ static void handle_tty_read(struct domain *dom)  }  xen_wmb();  intf->in_prod = prod; - xc_evtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(dom->xce_handle, dom->local_port);  } else {  domain_close_tty(dom);  shutdown_domain(dom); @@ -871,7 +872,7 @@ static void handle_ring_read(struct domain *dom)  if (dom->is_dead)  return;  - if ((port = xc_evtchn_pending(dom->xce_handle)) == -1) + if ((port = xenevtchn_pending(dom->xce_handle)) == -1)  return;   dom->event_count++; @@ -879,7 +880,7 @@ static void handle_ring_read(struct domain *dom)  buffer_append(dom);   if (dom->event_count < RATE_LIMIT_ALLOWANCE) - (void)xc_evtchn_unmask(dom->xce_handle, port); + (void)xenevtchn_unmask(dom->xce_handle, port); Â}  Âstatic void handle_xs(void) @@ -906,7 +907,7 @@ static void handle_xs(void)  free(vec); Â}  -static void handle_hv_logs(xc_evtchn *xce_handle, bool force) +static void handle_hv_logs(xenevtchn_handle *xce_handle, bool force) Â{  static char buffer[1024*16];  char *bufptr = buffer; @@ -914,7 +915,7 @@ static void handle_hv_logs(xc_evtchn *xce_handle, bool force)  static uint32_t index = 0;  evtchn_port_or_error_t port = -1;  - if (!force && ((port = xc_evtchn_pending(xce_handle)) == -1)) + if (!force && ((port = xenevtchn_pending(xce_handle)) == -1))  return;   do @@ -938,7 +939,7 @@ static void handle_hv_logs(xc_evtchn *xce_handle, bool force)  } while (size == sizeof(buffer));   if (port != -1) - (void)xc_evtchn_unmask(xce_handle, port); + (void)xenevtchn_unmask(xce_handle, port); Â}  Âstatic void handle_log_reload(void) @@ -1006,10 +1007,10 @@ void handle_io(void)  evtchn_port_or_error_t log_hv_evtchn = -1;  int xce_pollfd_idx = -1;  int xs_pollfd_idx = -1; - xc_evtchn *xce_handle = NULL; + xenevtchn_handle *xce_handle = NULL;   if (log_hv) { - xce_handle = xc_evtchn_open(NULL, 0); + xce_handle = xenevtchn_open(NULL, 0);  if (xce_handle == NULL) {  dolog(LOG_ERR, "Failed to open xce handle: %d (%s)",  ÂÂÂÂÂÂerrno, strerror(errno)); @@ -1018,7 +1019,7 @@ void handle_io(void)  log_hv_fd = create_hv_log();  if (log_hv_fd == -1)  goto out; - log_hv_evtchn = xc_evtchn_bind_virq(xce_handle, VIRQ_CON_RING); + log_hv_evtchn = xenevtchn_bind_virq(xce_handle, VIRQ_CON_RING);  if (log_hv_evtchn == -1) {  dolog(LOG_ERR, "Failed to bind to VIRQ_CON_RING: "  ÂÂÂÂÂÂ"%d (%s)", errno, strerror(errno)); @@ -1047,7 +1048,7 @@ void handle_io(void)  xs_pollfd_idx = set_fds(xs_fileno(xs), POLLIN|POLLPRI);   if (log_hv) - xce_pollfd_idx = set_fds(xc_evtchn_fd(xce_handle), + xce_pollfd_idx = set_fds(xenevtchn_fd(xce_handle),  ÂPOLLIN|POLLPRI);   if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) @@ -1066,7 +1067,7 @@ void handle_io(void)  if ((now+5) > d->next_period) {  d->next_period = now + RATE_LIMIT_PERIOD;  if (d->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xc_evtchn_unmask(d->xce_handle, d->local_port); + (void)xenevtchn_unmask(d->xce_handle, d->local_port);  }  d->event_count = 0;  } @@ -1082,7 +1083,7 @@ void handle_io(void)  if (discard_overflowed_data ||  ÂÂÂÂ!d->buffer.max_capacity ||  ÂÂÂÂd->buffer.size < d->buffer.max_capacity) { - int evtchn_fd = xc_evtchn_fd(d->xce_handle); + int evtchn_fd = xenevtchn_fd(d->xce_handle);  d->xce_pollfd_idx = set_fds(evtchn_fd,  Â POLLIN|POLLPRI);  } @@ -1202,7 +1203,7 @@ void handle_io(void)  log_hv_fd = -1;  }  if (xce_handle != NULL) { - xc_evtchn_close(xce_handle); + xenevtchn_close(xce_handle);  xce_handle = NULL;  }  if (xcg_handle != NULL) { diff --git a/tools/libs/Makefile b/tools/libs/Makefile index 73be500..0e3f523 100644 --- a/tools/libs/Makefile +++ b/tools/libs/Makefile @@ -3,5 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk  ÂSUBDIRS-y := ÂSUBDIRS-y += toollog +SUBDIRS-y += evtchn  Âall clean install distclean: %: subdirs-% diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile new file mode 100644 index 0000000..46a807f --- /dev/null +++ b/tools/libs/evtchn/Makefile @@ -0,0 +1,69 @@ +XEN_ROOT = $(CURDIR)/../../.. +include $(XEN_ROOT)/tools/Rules.mk + +MAJORÂÂÂÂ= 1 +MINORÂÂÂÂ= 0 +SHLIB_LDFLAGS += -Wl,--version-script=libxenevtchn.map + +CFLAGSÂÂÂ+= -Werror -Wmissing-prototypes +CFLAGSÂÂÂ+= -I./include $(CFLAGS_xeninclude) +CFLAGSÂÂÂ+= $(CFLAGS_libxentoollog) + +SRCS-yÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ+= core.c +SRCS-$(CONFIG_Linux)ÂÂÂ+= linux.c +SRCS-$(CONFIG_FreeBSD) += freebsd.c +SRCS-$(CONFIG_SunOS)ÂÂÂ+= solaris.c +SRCS-$(CONFIG_NetBSD)ÂÂ+= netbsd.c +SRCS-$(CONFIG_MiniOS)ÂÂ+= minios.c + +LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y)) +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y)) + +LIB := libxenevtchn.a +ifneq ($(nosharedlibs),y) +LIB += libxenevtchn.so +endif + +.PHONY: all +all: build + +.PHONY: build +build: + $(MAKE) libs + +.PHONY: libs +libs: $(LIB) + + +libxenevtchn.a: $(LIB_OBJS) + $(AR) rc $@ $^ + +libxenevtchn.so: libxenevtchn.so.$(MAJOR) + $(SYMLINK_SHLIB) $< $@ +libxenevtchn.so.$(MAJOR): libxenevtchn.so.$(MAJOR).$(MINOR) + $(SYMLINK_SHLIB) $< $@ + +libxenevtchn.so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxenevtchn.map + $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenevtchn.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(APPEND_LDFLAGS) + +.PHONY: install +install: build + $(INSTALL_DIR) $(DESTDIR)$(libdir) + $(INSTALL_DIR) $(DESTDIR)$(includedir) + $(INSTALL_SHLIB) libxenevtchn.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir) + $(INSTALL_DATA) libxenevtchn.a $(DESTDIR)$(libdir) + $(SYMLINK_SHLIB) libxenevtchn.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenevtchn.so.$(MAJOR) + $(SYMLINK_SHLIB) libxenevtchn.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenevtchn.so + $(INSTALL_DATA) include/xenevtchn.h $(DESTDIR)$(includedir) + +.PHONY: TAGS +TAGS: + etags -t *.c *.h + +.PHONY: clean +clean: + rm -rf *.rpm $(LIB) *~ $(DEPS) $(LIB_OBJS) $(PIC_OBJS) + rm -f libxenevtchn.so.$(MAJOR).$(MINOR) libxenevtchn.so.$(MAJOR) + +.PHONY: distclean +distclean: clean diff --git a/tools/libs/evtchn/core.c b/tools/libs/evtchn/core.c new file mode 100644 index 0000000..c31e08c --- /dev/null +++ b/tools/libs/evtchn/core.c @@ -0,0 +1,72 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#include <unistd.h> +#include <stdlib.h> + +#include "private.h" + +xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned open_flags) +{ +ÂÂÂÂxenevtchn_handle *xce = malloc(sizeof(*xce)); +ÂÂÂÂint rc; + +ÂÂÂÂif (!xce) return NULL; + +ÂÂÂÂxce->fd = -1; +ÂÂÂÂxce->logger = logger; +ÂÂÂÂxce->logger_tofreeÂÂ= NULL; + +ÂÂÂÂif (!xce->logger) { +ÂÂÂÂÂÂÂÂxce->logger = xce->logger_tofree = +ÂÂÂÂÂÂÂÂÂÂÂÂ(xentoollog_logger*) +ÂÂÂÂÂÂÂÂÂÂÂÂxtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0); +ÂÂÂÂÂÂÂÂif (!xce->logger) goto err; +ÂÂÂÂ} + +ÂÂÂÂrc = osdep_evtchn_open(xce); +ÂÂÂÂif ( rcÂÂ< 0 ) goto err; + +ÂÂÂÂreturn xce; + +err: +ÂÂÂÂosdep_evtchn_close(xce); +ÂÂÂÂxtl_logger_destroy(xce->logger_tofree); +ÂÂÂÂfree(xce); +ÂÂÂÂreturn NULL; +} + +int xenevtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂint rc; + +ÂÂÂÂif ( !xce ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂrc = osdep_evtchn_close(xce); +ÂÂÂÂxtl_logger_destroy(xce->logger_tofree); +ÂÂÂÂfree(xce); +ÂÂÂÂreturn rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/freebsd.c b/tools/libs/evtchn/freebsd.c new file mode 100644 index 0000000..636f052 --- /dev/null +++ b/tools/libs/evtchn/freebsd.c @@ -0,0 +1,138 @@ + /****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc.ÂÂAll rights reserved. + * Use is subject to license terms. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split off from xc_freebsd_osdep.c + */ + +#include <fcntl.h> +#include <unistd.h> + +#include <sys/ioctl.h> + +#include <xen/sys/evtchn.h> + +#include "private.h" + +#define EVTCHN_DEVÂÂÂÂÂÂ"/dev/xen/evtchn" + +int osdep_evtchn_open(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = open(EVTCHN_DEV, O_RDWR); +ÂÂÂÂif ( fd == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂxce->fd = fd; +ÂÂÂÂreturn 0; +} + +int osdep_evtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂif ( xce->fd == -1 ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂreturn close(xce->fd); +} + +int xenevtchn_fd(xenevtchn_handle *xce) +{ +ÂÂÂÂreturn xce->fd; +} + +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_notify notify; + +ÂÂÂÂnotify.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +evtchn_port_or_error_t xenevtchn_bind_unbound_port(xenevtchn_handle *xce, int domid) +{ +ÂÂÂÂint ret, fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; + +ÂÂÂÂbind.remote_domain = domid; + +ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); +ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; +} + +evtchn_port_or_error_t +xenevtchn_bind_interdomain(xenevtchn_handle *xce, int domid, evtchn_port_t remote_port) +{ +ÂÂÂÂint ret, fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; + +ÂÂÂÂbind.remote_domain = domid; +ÂÂÂÂbind.remote_port = remote_port; + +ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); +ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; +} + +evtchn_port_or_error_t xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq) +{ +ÂÂÂÂint ret, fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; + +ÂÂÂÂbind.virq = virq; + +ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); +ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; +} + +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_unbind unbind; + +ÂÂÂÂunbind.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); +} + +evtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂif ( read(fd, &port, sizeof(port)) != sizeof(port) ) +ÂÂÂÂÂÂÂÂreturn -1; + +ÂÂÂÂreturn port; +} + +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; + +ÂÂÂÂif ( write(fd, &port, sizeof(port)) != sizeof(port) ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂreturn 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/include/xenevtchn.h b/tools/libs/evtchn/include/xenevtchn.h new file mode 100644 index 0000000..3380fa3 --- /dev/null +++ b/tools/libs/evtchn/include/xenevtchn.h @@ -0,0 +1,150 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split off from: + * xenctrl.h + * + * A library for low-level access to the Xen control interfaces. + * + * Copyright (c) 2003-2004, K A Fraser. + */ + +#ifndef XENEVTCHN_H +#define XENEVTCHN_H + +#include <stdint.h> + +#include <xen/event_channel.h> + +/* A port identifier is guaranteed to fit in 31 bits. */ +typedef int evtchn_port_or_error_t; + +typedef struct xenevtchn_handle xenevtchn_handle; + +/* Callers who don't care don't need to #include <xentoollog.h> */ +typedef struct xentoollog_logger xentoollog_logger; + +/* + * EVENT CHANNEL FUNCTIONS + * + * None of these do any logging. + */ + +/* + * Return a handle to the event channel driver, or NULL on failure, in + * which case errno will be set appropriately. + * + * Note: + * After fork a child process must not use any opened xc evtchn + * handle inherited from their parent. They must open a new handle if + * they want to interact with xc. + * + * Before Xen pre-4.1 this function would sometimes report errors with perror. + */ +/* Currently no flags are defined */ +xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned open_flags); + +/* + * Close a handle previously allocated with xenevtchn_open(). + */ +int xenevtchn_close(xenevtchn_handle *xce); + +/* + * Return an fd that can be select()ed on. + * + * Note that due to bugs, setting this fd to non blocking may not + * work: you would hope that it would result in xenevtchn_pending + * failing with EWOULDBLOCK if there are no events signaled, but in + * fact it may block.ÂÂ(Bug is present in at least Linux 3.12, and + * perhaps on other platforms or later version.) + * + * To be safe, you must use poll() or select() before each call to + * xenevtchn_pending.ÂÂIf you have multiple threads (or processes) + * sharing a single xce handle this will not work, and there is no + * straightforward workaround.ÂÂPlease design your program some other + * way. + */ +int xenevtchn_fd(xenevtchn_handle *xce); + +/* + * Notify the given event channel. Returns -1 on failure, in which case + * errno will be set appropriately. + */ +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port); + +/* + * Returns a new event port awaiting interdomain connection from the given + * domain ID, or -1 on failure, in which case errno will be set appropriately. + */ +evtchn_port_or_error_t +xenevtchn_bind_unbound_port(xenevtchn_handle *xce, int domid); + +/* + * Returns a new event port bound to the remote port for the given domain ID, + * or -1 on failure, in which case errno will be set appropriately. + */ +evtchn_port_or_error_t +xenevtchn_bind_interdomain(xenevtchn_handle *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port); + +/* + * Bind an event channel to the given VIRQ. Returns the event channel bound to + * the VIRQ, or -1 on failure, in which case errno will be set appropriately. + */ +evtchn_port_or_error_t +xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq); + +/* + * Unbind the given event channel. Returns -1 on failure, in which case errno + * will be set appropriately. + */ +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port); + +/* + * Return the next event channel to become pending, or -1 on failure, in which + * case errno will be set appropriately. + * + * At the hypervisor level the event channel will have been masked, + * and then cleared, by the underlying machinery (evtchn kernel + * driver, or equivalent).ÂÂSo if the event channel is signaled again + * after it is returned here, it will be queued up, and delivered + * again after you unmask it.ÂÂ(See the documentation in the Xen + * public header event_channel.h.) + * + * On receiving the notification from xenevtchn_pending, you should + * normally: check (by other means) what work needs doing; do the + * necessary work (if any); unmask the event channel with + * xenevtchn_unmask (if you want to receive any further + * notifications). + */ +evtchn_port_or_error_t +xenevtchn_pending(xenevtchn_handle *xce); + +/* + * Unmask the given event channel. Returns -1 on failure, in which case errno + * will be set appropriately. + */ +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port); + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/libxenevtchn.map b/tools/libs/evtchn/libxenevtchn.map new file mode 100644 index 0000000..625a1e2 --- /dev/null +++ b/tools/libs/evtchn/libxenevtchn.map @@ -0,0 +1,19 @@ +VERS_1.0 { + global: + xenevtchn_open; + xenevtchn_close; + + xenevtchn_fd; + + xenevtchn_bind_unbound_port; + xenevtchn_bind_interdomain; + xenevtchn_bind_virq; + + xenevtchn_notify; + + xenevtchn_unbind; + xenevtchn_unmask; + + xenevtchn_pending; + local: *; /* Do not expose anything by default */ +}; diff --git a/tools/libs/evtchn/linux.c b/tools/libs/evtchn/linux.c new file mode 100644 index 0000000..27fd6e9 --- /dev/null +++ b/tools/libs/evtchn/linux.c @@ -0,0 +1,136 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split out from xc_linus_osdep.c: + * + * Copyright 2006 Sun Microsystems, Inc.ÂÂAll rights reserved. + */ + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> + +#include <sys/ioctl.h> + +#include <xen/sys/evtchn.h> + +#include "private.h" + +int osdep_evtchn_open(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = open("/dev/xen/evtchn", O_RDWR); +ÂÂÂÂif ( fd == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂxce->fd = fd; +ÂÂÂÂreturn 0; +} + +int osdep_evtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂif ( xce->fd == -1 ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂreturn close(xce->fd); +} + +int xenevtchn_fd(xenevtchn_handle *xce) +{ +ÂÂÂÂreturn xce->fd; +} + +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_notify notify; + +ÂÂÂÂnotify.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +evtchn_port_or_error_t xenevtchn_bind_unbound_port(xenevtchn_handle *xce, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; + +ÂÂÂÂbind.remote_domain = domid; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); +} + +evtchn_port_or_error_t xenevtchn_bind_interdomain(xenevtchn_handle *xce, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; + +ÂÂÂÂbind.remote_domain = domid; +ÂÂÂÂbind.remote_port = remote_port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); +} + +evtchn_port_or_error_t xenevtchn_bind_virq(xenevtchn_handle *xce, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned int virq) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; + +ÂÂÂÂbind.virq = virq; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); +} + +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_unbind unbind; + +ÂÂÂÂunbind.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); +} + +evtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂif ( read(fd, &port, sizeof(port)) != sizeof(port) ) +ÂÂÂÂÂÂÂÂreturn -1; + +ÂÂÂÂreturn port; +} + +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; + +ÂÂÂÂif ( write(fd, &port, sizeof(port)) != sizeof(port) ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂreturn 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/minios.c b/tools/libs/evtchn/minios.c new file mode 100644 index 0000000..fb913a2 --- /dev/null +++ b/tools/libs/evtchn/minios.c @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Copyright 2007-2008 Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>. + * All rights reserved. + * Use is subject to license terms. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split off from xc_minios.c + */ + +#include "xen-external/bsd-sys-queue.h" +#include <mini-os/types.h> +#include <mini-os/os.h> +#include <mini-os/lib.h> +#include <mini-os/events.h> +#include <mini-os/wait.h> + +#include <sys/socket.h> + +#include <assert.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> +#include <malloc.h> + +#include "private.h" + +extern void minios_evtchn_close_fd(int fd); + +extern struct wait_queue_head event_queue; + +//void minios_evtchn_close_fd(int fd); + +/* XXX Note: This is not threadsafe */ +static struct evtchn_port_info* port_alloc(int fd) { +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂport_info = malloc(sizeof(struct evtchn_port_info)); +ÂÂÂÂif (port_info == NULL) +ÂÂÂÂÂÂÂÂreturn NULL; +ÂÂÂÂport_info->pending = 0; +ÂÂÂÂport_info->port = -1; +ÂÂÂÂport_info->bound = 0; + +ÂÂÂÂLIST_INSERT_HEAD(&files[fd].evtchn.ports, port_info, list); +ÂÂÂÂreturn port_info; +} + +static void port_dealloc(struct evtchn_port_info *port_info) { +ÂÂÂÂif (port_info->bound) +ÂÂÂÂÂÂÂÂunbind_evtchn(port_info->port); +ÂÂÂÂLIST_REMOVE(port_info, list); +ÂÂÂÂfree(port_info); +} + +int osdep_evtchn_open(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = alloc_fd(FTYPE_EVTCHN); +ÂÂÂÂif ( fd == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂLIST_INIT(&files[fd].evtchn.ports); +ÂÂÂÂxce->fd = fd; +ÂÂÂÂprintf("evtchn_open() -> %d\n", fd); +ÂÂÂÂreturn 0; +} + +int osdep_evtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂif ( xce->fd == -1 ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂreturn close(xce->fd); +} + +void minios_evtchn_close_fd(int fd) +{ +ÂÂÂÂstruct evtchn_port_info *port_info, *tmp; +ÂÂÂÂLIST_FOREACH_SAFE(port_info, &files[fd].evtchn.ports, list, tmp) +ÂÂÂÂÂÂÂÂport_dealloc(port_info); + +ÂÂÂÂfiles[fd].type = FTYPE_NONE; +} + +int xenevtchn_fd(xenevtchn_handle *xce) +{ +ÂÂÂÂreturn xce->fd; +} + +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint ret; + +ÂÂÂÂret = notify_remote_via_evtchn(port); + +ÂÂÂÂif (ret < 0) { + errno = -ret; + ret = -1; +ÂÂÂÂ} +ÂÂÂÂreturn ret; +} + +static void evtchn_handler(evtchn_port_t port, struct pt_regs *regs, void *data) +{ +ÂÂÂÂint fd = (int)(intptr_t)data; +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂassert(files[fd].type == FTYPE_EVTCHN); +ÂÂÂÂmask_evtchn(port); +ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { +ÂÂÂÂÂÂÂÂif (port_info->port == port) +ÂÂÂÂÂÂÂÂÂÂÂÂgoto found; +ÂÂÂÂ} +ÂÂÂÂprintk("Unknown port for handle %d\n", fd); +ÂÂÂÂreturn; + + found: +ÂÂÂÂport_info->pending = 1; +ÂÂÂÂfiles[fd].read = 1; +ÂÂÂÂwake_up(&event_queue); +} + +evtchn_port_or_error_t xenevtchn_bind_unbound_port(xenevtchn_handle *xce, int domid) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂint ret; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂassert(get_current() == main_thread); +ÂÂÂÂport_info = port_alloc(fd); +ÂÂÂÂif (port_info == NULL) + return -1; + +ÂÂÂÂprintf("xenevtchn_bind_unbound_port(%d)", domid); +ÂÂÂÂret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)fd, &port); +ÂÂÂÂprintf(" = %d\n", ret); + +ÂÂÂÂif (ret < 0) { + port_dealloc(port_info); + errno = -ret; + return -1; +ÂÂÂÂ} +ÂÂÂÂport_info->bound = 1; +ÂÂÂÂport_info->port = port; +ÂÂÂÂunmask_evtchn(port); +ÂÂÂÂreturn port; +} + +evtchn_port_or_error_t xenevtchn_bind_interdomain(xenevtchn_handle *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂevtchn_port_t local_port; +ÂÂÂÂint ret; + +ÂÂÂÂassert(get_current() == main_thread); +ÂÂÂÂport_info = port_alloc(fd); +ÂÂÂÂif (port_info == NULL) + return -1; + +ÂÂÂÂprintf("xenevtchn_bind_interdomain(%d, %"PRId32")", domid, remote_port); +ÂÂÂÂret = evtchn_bind_interdomain(domid, remote_port, evtchn_handler, (void*)(intptr_t)fd, &local_port); +ÂÂÂÂprintf(" = %d\n", ret); + +ÂÂÂÂif (ret < 0) { + port_dealloc(port_info); + errno = -ret; + return -1; +ÂÂÂÂ} +ÂÂÂÂport_info->bound = 1; +ÂÂÂÂport_info->port = local_port; +ÂÂÂÂunmask_evtchn(local_port); +ÂÂÂÂreturn local_port; +} + +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct evtchn_port_info *port_info; + +ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { +ÂÂÂÂÂÂÂÂif (port_info->port == port) { +ÂÂÂÂÂÂÂÂÂÂÂÂport_dealloc(port_info); +ÂÂÂÂÂÂÂÂÂÂÂÂreturn 0; +ÂÂÂÂÂÂÂÂ} +ÂÂÂÂ} +ÂÂÂÂprintf("Warning: couldn't find port %"PRId32" for xc handle %x\n", port, fd); +ÂÂÂÂerrno = EINVAL; +ÂÂÂÂreturn -1; +} + +evtchn_port_or_error_t xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂassert(get_current() == main_thread); +ÂÂÂÂport_info = port_alloc(fd); +ÂÂÂÂif (port_info == NULL) + return -1; + +ÂÂÂÂprintf("xenevtchn_bind_virq(%d)", virq); +ÂÂÂÂport = bind_virq(virq, evtchn_handler, (void*)(intptr_t)fd); + +ÂÂÂÂif (port < 0) { + port_dealloc(port_info); + errno = -port; + return -1; +ÂÂÂÂ} +ÂÂÂÂport_info->bound = 1; +ÂÂÂÂport_info->port = port; +ÂÂÂÂunmask_evtchn(port); +ÂÂÂÂreturn port; +} + +evtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct evtchn_port_info *port_info; +ÂÂÂÂunsigned long flags; +ÂÂÂÂevtchn_port_t ret = -1; + +ÂÂÂÂlocal_irq_save(flags); +ÂÂÂÂfiles[fd].read = 0; + +ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { +ÂÂÂÂÂÂÂÂif (port_info->port != -1 && port_info->pending) { +ÂÂÂÂÂÂÂÂÂÂÂÂif (ret == -1) { +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂret = port_info->port; +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂport_info->pending = 0; +ÂÂÂÂÂÂÂÂÂÂÂÂ} else { +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfiles[fd].read = 1; +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak; +ÂÂÂÂÂÂÂÂÂÂÂÂ} +ÂÂÂÂÂÂÂÂ} +ÂÂÂÂ} +ÂÂÂÂlocal_irq_restore(flags); +ÂÂÂÂreturn ret; +} + +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂunmask_evtchn(port); +ÂÂÂÂreturn 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/netbsd.c b/tools/libs/evtchn/netbsd.c new file mode 100644 index 0000000..c4123fe --- /dev/null +++ b/tools/libs/evtchn/netbsd.c @@ -0,0 +1,147 @@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc.ÂÂAll rights reserved. + * Use is subject to license terms. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split out from xc_netbsd.c + */ + +#include <fcntl.h> +#include <unistd.h> + +#include <sys/ioctl.h> + +#include <xen/sys/evtchn.h> + +#include "private.h" + +#define EVTCHN_DEV_NAMEÂÂ"/dev/xenevt" + +int osdep_evtchn_open(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); +ÂÂÂÂif ( fd == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂxce->fd = fd; +ÂÂÂÂreturn 0; +} + +int osdep_evtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂif ( xce->fd == -1 ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂreturn close(xce->fd); +} + +int xenevtchn_fd(xenevtchn_handle *xce) +{ +ÂÂÂÂreturn xce->fd; +} + +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_notify notify; + +ÂÂÂÂnotify.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +evtchn_port_or_error_t xenevtchn_bind_unbound_port(xenevtchn_handle * xce, int domid) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; +ÂÂÂÂint ret; + +ÂÂÂÂbind.remote_domain = domid; + +ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); +ÂÂÂÂif (ret == 0) + return bind.port; +ÂÂÂÂelse + return -1; +} + +evtchn_port_or_error_t xenevtchn_bind_interdomain(xenevtchn_handle *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; +ÂÂÂÂint ret; + +ÂÂÂÂbind.remote_domain = domid; +ÂÂÂÂbind.remote_port = remote_port; + +ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); +ÂÂÂÂif (ret == 0) + return bind.port; +ÂÂÂÂelse + return -1; +} + +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_unbind unbind; + +ÂÂÂÂunbind.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); +} + +evtchn_port_or_error_t xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; +ÂÂÂÂint err; + +ÂÂÂÂbind.virq = virq; + +ÂÂÂÂerr = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); +ÂÂÂÂif (err) + return -1; +ÂÂÂÂelse + return bind.port; +} + +evtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂif ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; + +ÂÂÂÂreturn port; +} + +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂreturn write_exact(fd, (char *)&port, sizeof(port)); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/private.h b/tools/libs/evtchn/private.h new file mode 100644 index 0000000..fcd0e96 --- /dev/null +++ b/tools/libs/evtchn/private.h @@ -0,0 +1,25 @@ +#ifndef XENEVTCHN_PRIVATE_H +#define XENEVTCHN_PRIVATE_H + +#include <xentoollog.h> +#include <xenevtchn.h> + +struct xenevtchn_handle { +ÂÂÂÂxentoollog_logger *logger, *logger_tofree; +ÂÂÂÂint fd; +}; + +int osdep_evtchn_open(xenevtchn_handle *xce); +int osdep_evtchn_close(xenevtchn_handle *xce); + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/evtchn/solaris.c b/tools/libs/evtchn/solaris.c new file mode 100644 index 0000000..114cefb --- /dev/null +++ b/tools/libs/evtchn/solaris.c @@ -0,0 +1,135 @@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc.ÂÂAll rights reserved. + * Use is subject to license terms. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + * + * Split out from xc_solaris.c + */ + +#include <fcntl.h> +#include <unistd.h> + +#include <sys/ioctl.h> + +#include <xen/sys/evtchn.h> + +#include "private.h" + +int osdep_evtchn_open(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd; + +ÂÂÂÂif ( (fd = open("/dev/xen/evtchn", O_RDWR)) == -1 ) +ÂÂÂÂ{ +ÂÂÂÂÂÂÂÂPERROR("Could not open event channel interface"); +ÂÂÂÂÂÂÂÂreturn -1; +ÂÂÂÂ} + +ÂÂÂÂxce->fd = fd; +ÂÂÂÂreturn 0; +} + +int osdep_evtchn_close(xenevtchn_handle *xce) +{ +ÂÂÂÂif ( xce->fd == -1 ) +ÂÂÂÂÂÂÂÂreturn 0; + +ÂÂÂÂreturn close(xce->fd); +} + +int xenevtchn_fd(xenevtchn_handle *xce) +{ +ÂÂÂÂreturn xce->fd; +} + +int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_notify notify; + +ÂÂÂÂnotify.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +evtchn_port_or_error_t xenevtchn_bind_unbound_port(xenevtchn_handle *xce, int domid) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; + +ÂÂÂÂbind.remote_domain = domid; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); +} + +evtchn_port_or_error_t xenevtchn_bind_interdomain(xenevtchn_handle *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; + +ÂÂÂÂbind.remote_domain = domid; +ÂÂÂÂbind.remote_port = remote_port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); +} + +evtchn_port_or_error_t xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; + +ÂÂÂÂbind.virq = virq; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); +} + +int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂstruct ioctl_evtchn_unbind unbind; + +ÂÂÂÂunbind.port = port; + +ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); +} + +evtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂevtchn_port_t port; + +ÂÂÂÂif ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) +ÂÂÂÂÂÂÂÂreturn -1; + +ÂÂÂÂreturn port; +} + +int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port) +{ +ÂÂÂÂint fd = xce->fd; +ÂÂÂÂreturn write_exact(fd, (char *)&port, sizeof(port)); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/toollog/include/xentoollog.h b/tools/libs/toollog/include/xentoollog.h index 853e9c7..76f17fe 100644 --- a/tools/libs/toollog/include/xentoollog.h +++ b/tools/libs/toollog/include/xentoollog.h @@ -134,3 +134,13 @@ const char *xtl_level_to_string(xentoollog_level); /* never fails */   Â#endif /* XENTOOLLOG_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/toollog/xtl_core.c b/tools/libs/toollog/xtl_core.c index c4724a0..099d2f3 100644 --- a/tools/libs/toollog/xtl_core.c +++ b/tools/libs/toollog/xtl_core.c @@ -81,3 +81,13 @@ void xtl_logger_destroy(struct xentoollog_logger *logger) { ÂÂÂÂÂif (!logger) return; ÂÂÂÂÂlogger->destroy(logger); Â} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/toollog/xtl_logger_stdio.c b/tools/libs/toollog/xtl_logger_stdio.c index 0cd9206..f9c5bd8 100644 --- a/tools/libs/toollog/xtl_logger_stdio.c +++ b/tools/libs/toollog/xtl_logger_stdio.c @@ -190,3 +190,13 @@ xentoollog_logger_stdiostream *xtl_createlogger_stdiostream  ÂÂÂÂÂreturn XTL_NEW_LOGGER(stdiostream, newlogger); Â} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile index 3c50fe6..84128a3 100644 --- a/tools/libvchan/Makefile +++ b/tools/libvchan/Makefile @@ -10,9 +10,9 @@ NODE_OBJS = node.o ÂNODE2_OBJS = node-select.o  ÂLIBVCHAN_PIC_OBJS = $(patsubst %.o,%.opic,$(LIBVCHAN_OBJS)) -LIBVCHAN_LIBS = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -$(LIBVCHAN_OBJS) $(LIBVCHAN_PIC_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) -$(NODE_OBJS) $(NODE2_OBJS): CFLAGS += $(CFLAGS_libxenctrl) +LIBVCHAN_LIBS = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) +$(LIBVCHAN_OBJS) $(LIBVCHAN_PIC_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) +$(NODE_OBJS) $(NODE2_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)  ÂMAJOR = 1.0 ÂMINOR = 0 diff --git a/tools/libvchan/init.c b/tools/libvchan/init.c index 77be4e7..66cb103 100644 --- a/tools/libvchan/init.c +++ b/tools/libvchan/init.c @@ -216,25 +216,25 @@ static int init_evt_srv(struct libxenvchan *ctrl, int domain, xentoollog_logger Â{  evtchn_port_or_error_t port;  - ctrl->event = xc_evtchn_open(logger, 0); + ctrl->event = xenevtchn_open(logger, 0);  if (!ctrl->event)  return -1;  - port = xc_evtchn_bind_unbound_port(ctrl->event, domain); + port = xenevtchn_bind_unbound_port(ctrl->event, domain);  if (port < 0)  goto fail;  ctrl->event_port = port;  - if (xc_evtchn_unmask(ctrl->event, ctrl->event_port)) + if (xenevtchn_unmask(ctrl->event, ctrl->event_port))  goto fail;   return 0;  Âfail:  if (port >= 0) - xc_evtchn_unbind(ctrl->event, port); + xenevtchn_unbind(ctrl->event, port);  - xc_evtchn_close(ctrl->event); + xenevtchn_close(ctrl->event);  ctrl->event = NULL;   return -1; @@ -346,26 +346,26 @@ static int init_evt_cli(struct libxenvchan *ctrl, int domain, xentoollog_logger Â{  evtchn_port_or_error_t port;  - ctrl->event = xc_evtchn_open(logger, 0); + ctrl->event = xenevtchn_open(logger, 0);  if (!ctrl->event)  return -1;  - port = xc_evtchn_bind_interdomain(ctrl->event, + port = xenevtchn_bind_interdomain(ctrl->event,  domain, ctrl->event_port);  if (port < 0)  goto fail;  ctrl->event_port = port;  - if (xc_evtchn_unmask(ctrl->event, ctrl->event_port)) + if (xenevtchn_unmask(ctrl->event, ctrl->event_port))  goto fail;   return 0;  Âfail:  if (port >= 0) - xc_evtchn_unbind(ctrl->event, port); + xenevtchn_unbind(ctrl->event, port);  - xc_evtchn_close(ctrl->event); + xenevtchn_close(ctrl->event);  ctrl->event = NULL;   return -1; diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c index 381cc05..53393a5 100644 --- a/tools/libvchan/io.c +++ b/tools/libvchan/io.c @@ -105,7 +105,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)  notify = ctrl->is_server ? &ctrl->ring->srv_notify : &ctrl->ring->cli_notify;  prev = __sync_fetch_and_and(notify, ~bit);  if (prev & bit) - return xc_evtchn_notify(ctrl->event, ctrl->event_port); + return xenevtchn_notify(ctrl->event, ctrl->event_port);  else  return 0; Â} @@ -196,10 +196,10 @@ int libxenvchan_buffer_space(struct libxenvchan *ctrl)  Âint libxenvchan_wait(struct libxenvchan *ctrl) Â{ - int ret = xc_evtchn_pending(ctrl->event); + int ret = xenevtchn_pending(ctrl->event);  if (ret < 0)  return -1; - xc_evtchn_unmask(ctrl->event, ret); + xenevtchn_unmask(ctrl->event, ret);  return 0; Â}  @@ -352,7 +352,7 @@ int libxenvchan_is_open(struct libxenvchan* ctrl)  Âint libxenvchan_fd_for_select(struct libxenvchan *ctrl) Â{ - return xc_evtchn_fd(ctrl->event); + return xenevtchn_fd(ctrl->event); Â}  Âvoid libxenvchan_close(struct libxenvchan *ctrl) @@ -374,8 +374,8 @@ void libxenvchan_close(struct libxenvchan *ctrl)  }  if (ctrl->event) {  if (ctrl->ring) - xc_evtchn_notify(ctrl->event, ctrl->event_port); - xc_evtchn_close(ctrl->event); + xenevtchn_notify(ctrl->event, ctrl->event_port); + xenevtchn_close(ctrl->event);  }  if (ctrl->is_server) {  if (ctrl->gntshr) diff --git a/tools/libvchan/libxenvchan.h b/tools/libvchan/libxenvchan.h index 0944a0e..1544378 100644 --- a/tools/libvchan/libxenvchan.h +++ b/tools/libvchan/libxenvchan.h @@ -44,6 +44,7 @@  Â#include <xen/io/libxenvchan.h> Â#include <xen/sys/evtchn.h> +#include <xenevtchn.h> Â#include <xenctrl.h>  Âstruct libxenvchan_ring { @@ -71,7 +72,7 @@ struct libxenvchan {  /* Pointer to shared ring page */  struct vchan_interface *ring;  /* event channel interface */ - xc_evtchn *event; + xenevtchn_handle *event;  uint32_t event_port;  /* informative flags: are we acting as server? */  int is_server:1; diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 940708f..b8fc6a5 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -48,6 +48,7 @@ CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c ÂCTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c ÂCTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd.c ÂCTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c +CTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_evtchn_compat.c  ÂGUEST_SRCS-y := ÂGUEST_SRCS-y += xg_private.c xc_suspend.c @@ -111,6 +112,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE  ÂCFLAGS += $(PTHREAD_CFLAGS) ÂCFLAGS += $(CFLAGS_libxentoollog) +CFLAGS += $(CFLAGS_libxenevtchn)  ÂCTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) ÂCTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y)) @@ -164,7 +166,7 @@ install: build  $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)  $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)  $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so - $(INSTALL_DATA) include/xenctrl.h include/xenctrlosdep.h $(DESTDIR)$(includedir) + $(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h include/xenctrlosdep.h $(DESTDIR)$(includedir)  $(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)  $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)  $(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR) @@ -207,7 +209,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)  $(SYMLINK_SHLIB) $< $@  Âlibxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(DLOPEN_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(DLOPEN_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)  Â# libxenguest  @@ -230,7 +232,7 @@ xc_dom_bzimageloader.opic: CFLAGS += $(call zlib-options,D)  Âlibxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(call zlib-options,l) Âlibxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so - $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)  Âxenctrl_osdep_ENOSYS.so: $(OSDEP_PIC_OBJS) libxenctrl.so  $(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $(OSDEP_PIC_OBJS) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1bf70f9..53f3033 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -117,7 +117,6 @@  */  Âtypedef struct xc_interface_core xc_interface; -typedef struct xenevtchn_handle xc_evtchn; Âtypedef struct xc_interface_core xc_gnttab; Âtypedef struct xc_interface_core xc_gntshr;  @@ -1085,7 +1084,6 @@ int xc_cpupool_movedomain(xc_interface *xch,  */ Âxc_cpumap_t xc_cpupool_freeinfo(xc_interface *xch);  - Â/*  * EVENT CHANNEL FUNCTIONS  * @@ -1120,101 +1118,7 @@ int xc_evtchn_reset(xc_interface *xch, Âtypedef struct evtchn_status xc_evtchn_status_t; Âint xc_evtchn_status(xc_interface *xch, xc_evtchn_status_t *status);  -/* - * Return a handle to the event channel driver, or NULL on failure, in - * which case errno will be set appropriately. - * - * Note: - * After fork a child process must not use any opened xc evtchn - * handle inherited from their parent. They must open a new handle if - * they want to interact with xc. - * - * Before Xen pre-4.1 this function would sometimes report errors with perror. - */ -xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned open_flags);  -/* - * Close a handle previously allocated with xc_evtchn_open(). - */ -int xc_evtchn_close(xc_evtchn *xce); - -/* - * Return an fd that can be select()ed on. - * - * Note that due to bugs, setting this fd to non blocking may not - * work: you would hope that it would result in xc_evtchn_pending - * failing with EWOULDBLOCK if there are no events signaled, but in - * fact it may block.ÂÂ(Bug is present in at least Linux 3.12, and - * perhaps on other platforms or later version.) - * - * To be safe, you must use poll() or select() before each call to - * xc_evtchn_pending.ÂÂIf you have multiple threads (or processes) - * sharing a single xce handle this will not work, and there is no - * straightforward workaround.ÂÂPlease design your program some other - * way. - */ -int xc_evtchn_fd(xc_evtchn *xce); - -/* - * Notify the given event channel. Returns -1 on failure, in which case - * errno will be set appropriately. - */ -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port); - -/* - * Returns a new event port awaiting interdomain connection from the given - * domain ID, or -1 on failure, in which case errno will be set appropriately. - */ -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid); - -/* - * Returns a new event port bound to the remote port for the given domain ID, - * or -1 on failure, in which case errno will be set appropriately. - */ -evtchn_port_or_error_t -xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port); - -/* - * Bind an event channel to the given VIRQ. Returns the event channel bound to - * the VIRQ, or -1 on failure, in which case errno will be set appropriately. - */ -evtchn_port_or_error_t -xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq); - -/* - * Unbind the given event channel. Returns -1 on failure, in which case errno - * will be set appropriately. - */ -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port); - -/* - * Return the next event channel to become pending, or -1 on failure, in which - * case errno will be set appropriately. - * - * At the hypervisor level the event channel will have been masked, - * and then cleared, by the underlying machinery (evtchn kernel - * driver, or equivalent).ÂÂSo if the event channel is signaled again - * after it is returned here, it will be queued up, and delivered - * again after you unmask it.ÂÂ(See the documentation in the Xen - * public header event_channel.h.) - * - * On receiving the notification from xc_evtchn_pending, you should - * normally: check (by other means) what work needs doing; do the - * necessary work (if any); unmask the event channel with - * xc_evtchn_unmask (if you want to receive any further - * notifications). - */ -evtchn_port_or_error_t -xc_evtchn_pending(xc_evtchn *xce); - -/* - * Unmask the given event channel. Returns -1 on failure, in which case errno - * will be set appropriately. - */ -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port);  Âint xc_physdev_pci_access_modify(xc_interface *xch, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂuint32_t domid, @@ -2851,6 +2755,9 @@ int xc_psr_cat_get_l3_info(xc_interface *xch, uint32_t socket, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbool *cdp_enabled); Â#endif  +/* Compat shims */ +#include "xenctrl_compat.h" + Â#endif /* XENCTRL_H */  Â/* diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h new file mode 100644 index 0000000..48daeb2 --- /dev/null +++ b/tools/libxc/include/xenctrl_compat.h @@ -0,0 +1,48 @@ +/* + * Compat shims for use of 3rd party consumers of libxenctrl + * functionality which has been split into separate libraries. + * + * New code should use the separate libraries. + * + * Each interface must be opted-into separately by defining: + * + * XC_WANT_COMPAT_EVTCHN_API + *ÂÂ- Functions relating to /dev/xen/evtchn + */ +#ifndef XENCTRL_COMPAT_H +#define XENCTRL_COMPAT_H + +#ifdef XC_WANT_COMPAT_EVTCHN_API + +typedef struct xenevtchn_handle xc_evtchn; + +xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned open_flags); +int xc_evtchn_close(xc_evtchn *xce); +int xc_evtchn_fd(xc_evtchn *xce); +int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port); +evtchn_port_or_error_t +xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid); +evtchn_port_or_error_t +xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port); +evtchn_port_or_error_t +xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq); +int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port); +evtchn_port_or_error_t +xc_evtchn_pending(xc_evtchn *xce); +int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port); + +#endif /* XC_WANT_COMPAT_EVTCHN_API */ + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index 8f918b1..050a537 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -34,6 +34,12 @@ Â#define X86_64_B_SIZEÂÂÂ64 Â#define X86_32_B_SIZEÂÂÂ32  +/* + * User not using xc_suspend_* / xc_await_suspent may not want to + * include the full libxenevtchn API here. + */ +typedef struct xenevtchn_handle xenevtchn_handle; + Â/* callbacks provided by xc_domain_save */ Âstruct save_callbacks { ÂÂÂÂÂ/* Called after expiration of checkpoint interval, @@ -161,18 +167,18 @@ struct xc_hvm_firmware_module {  * Sets *lockfd to -1.  * Has deallocated everything even on error.  */ -int xc_suspend_evtchn_release(xc_interface *xch, xc_evtchn *xce, int domid, int suspend_evtchn, int *lockfd); +int xc_suspend_evtchn_release(xc_interface *xch, xenevtchn_handle *xce, int domid, int suspend_evtchn, int *lockfd);  Â/**  * This function eats the initial notification.  * xce must not be used for anything else  * See xc_suspend_evtchn_init_sane re lockfd.  */ -int xc_suspend_evtchn_init_exclusive(xc_interface *xch, xc_evtchn *xce, +int xc_suspend_evtchn_init_exclusive(xc_interface *xch, xenevtchn_handle *xce, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, int port, int *lockfd);  Â/* xce must not be used for anything else */ -int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn); +int xc_await_suspend(xc_interface *xch, xenevtchn_handle *xce, int suspend_evtchn);  Â/**  * The port will be signaled immediately after this call @@ -181,7 +187,7 @@ int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn);  * and fed to xc_suspend_evtchn_release.ÂÂ(On error *lockfd is  * undefined and xc_suspend_evtchn_release is not allowed.)  */ -int xc_suspend_evtchn_init_sane(xc_interface *xch, xc_evtchn *xce, +int xc_suspend_evtchn_init_sane(xc_interface *xch, xenevtchn_handle *xce, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, int port, int *lockfd);  Âint xc_mark_page_online(xc_interface *xch, unsigned long start, diff --git a/tools/libxc/xc_evtchn_compat.c b/tools/libxc/xc_evtchn_compat.c new file mode 100644 index 0000000..5d3e4ba --- /dev/null +++ b/tools/libxc/xc_evtchn_compat.c @@ -0,0 +1,75 @@ +/* + * Compat shims for use of 3rd party consumers of libxenctrl xc_evtchn + * functionality which has been split into separate libraries. + */ + +#include <xenevtchn.h> + +#define XC_WANT_COMPAT_EVTCHN_API +#include "xenctrl.h" + +xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned open_flags) +{ +ÂÂÂÂreturn xenevtchn_open(logger, open_flags); +} + +int xc_evtchn_close(xc_evtchn *xce) +{ +ÂÂÂÂreturn xenevtchn_close(xce); +} + +int xc_evtchn_fd(xc_evtchn *xce) +{ +ÂÂÂÂreturn xenevtchn_fd(xce); +} + +int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) +{ +ÂÂÂÂreturn xenevtchn_notify(xce, port); +} + +evtchn_port_or_error_t +xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) +{ +ÂÂÂÂreturn xenevtchn_bind_unbound_port(xce, domid); +} + +evtchn_port_or_error_t +xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) +{ +ÂÂÂÂreturn xenevtchn_bind_interdomain(xce, domid, remote_port); +} + +evtchn_port_or_error_t +xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) +{ +ÂÂÂÂreturn xenevtchn_bind_virq(xce, virq); +} + +int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) +{ +ÂÂÂÂreturn xenevtchn_unbind(xce, port); +} + +evtchn_port_or_error_t +xc_evtchn_pending(xc_evtchn *xce) +{ +ÂÂÂÂreturn xenevtchn_pending(xce); +} + +int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) +{ +ÂÂÂÂreturn xenevtchn_unmask(xce, port); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxc/xc_freebsd_osdep.c b/tools/libxc/xc_freebsd_osdep.c index 4323e16..339997c 100644 --- a/tools/libxc/xc_freebsd_osdep.c +++ b/tools/libxc/xc_freebsd_osdep.c @@ -31,13 +31,11 @@ Â#include <sys/ioctl.h>  Â#include <xen/memory.h> -#include <xen/sys/evtchn.h>  Â#include "xenctrl.h" Â#include "xenctrlosdep.h"  Â#define PRIVCMD_DEVÂÂÂÂÂ"/dev/xen/privcmd" -#define EVTCHN_DEVÂÂÂÂÂÂ"/dev/xen/evtchn"  Â#define PERROR(_m, _a...) xc_osdep_log(xch,XTL_ERROR,XC_INTERNAL_ERROR,_m \ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ" (%d = %s)", ## _a , errno, xc_strerror(xch, errno)) @@ -251,105 +249,6 @@ static struct xc_osdep_ops freebsd_privcmd_ops = { ÂÂÂÂÂ}, Â};  -/*-------------------------- Evtchn device interface -------------------------*/ -int osdep_evtchn_open(xc_evtchn *xce) -{ -ÂÂÂÂint fd = open(EVTCHN_DEV, O_RDWR); -ÂÂÂÂif ( fd == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂxce->fd = fd; -ÂÂÂÂreturn 0; -} - -int osdep_evtchn_close(xc_evtchn *xce) -{ -ÂÂÂÂif ( xce->fd == -1 ) -ÂÂÂÂÂÂÂÂreturn 0; - -ÂÂÂÂreturn close(xce->fd); -} - -int xc_evtchn_fd(xc_evtchn *xce) -{ -ÂÂÂÂreturn xce->fd; -} - -/*------------------------------ Evtchn interface ----------------------------*/ -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_notify notify; - -ÂÂÂÂnotify.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); -} - -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) -{ -ÂÂÂÂint ret, fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; - -ÂÂÂÂbind.remote_domain = domid; - -ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); -ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; -} - -evtchn_port_or_error_t -xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, evtchn_port_t remote_port) -{ -ÂÂÂÂint ret, fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; - -ÂÂÂÂbind.remote_domain = domid; -ÂÂÂÂbind.remote_port = remote_port; - -ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); -ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; -} - -evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) -{ -ÂÂÂÂint ret, fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; - -ÂÂÂÂbind.virq = virq; - -ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); -ÂÂÂÂreturn ( ret == 0 ) ? bind.port : ret; -} - -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_unbind unbind; - -ÂÂÂÂunbind.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); -} - -evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂif ( read(fd, &port, sizeof(port)) != sizeof(port) ) -ÂÂÂÂÂÂÂÂreturn -1; - -ÂÂÂÂreturn port; -} - -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; - -ÂÂÂÂif ( write(fd, &port, sizeof(port)) != sizeof(port) ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂreturn 0; -} - Â/*---------------------------- FreeBSD interface -----------------------------*/ Âstatic struct xc_osdep_ops * Âfreebsd_osdep_init(xc_interface *xch, enum xc_osdep_type type) diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c index 90544fb..65299d0 100644 --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -31,7 +31,6 @@ Â#include <sys/ioctl.h>  Â#include <xen/memory.h> -#include <xen/sys/evtchn.h> Â#include <xen/sys/gntdev.h> Â#include <xen/sys/gntalloc.h>  @@ -461,100 +460,6 @@ static struct xc_osdep_ops linux_privcmd_ops = {  Â#define DEVXEN "/dev/xen/"  -int osdep_evtchn_open(xc_evtchn *xce) -{ -ÂÂÂÂint fd = open(DEVXEN "evtchn", O_RDWR); -ÂÂÂÂif ( fd == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂxce->fd = fd; -ÂÂÂÂreturn 0; -} - -int osdep_evtchn_close(xc_evtchn *xce) -{ -ÂÂÂÂif ( xce->fd == -1 ) -ÂÂÂÂÂÂÂÂreturn 0; - -ÂÂÂÂreturn close(xce->fd); -} - -int xc_evtchn_fd(xc_evtchn *xce) -{ -ÂÂÂÂreturn xce->fd; -} - -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_notify notify; - -ÂÂÂÂnotify.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); -} - -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; - -ÂÂÂÂbind.remote_domain = domid; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); -} - -evtchn_port_or_error_t xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; - -ÂÂÂÂbind.remote_domain = domid; -ÂÂÂÂbind.remote_port = remote_port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); -} - -evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; - -ÂÂÂÂbind.virq = virq; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); -} - -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_unbind unbind; - -ÂÂÂÂunbind.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); -} - -evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂif ( read(fd, &port, sizeof(port)) != sizeof(port) ) -ÂÂÂÂÂÂÂÂreturn -1; - -ÂÂÂÂreturn port; -} - -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; - -ÂÂÂÂif ( write(fd, &port, sizeof(port)) != sizeof(port) ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂreturn 0; -} - Âstatic xc_osdep_handle linux_gnttab_open(xc_gnttab *xcg) Â{ ÂÂÂÂÂint fd = open(DEVXEN "gntdev", O_RDWR); diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index 4ace1b5..db7b344 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -19,14 +19,11 @@  */  Â#undef NDEBUG -#include "xen-external/bsd-sys-queue.h" Â#include <mini-os/types.h> Â#include <mini-os/os.h> Â#include <mini-os/mm.h> Â#include <mini-os/lib.h> Â#include <mini-os/gntmap.h> -#include <mini-os/events.h> -#include <mini-os/wait.h> Â#include <sys/mman.h>  Â#include <xen/memory.h> @@ -41,13 +38,9 @@ Â#include "xc_private.h"  Âvoid minios_interface_close_fd(int fd); -void minios_evtchn_close_fd(int fd); Âvoid minios_gnttab_close_fd(int fd);  Âextern void minios_interface_close_fd(int fd); -extern void minios_evtchn_close_fd(int fd); - -extern struct wait_queue_head event_queue;  Âstatic xc_osdep_handle minios_privcmd_open(xc_interface *xch) Â{ @@ -197,220 +190,6 @@ static struct xc_osdep_ops minios_privcmd_ops = { ÂÂÂÂÂ}, Â};  - -/* XXX Note: This is not threadsafe */ -static struct evtchn_port_info* port_alloc(int fd) { -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂport_info = malloc(sizeof(struct evtchn_port_info)); -ÂÂÂÂif (port_info == NULL) -ÂÂÂÂÂÂÂÂreturn NULL; -ÂÂÂÂport_info->pending = 0; -ÂÂÂÂport_info->port = -1; -ÂÂÂÂport_info->bound = 0; - -ÂÂÂÂLIST_INSERT_HEAD(&files[fd].evtchn.ports, port_info, list); -ÂÂÂÂreturn port_info; -} - -static void port_dealloc(struct evtchn_port_info *port_info) { -ÂÂÂÂif (port_info->bound) -ÂÂÂÂÂÂÂÂunbind_evtchn(port_info->port); -ÂÂÂÂLIST_REMOVE(port_info, list); -ÂÂÂÂfree(port_info); -} - -int osdep_evtchn_open(xc_evtchn *xce) -{ -ÂÂÂÂint fd = alloc_fd(FTYPE_EVTCHN); -ÂÂÂÂif ( fd == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂLIST_INIT(&files[fd].evtchn.ports); -ÂÂÂÂxce->fd = fd; -ÂÂÂÂprintf("evtchn_open() -> %d\n", fd); -ÂÂÂÂreturn 0; -} - -int osdep_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) -{ -ÂÂÂÂif ( xce->fd == -1 ) -ÂÂÂÂÂÂÂÂreturn 0; - -ÂÂÂÂreturn close(xce->fd); -} - -void minios_evtchn_close_fd(int fd) -{ -ÂÂÂÂstruct evtchn_port_info *port_info, *tmp; -ÂÂÂÂLIST_FOREACH_SAFE(port_info, &files[fd].evtchn.ports, list, tmp) -ÂÂÂÂÂÂÂÂport_dealloc(port_info); - -ÂÂÂÂfiles[fd].type = FTYPE_NONE; -} - -int xc_evtchn_fd(xc_evtchn *xce) -{ -ÂÂÂÂreturn xce->fd; -} - -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint ret; - -ÂÂÂÂret = notify_remote_via_evtchn(port); - -ÂÂÂÂif (ret < 0) { - errno = -ret; - ret = -1; -ÂÂÂÂ} -ÂÂÂÂreturn ret; -} - -static void evtchn_handler(evtchn_port_t port, struct pt_regs *regs, void *data) -{ -ÂÂÂÂint fd = (int)(intptr_t)data; -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂassert(files[fd].type == FTYPE_EVTCHN); -ÂÂÂÂmask_evtchn(port); -ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { -ÂÂÂÂÂÂÂÂif (port_info->port == port) -ÂÂÂÂÂÂÂÂÂÂÂÂgoto found; -ÂÂÂÂ} -ÂÂÂÂprintk("Unknown port for handle %d\n", fd); -ÂÂÂÂreturn; - - found: -ÂÂÂÂport_info->pending = 1; -ÂÂÂÂfiles[fd].read = 1; -ÂÂÂÂwake_up(&event_queue); -} - -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂint ret; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂassert(get_current() == main_thread); -ÂÂÂÂport_info = port_alloc(fd); -ÂÂÂÂif (port_info == NULL) - return -1; - -ÂÂÂÂprintf("xc_evtchn_bind_unbound_port(%d)", domid); -ÂÂÂÂret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)fd, &port); -ÂÂÂÂprintf(" = %d\n", ret); - -ÂÂÂÂif (ret < 0) { - port_dealloc(port_info); - errno = -ret; - return -1; -ÂÂÂÂ} -ÂÂÂÂport_info->bound = 1; -ÂÂÂÂport_info->port = port; -ÂÂÂÂunmask_evtchn(port); -ÂÂÂÂreturn port; -} - -evtchn_port_or_error_t xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂevtchn_port_t local_port; -ÂÂÂÂint ret; - -ÂÂÂÂassert(get_current() == main_thread); -ÂÂÂÂport_info = port_alloc(fd); -ÂÂÂÂif (port_info == NULL) - return -1; - -ÂÂÂÂprintf("xc_evtchn_bind_interdomain(%d, %"PRId32")", domid, remote_port); -ÂÂÂÂret = evtchn_bind_interdomain(domid, remote_port, evtchn_handler, (void*)(intptr_t)fd, &local_port); -ÂÂÂÂprintf(" = %d\n", ret); - -ÂÂÂÂif (ret < 0) { - port_dealloc(port_info); - errno = -ret; - return -1; -ÂÂÂÂ} -ÂÂÂÂport_info->bound = 1; -ÂÂÂÂport_info->port = local_port; -ÂÂÂÂunmask_evtchn(local_port); -ÂÂÂÂreturn local_port; -} - -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct evtchn_port_info *port_info; - -ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { -ÂÂÂÂÂÂÂÂif (port_info->port == port) { -ÂÂÂÂÂÂÂÂÂÂÂÂport_dealloc(port_info); -ÂÂÂÂÂÂÂÂÂÂÂÂreturn 0; -ÂÂÂÂÂÂÂÂ} -ÂÂÂÂ} -ÂÂÂÂprintf("Warning: couldn't find port %"PRId32" for xc handle %x\n", port, fd); -ÂÂÂÂerrno = EINVAL; -ÂÂÂÂreturn -1; -} - -evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂassert(get_current() == main_thread); -ÂÂÂÂport_info = port_alloc(fd); -ÂÂÂÂif (port_info == NULL) - return -1; - -ÂÂÂÂprintf("xc_evtchn_bind_virq(%d)", virq); -ÂÂÂÂport = bind_virq(virq, evtchn_handler, (void*)(intptr_t)fd); - -ÂÂÂÂif (port < 0) { - port_dealloc(port_info); - errno = -port; - return -1; -ÂÂÂÂ} -ÂÂÂÂport_info->bound = 1; -ÂÂÂÂport_info->port = port; -ÂÂÂÂunmask_evtchn(port); -ÂÂÂÂreturn port; -} - -evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct evtchn_port_info *port_info; -ÂÂÂÂunsigned long flags; -ÂÂÂÂevtchn_port_t ret = -1; - -ÂÂÂÂlocal_irq_save(flags); -ÂÂÂÂfiles[fd].read = 0; - -ÂÂÂÂLIST_FOREACH(port_info, &files[fd].evtchn.ports, list) { -ÂÂÂÂÂÂÂÂif (port_info->port != -1 && port_info->pending) { -ÂÂÂÂÂÂÂÂÂÂÂÂif (ret == -1) { -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂret = port_info->port; -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂport_info->pending = 0; -ÂÂÂÂÂÂÂÂÂÂÂÂ} else { -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfiles[fd].read = 1; -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak; -ÂÂÂÂÂÂÂÂÂÂÂÂ} -ÂÂÂÂÂÂÂÂ} -ÂÂÂÂ} -ÂÂÂÂlocal_irq_restore(flags); -ÂÂÂÂreturn ret; -} - -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂunmask_evtchn(port); -ÂÂÂÂreturn 0; -} - Â/* Optionally flush file to disk and discard page cache */ Âvoid discard_file_cache(xc_interface *xch, int fd, int flush) Â{ diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c index b1b828f..fe4f0a1 100644 --- a/tools/libxc/xc_netbsd.c +++ b/tools/libxc/xc_netbsd.c @@ -19,7 +19,6 @@  Â#include "xc_private.h"  -#include <xen/sys/evtchn.h> Â#include <unistd.h> Â#include <fcntl.h> Â#include <malloc.h> @@ -223,114 +222,6 @@ static struct xc_osdep_ops netbsd_privcmd_ops = { ÂÂÂÂÂ}, Â};  -#define EVTCHN_DEV_NAMEÂÂ"/dev/xenevt" - -int osdep_evtchn_open(xc_evtchn *xce) -{ -ÂÂÂÂint fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); -ÂÂÂÂif ( fd == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂxce->fd = fd; -ÂÂÂÂreturn 0; -} - -int osdep_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) -{ -ÂÂÂÂif ( xce->fd == -1 ) -ÂÂÂÂÂÂÂÂreturn 0; - -ÂÂÂÂreturn close(xce->fd); -} - -int xc_evtchn_fd(xc_evtchn *xce) -{ -ÂÂÂÂreturn xce->fd; -} - -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_notify notify; - -ÂÂÂÂnotify.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); -} - -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn * xce, int domid) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; -ÂÂÂÂint ret; - -ÂÂÂÂbind.remote_domain = domid; - -ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); -ÂÂÂÂif (ret == 0) - return bind.port; -ÂÂÂÂelse - return -1; -} - -evtchn_port_or_error_t xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; -ÂÂÂÂint ret; - -ÂÂÂÂbind.remote_domain = domid; -ÂÂÂÂbind.remote_port = remote_port; - -ÂÂÂÂret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); -ÂÂÂÂif (ret == 0) - return bind.port; -ÂÂÂÂelse - return -1; -} - -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_unbind unbind; - -ÂÂÂÂunbind.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); -} - -evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; -ÂÂÂÂint err; - -ÂÂÂÂbind.virq = virq; - -ÂÂÂÂerr = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); -ÂÂÂÂif (err) - return -1; -ÂÂÂÂelse - return bind.port; -} - -evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂif ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; - -ÂÂÂÂreturn port; -} - -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂreturn write_exact(fd, (char *)&port, sizeof(port)); -} - Â/* Optionally flush file to disk and discard page cache */ Âvoid discard_file_cache(xc_interface *xch, int fd, int flush) Â{ diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index cb79f22..56d54b6 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -251,46 +251,6 @@ int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) ÂÂÂÂÂreturn xch->ops->u.privcmd.hypercall(xch, xch->ops_handle, hypercall); Â}  -xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, unsigned open_flags) -{ -ÂÂÂÂxc_evtchn *xce = malloc(sizeof(*xce)); -ÂÂÂÂint rc; - -ÂÂÂÂif (!xce) return NULL; - -ÂÂÂÂxce->fd = -1; -ÂÂÂÂxce->logger = logger; -ÂÂÂÂxce->logger_tofreeÂÂ= NULL; - -ÂÂÂÂif (!xce->logger) { -ÂÂÂÂÂÂÂÂxce->logger = xce->logger_tofree = -ÂÂÂÂÂÂÂÂÂÂÂÂ(xentoollog_logger*) -ÂÂÂÂÂÂÂÂÂÂÂÂxtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0); -ÂÂÂÂÂÂÂÂif (!xce->logger) goto err; -ÂÂÂÂ} - -ÂÂÂÂrc = osdep_evtchn_open(xce); -ÂÂÂÂif ( rcÂÂ< 0 ) goto err; - -ÂÂÂÂreturn xce; - -err: -ÂÂÂÂosdep_evtchn_close(xce); -ÂÂÂÂxtl_logger_destroy(xce->logger_tofree); -ÂÂÂÂfree(xce); -ÂÂÂÂreturn NULL; -} - -int xc_evtchn_close(xc_evtchn *xce) -{ -ÂÂÂÂint rc; - -ÂÂÂÂrc = osdep_evtchn_close(xce); -ÂÂÂÂxtl_logger_destroy(xce->logger_tofree); -ÂÂÂÂfree(xce); -ÂÂÂÂreturn rc; -} - Âxc_gnttab *xc_gnttab_open(xentoollog_logger *logger, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned open_flags) Â{ diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index f4d155a..a32accb 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -123,13 +123,6 @@ struct xc_interface_core { ÂÂÂÂÂxc_osdep_handleÂÂops_handle; /* opaque data for xc_osdep_ops */ Â};  -struct xenevtchn_handle { -ÂÂÂÂxentoollog_logger *logger, *logger_tofree; -ÂÂÂÂint fd; -}; -int osdep_evtchn_open(xc_evtchn *xce); -int osdep_evtchn_close(xc_evtchn *xce); - Âvoid xc_report_error(xc_interface *xch, int code, const char *fmt, ...) ÂÂÂÂÂ__attribute__((format(printf,3,4))); Âvoid xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c index 088228a..ed7987c 100644 --- a/tools/libxc/xc_solaris.c +++ b/tools/libxc/xc_solaris.c @@ -20,7 +20,6 @@ Â#include "xc_private.h"  Â#include <xen/memory.h> -#include <xen/sys/evtchn.h> Â#include <unistd.h> Â#include <fcntl.h> Â#include <malloc.h> @@ -194,102 +193,6 @@ static struct xc_osdep_ops solaris_privcmd_ops = { ÂÂÂÂÂ}, Â};  -int osdep_evtchn_open(xc_evtchn *xce) -{ -ÂÂÂÂint fd; - -ÂÂÂÂif ( (fd = open("/dev/xen/evtchn", O_RDWR)) == -1 ) -ÂÂÂÂ{ -ÂÂÂÂÂÂÂÂPERROR("Could not open event channel interface"); -ÂÂÂÂÂÂÂÂreturn -1; -ÂÂÂÂ} - -ÂÂÂÂxce->fd = fd; -ÂÂÂÂreturn 0; -} - -int osdep_evtchn_close(xc_evtchn *xce) -{ -ÂÂÂÂif ( xce->fd == -1 ) -ÂÂÂÂÂÂÂÂreturn 0; - -ÂÂÂÂreturn close(xce->fd); -} - -int xc_evtchn_fd(xc_evtchn *xce) -{ -ÂÂÂÂreturn xce->fd; -} - -int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_notify notify; - -ÂÂÂÂnotify.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); -} - -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_unbound_port bind; - -ÂÂÂÂbind.remote_domain = domid; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); -} - -evtchn_port_or_error_t xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂevtchn_port_t remote_port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_interdomain bind; - -ÂÂÂÂbind.remote_domain = domid; -ÂÂÂÂbind.remote_port = remote_port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); -} - -evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_bind_virq bind; - -ÂÂÂÂbind.virq = virq; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); -} - -int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂstruct ioctl_evtchn_unbind unbind; - -ÂÂÂÂunbind.port = port; - -ÂÂÂÂreturn ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); -} - -evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂevtchn_port_t port; - -ÂÂÂÂif ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) -ÂÂÂÂÂÂÂÂreturn -1; - -ÂÂÂÂreturn port; -} - -int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port) -{ -ÂÂÂÂint fd = xce->fd; -ÂÂÂÂreturn write_exact(fd, (char *)&port, sizeof(port)); -} - Â/* Optionally flush file to disk and discard page cache */ Âvoid discard_file_cache(xc_interface *xch, int fd, int flush) Â{ diff --git a/tools/libxc/xc_suspend.c b/tools/libxc/xc_suspend.c index bba36e7..8361c7b 100644 --- a/tools/libxc/xc_suspend.c +++ b/tools/libxc/xc_suspend.c @@ -16,6 +16,8 @@ Â#include <unistd.h> Â#include <fcntl.h>  +#include <xenevtchn.h> + Â#include "xc_private.h" Â#include "xenguest.h"  @@ -124,12 +126,12 @@ static int unlock_suspend_event(xc_interface *xch, int domid, int *lockfd) ÂÂÂÂÂreturn -1; Â}  -int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn) +int xc_await_suspend(xc_interface *xch, xenevtchn_handle *xce, int suspend_evtchn) Â{ ÂÂÂÂÂint rc;  ÂÂÂÂÂdo { -ÂÂÂÂÂÂÂÂrc = xc_evtchn_pending(xce); +ÂÂÂÂÂÂÂÂrc = xenevtchn_pending(xce); ÂÂÂÂÂÂÂÂÂif (rc < 0) { ÂÂÂÂÂÂÂÂÂÂÂÂÂERROR("error polling suspend notification channel: %d", rc); ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -1; @@ -137,7 +139,7 @@ int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn) ÂÂÂÂÂ} while (rc != suspend_evtchn);  ÂÂÂÂÂ/* harmless for one-off suspend */ -ÂÂÂÂif (xc_evtchn_unmask(xce, suspend_evtchn) < 0) +ÂÂÂÂif (xenevtchn_unmask(xce, suspend_evtchn) < 0) ÂÂÂÂÂÂÂÂÂERROR("failed to unmask suspend notification channel: %d", rc);  ÂÂÂÂÂreturn 0; @@ -145,16 +147,16 @@ int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn)  Â/* Internal callers are allowed to call this with suspend_evtchn<0  * but *lockfd>0. */ -int xc_suspend_evtchn_release(xc_interface *xch, xc_evtchn *xce, +int xc_suspend_evtchn_release(xc_interface *xch, xenevtchn_handle *xce, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, int suspend_evtchn, int *lockfd) Â{ ÂÂÂÂÂif (suspend_evtchn >= 0) -ÂÂÂÂÂÂÂÂxc_evtchn_unbind(xce, suspend_evtchn); +ÂÂÂÂÂÂÂÂxenevtchn_unbind(xce, suspend_evtchn);  ÂÂÂÂÂreturn unlock_suspend_event(xch, domid, lockfd); Â}  -int xc_suspend_evtchn_init_sane(xc_interface *xch, xc_evtchn *xce, +int xc_suspend_evtchn_init_sane(xc_interface *xch, xenevtchn_handle *xce, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, int port, int *lockfd) Â{ ÂÂÂÂÂint rc, suspend_evtchn = -1; @@ -164,7 +166,7 @@ int xc_suspend_evtchn_init_sane(xc_interface *xch, xc_evtchn *xce, ÂÂÂÂÂÂÂÂÂgoto cleanup; ÂÂÂÂÂ}  -ÂÂÂÂsuspend_evtchn = xc_evtchn_bind_interdomain(xce, domid, port); +ÂÂÂÂsuspend_evtchn = xenevtchn_bind_interdomain(xce, domid, port); ÂÂÂÂÂif (suspend_evtchn < 0) { ÂÂÂÂÂÂÂÂÂERROR("failed to bind suspend event channel: %d", suspend_evtchn); ÂÂÂÂÂÂÂÂÂgoto cleanup; @@ -184,7 +186,7 @@ cleanup: ÂÂÂÂÂreturn -1; Â}  -int xc_suspend_evtchn_init_exclusive(xc_interface *xch, xc_evtchn *xce, +int xc_suspend_evtchn_init_exclusive(xc_interface *xch, xenevtchn_handle *xce, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint domid, int port, int *lockfd) Â{ ÂÂÂÂÂint suspend_evtchn; diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index b0cb9e4..620720e 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -20,12 +20,13 @@ LIBUUID_LIBS += -luuid Âendif  ÂLIBXL_LIBS = -LIBXL_LIBS = $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) +LIBXL_LIBS = $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) Âifeq ($(CONFIG_REMUS_NETBUF),y) ÂLIBXL_LIBS += $(LIBNL3_LIBS) Âendif  ÂCFLAGS_LIBXL += $(CFLAGS_libxentoollog) +CFLAGS_LIBXL += $(CFLAGS_libxenevtchn) ÂCFLAGS_LIBXL += $(CFLAGS_libxenctrl) ÂCFLAGS_LIBXL += $(CFLAGS_libxenguest) ÂCFLAGS_LIBXL += $(CFLAGS_libxenstore) @@ -155,7 +156,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL) Â$(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.  ÂSAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o -$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) +$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)  ÂPKG_CONFIG = xenlight.pc xlutil.pc  diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 901e8eb..2bde0f5 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -186,7 +186,7 @@ int libxl_ctx_free(libxl_ctx *ctx) ÂÂÂÂÂif (ctx->xch) xc_interface_close(ctx->xch); ÂÂÂÂÂlibxl_version_info_dispose(&ctx->version_info); ÂÂÂÂÂif (ctx->xsh) xs_daemon_close(ctx->xsh); -ÂÂÂÂif (ctx->xce) xc_evtchn_close(ctx->xce); +ÂÂÂÂif (ctx->xce) xenevtchn_close(ctx->xce);  ÂÂÂÂÂlibxl__poller_put(ctx, ctx->poller_app); ÂÂÂÂÂctx->poller_app = NULL; diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspend.c index 3313ad1..16f603f 100644 --- a/tools/libxl/libxl_dom_suspend.c +++ b/tools/libxl/libxl_dom_suspend.c @@ -109,9 +109,9 @@ static void domain_suspend_callback_common(libxl__egc *egc, ÂÂÂÂÂif ((hvm_s_state == 0) && (dss->guest_evtchn.port >= 0)) { ÂÂÂÂÂÂÂÂÂLOG(DEBUG, "issuing %s suspend request via event channel", ÂÂÂÂÂÂÂÂÂÂÂÂÂdss->hvm ? "PVHVM" : "PV"); -ÂÂÂÂÂÂÂÂret = xc_evtchn_notify(CTX->xce, dss->guest_evtchn.port); +ÂÂÂÂÂÂÂÂret = xenevtchn_notify(CTX->xce, dss->guest_evtchn.port); ÂÂÂÂÂÂÂÂÂif (ret < 0) { -ÂÂÂÂÂÂÂÂÂÂÂÂLOG(ERROR, "xc_evtchn_notify failed ret=%d", ret); +ÂÂÂÂÂÂÂÂÂÂÂÂLOG(ERROR, "xenevtchn_notify failed ret=%d", ret); ÂÂÂÂÂÂÂÂÂÂÂÂÂrc = ERROR_FAIL; ÂÂÂÂÂÂÂÂÂÂÂÂÂgoto err; ÂÂÂÂÂÂÂÂÂ} diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 139e49a..8548365 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -739,7 +739,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, ÂÂÂÂÂÂÂÂÂ/* OK, that's that workaround done.ÂÂWe can actually check for ÂÂÂÂÂÂÂÂÂÂ* work for us to do: */  -ÂÂÂÂÂÂÂÂport = xc_evtchn_pending(CTX->xce); +ÂÂÂÂÂÂÂÂport = xenevtchn_pending(CTX->xce); ÂÂÂÂÂÂÂÂÂif (port < 0) { ÂÂÂÂÂÂÂÂÂÂÂÂÂif (errno == EAGAIN) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak; @@ -765,20 +765,20 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, Â}  Âint libxl__ctx_evtchn_init(libxl__gc *gc) { -ÂÂÂÂxc_evtchn *xce; +ÂÂÂÂxenevtchn_handle *xce; ÂÂÂÂÂint rc, fd;  ÂÂÂÂÂif (CTX->xce) ÂÂÂÂÂÂÂÂÂreturn 0;  -ÂÂÂÂxce = xc_evtchn_open(CTX->lg, 0); +ÂÂÂÂxce = xenevtchn_open(CTX->lg, 0); ÂÂÂÂÂif (!xce) { ÂÂÂÂÂÂÂÂÂLOGE(ERROR,"cannot open libxc evtchn handle"); ÂÂÂÂÂÂÂÂÂrc = ERROR_FAIL; ÂÂÂÂÂÂÂÂÂgoto out; ÂÂÂÂÂ}  -ÂÂÂÂfd = xc_evtchn_fd(xce); +ÂÂÂÂfd = xenevtchn_fd(xce); ÂÂÂÂÂassert(fd >= 0);  ÂÂÂÂÂrc = libxl_fd_set_nonblock(CTX, fd, 1); @@ -788,7 +788,7 @@ int libxl__ctx_evtchn_init(libxl__gc *gc) { ÂÂÂÂÂreturn 0;   out: -ÂÂÂÂxc_evtchn_close(xce); +ÂÂÂÂxenevtchn_close(xce); ÂÂÂÂÂreturn rc; Â}  @@ -810,14 +810,14 @@ int libxl__ev_evtchn_wait(libxl__gc *gc, libxl__ev_evtchn *evev)  ÂÂÂÂÂif (!libxl__ev_fd_isregistered(&CTX->evtchn_efd)) { ÂÂÂÂÂÂÂÂÂrc = libxl__ev_fd_register(gc, &CTX->evtchn_efd, evtchn_fd_callback, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_evtchn_fd(CTX->xce), POLLIN); +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenevtchn_fd(CTX->xce), POLLIN); ÂÂÂÂÂÂÂÂÂif (rc) goto out; ÂÂÂÂÂ}  ÂÂÂÂÂif (evev->waiting) ÂÂÂÂÂÂÂÂÂreturn 0;  -ÂÂÂÂr = xc_evtchn_unmask(CTX->xce, evev->port); +ÂÂÂÂr = xenevtchn_unmask(CTX->xce, evev->port); ÂÂÂÂÂif (r) { ÂÂÂÂÂÂÂÂÂLOGE(ERROR,"cannot unmask event channel %d",evev->port); ÂÂÂÂÂÂÂÂÂrc = ERROR_FAIL; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 233d44a..2198d07 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -48,6 +48,7 @@ Â#include <sys/file.h> Â#include <sys/ioctl.h>  +#include <xenevtchn.h> Â#include <xenstore.h> Â#include <xenctrl.h> Â#include <xenguest.h> @@ -448,7 +449,7 @@ struct libxl__ctx { ÂÂÂÂÂuint32_t watch_counter; /* helps disambiguate slot reuse */ ÂÂÂÂÂlibxl__ev_fd watch_efd;  -ÂÂÂÂxc_evtchn *xce; /* waiting must be done only with libxl__ev_evtchn* */ +ÂÂÂÂxenevtchn_handle *xce; /* waiting must be done only with libxl__ev_evtchn* */ ÂÂÂÂÂLIBXL_LIST_HEAD(, libxl__ev_evtchn) evtchns_waiting; ÂÂÂÂÂlibxl__ev_fd evtchn_efd;  @@ -925,7 +926,7 @@ static inline int libxl__ev_xswatch_isregistered(const libxl__ev_xswatch *xw)  * When the event is signaled then the callback will be made, once.  * Then you must call libxl__ev_evtchn_wait again, if desired.  * - * You must NOT call xc_evtchn_unmask.ÂÂwait will do that for you. + * You must NOT call xenevtchn_unmask.ÂÂwait will do that for you.  *  * Calling libxl__ev_evtchn_cancel will arrange for libxl to disregard  * future occurrences of event.ÂÂBoth libxl__ev_evtchn_wait and diff --git a/tools/misc/Makefile b/tools/misc/Makefile index c4490f3..cf6a475 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk ÂCFLAGS += -Werror Â# Include configure output (config.h) ÂCFLAGS += -include $(XEN_ROOT)/tools/config.h +CFLAGS += $(CFLAGS_libxenevtchn) ÂCFLAGS += $(CFLAGS_libxenctrl) ÂCFLAGS += $(CFLAGS_xeninclude) ÂCFLAGS += $(CFLAGS_libxenstore) @@ -88,18 +89,18 @@ xenlockprof: xenlockprof.o Â# xen-hptool incorrectly uses libxc internals Âxen-hptool.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc Âxen-hptool: xen-hptool.o - $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)  Â# xen-mfndump incorrectly uses libxc internals Âxen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc Âxen-mfndump: xen-mfndump.o - $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)  Âxenwatchdogd: xenwatchdogd.o  $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)  Âxen-lowmemd: xen-lowmemd.o - $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)  Âgtraceview: gtraceview.o  $(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(TINFO_LIBS) $(APPEND_LDFLAGS) diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c index c7561a9..ebcc9e8 100644 --- a/tools/misc/xen-hptool.c +++ b/tools/misc/xen-hptool.c @@ -1,3 +1,4 @@ +#include <xenevtchn.h> Â#include <xenctrl.h> Â#include <xc_private.h> Â#include <xc_core.h> @@ -98,7 +99,7 @@ static int hp_mem_query_func(int argc, char *argv[]) ÂÂÂÂÂreturn ret; Â}  -static int suspend_guest(xc_interface *xch, xc_evtchn *xce, int domid, +static int suspend_guest(xc_interface *xch, xenevtchn_handle *xce, int domid, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint *evtchn, int *lockfd) Â{ ÂÂÂÂÂint port, rc, suspend_evtchn = -1; @@ -123,7 +124,7 @@ static int suspend_guest(xc_interface *xch, xc_evtchn *xce, int domid, ÂÂÂÂÂ} ÂÂÂÂÂ*evtchn = suspend_evtchn;  -ÂÂÂÂrc = xc_evtchn_notify(xce, suspend_evtchn); +ÂÂÂÂrc = xenevtchn_notify(xce, suspend_evtchn); ÂÂÂÂÂif (rc < 0) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂfprintf(stderr, "Failed to notify suspend channel: errno %d\n", rc); @@ -198,8 +199,8 @@ static int hp_mem_offline_func(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse if (status & PG_OFFLINE_OWNED) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint result, suspend_evtchn = -1, suspend_lockfd = -1; -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_evtchn *xce; -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxce = xc_evtchn_open(NULL, 0); +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenevtchn_handle *xce; +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxce = xenevtchn_open(NULL, 0);  ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (xce == NULL) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{ @@ -214,7 +215,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfprintf(stderr, "Failed to suspend guest %d for" ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ" mfn %lx\n", domid, mfn); -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_evtchn_close(xce); +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenevtchn_close(xce); ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -1; ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}  @@ -238,7 +239,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_domain_resume(xch, domid, 1); ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_suspend_evtchn_release(xch, xce, domid, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsuspend_evtchn, &suspend_lockfd); -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxc_evtchn_close(xce); +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenevtchn_close(xce); ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ} ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak; ÂÂÂÂÂÂÂÂÂÂÂÂÂ} diff --git a/tools/misc/xen-lowmemd.c b/tools/misc/xen-lowmemd.c index 82ffd75..3200404 100644 --- a/tools/misc/xen-lowmemd.c +++ b/tools/misc/xen-lowmemd.c @@ -4,22 +4,23 @@  */  Â#include <stdio.h> +#include <xenevtchn.h> Â#include <xenctrl.h> Â#include <xenstore.h> Â#include <stdlib.h> Â#include <string.h>  Âstatic evtchn_port_t virq_portÂÂÂÂÂÂ= -1; -static xc_evtchn *xce_handleÂÂÂÂÂÂÂÂ= NULL; +static xenevtchn_handle *xce_handle = NULL; Âstatic xc_interface *xchÂÂÂÂÂÂÂÂÂÂÂÂ= NULL; Âstatic struct xs_handle *xs_handleÂÂ= NULL;  Âvoid cleanup(void) Â{ ÂÂÂÂÂif (virq_port > -1) -ÂÂÂÂÂÂÂÂxc_evtchn_unbind(xce_handle, virq_port); +ÂÂÂÂÂÂÂÂxenevtchn_unbind(xce_handle, virq_port); ÂÂÂÂÂif (xce_handle) -ÂÂÂÂÂÂÂÂxc_evtchn_close(xce_handle); +ÂÂÂÂÂÂÂÂxenevtchn_close(xce_handle); ÂÂÂÂÂif (xch) ÂÂÂÂÂÂÂÂÂxc_interface_close(xch); ÂÂÂÂÂif (xs_handle) @@ -94,7 +95,7 @@ int main(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂreturn 1; ÂÂÂÂÂ}  - xce_handle = xc_evtchn_open(NULL, 0); + xce_handle = xenevtchn_open(NULL, 0);  if (xce_handle == NULL) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂperror("Failed to open evtchn device"); @@ -108,7 +109,7 @@ int main(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂreturn 3; ÂÂÂÂÂ}  - if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_ENOMEM)) == -1) + if ((rc = xenevtchn_bind_virq(xce_handle, VIRQ_ENOMEM)) == -1) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂperror("Failed to bind to domain exception virq port"); ÂÂÂÂÂÂÂÂÂreturn 4; @@ -120,7 +121,7 @@ int main(int argc, char *argv[]) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂevtchn_port_t port;  -ÂÂÂÂÂÂÂÂif ((port = xc_evtchn_pending(xce_handle)) == -1) +ÂÂÂÂÂÂÂÂif ((port = xenevtchn_pending(xce_handle)) == -1) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂperror("Failed to listen for pending event channel"); ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 5; @@ -134,7 +135,7 @@ int main(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 6; ÂÂÂÂÂÂÂÂÂ}  -ÂÂÂÂÂÂÂÂif (xc_evtchn_unmask(xce_handle, port) == -1) +ÂÂÂÂÂÂÂÂif (xenevtchn_unmask(xce_handle, port) == -1) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂperror("Failed to unmask port"); ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 7; diff --git a/tools/ocaml/libs/eventchn/Makefile b/tools/ocaml/libs/eventchn/Makefile index 2d8d618..154efd4 100644 --- a/tools/ocaml/libs/eventchn/Makefile +++ b/tools/ocaml/libs/eventchn/Makefile @@ -2,13 +2,13 @@ TOPLEVEL=$(CURDIR)/../.. ÂXEN_ROOT=$(TOPLEVEL)/../.. Âinclude $(TOPLEVEL)/common.make  -CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude) +CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_xeninclude)  ÂOBJS = xeneventchn ÂINTF = $(foreach obj, $(OBJS),$(obj).cmi) ÂLIBS = xeneventchn.cma xeneventchn.cmxa  -LIBS_xeneventchn = $(LDLIBS_libxenctrl) +LIBS_xeneventchn = $(LDLIBS_libxenevtchn)  Âall: $(INTF) $(LIBS) $(PROGRAMS)  diff --git a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c index 5939e7c..c2d4737 100644 --- a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c +++ b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c @@ -24,7 +24,7 @@ Â#include <xen/sysctl.h> Â#include <xen/xen.h> Â#include <xen/sys/evtchn.h> -#include <xenctrl.h> +#include <xenevtchn.h>  Â#define CAML_NAME_SPACE Â#include <caml/mlvalues.h> @@ -34,14 +34,14 @@ Â#include <caml/callback.h> Â#include <caml/fail.h>  -#define _H(__h) ((xc_evtchn *)(__h)) +#define _H(__h) ((xenevtchn_handle *)(__h))  ÂCAMLprim value stub_eventchn_init(void) Â{  CAMLparam0();  CAMLlocal1(result);  - xc_evtchn *xce = xc_evtchn_open(NULL, XC_OPENFLAG_NON_REENTRANT); + xenevtchn_handle *xce = xenevtchn_open(NULL, 0);  if (xce == NULL)  caml_failwith("open failed");  @@ -55,7 +55,7 @@ CAMLprim value stub_eventchn_fd(value xce)  CAMLlocal1(result);  int fd;  - fd = xc_evtchn_fd(_H(xce)); + fd = xenevtchn_fd(_H(xce));  if (fd == -1)  caml_failwith("evtchn fd failed");  @@ -69,7 +69,7 @@ CAMLprim value stub_eventchn_notify(value xce, value port)  CAMLparam2(xce, port);  int rc;  - rc = xc_evtchn_notify(_H(xce), Int_val(port)); + rc = xenevtchn_notify(_H(xce), Int_val(port));  if (rc == -1)  caml_failwith("evtchn notify failed");  @@ -83,7 +83,7 @@ CAMLprim value stub_eventchn_bind_interdomain(value xce, value domid,  CAMLlocal1(port);  evtchn_port_or_error_t rc;  - rc = xc_evtchn_bind_interdomain(_H(xce), Int_val(domid), Int_val(remote_port)); + rc = xenevtchn_bind_interdomain(_H(xce), Int_val(domid), Int_val(remote_port));  if (rc == -1)  caml_failwith("evtchn bind_interdomain failed");  port = Val_int(rc); @@ -97,7 +97,7 @@ CAMLprim value stub_eventchn_bind_dom_exc_virq(value xce)  CAMLlocal1(port);  evtchn_port_or_error_t rc;  - rc = xc_evtchn_bind_virq(_H(xce), VIRQ_DOM_EXC); + rc = xenevtchn_bind_virq(_H(xce), VIRQ_DOM_EXC);  if (rc == -1)  caml_failwith("evtchn bind_dom_exc_virq failed");  port = Val_int(rc); @@ -110,7 +110,7 @@ CAMLprim value stub_eventchn_unbind(value xce, value port)  CAMLparam2(xce, port);  int rc;  - rc = xc_evtchn_unbind(_H(xce), Int_val(port)); + rc = xenevtchn_unbind(_H(xce), Int_val(port));  if (rc == -1)  caml_failwith("evtchn unbind failed");  @@ -123,7 +123,7 @@ CAMLprim value stub_eventchn_pending(value xce)  CAMLlocal1(result);  evtchn_port_or_error_t port;  - port = xc_evtchn_pending(_H(xce)); + port = xenevtchn_pending(_H(xce));  if (port == -1)  caml_failwith("evtchn pending failed");  result = Val_int(port); @@ -137,7 +137,7 @@ CAMLprim value stub_eventchn_unmask(value xce, value _port)  evtchn_port_t port;   port = Int_val(_port); - if (xc_evtchn_unmask(_H(xce), port)) + if (xenevtchn_unmask(_H(xce), port))  caml_failwith("evtchn unmask failed");  CAMLreturn(Val_unit); Â} diff --git a/tools/python/setup.py b/tools/python/setup.py index 604b314..8faf1c0 100644 --- a/tools/python/setup.py +++ b/tools/python/setup.py @@ -8,13 +8,18 @@ extra_compile_argsÂÂ= [ "-fno-strict-aliasing", "-Werror" ]  ÂPATH_XENÂÂÂÂÂÂ= XEN_ROOT + "/tools/include" ÂPATH_LIBXENTOOLLOG = XEN_ROOT + "/tools/libs/toollog" +PATH_LIBXENEVTCHN = XEN_ROOT + "/tools/libs/evtchn" ÂPATH_LIBXCÂÂÂÂ= XEN_ROOT + "/tools/libxc" ÂPATH_LIBXLÂÂÂÂ= XEN_ROOT + "/tools/libxl" ÂPATH_XENSTORE = XEN_ROOT + "/tools/xenstore"  Âxc = Extension("xc", ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂextra_compile_args = extra_compile_args, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinclude_dirsÂÂÂÂÂÂÂ= [ PATH_XEN, PATH_LIBXENTOOLLOG + "/include", PATH_LIBXC + "/include", "xen/lowlevel/xc" ], +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinclude_dirsÂÂÂÂÂÂÂ= [ PATH_XEN, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPATH_LIBXENTOOLLOG + "/include", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPATH_LIBXENEVTCHN + "/include", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPATH_LIBXC + "/include", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"xen/lowlevel/xc" ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlibrary_dirsÂÂÂÂÂÂÂ= [ PATH_LIBXC ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlibrariesÂÂÂÂÂÂÂÂÂÂ= [ "xenctrl", "xenguest" ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdependsÂÂÂÂÂÂÂÂÂÂÂÂ= [ PATH_LIBXC + "/libxenctrl.so", PATH_LIBXC + "/libxenguest.so" ], diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile index dd70f9f..25ff469 100644 --- a/tools/tests/xen-access/Makefile +++ b/tools/tests/xen-access/Makefile @@ -5,6 +5,7 @@ CFLAGS += -Werror  ÂCFLAGS += $(CFLAGS_libxenctrl) ÂCFLAGS += $(CFLAGS_libxenguest) +CFLAGS += $(CFLAGS_libxenevtchn) ÂCFLAGS += $(CFLAGS_xeninclude)  ÂTARGETS-y := xen-access @@ -24,6 +25,6 @@ clean: Âdistclean: clean  Âxen-access: xen-access.o Makefile - $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) + $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenevtchn)  Â-include $(DEPS) diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index a52ca6e..7993947 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -39,6 +39,7 @@ Â#include <sys/poll.h>  Â#include <xenctrl.h> +#include <xenevtchn.h> Â#include <xen/vm_event.h>  Â#if defined(__arm__) || defined(__aarch64__) @@ -54,7 +55,7 @@  Âtypedef struct vm_event { ÂÂÂÂÂdomid_t domain_id; -ÂÂÂÂxc_evtchn *xce_handle; +ÂÂÂÂxenevtchn_handle *xce_handle; ÂÂÂÂÂint port; ÂÂÂÂÂvm_event_back_ring_t back_ring; ÂÂÂÂÂuint32_t evtchn_port; @@ -77,9 +78,9 @@ static void close_handler(int sig) ÂÂÂÂÂinterrupted = sig; Â}  -int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms) +int xc_wait_for_event_or_timeout(xc_interface *xch, xenevtchn_handle *xce, unsigned long ms) Â{ -ÂÂÂÂstruct pollfd fd = { .fd = xc_evtchn_fd(xce), .events = POLLIN | POLLERR }; +ÂÂÂÂstruct pollfd fd = { .fd = xenevtchn_fd(xce), .events = POLLIN | POLLERR }; ÂÂÂÂÂint port; ÂÂÂÂÂint rc;  @@ -95,14 +96,14 @@ int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned lon  ÂÂÂÂÂif ( rc == 1 ) ÂÂÂÂÂ{ -ÂÂÂÂÂÂÂÂport = xc_evtchn_pending(xce); +ÂÂÂÂÂÂÂÂport = xenevtchn_pending(xce); ÂÂÂÂÂÂÂÂÂif ( port == -1 ) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂERROR("Failed to read port from event channel"); ÂÂÂÂÂÂÂÂÂÂÂÂÂgoto err; ÂÂÂÂÂÂÂÂÂ}  -ÂÂÂÂÂÂÂÂrc = xc_evtchn_unmask(xce, port); +ÂÂÂÂÂÂÂÂrc = xenevtchn_unmask(xce, port); ÂÂÂÂÂÂÂÂÂif ( rc != 0 ) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂERROR("Failed to unmask event channel port"); @@ -143,7 +144,7 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) ÂÂÂÂÂ/* Unbind VIRQ */ ÂÂÂÂÂif ( evtchn_bind ) ÂÂÂÂÂ{ -ÂÂÂÂÂÂÂÂrc = xc_evtchn_unbind(xenaccess->vm_event.xce_handle, +ÂÂÂÂÂÂÂÂrc = xenevtchn_unbind(xenaccess->vm_event.xce_handle, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenaccess->vm_event.port); ÂÂÂÂÂÂÂÂÂif ( rc != 0 ) ÂÂÂÂÂÂÂÂÂ{ @@ -155,7 +156,7 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) ÂÂÂÂÂ/* Close event channel */ ÂÂÂÂÂif ( evtchn_open ) ÂÂÂÂÂ{ -ÂÂÂÂÂÂÂÂrc = xc_evtchn_close(xenaccess->vm_event.xce_handle); +ÂÂÂÂÂÂÂÂrc = xenevtchn_close(xenaccess->vm_event.xce_handle); ÂÂÂÂÂÂÂÂÂif ( rc != 0 ) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂERROR("Error closing event channel"); @@ -223,7 +224,7 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) ÂÂÂÂÂmem_access_enable = 1;  ÂÂÂÂÂ/* Open event channel */ -ÂÂÂÂxenaccess->vm_event.xce_handle = xc_evtchn_open(NULL, 0); +ÂÂÂÂxenaccess->vm_event.xce_handle = xenevtchn_open(NULL, 0); ÂÂÂÂÂif ( xenaccess->vm_event.xce_handle == NULL ) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂERROR("Failed to open event channel"); @@ -232,7 +233,7 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) ÂÂÂÂÂevtchn_open = 1;  ÂÂÂÂÂ/* Bind event notification */ -ÂÂÂÂrc = xc_evtchn_bind_interdomain(xenaccess->vm_event.xce_handle, +ÂÂÂÂrc = xenevtchn_bind_interdomain(xenaccess->vm_event.xce_handle, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenaccess->vm_event.domain_id, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenaccess->vm_event.evtchn_port); ÂÂÂÂÂif ( rc < 0 ) @@ -678,7 +679,7 @@ int main(int argc, char *argv[]) ÂÂÂÂÂÂÂÂÂ}  ÂÂÂÂÂÂÂÂÂ/* Tell Xen page is ready */ -ÂÂÂÂÂÂÂÂrc = xc_evtchn_notify(xenaccess->vm_event.xce_handle, +ÂÂÂÂÂÂÂÂrc = xenevtchn_notify(xenaccess->vm_event.xce_handle, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxenaccess->vm_event.port);  ÂÂÂÂÂÂÂÂÂif ( rc != 0 ) diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile index fff519d..2d1f112 100644 --- a/tools/xcutils/Makefile +++ b/tools/xcutils/Makefile @@ -16,8 +16,8 @@ PROGRAMS = readnotes lsevtchn ÂCFLAGS += -Werror  Â# incorrectly uses libxc internals -CFLAGS_readnotes.oÂÂ:= $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) -I$(XEN_ROOT)/tools/libxc -CFLAGS_lsevtchn.oÂÂÂ:= $(CFLAGS_libxenctrl) +CFLAGS_readnotes.oÂÂ:= $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) -I$(XEN_ROOT)/tools/libxc +CFLAGS_lsevtchn.oÂÂÂ:= $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl)  Â.PHONY: all Âall: build diff --git a/tools/xenmon/Makefile b/tools/xenmon/Makefile index 20ea100..98056f2 100644 --- a/tools/xenmon/Makefile +++ b/tools/xenmon/Makefile @@ -14,8 +14,10 @@ XEN_ROOT=$(CURDIR)/../.. Âinclude $(XEN_ROOT)/tools/Rules.mk  ÂCFLAGSÂÂ+= -Werror +CFLAGSÂÂ+= $(CFLAGS_libxenevtchn) ÂCFLAGSÂÂ+= $(CFLAGS_libxenctrl) ÂLDLIBSÂÂ+= $(LDLIBS_libxenctrl) +LDLIBSÂÂ+= $(LDLIBS_libxenevtchn)  ÂSCRIPTS = xenmon.py  diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c index 1ddb29b..e4602ef 100644 --- a/tools/xenmon/xenbaked.c +++ b/tools/xenmon/xenbaked.c @@ -37,6 +37,7 @@ Â#include <unistd.h> Â#include <errno.h> Â#include <signal.h> +#include <xenevtchn.h> Â#include <xenctrl.h> Â#include <xen/xen.h> Â#include <string.h> @@ -267,7 +268,7 @@ static void log_event(int event_id) Â}  Âint virq_port; -xc_evtchn *xce_handle = NULL; +xenevtchn_handle *xce_handle = NULL;  Â/* Returns the event channel handle. */ Â/* Stolen from xenstore code */ @@ -279,12 +280,12 @@ static int eventchn_init(void) ÂÂÂÂÂif (0) ÂÂÂÂÂÂÂÂÂreturn -1;  -ÂÂÂÂxce_handle = xc_evtchn_open(NULL, 0); +ÂÂÂÂxce_handle = xenevtchn_open(NULL, 0);  ÂÂÂÂÂif (xce_handle == NULL) ÂÂÂÂÂÂÂÂÂperror("Failed to open evtchn device");  -ÂÂÂÂif ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_TBUF)) == -1) +ÂÂÂÂif ((rc = xenevtchn_bind_virq(xce_handle, VIRQ_TBUF)) == -1) ÂÂÂÂÂÂÂÂÂperror("Failed to bind to domain exception virq port"); ÂÂÂÂÂvirq_port = rc;  @@ -304,7 +305,7 @@ static void wait_for_event(void) ÂÂÂÂÂÂÂÂÂreturn; ÂÂÂÂÂ}  -ÂÂÂÂevtchn_fd = xc_evtchn_fd(xce_handle); +ÂÂÂÂevtchn_fd = xenevtchn_fd(xce_handle);  ÂÂÂÂÂFD_ZERO(&inset); ÂÂÂÂÂFD_SET(evtchn_fd, &inset); @@ -314,13 +315,13 @@ static void wait_for_event(void) ÂÂÂÂÂret = select(evtchn_fd+1, &inset, NULL, NULL, &tv);  ÂÂÂÂÂif ( (ret == 1) && FD_ISSET(evtchn_fd, &inset)) { -ÂÂÂÂÂÂÂÂif ((port = xc_evtchn_pending(xce_handle)) == -1) +ÂÂÂÂÂÂÂÂif ((port = xenevtchn_pending(xce_handle)) == -1) ÂÂÂÂÂÂÂÂÂÂÂÂÂperror("Failed to read from event fd");  ÂÂÂÂÂÂÂÂÂ//ÂÂÂÂif (port == virq_port) ÂÂÂÂÂÂÂÂÂ//ÂÂÂÂÂÂprintf("got the event I was looking for\r\n");  -ÂÂÂÂÂÂÂÂif (xc_evtchn_unmask(xce_handle, port) == -1) +ÂÂÂÂÂÂÂÂif (xenevtchn_unmask(xce_handle, port) == -1) ÂÂÂÂÂÂÂÂÂÂÂÂÂperror("Failed to write to event fd"); ÂÂÂÂÂ} Â} diff --git a/tools/xenpaging/Makefile b/tools/xenpaging/Makefile index e63d894..d491867 100644 --- a/tools/xenpaging/Makefile +++ b/tools/xenpaging/Makefile @@ -2,8 +2,8 @@ XEN_ROOT=$(CURDIR)/../.. Âinclude $(XEN_ROOT)/tools/Rules.mk  Â# xenpaging.c and file_ops.c incorrectly use libxc internals -CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(PTHREAD_CFLAGS) -I$(XEN_ROOT)/tools/libxc -LDLIBS += $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS) +CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(PTHREAD_CFLAGS) -I$(XEN_ROOT)/tools/libxc +LDLIBS += $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS) ÂLDFLAGS += $(PTHREAD_LDFLAGS)  ÂPOLICYÂÂÂÂ= default diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index b5ffee6..df99c6a 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -73,7 +73,7 @@ static void xenpaging_mem_paging_flush_ioemu_cache(struct xenpaging *paging) Âstatic int xenpaging_wait_for_event_or_timeout(struct xenpaging *paging) Â{ ÂÂÂÂÂxc_interface *xch = paging->xc_handle; -ÂÂÂÂxc_evtchn *xce = paging->vm_event.xce_handle; +ÂÂÂÂxenevtchn_handle *xce = paging->vm_event.xce_handle; ÂÂÂÂÂchar **vec, *val; ÂÂÂÂÂunsigned int num; ÂÂÂÂÂstruct pollfd fd[2]; @@ -82,7 +82,7 @@ static int xenpaging_wait_for_event_or_timeout(struct xenpaging *paging) ÂÂÂÂÂint timeout;  ÂÂÂÂÂ/* Wait for event channel and xenstore */ -ÂÂÂÂfd[0].fd = xc_evtchn_fd(xce); +ÂÂÂÂfd[0].fd = xenevtchn_fd(xce); ÂÂÂÂÂfd[0].events = POLLIN | POLLERR; ÂÂÂÂÂfd[1].fd = xs_fileno(paging->xs_handle); ÂÂÂÂÂfd[1].events = POLLIN | POLLERR; @@ -146,7 +146,7 @@ static int xenpaging_wait_for_event_or_timeout(struct xenpaging *paging) ÂÂÂÂÂif ( rc && fd[0].revents & POLLIN ) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂDPRINTF("Got event from evtchn\n"); -ÂÂÂÂÂÂÂÂport = xc_evtchn_pending(xce); +ÂÂÂÂÂÂÂÂport = xenevtchn_pending(xce); ÂÂÂÂÂÂÂÂÂif ( port == -1 ) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂPERROR("Failed to read port from event channel"); @@ -154,7 +154,7 @@ static int xenpaging_wait_for_event_or_timeout(struct xenpaging *paging) ÂÂÂÂÂÂÂÂÂÂÂÂÂgoto err; ÂÂÂÂÂÂÂÂÂ}  -ÂÂÂÂÂÂÂÂrc = xc_evtchn_unmask(xce, port); +ÂÂÂÂÂÂÂÂrc = xenevtchn_unmask(xce, port); ÂÂÂÂÂÂÂÂÂif ( rc < 0 ) ÂÂÂÂÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂÂÂÂÂPERROR("Failed to unmask event channel port"); @@ -393,7 +393,7 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[]) ÂÂÂÂÂ}  ÂÂÂÂÂ/* Open event channel */ -ÂÂÂÂpaging->vm_event.xce_handle = xc_evtchn_open(NULL, 0); +ÂÂÂÂpaging->vm_event.xce_handle = xenevtchn_open(NULL, 0); ÂÂÂÂÂif ( paging->vm_event.xce_handle == NULL ) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂPERROR("Failed to open event channel"); @@ -401,7 +401,7 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[]) ÂÂÂÂÂ}  ÂÂÂÂÂ/* Bind event notification */ -ÂÂÂÂrc = xc_evtchn_bind_interdomain(paging->vm_event.xce_handle, +ÂÂÂÂrc = xenevtchn_bind_interdomain(paging->vm_event.xce_handle, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpaging->vm_event.domain_id, ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpaging->vm_event.evtchn_port); ÂÂÂÂÂif ( rc < 0 ) @@ -531,7 +531,7 @@ static void xenpaging_teardown(struct xenpaging *paging) ÂÂÂÂÂ}  ÂÂÂÂÂ/* Unbind VIRQ */ -ÂÂÂÂrc = xc_evtchn_unbind(paging->vm_event.xce_handle, paging->vm_event.port); +ÂÂÂÂrc = xenevtchn_unbind(paging->vm_event.xce_handle, paging->vm_event.port); ÂÂÂÂÂif ( rc != 0 ) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂPERROR("Error unbinding event port"); @@ -539,7 +539,7 @@ static void xenpaging_teardown(struct xenpaging *paging) ÂÂÂÂÂpaging->vm_event.port = -1;  ÂÂÂÂÂ/* Close event channel */ -ÂÂÂÂrc = xc_evtchn_close(paging->vm_event.xce_handle); +ÂÂÂÂrc = xenevtchn_close(paging->vm_event.xce_handle); ÂÂÂÂÂif ( rc != 0 ) ÂÂÂÂÂ{ ÂÂÂÂÂÂÂÂÂPERROR("Error closing event channel"); @@ -692,7 +692,7 @@ static int xenpaging_resume_page(struct xenpaging *paging, vm_event_response_t * ÂÂÂÂÂ}  ÂÂÂÂÂ/* Tell Xen page is ready */ -ÂÂÂÂreturn xc_evtchn_notify(paging->vm_event.xce_handle, paging->vm_event.port); +ÂÂÂÂreturn xenevtchn_notify(paging->vm_event.xce_handle, paging->vm_event.port); Â}  Âstatic int xenpaging_populate_page(struct xenpaging *paging, unsigned long gfn, int i) diff --git a/tools/xenpaging/xenpaging.h b/tools/xenpaging/xenpaging.h index c6ab77c..d0f8d20 100644 --- a/tools/xenpaging/xenpaging.h +++ b/tools/xenpaging/xenpaging.h @@ -24,6 +24,7 @@ Â#define __XEN_PAGING2_H__   +#include <xenevtchn.h> Â#include <xc_private.h> Â#include <xen/event_channel.h> Â#include <xen/vm_event.h> @@ -32,7 +33,7 @@  Âstruct vm_event { ÂÂÂÂÂdomid_t domain_id; -ÂÂÂÂxc_evtchn *xce_handle; +ÂÂÂÂxenevtchn_handle *xce_handle; ÂÂÂÂÂint port; ÂÂÂÂÂvm_event_back_ring_t back_ring; ÂÂÂÂÂuint32_t evtchn_port; diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile index 404d4cb..5970fde 100644 --- a/tools/xenstore/Makefile +++ b/tools/xenstore/Makefile @@ -9,6 +9,7 @@ CFLAGS += -I. Â# Include configure output (config.h) ÂCFLAGS += -include $(XEN_ROOT)/tools/config.h ÂCFLAGS += -I./include +CFLAGS += $(CFLAGS_libxenevtchn) ÂCFLAGS += $(CFLAGS_libxenctrl) ÂCFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""  @@ -69,7 +70,7 @@ CFLAGS += -DHAVE_DTRACE=1 Âendif  Âxenstored: $(XENSTORED_OBJS) - $(CC) $^ $(LDFLAGS) $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) + $(CC) $^ $(LDFLAGS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)  Âxenstored.a: $(XENSTORED_OBJS)  $(AR) cr $@ $^ diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 3c0307e..f62c192 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -40,6 +40,8 @@ Â#include <assert.h> Â#include <setjmp.h>  +#include <xenevtchn.h> + Â#include "utils.h" Â#include "list.h" Â#include "talloc.h" @@ -63,7 +65,7 @@ Â#include <systemd/sd-daemon.h> Â#endif  -extern xc_evtchn *xce_handle; /* in xenstored_domain.c */ +extern xenevtchn_handle *xce_handle; /* in xenstored_domain.c */ Âstatic int xce_pollfd_idx = -1; Âstatic struct pollfd *fds; Âstatic unsigned int current_array_size; @@ -372,7 +374,7 @@ static void initialize_fds(int sock, int *p_sock_pollfd_idx,  set_fd(reopen_log_pipe[0], POLLIN|POLLPRI);   if (xce_handle != NULL) - xce_pollfd_idx = set_fd(xc_evtchn_fd(xce_handle), + xce_pollfd_idx = set_fd(xenevtchn_fd(xce_handle),  POLLIN|POLLPRI);   list_for_each_entry(conn, &connections, list) { diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index dcd6581..6ceec29 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -29,6 +29,7 @@ Â#include "xenstored_transaction.h" Â#include "xenstored_watch.h"  +#include <xenevtchn.h> Â#include <xenctrl.h> Â#include <xen/grant_table.h>  @@ -36,7 +37,7 @@ static xc_interface **xc_handle; Âxc_gnttab **xcg_handle; Âstatic evtchn_port_t virq_port;  -xc_evtchn *xce_handle = NULL; +xenevtchn_handle *xce_handle = NULL;  Âstruct domain Â{ @@ -128,7 +129,7 @@ static int writechn(struct connection *conn,  xen_mb();  intf->rsp_prod += len;  - xc_evtchn_notify(xce_handle, conn->domain->port); + xenevtchn_notify(xce_handle, conn->domain->port);   return len; Â} @@ -158,7 +159,7 @@ static int readchn(struct connection *conn, void *data, unsigned int len)  xen_mb();  intf->req_cons += len;  - xc_evtchn_notify(xce_handle, conn->domain->port); + xenevtchn_notify(xce_handle, conn->domain->port);   return len; Â} @@ -190,7 +191,7 @@ static int destroy_domain(void *_domain)  list_del(&domain->list);   if (domain->port) { - if (xc_evtchn_unbind(xce_handle, domain->port) == -1) + if (xenevtchn_unbind(xce_handle, domain->port) == -1)  eprintf("> Unbinding port %i failed!\n", domain->port);  }  @@ -239,13 +240,13 @@ void handle_event(void) Â{  evtchn_port_t port;  - if ((port = xc_evtchn_pending(xce_handle)) == -1) + if ((port = xenevtchn_pending(xce_handle)) == -1)  barf_perror("Failed to read from event fd");   if (port == virq_port)  domain_cleanup();  - if (xc_evtchn_unmask(xce_handle, port) == -1) + if (xenevtchn_unmask(xce_handle, port) == -1)  barf_perror("Failed to write to event fd"); Â}  @@ -287,7 +288,7 @@ static struct domain *new_domain(void *context, unsigned int domid,  talloc_set_destructor(domain, destroy_domain);   /* Tell kernel we're interested in this event. */ - rc = xc_evtchn_bind_interdomain(xce_handle, domid, port); + rc = xenevtchn_bind_interdomain(xce_handle, domid, port);  if (rc == -1)  ÂÂÂÂreturn NULL;  domain->port = rc; @@ -392,8 +393,8 @@ void do_introduce(struct connection *conn, struct buffered_data *in)  } else if ((domain->mfn == mfn) && (domain->conn != conn)) {  /* Use XS_INTRODUCE for recreating the xenbus event-channel. */  if (domain->port) - xc_evtchn_unbind(xce_handle, domain->port); - rc = xc_evtchn_bind_interdomain(xce_handle, domid, port); + xenevtchn_unbind(xce_handle, domain->port); + rc = xenevtchn_bind_interdomain(xce_handle, domid, port);  domain->port = (rc == -1) ? 0 : rc;  domain->remote_port = port;  } else { @@ -614,7 +615,7 @@ static int dom0_init(void)   talloc_steal(dom0->conn, dom0);  - xc_evtchn_notify(xce_handle, dom0->port); + xenevtchn_notify(xce_handle, dom0->port);   return 0; Â} @@ -643,7 +644,7 @@ void domain_init(void)  else  talloc_set_destructor(xcg_handle, close_xcg_handle);  - xce_handle = xc_evtchn_open(NULL, 0); + xce_handle = xenevtchn_open(NULL, 0);   if (xce_handle == NULL)  barf_perror("Failed to open evtchn device"); @@ -651,7 +652,7 @@ void domain_init(void)  if (dom0_init() != 0)  barf_perror("Failed to initialize dom0 state");  - if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_DOM_EXC)) == -1) + if ((rc = xenevtchn_bind_virq(xce_handle, VIRQ_DOM_EXC)) == -1)  barf_perror("Failed to bind to domain exception virq port");  virq_port = rc; Â} diff --git a/tools/xentrace/Makefile b/tools/xentrace/Makefile index 6c13cd1..0157be2 100644 --- a/tools/xentrace/Makefile +++ b/tools/xentrace/Makefile @@ -3,8 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk  ÂCFLAGS += -Werror  +CFLAGS += $(CFLAGS_libxenevtchn) ÂCFLAGS += $(CFLAGS_libxenctrl) -LDLIBS += $(LDLIBS_libxenctrl) $(ARGP_LDFLAGS) +LDLIBS += $(LDLIBS_libxenevtchn) +LDLIBS += $(LDLIBS_libxenctrl) +LDLIBS += $(ARGP_LDFLAGS)  ÂBIN-$(CONFIG_X86) = xenalyze ÂBINÂÂÂÂÂÂ= $(BIN-y) diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c index 4ee1458..c970d42 100644 --- a/tools/xentrace/xentrace.c +++ b/tools/xentrace/xentrace.c @@ -30,6 +30,7 @@ Â#include <xen/xen.h> Â#include <xen/trace.h>  +#include <xenevtchn.h> Â#include <xenctrl.h>  Â#define PERROR(_m, _a...)ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ @@ -74,7 +75,7 @@ settings_t opts; Âint interrupted = 0; /* gets set if we get a SIGHUP */  Âstatic xc_interface *xc_handle; -static xc_evtchn *xce_handle = NULL; +static xenevtchn_handle *xce_handle = NULL; Âstatic int virq_port = -1; Âstatic int outfd = 1;  @@ -602,13 +603,13 @@ static void event_init(void) Â{ ÂÂÂÂÂint rc;  -ÂÂÂÂxce_handle = xc_evtchn_open(NULL, 0); +ÂÂÂÂxce_handle = xenevtchn_open(NULL, 0); ÂÂÂÂÂif (xce_handle == NULL) { ÂÂÂÂÂÂÂÂÂperror("event channel open"); ÂÂÂÂÂÂÂÂÂexit(EXIT_FAILURE); ÂÂÂÂÂ}  -ÂÂÂÂrc = xc_evtchn_bind_virq(xce_handle, VIRQ_TBUF); +ÂÂÂÂrc = xenevtchn_bind_virq(xce_handle, VIRQ_TBUF); ÂÂÂÂÂif (rc == -1) { ÂÂÂÂÂÂÂÂÂPERROR("failed to bind to VIRQ port"); ÂÂÂÂÂÂÂÂÂexit(EXIT_FAILURE); @@ -623,7 +624,7 @@ static void event_init(void) Âstatic void wait_for_event_or_timeout(unsigned long milliseconds) Â{ ÂÂÂÂÂint rc; -ÂÂÂÂstruct pollfd fd = { .fd = xc_evtchn_fd(xce_handle), +ÂÂÂÂstruct pollfd fd = { .fd = xenevtchn_fd(xce_handle), ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ.events = POLLIN | POLLERR }; ÂÂÂÂÂint port;  @@ -636,7 +637,7 @@ static void wait_for_event_or_timeout(unsigned long milliseconds) ÂÂÂÂÂ}  ÂÂÂÂÂif (rc == 1) { -ÂÂÂÂÂÂÂÂport = xc_evtchn_pending(xce_handle); +ÂÂÂÂÂÂÂÂport = xenevtchn_pending(xce_handle); ÂÂÂÂÂÂÂÂÂif (port == -1) { ÂÂÂÂÂÂÂÂÂÂÂÂÂPERROR("failed to read port from evtchn"); ÂÂÂÂÂÂÂÂÂÂÂÂÂexit(EXIT_FAILURE); @@ -647,7 +648,7 @@ static void wait_for_event_or_timeout(unsigned long milliseconds) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂport, virq_port); ÂÂÂÂÂÂÂÂÂÂÂÂÂexit(EXIT_FAILURE); ÂÂÂÂÂÂÂÂÂ} -ÂÂÂÂÂÂÂÂrc = xc_evtchn_unmask(xce_handle, port); +ÂÂÂÂÂÂÂÂrc = xenevtchn_unmask(xce_handle, port); ÂÂÂÂÂÂÂÂÂif (rc == -1) { ÂÂÂÂÂÂÂÂÂÂÂÂÂPERROR("failed to write port to evtchn"); ÂÂÂÂÂÂÂÂÂÂÂÂÂexit(EXIT_FAILURE); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |