From patchwork Fri Feb 17 10:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9579543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD133600C5 for ; Fri, 17 Feb 2017 10:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AB74286AB for ; Fri, 17 Feb 2017 10:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EF87286B7; Fri, 17 Feb 2017 10:30:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D51B286AB for ; Fri, 17 Feb 2017 10:30:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cefl0-00087M-14; Fri, 17 Feb 2017 10:27:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cefky-00085T-6h for xen-devel@lists.xenproject.org; Fri, 17 Feb 2017 10:27:16 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id C3/9B-26824-300D6A85; Fri, 17 Feb 2017 10:27:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXitHRDpC7zhWU RBt19Ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b+pm+sBQ9bGCuWdc9jbWBsLepi5OSQEPCX 6P++jxnEZhPQkZj69BJrFyMHh4iAisTtvQZdjFwczAJLGCW6Xi1lAakRFnCXuHdtJhNIDYuAq sTxtSJdjOwcvEDh+wkQA+Ukzh//CTZQCGjI+qmz2EBsXgFBiZMzn4ANYRaQkDj44gXzBEbuWU hSs5CkFjAyrWJUL04tKkst0jXWSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDAM GINjB2PHP6RCjJAeTkijvomnLIoT4kvJTKjMSizPii0pzUosPMcpwcChJ8N46C5QTLEpNT61I y8wBBiRMWoKDR0kEIs1bXJCYW5yZDpE6xWjMcerG6ZdMHPu2n3nJJMSSl5+XKiXOa3keqFQAp DSjNA9uECxSLjHKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUUmY9w7IQp7MvBK4fa+ATmECOqUzYi nIKSWJCCmpBkb3GXcj7PtuJUw4q9XUcWx+KZ/PIfnDSQfmM72+cy/4wL0Fnk0JRZIJblsE9k6 eaD3XZtaT36abtgr3s/EsXVgnqpKT/Ni9L7ZBK2P/nrAvwUfmtFR2zjJOuJwyfWfTjKtz7S7n dZlyJ7BYmzN/Te2bVefGsEX1Yrdkhq+qf4ir88Iltx8V1CuxFGckGmoxFxUnAgA471IzjwIAA A== X-Env-Sender: prvs=214e09179=Paul.Durrant@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1487327232!52460131!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39399 invoked from network); 17 Feb 2017 10:27:15 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 17 Feb 2017 10:27:15 -0000 X-IronPort-AV: E=Sophos;i="5.35,171,1484006400"; d="scan'208";a="407699464" From: Paul Durrant To: Date: Fri, 17 Feb 2017 10:27:06 +0000 Message-ID: <1487327229-14641-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Wei Liu , Paul Durrant , Ian Jackson , Samuel Thibault Subject: [Xen-devel] [PATCH 1/4] tools/libxendevicemodel: introduce the new library X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the dm_op hypercall added by commit 524a98c2. This patch adds the boilerplate for the new library, with only open() and close() entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch. NOTE: After applying this patch libxenctrl will depend on libxendevicemodel and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively. [1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-traditional.git;a=commit;h=a445da7e [2] http://xenbits.xen.org/gitweb/?p=people/pauldu/mini-os.git;a=commit;h=41c9f2ae Signed-off-by: Paul Durrant Acked-by: Samuel Thibault --- Cc: Ian Jackson Cc: Wei Liu Cc: Samuel Thibault --- stubdom/Makefile | 17 ++++++- tools/Makefile | 1 + tools/Rules.mk | 10 +++- tools/libs/Makefile | 1 + tools/libs/devicemodel/Makefile | 66 ++++++++++++++++++++++++ tools/libs/devicemodel/core.c | 68 +++++++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 40 +++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 6 +++ tools/libs/devicemodel/private.h | 22 ++++++++ tools/libxc/Makefile | 3 +- tools/libxc/xc_private.c | 11 +++- tools/libxc/xc_private.h | 4 ++ 12 files changed, 243 insertions(+), 6 deletions(-) create mode 100644 tools/libs/devicemodel/Makefile create mode 100644 tools/libs/devicemodel/core.c create mode 100644 tools/libs/devicemodel/include/xendevicemodel.h create mode 100644 tools/libs/devicemodel/libxendevicemodel.map create mode 100644 tools/libs/devicemodel/private.h diff --git a/stubdom/Makefile b/stubdom/Makefile index f858210..39b81c9 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -337,13 +337,16 @@ libs-$(XEN_TARGET_ARCH)/call/stamp: $(XEN_ROOT)/tools/libs/call/Makefile libs-$(XEN_TARGET_ARCH)/foreignmemory/stamp: $(XEN_ROOT)/tools/libs/foreignmemory/Makefile $(do_links) +libs-$(XEN_TARGET_ARCH)/devicemodel/stamp: $(XEN_ROOT)/tools/libs/devicemodel/Makefile + $(do_links) + libxc-$(XEN_TARGET_ARCH)/stamp: $(XEN_ROOT)/tools/libxc/Makefile $(do_links) xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile $(do_links) -LINK_LIBS_DIRS := toollog evtchn gnttab call foreignmemory +LINK_LIBS_DIRS := toollog evtchn gnttab call foreignmemory devicemodel LINK_DIRS := libxc-$(XEN_TARGET_ARCH) xenstore $(foreach dir,$(LINK_LIBS_DIRS),libs-$(XEN_TARGET_ARCH)/$(dir)) LINK_STAMPS := $(foreach dir,$(LINK_DIRS),$(dir)/stamp) @@ -414,12 +417,21 @@ libs-$(XEN_TARGET_ARCH)/foreignmemory/libxenforeignmemory.a: mk-headers-$(XEN_TA CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory ####### +# libxendevicemodel +####### + +.PHONY: libxendevicemodel +libxendevicemodel: libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a +libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel + +####### # 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 libxenevtchn libxengnttab libxencall libxenforeignmemory cross-zlib +libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog libxenevtchn libxengnttab libxencall libxenforeignmemory libxendevicemodel 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 @@ -616,6 +628,7 @@ clean: [ ! -e libs-$(XEN_TARGET_ARCH)/gnttab/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/gnttab clean [ ! -e libs-$(XEN_TARGET_ARCH)/call/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/call clean [ ! -e libs-$(XEN_TARGET_ARCH)/foreignmemory/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory clean + [ ! -e libs-$(XEN_TARGET_ARCH)/devicemodel/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel clean [ ! -e libxc-$(XEN_TARGET_ARCH)/Makefile ] || $(MAKE) DESTDIR= -C libxc-$(XEN_TARGET_ARCH) clean -[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean -[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean diff --git a/tools/Makefile b/tools/Makefile index 77e0723..0890cc9 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -281,6 +281,7 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \ + -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/devicemodel \ $(QEMU_UPSTREAM_RPATH)" \ --bindir=$(LIBEXEC_BIN) \ --datadir=$(SHAREDIR)/qemu-xen \ diff --git a/tools/Rules.mk b/tools/Rules.mk index b35999b..e3415f0 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -15,6 +15,7 @@ XEN_LIBXENEVTCHN = $(XEN_ROOT)/tools/libs/evtchn XEN_LIBXENGNTTAB = $(XEN_ROOT)/tools/libs/gnttab XEN_LIBXENCALL = $(XEN_ROOT)/tools/libs/call XEN_LIBXENFOREIGNMEMORY = $(XEN_ROOT)/tools/libs/foreignmemory +XEN_LIBXENDEVICEMODEL = $(XEN_ROOT)/tools/libs/devicemodel XEN_LIBXC = $(XEN_ROOT)/tools/libxc XEN_XENLIGHT = $(XEN_ROOT)/tools/libxl XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore @@ -117,10 +118,15 @@ CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xenin LDLIBS_libxenforeignmemory = $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension) SHLIB_libxenforeignmemory = -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) +CFLAGS_libxendevicemodel = -I$(XEN_LIBXENDEVICEMODEL)/include $(CFLAGS_xeninclude) +SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) +LDLIBS_libxendevicemodel = $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension) +SHLIB_libxendevicemodel = -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL) + # code which compiles against libxenctrl get __XEN_TOOLS__ and # therefore sees the unstable hypercall interfaces. -CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) +CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ +SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) $(SHLIB_libxendevicemodel) LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension) SHLIB_libxenctrl = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC) diff --git a/tools/libs/Makefile b/tools/libs/Makefile index dc5726d..deae4ae 100644 --- a/tools/libs/Makefile +++ b/tools/libs/Makefile @@ -7,5 +7,6 @@ SUBDIRS-y += evtchn SUBDIRS-y += gnttab SUBDIRS-y += call SUBDIRS-y += foreignmemory +SUBDIRS-y += devicemodel all clean install distclean: %: subdirs-% diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile new file mode 100644 index 0000000..4f1e616 --- /dev/null +++ b/tools/libs/devicemodel/Makefile @@ -0,0 +1,66 @@ +XEN_ROOT = $(CURDIR)/../../.. +include $(XEN_ROOT)/tools/Rules.mk + +MAJOR = 1 +MINOR = 0 +SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map + +CFLAGS += -Werror -Wmissing-prototypes +CFLAGS += -I./include $(CFLAGS_xeninclude) +CFLAGS += $(CFLAGS_libxentoollog) + +SRCS-y += core.c + +LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y)) +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y)) + +LIB := libxendevicemodel.a +ifneq ($(nosharedlibs),y) +LIB += libxendevicemodel.so +endif + +.PHONY: all +all: build + +.PHONY: build +build: + $(MAKE) libs + +.PHONY: libs +libs: headers.chk $(LIB) + +headers.chk: $(wildcard include/*.h) + +libxendevicemodel.a: $(LIB_OBJS) + $(AR) rc $@ $^ + +libxendevicemodel.so: libxendevicemodel.so.$(MAJOR) + $(SYMLINK_SHLIB) $< $@ +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) $(APPEND_LDFLAGS) + +.PHONY: install +install: build + $(INSTALL_DIR) $(DESTDIR)$(libdir) + $(INSTALL_DIR) $(DESTDIR)$(includedir) + $(INSTALL_SHLIB) libxendevicemodel.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir) + $(INSTALL_DATA) libxendevicemodel.a $(DESTDIR)$(libdir) + $(SYMLINK_SHLIB) libxendevicemodel.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR) + $(SYMLINK_SHLIB) libxendevicemodel.so.$(MAJOR) $(DESTDIR)$(libdir)/libxendevicemodel.so + $(INSTALL_DATA) include/xendevicemodel.h $(DESTDIR)$(includedir) + +.PHONY: TAGS +TAGS: + etags -t *.c *.h + +.PHONY: clean +clean: + rm -rf *.rpm $(LIB) *~ $(DEPS) $(LIB_OBJS) $(PIC_OBJS) + rm -f libxendevicemodel.so.$(MAJOR).$(MINOR) libxendevicemodel.so.$(MAJOR) + rm -f headers.chk + +.PHONY: distclean +distclean: clean diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c new file mode 100644 index 0000000..ec18142 --- /dev/null +++ b/tools/libs/devicemodel/core.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 Citrix Systems Inc. + * + * 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 . + */ + +#include + +#include "private.h" + +xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, + unsigned open_flags) +{ + xendevicemodel_handle *dmod = malloc(sizeof(*dmod)); + + if (!dmod) + return NULL; + + dmod->flags = open_flags; + dmod->logger = logger; + dmod->logger_tofree = NULL; + + if (!dmod->logger) { + dmod->logger = dmod->logger_tofree = + (xentoollog_logger*) + xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0); + if (!dmod->logger) + goto err; + } + + return dmod; + +err: + xtl_logger_destroy(dmod->logger_tofree); + free(dmod); + return NULL; +} + +int xendevicemodel_close(xendevicemodel_handle *dmod) +{ + if (!dmod) + return 0; + + xtl_logger_destroy(dmod->logger_tofree); + free(dmod); + 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/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h new file mode 100644 index 0000000..f977b0e --- /dev/null +++ b/tools/libs/devicemodel/include/xendevicemodel.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017 Citrix Systems Inc. + * + * 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 . + */ +#ifndef XENDEVICEMODEL_H +#define XENDEVICEMODEL_H + +/* Callers who don't care don't need to #include */ +struct xentoollog_logger; + +typedef struct xendevicemodel_handle xendevicemodel_handle; + +xendevicemodel_handle *xendevicemodel_open(struct xentoollog_logger *logger, + unsigned int open_flags); + +int xendevicemodel_close(xendevicemodel_handle *dmod); + +#endif /* XENDEVICEMODEL_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/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map new file mode 100644 index 0000000..980c429 --- /dev/null +++ b/tools/libs/devicemodel/libxendevicemodel.map @@ -0,0 +1,6 @@ +VERS_1.0 { + global: + xendevicemodel_open; + xendevicemodel_close; + local: *; /* Do not expose anything by default */ +}; diff --git a/tools/libs/devicemodel/private.h b/tools/libs/devicemodel/private.h new file mode 100644 index 0000000..cf1e4b0 --- /dev/null +++ b/tools/libs/devicemodel/private.h @@ -0,0 +1,22 @@ +#ifndef XENDEVICEMODEL_PRIVATE_H +#define XENDEVICEMODEL_PRIVATE_H + +#include +#include + +struct xendevicemodel_handle { + xentoollog_logger *logger, *logger_tofree; + unsigned int flags; +}; + +#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/Makefile b/tools/libxc/Makefile index 37235e3..af5e49c 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -113,6 +113,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE CFLAGS += $(PTHREAD_CFLAGS) CFLAGS += $(CFLAGS_libxentoollog) CFLAGS += $(CFLAGS_libxenevtchn) +CFLAGS += $(CFLAGS_libxendevicemodel) CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y)) @@ -217,7 +218,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) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) # libxenguest diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index f0e089c..32379b6 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -65,12 +65,18 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, xch->fmem = xenforeignmemory_open(xch->error_handler, 0); - if ( xch->xcall == NULL ) + if ( xch->fmem == NULL ) + goto err; + + xch->dmod = xendevicemodel_open(xch->error_handler, 0); + + if ( xch->dmod == NULL ) goto err; return xch; err: + xenforeignmemory_close(xch->fmem); xencall_close(xch->xcall); xtl_logger_destroy(xch->error_handler_tofree); if (xch != &xch_buf) free(xch); @@ -90,6 +96,9 @@ int xc_interface_close(xc_interface *xch) rc = xenforeignmemory_close(xch->fmem); if (rc) PERROR("Could not close foreign memory interface"); + rc = xendevicemodel_close(xch->dmod); + if (rc) PERROR("Could not close device model interface"); + xtl_logger_destroy(xch->dombuild_logger_tofree); xtl_logger_destroy(xch->error_handler_tofree); diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index d0ff4b5..1c27b0f 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -36,6 +36,7 @@ #include #include +#include #include @@ -97,6 +98,9 @@ struct xc_interface_core { /* Foreign mappings */ xenforeignmemory_handle *fmem; + + /* Device model */ + xendevicemodel_handle *dmod; }; int osdep_privcmd_open(xc_interface *xch);