@@ -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)
@@ -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
@@ -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;
@@ -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);
@@ -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
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- 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(-)