From: Ian Campbell Subject: Re: [PATCH 1/9] libxl: New API for providing OS events to libxl Date: Wed, 18 Jan 2012 16:35:42 +0000 Message-ID: <1326904542.14689.258.camel@zakaz.uk.xensource.com> References: <1326482728-10733-1-git-send-email-ian.jackson@eu.citrix.com> <1326482728-10733-2-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1326482728-10733-2-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-01-13 at 19:25 +0000, Ian Jackson wrote: > We provide a new set of functions and related structures > libxl_osevent_* > which are to be used by event-driven applications to receive > information from libxl about which fds libxl is interested in, and > what timeouts libxl is waiting for, and to pass back to libxl > information about which fds are readable/writeable etc., and which > timeouts have occurred. Ie, low-level events. > > In this patch, this new machinery is still all unused. Callers will > appear in the next patch in the series, which introduces a new API for > applications to receive high-level events about actual domains etc. > > Signed-off-by: Ian Jackson > --- > tools/libxl/Makefile | 2 +- > tools/libxl/libxl.c | 30 ++ > tools/libxl/libxl.h | 6 + > tools/libxl/libxl_event.c | 750 ++++++++++++++++++++++++++++++++++++++++++ > tools/libxl/libxl_event.h | 205 ++++++++++++ > tools/libxl/libxl_internal.h | 277 +++++++++++++++- > 6 files changed, 1267 insertions(+), 3 deletions(-) > create mode 100644 tools/libxl/libxl_event.c > create mode 100644 tools/libxl/libxl_event.h [...] > @@ -109,6 +110,71 @@ _hidden void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval, > > /* these functions preserve errno (saving and restoring) */ > > +typedef struct libxl__gc libxl__gc; > +typedef struct libxl__egc libxl__egc; > + > +typedef struct libxl__ev_fd libxl__ev_fd; > +typedef void libxl__ev_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, > + int fd, short events, short revents); > +struct libxl__ev_fd { > + /* caller should include this in their own struct */ > + /* read-only for caller, who may read only when registered: */ > + int fd; > + short events; > + libxl__ev_fd_callback *func; Are there actually cases where a caller would want to read these? The most obvious case would be in the callback but it already gets given all three there. Not suggesting we disallow this I'm just curious. > + /* remainder is private for libxl__ev_fd... */ > + LIBXL_LIST_ENTRY(libxl__ev_fd) entry; > + void *for_app_reg; > +}; [...] > + * int libxl__ev_KIND_register(libxl__gc *gc, libxl__ev_KIND *GEN, > + * libxl__ev_KIND_callback *FUNC, > + * DETAILS); > + * On entry *GEN must be in state Undefined or Idle. > + * Returns a libxl error code; on error return *GEN is Idle. > + * On successful return *GEN is Active and FUNC wil be will > + * called by the event machinery in future. FUNC will > + * not be called from within the call to _register. > + * FUNC will be called with the context locked (with CTX_LOCK). [...] Acked-by: Ian Campbell