[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 10/22] xentoolcore_restrict_all: Implement for libxenforeignmemory
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- tools/Rules.mk | 2 +- tools/libs/foreignmemory/Makefile | 4 ++-- tools/libs/foreignmemory/core.c | 15 +++++++++++++++ tools/libs/foreignmemory/private.h | 3 +++ tools/libs/foreignmemory/xenforeignmemory.pc.in | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/Rules.mk b/tools/Rules.mk index 71037a1..7dd126a 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -124,7 +124,7 @@ LDLIBS_libxencall = $(SHDEPS_libxencall) $(XEN_LIBXENCALL)/libxencall$(libextens SHLIB_libxencall = $(SHDEPS_libxencall) -Wl,-rpath-link=$(XEN_LIBXENCALL) CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xeninclude) -SHDEPS_libxenforeignmemory = +SHDEPS_libxenforeignmemory = $(SHLIB_libxentoolcore) LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension) SHLIB_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile index ab7f873..cbe815f 100644 --- a/tools/libs/foreignmemory/Makefile +++ b/tools/libs/foreignmemory/Makefile @@ -7,7 +7,7 @@ SHLIB_LDFLAGS += -Wl,--version-script=libxenforeignmemory.map CFLAGS += -Werror -Wmissing-prototypes CFLAGS += -I./include $(CFLAGS_xeninclude) -CFLAGS += $(CFLAGS_libxentoollog) +CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore) SRCS-y += core.c SRCS-$(CONFIG_Linux) += linux.c @@ -62,7 +62,7 @@ libxenforeignmemory.so.$(MAJOR): libxenforeignmemory.so.$(MAJOR).$(MINOR) $(SYMLINK_SHLIB) $< $@ libxenforeignmemory.so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxenforeignmemory.map - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenforeignmemory.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenforeignmemory.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS) .PHONY: install install: build diff --git a/tools/libs/foreignmemory/core.c b/tools/libs/foreignmemory/core.c index a6897dc..b48ecba 100644 --- a/tools/libs/foreignmemory/core.c +++ b/tools/libs/foreignmemory/core.c @@ -19,6 +19,16 @@ #include "private.h" +static int all_restrict_cb(Xentoolcore__Active_Handle *ah, uint32_t domid) { + xenforeignmemory_handle *fmem = CONTAINER_OF(ah, *fmem, tc_ah); + + if (fmem->fd < 0) + /* just in case */ + return 0; + + return xenforeignmemory_restrict(fmem, domid); +} + xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger, unsigned open_flags) { @@ -31,6 +41,9 @@ xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger, fmem->logger = logger; fmem->logger_tofree = NULL; + fmem->tc_ah.restrict_callback = all_restrict_cb; + xentoolcore__register_active_handle(&fmem->tc_ah); + if (!fmem->logger) { fmem->logger = fmem->logger_tofree = (xentoollog_logger*) @@ -45,6 +58,7 @@ xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger, err: osdep_xenforeignmemory_close(fmem); + xentoolcore__deregister_active_handle(&fmem->tc_ah); xtl_logger_destroy(fmem->logger_tofree); free(fmem); return NULL; @@ -58,6 +72,7 @@ int xenforeignmemory_close(xenforeignmemory_handle *fmem) return 0; rc = osdep_xenforeignmemory_close(fmem); + xentoolcore__deregister_active_handle(&fmem->tc_ah); xtl_logger_destroy(fmem->logger_tofree); free(fmem); return rc; diff --git a/tools/libs/foreignmemory/private.h b/tools/libs/foreignmemory/private.h index c5c07cc..2470f3c 100644 --- a/tools/libs/foreignmemory/private.h +++ b/tools/libs/foreignmemory/private.h @@ -5,6 +5,8 @@ #include <xenforeignmemory.h> +#include <xentoolcore_internal.h> + #include <xen/xen.h> #include <xen/sys/privcmd.h> @@ -20,6 +22,7 @@ struct xenforeignmemory_handle { xentoollog_logger *logger, *logger_tofree; unsigned flags; int fd; + Xentoolcore__Active_Handle tc_ah; }; int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem); diff --git a/tools/libs/foreignmemory/xenforeignmemory.pc.in b/tools/libs/foreignmemory/xenforeignmemory.pc.in index 63432dc..61c9def 100644 --- a/tools/libs/foreignmemory/xenforeignmemory.pc.in +++ b/tools/libs/foreignmemory/xenforeignmemory.pc.in @@ -7,4 +7,4 @@ Description: The Xenforeignmemory library for Xen hypervisor Version: @@version@@ Cflags: -I${includedir} @@cflagslocal@@ Libs: @@libsflag@@${libdir} -lxenforeignmemory -Requires.private: xentoollog +Requires.private: xentoollog,xentoolcore -- 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 |