[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 07/22] xentoolcore_restrict_all: Implement for libxendevicemodel
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- tools/Rules.mk | 2 +- tools/libs/devicemodel/Makefile | 3 ++- tools/libs/devicemodel/core.c | 16 ++++++++++++++++ tools/libs/devicemodel/private.h | 3 +++ tools/libs/devicemodel/xendevicemodel.pc.in | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/Rules.mk b/tools/Rules.mk index 5e1c7cb..9b2fe36 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -129,7 +129,7 @@ LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_LIBXENFOREIGNME SHLIB_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) CFLAGS_libxendevicemodel = -I$(XEN_LIBXENDEVICEMODEL)/include $(CFLAGS_xeninclude) -SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_xencall) +SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_xencall) LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension) SHLIB_libxendevicemodel = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL) diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile index f0e1e6c..3f7efd5 100644 --- a/tools/libs/devicemodel/Makefile +++ b/tools/libs/devicemodel/Makefile @@ -8,6 +8,7 @@ SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map CFLAGS += -Werror -Wmissing-prototypes CFLAGS += -I./include $(CFLAGS_xeninclude) CFLAGS += $(CFLAGS_libxentoollog) +CFLAGS += $(CFLAGS_libxentoolcore) CFLAGS += $(CFLAGS_libxencall) SRCS-y += core.c @@ -63,7 +64,7 @@ libxendevicemodel.so.$(MAJOR): libxendevicemodel.so.$(MAJOR).$(MINOR) $(SYMLINK_SHLIB) $< $@ libxendevicemodel.so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxendevicemodel.map - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxendevicemodel.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxencall) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxendevicemodel.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxencall) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS) .PHONY: install install: build diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 2093884..3292e53 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -21,6 +21,16 @@ #include "private.h" +static int all_restrict_cb(Xentoolcore__Active_Handle *ah, uint32_t domid) { + xendevicemodel_handle *dmod = CONTAINER_OF(ah, *dmod, tc_ah); + + if (dmod->fd < 0) + /* just in case */ + return 0; + + return xendevicemodel_restrict(dmod, domid); +} + xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, unsigned open_flags) { @@ -30,6 +40,10 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, if (!dmod) return NULL; + dmod->fd = -1; + dmod->tc_ah.restrict_callback = all_restrict_cb; + xentoolcore__register_active_handle(&dmod->tc_ah); + dmod->flags = open_flags; dmod->logger = logger; dmod->logger_tofree = NULL; @@ -55,6 +69,7 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, err: xtl_logger_destroy(dmod->logger_tofree); xencall_close(dmod->xcall); + xentoolcore__deregister_active_handle(&dmod->tc_ah); free(dmod); return NULL; } @@ -69,6 +84,7 @@ int xendevicemodel_close(xendevicemodel_handle *dmod) rc = osdep_xendevicemodel_close(dmod); xencall_close(dmod->xcall); + xentoolcore__deregister_active_handle(&dmod->tc_ah); xtl_logger_destroy(dmod->logger_tofree); free(dmod); return rc; diff --git a/tools/libs/devicemodel/private.h b/tools/libs/devicemodel/private.h index 4ce5aac..c4a225f 100644 --- a/tools/libs/devicemodel/private.h +++ b/tools/libs/devicemodel/private.h @@ -7,11 +7,14 @@ #include <xendevicemodel.h> #include <xencall.h> +#include <xentoolcore_internal.h> + struct xendevicemodel_handle { xentoollog_logger *logger, *logger_tofree; unsigned int flags; xencall_handle *xcall; int fd; + Xentoolcore__Active_Handle tc_ah; }; struct xendevicemodel_buf { diff --git a/tools/libs/devicemodel/xendevicemodel.pc.in b/tools/libs/devicemodel/xendevicemodel.pc.in index ed08f83..8bd04fa 100644 --- a/tools/libs/devicemodel/xendevicemodel.pc.in +++ b/tools/libs/devicemodel/xendevicemodel.pc.in @@ -7,4 +7,4 @@ Description: The Xendevicemodel library for Xen hypervisor Version: @@version@@ Cflags: -I${includedir} @@cflagslocal@@ Libs: @@libsflag@@${libdir} -lxendevicemodel -Requires.private: xentoollog,xencall +Requires.private: xentoolcore,xentoollog,xencall -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |