[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH XEN v2 09/15] tools/libxc: Remove osdep indirection for privcmd
> On 16 Jul 2015, at 05:57, David Scott (Sales UK) <david.scott@xxxxxxxxxx> > wrote: > > One for you I think Dave? > > Sent from my iPhone > > Begin forwarded message: > >> From: "Ian Campbell" <ian.campbell@xxxxxxxxxx> >> To: "Ian Jackson" <Ian.Jackson@xxxxxxxxxx>, "Wei Liu" <wei.liu2@xxxxxxxxxx>, >> "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx> >> Cc: "Stefano Stabellini" <Stefano.Stabellini@xxxxxxxxxx>, "Roger Pau Monne" >> <roger.pau@xxxxxxxxxx>, "Ian Campbell" <Ian.Campbell@xxxxxxxxxx>, "David >> Scott (Sales UK)" <david.scott@xxxxxxxxxx> >> Subject: [PATCH XEN v2 09/15] tools/libxc: Remove osdep indirection for >> privcmd >> >> The alternative backend (a xen-api/xapi shim) is no longer around and >> so this stuff is now just baggage which is getting in the way of >> refactoring libxenctrl. Yes, we no longer use the fake libxenctrl (âxiuâ) stuff. >> >> Nested virt probably suffices for this use case now. >> >> This was the last component of the osdep infrastructure, so all the >> dynamic loading etc stuff all falls away too. >> >> As part of this I was forced to investigate the twisty >> xc_map_foreign_* maze, which I have added to the >> toolstack-library-apis doc in the hopes of doing something sensible. >> >> NetBSD and Solaris now call xc_map_foreign_bulk_compat directly from >> their xc_map_foreign_bulk, which could have been achieved by using >> some ifdefs around a renamed function. This will fall out in the wash >> when these functions move to their own library. >> >> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> >> Cc: David Scott <david.scott@xxxxxxxxxx> Confusingly my email is <dave.scott@xxxxxxxxxx> (âdaveâ rather than âdavidâ) â best to avoid cc:ing âdavid.scottâ as he probably hasnât got xen-devel email filters set up ;-) >> --- >> config/FreeBSD.mk | 2 - >> config/NetBSD.mk | 3 - >> config/NetBSDRump.mk | 1 - >> config/StdGNU.mk | 1 - >> config/SunOS.mk | 1 - >> docs/misc/toolstack-library-abis.pandoc | 64 +++++++++++- >> tools/libxc/Makefile | 27 ++--- >> tools/libxc/include/xenctrl.h | 9 -- >> tools/libxc/include/xenctrlosdep.h | 134 ------------------------ >> tools/libxc/xc_foreign_memory.c | 31 +----- >> tools/libxc/xc_freebsd_osdep.c | 100 +++++------------- >> tools/libxc/xc_hcall_buf.c | 6 +- >> tools/libxc/xc_linux_osdep.c | 88 +++++----------- >> tools/libxc/xc_minios.c | 82 +++++---------- >> tools/libxc/xc_netbsd.c | 90 ++++++----------- >> tools/libxc/xc_private.c | 174 >> ++------------------------------ >> tools/libxc/xc_private.h | 19 ++-- >> tools/libxc/xc_solaris.c | 90 ++++++----------- >> tools/libxc/xenctrl_osdep_ENOSYS.c | 123 ---------------------- >> tools/ocaml/libs/xc/xenctrl.ml | 2 - >> tools/ocaml/libs/xc/xenctrl.mli | 1 - >> tools/ocaml/libs/xc/xenctrl_stubs.c | 7 -- >> tools/ocaml/xenstored/domains.ml | 6 +- >> tools/ocaml/xenstored/xenstored.ml | 5 +- These are fine, Acked-by: David Scott <dave.scott@xxxxxxxxxx> Thanks, Dave >> 24 files changed, 240 insertions(+), 826 deletions(-) >> delete mode 100644 tools/libxc/include/xenctrlosdep.h >> delete mode 100644 tools/libxc/xenctrl_osdep_ENOSYS.c >> >> diff --git a/config/FreeBSD.mk b/config/FreeBSD.mk >> index 5a13d607..bb3a5d0 100644 >> --- a/config/FreeBSD.mk >> +++ b/config/FreeBSD.mk >> @@ -1,6 +1,4 @@ >> include $(XEN_ROOT)/config/StdGNU.mk >> >> -DLOPEN_LIBS = >> - >> # No wget on FreeBSD base system >> WGET = ftp >> diff --git a/config/NetBSD.mk b/config/NetBSD.mk >> index 21318d6..cf766e5 100644 >> --- a/config/NetBSD.mk >> +++ b/config/NetBSD.mk >> @@ -1,6 +1,3 @@ >> include $(XEN_ROOT)/config/StdGNU.mk >> >> -# Override settings for this OS >> -DLOPEN_LIBS = >> - >> WGET = ftp >> diff --git a/config/NetBSDRump.mk b/config/NetBSDRump.mk >> index 2a87218..74755a1 100644 >> --- a/config/NetBSDRump.mk >> +++ b/config/NetBSDRump.mk >> @@ -1,6 +1,5 @@ >> include $(XEN_ROOT)/config/StdGNU.mk >> >> -DLOPEN_LIBS = >> PTHREAD_LIBS = >> >> WGET = ftp >> diff --git a/config/StdGNU.mk b/config/StdGNU.mk >> index 129d5c8..39d36b2 100644 >> --- a/config/StdGNU.mk >> +++ b/config/StdGNU.mk >> @@ -31,7 +31,6 @@ DEBUG_DIR ?= /usr/lib/debug >> >> SOCKET_LIBS = >> UTIL_LIBS = -lutil >> -DLOPEN_LIBS = -ldl >> >> SONAME_LDFLAG = -soname >> SHLIB_LDFLAGS = -shared >> diff --git a/config/SunOS.mk b/config/SunOS.mk >> index db5e898..86a384d 100644 >> --- a/config/SunOS.mk >> +++ b/config/SunOS.mk >> @@ -27,7 +27,6 @@ SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64 >> SOCKET_LIBS = -lsocket >> PTHREAD_LIBS = -lpthread >> UTIL_LIBS = >> -DLOPEN_LIBS = -ldl >> >> SONAME_LDFLAG = -h >> SHLIB_LDFLAGS = -R $(SunOS_LIBDIR) -shared >> diff --git a/docs/misc/toolstack-library-abis.pandoc >> b/docs/misc/toolstack-library-abis.pandoc >> index 6b6146a..d1550a6 100644 >> --- a/docs/misc/toolstack-library-abis.pandoc >> +++ b/docs/misc/toolstack-library-abis.pandoc >> @@ -187,7 +187,6 @@ Notes: >> ### Basic interface >> >> - xc_interface_close >> - - xc_interface_is_fake >> - xc_interface_open >> >> ### Event channels >> @@ -511,7 +510,6 @@ Symbols: >> - xc_monitor_write_ctrlreg >> - xc_nodemap_alloc >> - xc_numainfo >> - - xc_osdep_log >> - xc_pcitopoinfo >> - xc_perfc_query >> - xc_perfc_query_number >> @@ -871,3 +869,65 @@ functionality areas: >> - xc_kexec_load >> - xc_kexec_unload >> - xc_version >> + >> +# Foreign memory mapping functions >> + >> +The `xc_map_foreign_*` functions are a bit of a twisty maze. >> + >> +osdep level interfaces: >> + >> +Interface Linux Minios Netbsd Freebsd Solaris >> +-------------------- ----- ------ ------ ------- ------- >> +`map_foreign_batch` Y Y Y Y >> +`map_foreign_bulk` Y Y compat Y compat >> +`map_foreign_range` Y Y Y Y Y >> +`map_foreign_ranges` Y Y Y Y Y >> + >> +_compat_ means using `xc_map_foreign_bulk_compat` >> + >> +`xc_map_foreign_pages` is common and implemented using >> +`xc_map_foreign_bulk`. >> + >> +Some osdep call other `xc_map_foreign_*` recursivley: >> + >> +Interface Linux FreeBSD >> +-------------------- ---------------------------- ------------------------- >> +`map_foreign_batch` `IOCTL_PRIVCMD_MMAPBATCH` N/A >> +`map_foreign_bulk` `IOCTL_PRIVCMD_MMAPBATCH_V2` `IOCTL_PRIVCMD_MMAPBATCH` >> +`map_foreign_range` `xc_map_foreign_pages` `xc_map_foreign_pages` >> +`map_foreign_ranges` `xc_map_foreign_pages` `xc_map_foreign_pages` >> + >> +libxenctrl level interfaces: >> + >> +Interface Underlying interface >> +---------------------- --------------------------- >> +`xc_map_foreign_pages` `xc_map_foreign_bulk` >> +`xc_map_foreign_range` `osdep: map_foreign_range` >> +`xc_map_foreign_ranges` `osdep: map_foreign_ranges` >> +`xc_map_foreign_batch` `osdep: map_foreign_batch` >> +`xc_map_foreign_bulk` `osdep: map_foreign_bulk` >> + >> +`osdep: *` have been collapsed since osdep layer was removed. >> + >> +`xc_map_foreign_bulk_compat` is an internal helper used by osdep >> +backends which have not implemented there own version. It uses >> +`xc_map_foreign_batch`. >> + >> +`xc_map_foreign_batch_single` is part of linux osdep, but name has >> +leaked. >> + >> +Interface Internal users External users >> +---------------------- -------------- -------------- >> +`xc_map_foreign_pages` xenpaging qemu-pv >> +`xc_map_foreign_range` xenconsole, kdd, libxl, qemu-dm, qemu-pv >> + mfndump, memshrtool, xenmon, >> + xenstored, xentrace >> +`xc_map_foreign_ranges` NONE >> +`xc_map_foreign_batch` xenmon, xenpaging, xentrace >> +`xc_map_foreign_bulk` used recursively qemu-dm >> + >> +Only one interface should become a stable API. Something based on >> +`xc_map_foreign_bulk` seems most appropriate (it is used by >> +`xc_map_foreign_pages` as well as by xc_map_foreign_range` and >> +`xc_map_foreign_ranges` on Linux + FreeBSD. A compat version exists in >> +terms for `xc_map_foreign_batch` for other OSes. >> diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile >> index 3c939ce..77d2ae1 100644 >> --- a/tools/libxc/Makefile >> +++ b/tools/libxc/Makefile >> @@ -102,8 +102,6 @@ GUEST_SRCS-y += >> xc_dom_decompress_unsafe_lzo1x.c >> GUEST_SRCS-y += xc_dom_decompress_unsafe_xz.c >> endif >> >> -OSDEP_SRCS-y += xenctrl_osdep_ENOSYS.c >> - >> -include $(XEN_TARGET_ARCH)/Makefile >> >> CFLAGS += -Werror -Wmissing-prototypes >> @@ -122,11 +120,8 @@ CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y)) >> GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y)) >> GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y)) >> >> -OSDEP_LIB_OBJS := $(patsubst %.c,%.o,$(OSDEP_SRCS-y)) >> -OSDEP_PIC_OBJS := $(patsubst %.c,%.opic,$(OSDEP_SRCS-y)) >> - >> -$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) $(OSDEP_LIB_OBJS) \ >> -$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS) $(OSDEP_PIC_OBJS) : CFLAGS += -include >> $(XEN_ROOT)/tools/config.h >> +$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \ >> +$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include >> $(XEN_ROOT)/tools/config.h >> >> $(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS): CFLAGS += $(CFLAGS_libxengnttab) >> $(CFLAGS_libxengntshr) >> >> @@ -140,17 +135,13 @@ ifneq ($(nosharedlibs),y) >> LIB += libxenguest.so libxenguest.so.$(MAJOR) >> libxenguest.so.$(MAJOR).$(MINOR) >> endif >> >> -ifneq ($(nosharedlibs),y) >> -LIB += xenctrl_osdep_ENOSYS.so >> -endif >> - >> genpath-target = $(call buildmakevars2header,_paths.h) >> $(eval $(genpath-target)) >> >> xc_private.h: _paths.h >> >> -$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) $(OSDEP_LIB_OBJS) \ >> -$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS) $(OSDEP_PIC_OBJS): xc_private.h >> +$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \ >> +$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h >> >> .PHONY: all >> all: build >> @@ -170,7 +161,7 @@ install: build >> $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir) >> $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) >> $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR) >> $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so >> - $(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h >> include/xenctrlosdep.h $(DESTDIR)$(includedir) >> + $(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h >> $(DESTDIR)$(includedir) >> $(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir) >> $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir) >> $(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) >> $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR) >> @@ -186,8 +177,7 @@ clean: >> rm -rf *.rpm $(LIB) *~ $(DEPS) \ >> _paths.h \ >> $(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \ >> - $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS) \ >> - $(OSDEP_LIB_OBJS) $(OSDEP_PIC_OBJS) >> + $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS) >> >> .PHONY: distclean >> distclean: clean >> @@ -213,7 +203,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) >> $(DLOPEN_LIBS) $(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) >> $(PTHREAD_LIBS) $(APPEND_LDFLAGS) >> >> # libxenguest >> >> @@ -238,8 +228,5 @@ libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = >> $(call zlib-options,l) >> libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so >> $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) >> $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz >> $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) >> >> -xenctrl_osdep_ENOSYS.so: $(OSDEP_PIC_OBJS) libxenctrl.so >> - $(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $(OSDEP_PIC_OBJS) >> $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) >> - >> -include $(DEPS) >> >> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h >> index 9675ebb..61f68bb 100644 >> --- a/tools/libxc/include/xenctrl.h >> +++ b/tools/libxc/include/xenctrl.h >> @@ -182,15 +182,6 @@ enum xc_open_flags { >> */ >> int xc_interface_close(xc_interface *xch); >> >> -/** >> - * Query the active OS interface (i.e. that which would be returned by >> - * xc_interface_open) to find out if it is fake (i.e. backends onto >> - * something other than an actual Xen hypervisor). >> - * >> - * @return 0 is "real", >0 if fake, -1 on error. >> - */ >> -int xc_interface_is_fake(void); >> - >> /* >> * HYPERCALL SAFE MEMORY BUFFER >> * >> diff --git a/tools/libxc/include/xenctrlosdep.h >> b/tools/libxc/include/xenctrlosdep.h >> deleted file mode 100644 >> index bad10f6..0000000 >> --- a/tools/libxc/include/xenctrlosdep.h >> +++ /dev/null >> @@ -1,134 +0,0 @@ >> -/****************************************************************************** >> - * >> - * Interface to OS specific low-level operations >> - * >> - * Copyright (c) 2010, 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, write to the Free Software >> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >> 02110-1301 USA >> - */ >> - >> -/* >> - * This interface defines the interactions between the Xen control >> - * libraries and the OS facilities used to communicate with the >> - * hypervisor. >> - * >> - * It is possible to override the default (native) implementation by >> - * setting the XENCTRL_OSDEP environment variable to point to a >> - * plugin library. Userspace can use this facility to intercept >> - * hypervisor operations. This can be used e.g. to implement a >> - * userspace simulator for Xen hypercalls. >> - * >> - * The plugin must contain a data structure: >> - * xc_osdep_info_t xc_osdep_info; >> - * >> - * xc_osdep_init: >> - * Must return a suitable struct xc_osdep_ops pointer or NULL on failure. >> - */ >> - >> -#ifndef XC_OSDEP_H >> -#define XC_OSDEP_H >> - >> -/* Tell the Xen public headers we are a user-space tools build. */ >> -#ifndef __XEN_TOOLS__ >> -#define __XEN_TOOLS__ 1 >> -#endif >> - >> -#include <sys/mman.h> >> -#include <sys/types.h> >> - >> -#include <xen/sys/privcmd.h> >> - >> -enum xc_osdep_type { >> - XC_OSDEP_PRIVCMD, >> -}; >> - >> -/* Opaque handle internal to the backend */ >> -typedef unsigned long xc_osdep_handle; >> - >> -#define XC_OSDEP_OPEN_ERROR ((xc_osdep_handle)-1) >> - >> -struct xc_osdep_ops >> -{ >> - /* Opens an interface. >> - * >> - * Must return an opaque handle on success or >> - * XC_OSDEP_OPEN_ERROR on failure >> - */ >> - xc_osdep_handle (*open)(xc_interface *xch); >> - >> - int (*close)(xc_interface *xch, xc_osdep_handle h); >> - >> - union { >> - struct { >> - void *(*alloc_hypercall_buffer)(xc_interface *xch, >> xc_osdep_handle h, int npages); >> - void (*free_hypercall_buffer)(xc_interface *xch, >> xc_osdep_handle h, void *ptr, int npages); >> - >> - int (*hypercall)(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall); >> - >> - void *(*map_foreign_batch)(xc_interface *xch, xc_osdep_handle >> h, uint32_t dom, int prot, >> - xen_pfn_t *arr, int num); >> - void *(*map_foreign_bulk)(xc_interface *xch, xc_osdep_handle h, >> uint32_t dom, int prot, >> - const xen_pfn_t *arr, int *err, >> unsigned int num); >> - void *(*map_foreign_range)(xc_interface *xch, xc_osdep_handle >> h, uint32_t dom, int size, int prot, >> - unsigned long mfn); >> - void *(*map_foreign_ranges)(xc_interface *xch, xc_osdep_handle >> h, uint32_t dom, size_t size, int prot, >> - size_t chunksize, >> privcmd_mmap_entry_t entries[], >> - int nentries); >> - } privcmd; >> - } u; >> -}; >> -typedef struct xc_osdep_ops xc_osdep_ops; >> - >> -typedef xc_osdep_ops *(*xc_osdep_init_fn)(xc_interface *xch, enum >> xc_osdep_type); >> - >> -struct xc_osdep_info >> -{ >> - /* Describes this backend. */ >> - const char *name; >> - >> - /* Returns ops function. */ >> - xc_osdep_init_fn init; >> - >> - /* True if this interface backs onto a fake Xen. */ >> - int fake; >> - >> - /* For internal use by loader. */ >> - void *dl_handle; >> -}; >> -typedef struct xc_osdep_info xc_osdep_info_t; >> - >> -/* All backends, including the builtin backend, must supply this structure. >> */ >> -extern xc_osdep_info_t xc_osdep_info; >> - >> -/* Stub for not yet converted OSes */ >> -void *xc_map_foreign_bulk_compat(xc_interface *xch, xc_osdep_handle h, >> - uint32_t dom, int prot, >> - const xen_pfn_t *arr, int *err, unsigned >> int num); >> - >> -/* Report errors through xc_interface */ >> -void xc_osdep_log(xc_interface *xch, xentoollog_level level, int code, >> - const char *fmt, ...) __attribute__((format(printf, 4, >> 5))); >> - >> -#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/xc_foreign_memory.c >> b/tools/libxc/xc_foreign_memory.c >> index 43abf01..53b6c9a 100644 >> --- a/tools/libxc/xc_foreign_memory.c >> +++ b/tools/libxc/xc_foreign_memory.c >> @@ -51,37 +51,8 @@ void *xc_map_foreign_pages(xc_interface *xch, uint32_t >> dom, int prot, >> return res; >> } >> >> -void *xc_map_foreign_range(xc_interface *xch, uint32_t dom, >> - int size, int prot, unsigned long mfn) >> -{ >> - return xch->ops->u.privcmd.map_foreign_range(xch, xch->ops_handle, >> - dom, size, prot, mfn); >> -} >> - >> -void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom, >> - size_t size, int prot, size_t chunksize, >> - privcmd_mmap_entry_t entries[], int nentries) >> -{ >> - return xch->ops->u.privcmd.map_foreign_ranges(xch, xch->ops_handle, >> - dom, size, prot, >> chunksize, entries, nentries); >> -} >> - >> -void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> -{ >> - return xch->ops->u.privcmd.map_foreign_batch(xch, xch->ops_handle, >> - dom, prot, arr, num); >> -} >> - >> -void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot, >> - const xen_pfn_t *arr, int *err, unsigned int num) >> -{ >> - return xch->ops->u.privcmd.map_foreign_bulk(xch, xch->ops_handle, >> - dom, prot, arr, err, num); >> -} >> - >> /* stub for all not yet converted OSes */ >> -void *xc_map_foreign_bulk_compat(xc_interface *xch, xc_osdep_handle h, >> +void *xc_map_foreign_bulk_compat(xc_interface *xch, >> uint32_t dom, int prot, >> const xen_pfn_t *arr, int *err, unsigned >> int num) >> { >> diff --git a/tools/libxc/xc_freebsd_osdep.c b/tools/libxc/xc_freebsd_osdep.c >> index d948b37..4c0e2fd 100644 >> --- a/tools/libxc/xc_freebsd_osdep.c >> +++ b/tools/libxc/xc_freebsd_osdep.c >> @@ -33,16 +33,12 @@ >> >> #include <xen/memory.h> >> >> -#include "xenctrl.h" >> -#include "xenctrlosdep.h" >> +#include "xc_private.h" >> >> #define PRIVCMD_DEV "/dev/xen/privcmd" >> >> -#define PERROR(_m, _a...) xc_osdep_log(xch,XTL_ERROR,XC_INTERNAL_ERROR,_m \ >> - " (%d = %s)", ## _a , errno, xc_strerror(xch, errno)) >> - >> /*------------------------- Privcmd device interface >> -------------------------*/ >> -static xc_osdep_handle freebsd_privcmd_open(xc_interface *xch) >> +int osdep_privcmd_open(xc_interface *xch) >> { >> int flags, saved_errno; >> int fd = open(PRIVCMD_DEV, O_RDWR); >> @@ -51,7 +47,7 @@ static xc_osdep_handle freebsd_privcmd_open(xc_interface >> *xch) >> { >> PERROR("Could not obtain handle on privileged command interface " >> PRIVCMD_DEV); >> - return XC_OSDEP_OPEN_ERROR; >> + return -1 >> } >> >> /* >> @@ -74,27 +70,27 @@ static xc_osdep_handle freebsd_privcmd_open(xc_interface >> *xch) >> goto error; >> } >> >> - return (xc_osdep_handle)fd; >> + xch->privcmdfd = fd; >> + return 0; >> >> error: >> saved_errno = errno; >> close(fd); >> errno = saved_errno; >> >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> -static int freebsd_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> +int osdep_privcmd_close(xc_interface *xch) >> { >> - int fd = (int)h; >> - >> + int fd = xch->privcmdfd; >> + if ( fd == -1 ) >> + return 0; >> return close(fd); >> } >> >> /*------------------------ Privcmd hypercall interface >> -----------------------*/ >> -static void *freebsd_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> - xc_osdep_handle h, >> - int npages) >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages) >> { >> size_t size = npages * XC_PAGE_SIZE; >> void *p; >> @@ -118,9 +114,7 @@ static void >> *freebsd_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> return p; >> } >> >> -static void freebsd_privcmd_free_hypercall_buffer(xc_interface *xch, >> - xc_osdep_handle h, void >> *ptr, >> - int npages) >> +void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages) >> { >> >> int saved_errno = errno; >> @@ -132,10 +126,9 @@ static void >> freebsd_privcmd_free_hypercall_buffer(xc_interface *xch, >> errno = saved_errno; >> } >> >> -static int freebsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> - privcmd_hypercall_t *hypercall) >> +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> int ret; >> >> ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); >> @@ -144,13 +137,12 @@ static int freebsd_privcmd_hypercall(xc_interface >> *xch, xc_osdep_handle h, >> } >> >> /*----------------------- Privcmd foreign map interface >> ----------------------*/ >> -static void *freebsd_privcmd_map_foreign_bulk(xc_interface *xch, >> - xc_osdep_handle h, >> - uint32_t dom, int prot, >> - const xen_pfn_t *arr, int >> *err, >> - unsigned int num) >> +void *xc_map_foreign_bulk(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, >> + unsigned int num) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmapbatch_t ioctlx; >> void *addr; >> int rc; >> @@ -181,10 +173,9 @@ static void >> *freebsd_privcmd_map_foreign_bulk(xc_interface *xch, >> return addr; >> } >> >> -static void *freebsd_privcmd_map_foreign_range(xc_interface *xch, >> - xc_osdep_handle h, >> - uint32_t dom, int size, int >> prot, >> - unsigned long mfn) >> +void *xc_map_foreign_range(xc_interface *xch, >> + uint32_t dom, int size, int prot, >> + unsigned long mfn) >> { >> xen_pfn_t *arr; >> int num; >> @@ -204,12 +195,11 @@ static void >> *freebsd_privcmd_map_foreign_range(xc_interface *xch, >> return ret; >> } >> >> -static void *freebsd_privcmd_map_foreign_ranges(xc_interface *xch, >> - xc_osdep_handle h, >> - uint32_t dom, size_t size, >> - int prot, size_t chunksize, >> - privcmd_mmap_entry_t >> entries[], >> - int nentries) >> +void *xc_map_foreign_ranges(xc_interface *xch, >> + uint32_t dom, size_t size, >> + int prot, size_t chunksize, >> + privcmd_mmap_entry_t entries[], >> + int nentries) >> { >> xen_pfn_t *arr; >> int num_per_entry; >> @@ -233,42 +223,6 @@ static void >> *freebsd_privcmd_map_foreign_ranges(xc_interface *xch, >> return ret; >> } >> >> -/*----------------------------- Privcmd handlers >> -----------------------------*/ >> -static struct xc_osdep_ops freebsd_privcmd_ops = { >> - .open = &freebsd_privcmd_open, >> - .close = &freebsd_privcmd_close, >> - >> - .u.privcmd = { >> - .alloc_hypercall_buffer = &freebsd_privcmd_alloc_hypercall_buffer, >> - .free_hypercall_buffer = &freebsd_privcmd_free_hypercall_buffer, >> - >> - .hypercall = &freebsd_privcmd_hypercall, >> - >> - .map_foreign_bulk = &freebsd_privcmd_map_foreign_bulk, >> - .map_foreign_range = &freebsd_privcmd_map_foreign_range, >> - .map_foreign_ranges = &freebsd_privcmd_map_foreign_ranges, >> - }, >> -}; >> - >> -/*---------------------------- FreeBSD interface >> -----------------------------*/ >> -static struct xc_osdep_ops * >> -freebsd_osdep_init(xc_interface *xch, enum xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - return &freebsd_privcmd_ops; >> - default: >> - return NULL; >> - } >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "FreeBSD Native OS interface", >> - .init = &freebsd_osdep_init, >> - .fake = 0, >> -}; >> - >> /* >> * Local variables: >> * mode: C >> diff --git a/tools/libxc/xc_hcall_buf.c b/tools/libxc/xc_hcall_buf.c >> index 932b47c..ab8bee5 100644 >> --- a/tools/libxc/xc_hcall_buf.c >> +++ b/tools/libxc/xc_hcall_buf.c >> @@ -123,7 +123,7 @@ void xc__hypercall_buffer_cache_release(xc_interface >> *xch) >> while ( xch->hypercall_buffer_cache_nr > 0 ) >> { >> p = xch->hypercall_buffer_cache[--xch->hypercall_buffer_cache_nr]; >> - xch->ops->u.privcmd.free_hypercall_buffer(xch, xch->ops_handle, p, >> 1); >> + osdep_free_hypercall_buffer(xch, p, 1); >> } >> >> hypercall_buffer_cache_unlock(xch); >> @@ -134,7 +134,7 @@ void *xc__hypercall_buffer_alloc_pages(xc_interface >> *xch, xc_hypercall_buffer_t >> void *p = hypercall_buffer_cache_alloc(xch, nr_pages); >> >> if ( !p ) >> - p = xch->ops->u.privcmd.alloc_hypercall_buffer(xch, >> xch->ops_handle, nr_pages); >> + p = osdep_alloc_hypercall_buffer(xch, nr_pages); >> >> if (!p) >> return NULL; >> @@ -152,7 +152,7 @@ void xc__hypercall_buffer_free_pages(xc_interface *xch, >> xc_hypercall_buffer_t *b >> return; >> >> if ( !hypercall_buffer_cache_free(xch, b->hbuf, nr_pages) ) >> - xch->ops->u.privcmd.free_hypercall_buffer(xch, xch->ops_handle, >> b->hbuf, nr_pages); >> + osdep_free_hypercall_buffer(xch, b->hbuf, nr_pages); >> } >> >> struct allocation_header { >> diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c >> index 7246b79..d17a52b 100644 >> --- a/tools/libxc/xc_linux_osdep.c >> +++ b/tools/libxc/xc_linux_osdep.c >> @@ -34,13 +34,12 @@ >> #include <xen/memory.h> >> >> #include "xenctrl.h" >> -#include "xenctrlosdep.h" >> >> #include "xc_private.h" >> >> #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & >> ~((1UL<<(_w))-1)) >> >> -static xc_osdep_handle linux_privcmd_open(xc_interface *xch) >> +int osdep_privcmd_open(xc_interface *xch) >> { >> int flags, saved_errno; >> int fd = open("/proc/xen/privcmd", O_RDWR); >> @@ -48,7 +47,7 @@ static xc_osdep_handle linux_privcmd_open(xc_interface >> *xch) >> if ( fd == -1 ) >> { >> PERROR("Could not obtain handle on privileged command interface"); >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> /* Although we return the file handle as the 'xc handle' the API >> @@ -69,22 +68,25 @@ static xc_osdep_handle linux_privcmd_open(xc_interface >> *xch) >> goto error; >> } >> >> - return (xc_osdep_handle)fd; >> + xch->privcmdfd = fd; >> + return 0; >> >> error: >> saved_errno = errno; >> close(fd); >> errno = saved_errno; >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> -static int linux_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> +int osdep_privcmd_close(xc_interface *xch) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> + if (fd == -1) >> + return 0; >> return close(fd); >> } >> >> -static void *linux_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, int npages) >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages) >> { >> size_t size = npages * XC_PAGE_SIZE; >> void *p; >> @@ -116,7 +118,7 @@ out: >> return NULL; >> } >> >> -static void linux_privcmd_free_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, void *ptr, int npages) >> +void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages) >> { >> int saved_errno = errno; >> /* Recover the VMA flags. Maybe it's not necessary */ >> @@ -127,9 +129,9 @@ static void >> linux_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_hand >> errno = saved_errno; >> } >> >> -static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall) >> +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); >> } >> >> @@ -155,11 +157,11 @@ static int xc_map_foreign_batch_single(int fd, >> uint32_t dom, >> return rc; >> } >> >> -static void *linux_privcmd_map_foreign_batch(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> +void *xc_map_foreign_batch(xc_interface *xch, >> + uint32_t dom, int prot, >> + xen_pfn_t *arr, int num) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmapbatch_t ioctlx; >> void *addr; >> int rc; >> @@ -261,11 +263,11 @@ out: >> return rc; >> } >> >> -static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - const xen_pfn_t *arr, int *err, >> unsigned int num) >> +void *xc_map_foreign_bulk(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, unsigned int num) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmapbatch_v2_t ioctlx; >> void *addr; >> unsigned int i; >> @@ -385,9 +387,9 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface >> *xch, xc_osdep_handle h >> return addr; >> } >> >> -static void *linux_privcmd_map_foreign_range(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int size, int >> prot, >> - unsigned long mfn) >> +void *xc_map_foreign_range(xc_interface *xch, >> + uint32_t dom, int size, int prot, >> + unsigned long mfn) >> { >> xen_pfn_t *arr; >> int num; >> @@ -407,10 +409,10 @@ static void >> *linux_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle >> return ret; >> } >> >> -static void *linux_privcmd_map_foreign_ranges(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, size_t size, >> int prot, >> - size_t chunksize, >> privcmd_mmap_entry_t entries[], >> - int nentries) >> +void *xc_map_foreign_ranges(xc_interface *xch, >> + uint32_t dom, size_t size, int prot, >> + size_t chunksize, privcmd_mmap_entry_t >> entries[], >> + int nentries) >> { >> xen_pfn_t *arr; >> int num_per_entry; >> @@ -434,40 +436,6 @@ static void >> *linux_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle >> return ret; >> } >> >> -static struct xc_osdep_ops linux_privcmd_ops = { >> - .open = &linux_privcmd_open, >> - .close = &linux_privcmd_close, >> - >> - .u.privcmd = { >> - .alloc_hypercall_buffer = &linux_privcmd_alloc_hypercall_buffer, >> - .free_hypercall_buffer = &linux_privcmd_free_hypercall_buffer, >> - >> - .hypercall = &linux_privcmd_hypercall, >> - >> - .map_foreign_batch = &linux_privcmd_map_foreign_batch, >> - .map_foreign_bulk = &linux_privcmd_map_foreign_bulk, >> - .map_foreign_range = &linux_privcmd_map_foreign_range, >> - .map_foreign_ranges = &linux_privcmd_map_foreign_ranges, >> - }, >> -}; >> - >> -static struct xc_osdep_ops *linux_osdep_init(xc_interface *xch, enum >> xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - return &linux_privcmd_ops; >> - default: >> - return NULL; >> - } >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "Linux Native OS interface", >> - .init = &linux_osdep_init, >> - .fake = 0, >> -}; >> - >> /* >> * Local variables: >> * mode: C >> diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c >> index 947b19a..0a2ac5c 100644 >> --- a/tools/libxc/xc_minios.c >> +++ b/tools/libxc/xc_minios.c >> @@ -40,19 +40,20 @@ void minios_interface_close_fd(int fd); >> >> extern void minios_interface_close_fd(int fd); >> >> -static xc_osdep_handle minios_privcmd_open(xc_interface *xch) >> +int osdep_privcmd_open(xc_interface *xch) >> { >> int fd = alloc_fd(FTYPE_XC); >> >> if ( fd == -1) >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> >> - return (xc_osdep_handle)fd; >> + xch->privcmdfd = fd; >> + return 0; >> } >> >> -static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> +int osdep_privcmd_close(xc_interface *xch) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> return close(fd); >> } >> >> @@ -61,17 +62,17 @@ void minios_interface_close_fd(int fd) >> files[fd].type = FTYPE_NONE; >> } >> >> -static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, int npages) >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages) >> { >> return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); >> } >> >> -static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, void *ptr, int npages) >> +void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages) >> { >> free(ptr); >> } >> >> -static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall) >> +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> { >> multicall_entry_t call; >> int i, ret; >> @@ -93,21 +94,21 @@ static int minios_privcmd_hypercall(xc_interface *xch, >> xc_osdep_handle h, privcm >> return call.result; >> } >> >> -static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - const xen_pfn_t *arr, int >> *err, unsigned int num) >> +void *xc_map_foreign_bulk(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, unsigned int num) >> { >> unsigned long pt_prot = 0; >> if (prot & PROT_READ) >> pt_prot = L1_PROT_RO; >> if (prot & PROT_WRITE) >> pt_prot = L1_PROT; >> - return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); >> + return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); >> } >> >> -static void *minios_privcmd_map_foreign_batch(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> +void *xc_map_foreign_batch(xc_interface *xch, >> + uint32_t dom, int prot, >> + xen_pfn_t *arr, int num) >> { >> unsigned long pt_prot = 0; >> int err[num]; >> @@ -127,10 +128,10 @@ static void >> *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handl >> return (void *) addr; >> } >> >> -static void *minios_privcmd_map_foreign_range(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, >> - int size, int prot, >> - unsigned long mfn) >> +void *xc_map_foreign_range(xc_interface *xch, >> + uint32_t dom, >> + int size, int prot, >> + unsigned long mfn) >> { >> unsigned long pt_prot = 0; >> >> @@ -143,10 +144,10 @@ static void >> *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle >> return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, >> pt_prot); >> } >> >> -static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, >> - size_t size, int prot, >> size_t chunksize, >> - privcmd_mmap_entry_t >> entries[], int nentries) >> +void *xc_map_foreign_ranges(xc_interface *xch, >> + uint32_t dom, >> + size_t size, int prot, size_t chunksize, >> + privcmd_mmap_entry_t entries[], int nentries) >> { >> unsigned long *mfns; >> int i, j, n; >> @@ -170,24 +171,6 @@ static void >> *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handl >> return ret; >> } >> >> - >> -static struct xc_osdep_ops minios_privcmd_ops = { >> - .open = &minios_privcmd_open, >> - .close = &minios_privcmd_close, >> - >> - .u.privcmd = { >> - .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, >> - .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, >> - >> - .hypercall = &minios_privcmd_hypercall, >> - >> - .map_foreign_batch = &minios_privcmd_map_foreign_batch, >> - .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, >> - .map_foreign_range = &minios_privcmd_map_foreign_range, >> - .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, >> - }, >> -}; >> - >> /* Optionally flush file to disk and discard page cache */ >> void discard_file_cache(xc_interface *xch, int fd, int flush) >> { >> @@ -200,23 +183,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, >> size_t size) >> return memalign(alignment, size); >> } >> >> -static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum >> xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - return &minios_privcmd_ops; >> - default: >> - return NULL; >> - } >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "Minios Native OS interface", >> - .init = &minios_osdep_init, >> - .fake = 0, >> -}; >> - >> /* >> * Local variables: >> * mode: C >> diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c >> index 48fd5d7..5361f2b 100644 >> --- a/tools/libxc/xc_netbsd.c >> +++ b/tools/libxc/xc_netbsd.c >> @@ -25,7 +25,7 @@ >> #include <malloc.h> >> #include <sys/mman.h> >> >> -static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch) >> +int osdep_privcmd_open(xc_interface *xch) >> { >> int flags, saved_errno; >> int fd = open("/kern/xen/privcmd", O_RDWR); >> @@ -33,7 +33,7 @@ static xc_osdep_handle netbsd_privcmd_open(xc_interface >> *xch) >> if ( fd == -1 ) >> { >> PERROR("Could not obtain handle on privileged command interface"); >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> /* Although we return the file handle as the 'xc handle' the API >> @@ -52,22 +52,23 @@ static xc_osdep_handle netbsd_privcmd_open(xc_interface >> *xch) >> goto error; >> } >> >> - return (xc_osdep_handle)fd; >> + xch->privcmdfd = fd; >> + return 0; >> >> error: >> saved_errno = errno; >> close(fd); >> errno = saved_errno; >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> -static int netbsd_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> +int osdep_privcmd_close(xc_interface *xch) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> return close(fd); >> } >> >> -static void *netbsd_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, int npages) >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages) >> { >> size_t size = npages * XC_PAGE_SIZE; >> void *p; >> @@ -84,15 +85,15 @@ static void >> *netbsd_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_h >> return p; >> } >> >> -static void netbsd_privcmd_free_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, void *ptr, int npages) >> +void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages) >> { >> (void) munlock(ptr, npages * XC_PAGE_SIZE); >> free(ptr); >> } >> >> -static int netbsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall) >> +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); >> >> /* >> @@ -107,11 +108,18 @@ static int netbsd_privcmd_hypercall(xc_interface *xch, >> xc_osdep_handle h, privcm >> return hypercall->retval; >> } >> >> -static void *netbsd_privcmd_map_foreign_batch(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> +void *xc_map_foreign_bulk(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, unsigned int num) >> { >> - int fd = (int)h; >> + return xc_map_foreign_bulk_compat(xch, dom, prot, arr, err, num); >> +} >> + >> +void *xc_map_foreign_batch(xc_interface *xch, >> + uint32_t dom, int prot, >> + xen_pfn_t *arr, int num) >> +{ >> + int fd = xch->privcmdfd; >> privcmd_mmapbatch_t ioctlx; >> void *addr; >> addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0); >> @@ -136,12 +144,12 @@ static void >> *netbsd_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle >> >> } >> >> -static void *netbsd_privcmd_map_foreign_range(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, >> - int size, int prot, >> - unsigned long mfn) >> +void *xc_map_foreign_range(xc_interface *xch, >> + uint32_t dom, >> + int size, int prot, >> + unsigned long mfn) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmap_t ioctlx; >> privcmd_mmap_entry_t entry; >> void *addr; >> @@ -168,12 +176,12 @@ static void >> *netbsd_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle >> return addr; >> } >> >> -static void *netbsd_privcmd_map_foreign_ranges(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, >> - size_t size, int prot, >> size_t chunksize, >> - privcmd_mmap_entry_t >> entries[], int nentries) >> +void *xc_map_foreign_ranges(xc_interface *xch, >> + uint32_t dom, >> + size_t size, int prot, size_t chunksize, >> + privcmd_mmap_entry_t entries[], int nentries) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmap_t ioctlx; >> int i, rc; >> void *addr; >> @@ -206,23 +214,6 @@ mmap_failed: >> return NULL; >> } >> >> -static struct xc_osdep_ops netbsd_privcmd_ops = { >> - .open = &netbsd_privcmd_open, >> - .close = &netbsd_privcmd_close, >> - >> - .u.privcmd = { >> - .alloc_hypercall_buffer = &netbsd_privcmd_alloc_hypercall_buffer, >> - .free_hypercall_buffer = &netbsd_privcmd_free_hypercall_buffer, >> - >> - .hypercall = &netbsd_privcmd_hypercall, >> - >> - .map_foreign_batch = &netbsd_privcmd_map_foreign_batch, >> - .map_foreign_bulk = &xc_map_foreign_bulk_compat, >> - .map_foreign_range = &netbsd_privcmd_map_foreign_range, >> - .map_foreign_ranges = &netbsd_privcmd_map_foreign_ranges, >> - }, >> -}; >> - >> /* Optionally flush file to disk and discard page cache */ >> void discard_file_cache(xc_interface *xch, int fd, int flush) >> { >> @@ -263,23 +254,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, >> size_t size) >> return valloc(size); >> } >> >> -static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum >> xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - return &netbsd_privcmd_ops; >> - default: >> - return NULL; >> - } >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "Netbsd Native OS interface", >> - .init = &netbsd_osdep_init, >> - .fake = 0, >> -}; >> - >> /* >> * Local variables: >> * mode: C >> diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c >> index e411210..c56d748 100644 >> --- a/tools/libxc/xc_private.c >> +++ b/tools/libxc/xc_private.c >> @@ -27,111 +27,12 @@ >> #include <pthread.h> >> #include <assert.h> >> >> -#ifndef __MINIOS__ >> -#include <dlfcn.h> >> -#endif >> - >> -#define XENCTRL_OSDEP "XENCTRL_OSDEP" >> - >> -#if !defined (__MINIOS__) && !defined(__RUMPUSER_XEN__) && >> !defined(__RUMPRUN__) >> -#define DO_DYNAMIC_OSDEP >> -#endif >> - >> -/* >> - * Returns a (shallow) copy of the xc_osdep_info_t for the >> - * active OS interface. >> - * >> - * On success a handle to the relevant library is opened. The user >> - * must subsequently call xc_osdep_put_info() when it is >> - * finished with the library. >> - * >> - * Logs IFF xch != NULL. >> - * >> - * Returns: >> - * 0 - on success >> - * -1 - on error >> - */ >> -static int xc_osdep_get_info(xc_interface *xch, xc_osdep_info_t *info) >> -{ >> - int rc = -1; >> -#ifdef DO_DYNAMIC_OSDEP >> - const char *lib = getenv(XENCTRL_OSDEP); >> - xc_osdep_info_t *pinfo; >> - void *dl_handle = NULL; >> - >> - if ( lib != NULL ) >> - { >> - if ( getuid() != geteuid() ) >> - { >> - if ( xch ) ERROR("cannot use %s=%s with setuid application", >> XENCTRL_OSDEP, lib); >> - abort(); >> - } >> - if ( getgid() != getegid() ) >> - { >> - if ( xch ) ERROR("cannot use %s=%s with setgid application", >> XENCTRL_OSDEP, lib); >> - abort(); >> - } >> - >> - dl_handle = dlopen(lib, RTLD_LAZY|RTLD_LOCAL); >> - if ( !dl_handle ) >> - { >> - if ( xch ) ERROR("unable to open osdep library %s: %s", lib, >> dlerror()); >> - goto out; >> - } >> - >> - pinfo = dlsym(dl_handle, "xc_osdep_info"); >> - if ( !pinfo ) >> - { >> - if ( xch ) ERROR("unable to find xc_osinteface_info in %s: %s", >> lib, dlerror()); >> - goto out; >> - } >> - >> - *info = *pinfo; >> - info->dl_handle = dl_handle; >> - } >> - else >> -#endif /*DO_DYNAMIC_OSDEP*/ >> - { >> - *info = xc_osdep_info; >> - info->dl_handle = NULL; >> - } >> - >> - rc = 0; >> - >> -#ifdef DO_DYNAMIC_OSDEP >> -out: >> - if ( dl_handle && rc == -1 ) >> - dlclose(dl_handle); >> -#endif /*DO_DYNAMIC_OSDEP*/ >> - >> - return rc; >> -} >> - >> -static void xc_osdep_put(xc_osdep_info_t *info) >> -{ >> -#ifdef DO_DYNAMIC_OSDEP >> - if ( info->dl_handle ) >> - dlclose(info->dl_handle); >> -#endif /*DO_DYNAMIC_OSDEP*/ >> -} >> - >> -static const char *xc_osdep_type_name(enum xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: return "privcmd"; >> - } >> - return "unknown"; >> -} >> - >> -static struct xc_interface_core *xc_interface_open_common(xentoollog_logger >> *logger, >> - xentoollog_logger >> *dombuild_logger, >> - unsigned >> open_flags, >> - enum >> xc_osdep_type type) >> +struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, >> + xentoollog_logger >> *dombuild_logger, >> + unsigned open_flags) >> { >> struct xc_interface_core xch_buf, *xch = &xch_buf; >> >> - xch->type = type; >> xch->flags = open_flags; >> xch->dombuild_logger_file = 0; >> xc_clear_last_error(xch); >> @@ -149,9 +50,6 @@ static struct xc_interface_core >> *xc_interface_open_common(xentoollog_logger *log >> xch->hypercall_buffer_cache_misses = 0; >> xch->hypercall_buffer_cache_toobig = 0; >> >> - xch->ops_handle = XC_OSDEP_OPEN_ERROR; >> - xch->ops = NULL; >> - >> if (!xch->error_handler) { >> xch->error_handler = xch->error_handler_tofree = >> (xentoollog_logger*) >> @@ -169,40 +67,26 @@ static struct xc_interface_core >> *xc_interface_open_common(xentoollog_logger *log >> *xch = xch_buf; >> >> if (!(open_flags & XC_OPENFLAG_DUMMY)) { >> - if ( xc_osdep_get_info(xch, &xch->osdep) < 0 ) >> + if ( osdep_privcmd_open(xch) < 0 ) >> goto err; >> - >> - xch->ops = xch->osdep.init(xch, type); >> - if ( xch->ops == NULL ) >> - { >> - DPRINTF("OSDEP: interface %d (%s) not supported on this >> platform", >> - type, xc_osdep_type_name(type)); >> - goto err_put_iface; >> - } >> - >> - xch->ops_handle = xch->ops->open(xch); >> - if (xch->ops_handle == XC_OSDEP_OPEN_ERROR) >> - goto err_put_iface; >> } >> >> return xch; >> >> -err_put_iface: >> - xc_osdep_put(&xch->osdep); >> err: >> xtl_logger_destroy(xch->error_handler_tofree); >> if (xch != &xch_buf) free(xch); >> return NULL; >> } >> >> -static int xc_interface_close_common(xc_interface *xch) >> +int xc_interface_close(xc_interface *xch) >> { >> int rc = 0; >> >> if (!xch) >> - return 0; >> + return 0; >> >> - rc = xch->ops->close(xch, xch->ops_handle); >> + rc = osdep_privcmd_close(xch); >> if (rc) PERROR("Could not close hypervisor interface"); >> >> xc__hypercall_buffer_cache_release(xch); >> @@ -214,42 +98,6 @@ static int xc_interface_close_common(xc_interface *xch) >> return rc; >> } >> >> -int xc_interface_is_fake(void) >> -{ >> - xc_osdep_info_t info; >> - >> - if ( xc_osdep_get_info(NULL, &info) < 0 ) >> - return -1; >> - >> - /* Have a copy of info so can release the interface now. */ >> - xc_osdep_put(&info); >> - >> - return info.fake; >> -} >> - >> -xc_interface *xc_interface_open(xentoollog_logger *logger, >> - xentoollog_logger *dombuild_logger, >> - unsigned open_flags) >> -{ >> - xc_interface *xch; >> - >> - xch = xc_interface_open_common(logger, dombuild_logger, open_flags, >> - XC_OSDEP_PRIVCMD); >> - >> - return xch; >> -} >> - >> -int xc_interface_close(xc_interface *xch) >> -{ >> - return xc_interface_close_common(xch); >> -} >> - >> - >> -int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> -{ >> - return xch->ops->u.privcmd.hypercall(xch, xch->ops_handle, hypercall); >> -} >> - >> static pthread_key_t errbuf_pkey; >> static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT; >> >> @@ -336,14 +184,6 @@ void xc_report_error(xc_interface *xch, int code, const >> char *fmt, ...) >> va_end(args); >> } >> >> -void xc_osdep_log(xc_interface *xch, xentoollog_level level, int code, >> const char *fmt, ...) >> -{ >> - va_list args; >> - va_start(args, fmt); >> - xc_reportv(xch, xch->error_handler, level, code, fmt, args); >> - va_end(args); >> -} >> - >> const char *xc_set_progress_prefix(xc_interface *xch, const char *doing) >> { >> const char *old = xch->currently_progress_reporting; >> diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h >> index 61f2f45..408b1be 100644 >> --- a/tools/libxc/xc_private.h >> +++ b/tools/libxc/xc_private.h >> @@ -31,7 +31,6 @@ >> >> #include "_paths.h" >> #include "xenctrl.h" >> -#include "xenctrlosdep.h" >> >> #include <xen/sys/privcmd.h> >> >> @@ -89,7 +88,6 @@ struct iovec { >> #define MAX_PAGECACHE_USAGE (4*1024) >> >> struct xc_interface_core { >> - enum xc_osdep_type type; >> int flags; >> xentoollog_logger *error_handler, *error_handler_tofree; >> xentoollog_logger *dombuild_logger, *dombuild_logger_tofree; >> @@ -118,12 +116,21 @@ struct xc_interface_core { >> int hypercall_buffer_cache_misses; >> int hypercall_buffer_cache_toobig; >> >> - /* Low lovel OS interface */ >> - xc_osdep_info_t osdep; >> - xc_osdep_ops *ops; /* backend operations */ >> - xc_osdep_handle ops_handle; /* opaque data for xc_osdep_ops */ >> + /* Privcmd interface */ >> + int privcmdfd; >> }; >> >> +int osdep_privcmd_open(xc_interface *xch); >> +int osdep_privcmd_close(xc_interface *xch); >> + >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages); >> +void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages); >> + >> +/* Stub for not yet converted OSes */ >> +void *xc_map_foreign_bulk_compat(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, unsigned >> int num); >> + >> void xc_report_error(xc_interface *xch, int code, const char *fmt, ...) >> __attribute__((format(printf,3,4))); >> void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, >> diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c >> index 182bd7d..d719a11 100644 >> --- a/tools/libxc/xc_solaris.c >> +++ b/tools/libxc/xc_solaris.c >> @@ -25,7 +25,7 @@ >> #include <fcntl.h> >> #include <malloc.h> >> >> -static xc_osdep_handle solaris_privcmd_open(xc_interface *xch) >> +int osdep_privcmd_open(xc_interface *xch) >> { >> int flags, saved_errno; >> int fd = open("/dev/xen/privcmd", O_RDWR); >> @@ -33,7 +33,7 @@ static xc_osdep_handle solaris_privcmd_open(xc_interface >> *xch) >> if ( fd == -1 ) >> { >> PERROR("Could not obtain handle on privileged command interface"); >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> /* Although we return the file handle as the 'xc handle' the API >> @@ -52,42 +52,43 @@ static xc_osdep_handle solaris_privcmd_open(xc_interface >> *xch) >> goto error; >> } >> >> - return (xc_osdep_handle)fd; >> + xch->privcmdfd = fd; >> + return 0; >> >> error: >> saved_errno = errno; >> close(fd); >> errno = saved_errno; >> - return XC_OSDEP_OPEN_ERROR; >> + return -1; >> } >> >> -static int solaris_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> +int osdep_privcmd_close(xc_interface *xch) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> return close(fd); >> } >> >> -static void *solaris_privcmd_alloc_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, int npages) >> +void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages) >> { >> return xc_memalign(xch, XC_PAGE_SIZE, npages * XC_PAGE_SIZE); >> } >> >> -static void solaris_privcmd_free_hypercall_buffer(xc_interface *xch, >> xc_osdep_handle h, void *ptr, int npages) >> +static void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int >> npages) >> { >> free(ptr); >> } >> >> -static int solaris_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall) >> +int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); >> } >> >> -static void *solaris_privcmd_map_foreign_batch(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> +void *xc_map_foreign_batch(xc_interface *xch, >> + uint32_t dom, int prot, >> + xen_pfn_t *arr, int num) >> { >> - int fd = (int)h; >> + int fd = xch->privcmdfd; >> privcmd_mmapbatch_t ioctlx; >> void *addr; >> addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_SHARED, fd, 0); >> @@ -110,12 +111,19 @@ static void >> *solaris_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handl >> >> } >> >> -static void *xc_map_foreign_range(xc_interface *xch, xc_osdep_handle h, >> - uint32_t dom, >> - int size, int prot, >> - unsigned long mfn) >> +void *xc_map_foreign_bulk(xc_interface *xch, >> + uint32_t dom, int prot, >> + const xen_pfn_t *arr, int *err, unsigned int num) >> { >> - int fd = (int)fd; >> + return xc_map_foreign_bulk_compat(xch, dom, prot, arr, err, num); >> +} >> + >> +void *xc_map_foreign_range(xc_interface *xch, >> + uint32_t dom, >> + int size, int prot, >> + unsigned long mfn) >> +{ >> + int fd = xch->privcmdfd; >> privcmd_mmap_t ioctlx; >> privcmd_mmap_entry_t entry; >> void *addr; >> @@ -139,12 +147,12 @@ static void *xc_map_foreign_range(xc_interface *xch, >> xc_osdep_handle h, >> return addr; >> } >> >> -static void *solaric_privcmd_map_foreign_ranges(xc_interface *xch, >> xc_osdep_handle h, >> - uint32_t dom, >> - size_t size, int prot, >> size_t chunksize, >> - privcmd_mmap_entry_t >> entries[], int nentries) >> +void *xc_map_foreign_ranges(xc_interface *xch, >> + uint32_t dom, >> + size_t size, int prot, size_t chunksize, >> + privcmd_mmap_entry_t entries[], int nentries) >> { >> - int fd = (int)fd; >> + int fd = xch->privcmdfd; >> privcmd_mmap_t ioctlx; >> int i, rc; >> void *addr; >> @@ -177,23 +185,6 @@ mmap_failed: >> return NULL; >> } >> >> -static struct xc_osdep_ops solaris_privcmd_ops = { >> - .open = &solaris_privcmd_open, >> - .close = &solaris_privcmd_close, >> - >> - .u.privcmd = { >> - .alloc_hypercall_buffer = &solaris_privcmd_alloc_hypercall_buffer, >> - .free_hypercall_buffer = &solaris_privcmd_free_hypercall_buffer, >> - >> - .hypercall = &solaris_privcmd_hypercall; >> - >> - .map_foreign_batch = &solaris_privcmd_map_foreign_batch, >> - .map_foreign_bulk = &xc_map_foreign_bulk_compat, >> - .map_foreign_range = &solaris_privcmd_map_foreign_range, >> - .map_foreign_ranges = &solaris_privcmd_map_foreign_ranges, >> - }, >> -}; >> - >> /* Optionally flush file to disk and discard page cache */ >> void discard_file_cache(xc_interface *xch, int fd, int flush) >> { >> @@ -205,23 +196,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, >> size_t size) >> return memalign(alignment, size); >> } >> >> -static struct xc_osdep_ops *solaris_osdep_init(xc_interface *xch, enum >> xc_osdep_type type) >> -{ >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - return &solaris_privcmd_ops; >> - default: >> - return NULL; >> - } >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "Solaris Native OS interface", >> - .init = &solaris_osdep_init, >> - .fake = 0, >> -}; >> - >> /* >> * Local variables: >> * mode: C >> diff --git a/tools/libxc/xenctrl_osdep_ENOSYS.c >> b/tools/libxc/xenctrl_osdep_ENOSYS.c >> deleted file mode 100644 >> index 5182532..0000000 >> --- a/tools/libxc/xenctrl_osdep_ENOSYS.c >> +++ /dev/null >> @@ -1,123 +0,0 @@ >> -/* Dummy backend which just logs and returns ENOSYS. */ >> - >> -#include <errno.h> >> -#include <inttypes.h> >> -#include <stdlib.h> >> - >> -#include "xenctrl.h" >> -#include "xenctrlosdep.h" >> - >> -#define IPRINTF(_x, _f, _a...) xc_osdep_log(_x,XTL_INFO,0, _f , ## _a) >> - >> -#define ERROR(_x, _m, _a...) >> xc_osdep_log(_x,XTL_ERROR,XC_INTERNAL_ERROR,_m , ## _a ) >> -#define PERROR(_x, _m, _a...) >> xc_osdep_log(_x,XTL_ERROR,XC_INTERNAL_ERROR,_m \ >> - " (%d = %s)", ## _a , errno, xc_strerror(xch, errno)) >> - >> -static xc_osdep_handle ENOSYS_privcmd_open(xc_interface *xch) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd: opening handle %d\n", 1); >> - return (xc_osdep_handle)1; /*dummy*/ >> -} >> - >> -static int ENOSYS_privcmd_close(xc_interface *xch, xc_osdep_handle h) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd: closing handle %lx\n", h); >> - return 0; >> -} >> - >> -static int ENOSYS_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, >> privcmd_hypercall_t *hypercall) >> -{ >> -#if defined(__FreeBSD__) || defined(__NetBSD__) >> - IPRINTF(xch, "ENOSYS_privcmd %lx: hypercall: >> %02lu(%#lx,%#lx,%#lx,%#lx,%#lx)\n", >> -#else >> - IPRINTF(xch, "ENOSYS_privcmd %lx: hypercall: >> %02lld(%#llx,%#llx,%#llx,%#llx,%#llx)\n", >> -#endif >> - h, hypercall->op, >> - hypercall->arg[0], hypercall->arg[1], hypercall->arg[2], >> - hypercall->arg[3], hypercall->arg[4]); >> - return -ENOSYS; >> -} >> - >> -static void *ENOSYS_privcmd_map_foreign_batch(xc_interface *xch, >> xc_osdep_handle h, uint32_t dom, int prot, >> - xen_pfn_t *arr, int num) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd %lx: map_foreign_batch: dom%d prot %#x arr >> %p num %d\n", h, dom, prot, arr, num); >> - return MAP_FAILED; >> -} >> - >> -static void *ENOSYS_privcmd_map_foreign_bulk(xc_interface *xch, >> xc_osdep_handle h, uint32_t dom, int prot, >> - const xen_pfn_t *arr, int *err, >> unsigned int num) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd %lx map_foreign_buld: dom%d prot %#x arr >> %p err %p num %d\n", h, dom, prot, arr, err, num); >> - return MAP_FAILED; >> -} >> - >> -static void *ENOSYS_privcmd_map_foreign_range(xc_interface *xch, >> xc_osdep_handle h, uint32_t dom, int size, int prot, >> - unsigned long mfn) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd %lx map_foreign_range: dom%d size %#x prot >> %#x mfn %ld\n", h, dom, size, prot, mfn); >> - return MAP_FAILED; >> -} >> - >> -static void *ENOSYS_privcmd_map_foreign_ranges(xc_interface *xch, >> xc_osdep_handle h, uint32_t dom, size_t size, int prot, >> - size_t chunksize, >> privcmd_mmap_entry_t entries[], >> - int nentries) >> -{ >> - IPRINTF(xch, "ENOSYS_privcmd %lx map_foreign_ranges: dom%d size %zd >> prot %#x chunksize %zd entries %p num %d\n", h, dom, size, prot, chunksize, >> entries, nentries); >> - return MAP_FAILED; >> -} >> - >> -static struct xc_osdep_ops ENOSYS_privcmd_ops = >> -{ >> - .open = &ENOSYS_privcmd_open, >> - .close = &ENOSYS_privcmd_close, >> - .u.privcmd = { >> - .hypercall = &ENOSYS_privcmd_hypercall, >> - >> - .map_foreign_batch = &ENOSYS_privcmd_map_foreign_batch, >> - .map_foreign_bulk = &ENOSYS_privcmd_map_foreign_bulk, >> - .map_foreign_range = &ENOSYS_privcmd_map_foreign_range, >> - .map_foreign_ranges = &ENOSYS_privcmd_map_foreign_ranges, >> - } >> -}; >> - >> -static struct xc_osdep_ops * ENOSYS_osdep_init(xc_interface *xch, enum >> xc_osdep_type type) >> -{ >> - struct xc_osdep_ops *ops; >> - >> - if (getenv("ENOSYS") == NULL) >> - { >> - PERROR(xch, "ENOSYS: not configured\n"); >> - return NULL; >> - } >> - >> - switch ( type ) >> - { >> - case XC_OSDEP_PRIVCMD: >> - ops = &ENOSYS_privcmd_ops; >> - break; >> - default: >> - ops = NULL; >> - break; >> - } >> - >> - IPRINTF(xch, "ENOSYS_osdep_init: initialising handle ops at %p\n", ops); >> - >> - return ops; >> -} >> - >> -xc_osdep_info_t xc_osdep_info = { >> - .name = "Pessimistic ENOSYS OS interface", >> - .init = &ENOSYS_osdep_init, >> - .fake = 1, >> -}; >> - >> -/* >> - * Local variables: >> - * mode: C >> - * c-file-style: "BSD" >> - * c-basic-offset: 4 >> - * tab-width: 4 >> - * indent-tabs-mode: nil >> - * End: >> - */ >> diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml >> index b7ba8b7..701b66c 100644 >> --- a/tools/ocaml/libs/xc/xenctrl.ml >> +++ b/tools/ocaml/libs/xc/xenctrl.ml >> @@ -108,8 +108,6 @@ external sizeof_xen_pfn: unit -> int = >> "stub_sizeof_xen_pfn" >> external interface_open: unit -> handle = "stub_xc_interface_open" >> external interface_close: handle -> unit = "stub_xc_interface_close" >> >> -external is_fake: unit -> bool = "stub_xc_interface_is_fake" >> - >> let with_intf f = >> let xc = interface_open () in >> let r = try f xc with exn -> interface_close xc; raise exn in >> diff --git a/tools/ocaml/libs/xc/xenctrl.mli >> b/tools/ocaml/libs/xc/xenctrl.mli >> index bc4af56..3f4947c 100644 >> --- a/tools/ocaml/libs/xc/xenctrl.mli >> +++ b/tools/ocaml/libs/xc/xenctrl.mli >> @@ -72,7 +72,6 @@ external sizeof_vcpu_guest_context : unit -> int >> = "stub_sizeof_vcpu_guest_context" >> external sizeof_xen_pfn : unit -> int = "stub_sizeof_xen_pfn" >> external interface_open : unit -> handle = "stub_xc_interface_open" >> -external is_fake : unit -> bool = "stub_xc_interface_is_fake" >> external interface_close : handle -> unit = "stub_xc_interface_close" >> val with_intf : (handle -> 'a) -> 'a >> val domain_create : handle -> int32 -> domain_create_flag list -> string -> >> domid >> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c >> b/tools/ocaml/libs/xc/xenctrl_stubs.c >> index 64f1137..9a201ee 100644 >> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c >> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c >> @@ -126,13 +126,6 @@ CAMLprim value stub_xc_interface_open(void) >> } >> >> >> -CAMLprim value stub_xc_interface_is_fake(void) >> -{ >> - CAMLparam0(); >> - int is_fake = xc_interface_is_fake(); >> - CAMLreturn(Val_int(is_fake)); >> -} >> - >> CAMLprim value stub_xc_interface_close(value xch) >> { >> CAMLparam1(xch); >> diff --git a/tools/ocaml/xenstored/domains.ml >> b/tools/ocaml/xenstored/domains.ml >> index 92e438f..395f3a9 100644 >> --- a/tools/ocaml/xenstored/domains.ml >> +++ b/tools/ocaml/xenstored/domains.ml >> @@ -65,11 +65,9 @@ let create xc doms domid mfn port = >> Domain.bind_interdomain dom; >> dom >> >> -let create0 fake doms = >> +let create0 doms = >> let port, interface = >> - if fake then ( >> - 0, Xenctrl.with_intf (fun xc -> Xenctrl.map_foreign_range xc 0 >> (Xenmmap.getpagesize()) 0n) >> - ) else ( >> + ( >> let port = Utils.read_file_single_integer >> Define.xenstored_proc_port >> and fd = Unix.openfile Define.xenstored_proc_kva >> [ Unix.O_RDWR ] 0o600 in >> diff --git a/tools/ocaml/xenstored/xenstored.ml >> b/tools/ocaml/xenstored/xenstored.ml >> index bfe689b..5c7ace1 100644 >> --- a/tools/ocaml/xenstored/xenstored.ml >> +++ b/tools/ocaml/xenstored/xenstored.ml >> @@ -176,7 +176,7 @@ let from_channel store cons doms chan = >> if domid > 0 then >> Domains.create xc doms domid mfn port >> else >> - Domains.create0 false doms >> + Domains.create0 doms >> in >> Connections.add_domain cons ndom; >> in >> @@ -278,8 +278,7 @@ let _ = >> Store.mkdir store (Perms.Connection.create 0) localpath; >> >> if cf.domain_init then ( >> - let usingxiu = Xenctrl.is_fake () in >> - Connections.add_domain cons (Domains.create0 usingxiu domains); >> + Connections.add_domain cons (Domains.create0 domains); >> Event.bind_dom_exc_virq eventchn >> ); >> ); >> -- >> 2.1.4 >> _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |