mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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. 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@citrix.com> Acked-by: David Scott <dave.scott@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
1 parent
a71ad0fead
commit
7a3543df83
23 files changed
+178
-823
No files matched your search
@@ -1,6 +1,4 @@
|
|||||||
include $(XEN_ROOT)/config/StdGNU.mk
|
include $(XEN_ROOT)/config/StdGNU.mk
|
||||||
|
|
||||||
DLOPEN_LIBS =
|
|
||||||
|
|
||||||
# No wget on FreeBSD base system
|
# No wget on FreeBSD base system
|
||||||
WGET = ftp
|
WGET = ftp
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
include $(XEN_ROOT)/config/StdGNU.mk
|
include $(XEN_ROOT)/config/StdGNU.mk
|
||||||
|
|
||||||
# Override settings for this OS
|
|
||||||
DLOPEN_LIBS =
|
|
||||||
|
|
||||||
WGET = ftp
|
WGET = ftp
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
include $(XEN_ROOT)/config/StdGNU.mk
|
include $(XEN_ROOT)/config/StdGNU.mk
|
||||||
|
|
||||||
DLOPEN_LIBS =
|
|
||||||
PTHREAD_LIBS =
|
PTHREAD_LIBS =
|
||||||
|
|
||||||
WGET = ftp
|
WGET = ftp
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ DEBUG_DIR ?= /usr/lib/debug
|
|||||||
|
|
||||||
SOCKET_LIBS =
|
SOCKET_LIBS =
|
||||||
UTIL_LIBS = -lutil
|
UTIL_LIBS = -lutil
|
||||||
DLOPEN_LIBS = -ldl
|
|
||||||
|
|
||||||
SONAME_LDFLAG = -soname
|
SONAME_LDFLAG = -soname
|
||||||
SHLIB_LDFLAGS = -shared
|
SHLIB_LDFLAGS = -shared
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64
|
|||||||
SOCKET_LIBS = -lsocket
|
SOCKET_LIBS = -lsocket
|
||||||
PTHREAD_LIBS = -lpthread
|
PTHREAD_LIBS = -lpthread
|
||||||
UTIL_LIBS =
|
UTIL_LIBS =
|
||||||
DLOPEN_LIBS = -ldl
|
|
||||||
|
|
||||||
SONAME_LDFLAG = -h
|
SONAME_LDFLAG = -h
|
||||||
SHLIB_LDFLAGS = -R $(SunOS_LIBDIR) -shared
|
SHLIB_LDFLAGS = -R $(SunOS_LIBDIR) -shared
|
||||||
|
|||||||
+7
-20
@@ -101,8 +101,6 @@ GUEST_SRCS-y += xc_dom_decompress_unsafe_lzo1x.c
|
|||||||
GUEST_SRCS-y += xc_dom_decompress_unsafe_xz.c
|
GUEST_SRCS-y += xc_dom_decompress_unsafe_xz.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OSDEP_SRCS-y += xenctrl_osdep_ENOSYS.c
|
|
||||||
|
|
||||||
-include $(XEN_TARGET_ARCH)/Makefile
|
-include $(XEN_TARGET_ARCH)/Makefile
|
||||||
|
|
||||||
CFLAGS += -Werror -Wmissing-prototypes
|
CFLAGS += -Werror -Wmissing-prototypes
|
||||||
@@ -121,11 +119,8 @@ CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
|
|||||||
GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y))
|
GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y))
|
||||||
GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y))
|
GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y))
|
||||||
|
|
||||||
OSDEP_LIB_OBJS := $(patsubst %.c,%.o,$(OSDEP_SRCS-y))
|
$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
|
||||||
OSDEP_PIC_OBJS := $(patsubst %.c,%.opic,$(OSDEP_SRCS-y))
|
$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
|
||||||
|
|
||||||
$(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) $(CTRL_PIC_OBJS): CFLAGS += $(CFLAGS_libxengnttab) $(CFLAGS_libxengntshr)
|
$(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS): CFLAGS += $(CFLAGS_libxengnttab) $(CFLAGS_libxengntshr)
|
||||||
|
|
||||||
@@ -139,17 +134,13 @@ ifneq ($(nosharedlibs),y)
|
|||||||
LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR)
|
LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(nosharedlibs),y)
|
|
||||||
LIB += xenctrl_osdep_ENOSYS.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
genpath-target = $(call buildmakevars2header,_paths.h)
|
genpath-target = $(call buildmakevars2header,_paths.h)
|
||||||
$(eval $(genpath-target))
|
$(eval $(genpath-target))
|
||||||
|
|
||||||
xc_private.h: _paths.h
|
xc_private.h: _paths.h
|
||||||
|
|
||||||
$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) $(OSDEP_LIB_OBJS) \
|
$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
|
||||||
$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS) $(OSDEP_PIC_OBJS): xc_private.h
|
$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build
|
all: build
|
||||||
@@ -169,7 +160,7 @@ install: build
|
|||||||
$(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)
|
$(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)
|
||||||
$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
|
$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
|
||||||
$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so
|
$(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_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
|
||||||
$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
|
$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
|
||||||
$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
|
$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
|
||||||
@@ -185,8 +176,7 @@ clean:
|
|||||||
rm -rf *.rpm $(LIB) *~ $(DEPS) \
|
rm -rf *.rpm $(LIB) *~ $(DEPS) \
|
||||||
_paths.h \
|
_paths.h \
|
||||||
$(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \
|
$(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \
|
||||||
$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS) \
|
$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS)
|
||||||
$(OSDEP_LIB_OBJS) $(OSDEP_PIC_OBJS)
|
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
@@ -212,7 +202,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)
|
|||||||
$(SYMLINK_SHLIB) $< $@
|
$(SYMLINK_SHLIB) $< $@
|
||||||
|
|
||||||
libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
|
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
|
# libxenguest
|
||||||
|
|
||||||
@@ -237,8 +227,5 @@ libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(call zlib-options,l)
|
|||||||
libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
|
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)
|
$(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)
|
-include $(DEPS)
|
||||||
|
|
||||||
@@ -181,15 +181,6 @@ enum xc_open_flags {
|
|||||||
*/
|
*/
|
||||||
int xc_interface_close(xc_interface *xch);
|
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
|
* HYPERCALL SAFE MEMORY BUFFER
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,133 +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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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:
|
|
||||||
*/
|
|
||||||
@@ -50,37 +50,8 @@ void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
|
|||||||
return res;
|
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 */
|
/* 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,
|
uint32_t dom, int prot,
|
||||||
const xen_pfn_t *arr, int *err, unsigned int num)
|
const xen_pfn_t *arr, int *err, unsigned int num)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,16 +32,12 @@
|
|||||||
|
|
||||||
#include <xen/memory.h>
|
#include <xen/memory.h>
|
||||||
|
|
||||||
#include "xenctrl.h"
|
#include "xc_private.h"
|
||||||
#include "xenctrlosdep.h"
|
|
||||||
|
|
||||||
#define PRIVCMD_DEV "/dev/xen/privcmd"
|
#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 -------------------------*/
|
/*------------------------- 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 flags, saved_errno;
|
||||||
int fd = open(PRIVCMD_DEV, O_RDWR);
|
int fd = open(PRIVCMD_DEV, O_RDWR);
|
||||||
@@ -50,7 +46,7 @@ static xc_osdep_handle freebsd_privcmd_open(xc_interface *xch)
|
|||||||
{
|
{
|
||||||
PERROR("Could not obtain handle on privileged command interface "
|
PERROR("Could not obtain handle on privileged command interface "
|
||||||
PRIVCMD_DEV);
|
PRIVCMD_DEV);
|
||||||
return XC_OSDEP_OPEN_ERROR;
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -73,27 +69,27 @@ static xc_osdep_handle freebsd_privcmd_open(xc_interface *xch)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (xc_osdep_handle)fd;
|
xch->privcmdfd = fd;
|
||||||
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = saved_errno;
|
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);
|
return close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------ Privcmd hypercall interface -----------------------*/
|
/*------------------------ Privcmd hypercall interface -----------------------*/
|
||||||
static void *freebsd_privcmd_alloc_hypercall_buffer(xc_interface *xch,
|
void *osdep_alloc_hypercall_buffer(xc_interface *xch, int npages)
|
||||||
xc_osdep_handle h,
|
|
||||||
int npages)
|
|
||||||
{
|
{
|
||||||
size_t size = npages * XC_PAGE_SIZE;
|
size_t size = npages * XC_PAGE_SIZE;
|
||||||
void *p;
|
void *p;
|
||||||
@@ -117,9 +113,7 @@ static void *freebsd_privcmd_alloc_hypercall_buffer(xc_interface *xch,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freebsd_privcmd_free_hypercall_buffer(xc_interface *xch,
|
void osdep_free_hypercall_buffer(xc_interface *xch, void *ptr, int npages)
|
||||||
xc_osdep_handle h, void *ptr,
|
|
||||||
int npages)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
@@ -131,10 +125,9 @@ static void freebsd_privcmd_free_hypercall_buffer(xc_interface *xch,
|
|||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int freebsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h,
|
int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
|
||||||
privcmd_hypercall_t *hypercall)
|
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||||
@@ -143,13 +136,12 @@ static int freebsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------- Privcmd foreign map interface ----------------------*/
|
/*----------------------- Privcmd foreign map interface ----------------------*/
|
||||||
static void *freebsd_privcmd_map_foreign_bulk(xc_interface *xch,
|
void *xc_map_foreign_bulk(xc_interface *xch,
|
||||||
xc_osdep_handle h,
|
uint32_t dom, int prot,
|
||||||
uint32_t dom, int prot,
|
const xen_pfn_t *arr, int *err,
|
||||||
const xen_pfn_t *arr, int *err,
|
unsigned int num)
|
||||||
unsigned int num)
|
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmapbatch_t ioctlx;
|
privcmd_mmapbatch_t ioctlx;
|
||||||
void *addr;
|
void *addr;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -180,10 +172,9 @@ static void *freebsd_privcmd_map_foreign_bulk(xc_interface *xch,
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *freebsd_privcmd_map_foreign_range(xc_interface *xch,
|
void *xc_map_foreign_range(xc_interface *xch,
|
||||||
xc_osdep_handle h,
|
uint32_t dom, int size, int prot,
|
||||||
uint32_t dom, int size, int prot,
|
unsigned long mfn)
|
||||||
unsigned long mfn)
|
|
||||||
{
|
{
|
||||||
xen_pfn_t *arr;
|
xen_pfn_t *arr;
|
||||||
int num;
|
int num;
|
||||||
@@ -203,12 +194,11 @@ static void *freebsd_privcmd_map_foreign_range(xc_interface *xch,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *freebsd_privcmd_map_foreign_ranges(xc_interface *xch,
|
void *xc_map_foreign_ranges(xc_interface *xch,
|
||||||
xc_osdep_handle h,
|
uint32_t dom, size_t size,
|
||||||
uint32_t dom, size_t size,
|
int prot, size_t chunksize,
|
||||||
int prot, size_t chunksize,
|
privcmd_mmap_entry_t entries[],
|
||||||
privcmd_mmap_entry_t entries[],
|
int nentries)
|
||||||
int nentries)
|
|
||||||
{
|
{
|
||||||
xen_pfn_t *arr;
|
xen_pfn_t *arr;
|
||||||
int num_per_entry;
|
int num_per_entry;
|
||||||
@@ -232,42 +222,6 @@ static void *freebsd_privcmd_map_foreign_ranges(xc_interface *xch,
|
|||||||
return ret;
|
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:
|
* Local variables:
|
||||||
* mode: C
|
* mode: C
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void xc__hypercall_buffer_cache_release(xc_interface *xch)
|
|||||||
while ( xch->hypercall_buffer_cache_nr > 0 )
|
while ( xch->hypercall_buffer_cache_nr > 0 )
|
||||||
{
|
{
|
||||||
p = xch->hypercall_buffer_cache[--xch->hypercall_buffer_cache_nr];
|
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);
|
hypercall_buffer_cache_unlock(xch);
|
||||||
@@ -133,7 +133,7 @@ void *xc__hypercall_buffer_alloc_pages(xc_interface *xch, xc_hypercall_buffer_t
|
|||||||
void *p = hypercall_buffer_cache_alloc(xch, nr_pages);
|
void *p = hypercall_buffer_cache_alloc(xch, nr_pages);
|
||||||
|
|
||||||
if ( !p )
|
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)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -151,7 +151,7 @@ void xc__hypercall_buffer_free_pages(xc_interface *xch, xc_hypercall_buffer_t *b
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !hypercall_buffer_cache_free(xch, b->hbuf, nr_pages) )
|
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 {
|
struct allocation_header {
|
||||||
|
|||||||
@@ -33,13 +33,12 @@
|
|||||||
#include <xen/memory.h>
|
#include <xen/memory.h>
|
||||||
|
|
||||||
#include "xenctrl.h"
|
#include "xenctrl.h"
|
||||||
#include "xenctrlosdep.h"
|
|
||||||
|
|
||||||
#include "xc_private.h"
|
#include "xc_private.h"
|
||||||
|
|
||||||
#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
|
#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 flags, saved_errno;
|
||||||
int fd = open("/dev/xen/privcmd", O_RDWR); /* prefer this newer interface */
|
int fd = open("/dev/xen/privcmd", O_RDWR); /* prefer this newer interface */
|
||||||
@@ -53,7 +52,7 @@ static xc_osdep_handle linux_privcmd_open(xc_interface *xch)
|
|||||||
if ( fd == -1 )
|
if ( fd == -1 )
|
||||||
{
|
{
|
||||||
PERROR("Could not obtain handle on privileged command interface");
|
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
|
/* Although we return the file handle as the 'xc handle' the API
|
||||||
@@ -74,22 +73,25 @@ static xc_osdep_handle linux_privcmd_open(xc_interface *xch)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (xc_osdep_handle)fd;
|
xch->privcmdfd = fd;
|
||||||
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = saved_errno;
|
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);
|
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;
|
size_t size = npages * XC_PAGE_SIZE;
|
||||||
void *p;
|
void *p;
|
||||||
@@ -121,7 +123,7 @@ out:
|
|||||||
return NULL;
|
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;
|
int saved_errno = errno;
|
||||||
/* Recover the VMA flags. Maybe it's not necessary */
|
/* Recover the VMA flags. Maybe it's not necessary */
|
||||||
@@ -132,9 +134,9 @@ static void linux_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_hand
|
|||||||
errno = saved_errno;
|
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);
|
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,11 +162,11 @@ static int xc_map_foreign_batch_single(int fd, uint32_t dom,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *linux_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_batch(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
xen_pfn_t *arr, int num)
|
xen_pfn_t *arr, int num)
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmapbatch_t ioctlx;
|
privcmd_mmapbatch_t ioctlx;
|
||||||
void *addr;
|
void *addr;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -266,11 +268,11 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_bulk(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
const xen_pfn_t *arr, int *err, unsigned int num)
|
const xen_pfn_t *arr, int *err, unsigned int num)
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmapbatch_v2_t ioctlx;
|
privcmd_mmapbatch_v2_t ioctlx;
|
||||||
void *addr;
|
void *addr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -390,9 +392,9 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *linux_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_range(xc_interface *xch,
|
||||||
uint32_t dom, int size, int prot,
|
uint32_t dom, int size, int prot,
|
||||||
unsigned long mfn)
|
unsigned long mfn)
|
||||||
{
|
{
|
||||||
xen_pfn_t *arr;
|
xen_pfn_t *arr;
|
||||||
int num;
|
int num;
|
||||||
@@ -412,10 +414,10 @@ static void *linux_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *linux_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_ranges(xc_interface *xch,
|
||||||
uint32_t dom, size_t size, int prot,
|
uint32_t dom, size_t size, int prot,
|
||||||
size_t chunksize, privcmd_mmap_entry_t entries[],
|
size_t chunksize, privcmd_mmap_entry_t entries[],
|
||||||
int nentries)
|
int nentries)
|
||||||
{
|
{
|
||||||
xen_pfn_t *arr;
|
xen_pfn_t *arr;
|
||||||
int num_per_entry;
|
int num_per_entry;
|
||||||
@@ -439,40 +441,6 @@ static void *linux_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle
|
|||||||
return ret;
|
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:
|
* Local variables:
|
||||||
* mode: C
|
* mode: C
|
||||||
|
|||||||
+24
-58
@@ -39,19 +39,20 @@ void minios_interface_close_fd(int fd);
|
|||||||
|
|
||||||
extern 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);
|
int fd = alloc_fd(FTYPE_XC);
|
||||||
|
|
||||||
if ( fd == -1)
|
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);
|
return close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,17 +61,17 @@ void minios_interface_close_fd(int fd)
|
|||||||
files[fd].type = FTYPE_NONE;
|
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);
|
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);
|
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;
|
multicall_entry_t call;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
@@ -92,21 +93,21 @@ static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcm
|
|||||||
return call.result;
|
return call.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_bulk(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
const xen_pfn_t *arr, int *err, unsigned int num)
|
const xen_pfn_t *arr, int *err, unsigned int num)
|
||||||
{
|
{
|
||||||
unsigned long pt_prot = 0;
|
unsigned long pt_prot = 0;
|
||||||
if (prot & PROT_READ)
|
if (prot & PROT_READ)
|
||||||
pt_prot = L1_PROT_RO;
|
pt_prot = L1_PROT_RO;
|
||||||
if (prot & PROT_WRITE)
|
if (prot & PROT_WRITE)
|
||||||
pt_prot = L1_PROT;
|
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,
|
void *xc_map_foreign_batch(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
xen_pfn_t *arr, int num)
|
xen_pfn_t *arr, int num)
|
||||||
{
|
{
|
||||||
unsigned long pt_prot = 0;
|
unsigned long pt_prot = 0;
|
||||||
int err[num];
|
int err[num];
|
||||||
@@ -126,10 +127,10 @@ static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handl
|
|||||||
return (void *) addr;
|
return (void *) addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_range(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom,
|
||||||
int size, int prot,
|
int size, int prot,
|
||||||
unsigned long mfn)
|
unsigned long mfn)
|
||||||
{
|
{
|
||||||
unsigned long pt_prot = 0;
|
unsigned long pt_prot = 0;
|
||||||
|
|
||||||
@@ -142,10 +143,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);
|
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,
|
void *xc_map_foreign_ranges(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom,
|
||||||
size_t size, int prot, size_t chunksize,
|
size_t size, int prot, size_t chunksize,
|
||||||
privcmd_mmap_entry_t entries[], int nentries)
|
privcmd_mmap_entry_t entries[], int nentries)
|
||||||
{
|
{
|
||||||
unsigned long *mfns;
|
unsigned long *mfns;
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
@@ -169,24 +170,6 @@ static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handl
|
|||||||
return ret;
|
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 */
|
/* Optionally flush file to disk and discard page cache */
|
||||||
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
||||||
{
|
{
|
||||||
@@ -199,23 +182,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
|
|||||||
return memalign(alignment, 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:
|
* Local variables:
|
||||||
* mode: C
|
* mode: C
|
||||||
|
|||||||
+32
-58
@@ -24,7 +24,7 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <sys/mman.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 flags, saved_errno;
|
||||||
int fd = open("/kern/xen/privcmd", O_RDWR);
|
int fd = open("/kern/xen/privcmd", O_RDWR);
|
||||||
@@ -32,7 +32,7 @@ static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch)
|
|||||||
if ( fd == -1 )
|
if ( fd == -1 )
|
||||||
{
|
{
|
||||||
PERROR("Could not obtain handle on privileged command interface");
|
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
|
/* Although we return the file handle as the 'xc handle' the API
|
||||||
@@ -51,22 +51,23 @@ static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (xc_osdep_handle)fd;
|
xch->privcmdfd = fd;
|
||||||
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = saved_errno;
|
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);
|
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;
|
size_t size = npages * XC_PAGE_SIZE;
|
||||||
void *p;
|
void *p;
|
||||||
@@ -83,15 +84,15 @@ static void *netbsd_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_h
|
|||||||
return p;
|
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);
|
(void) munlock(ptr, npages * XC_PAGE_SIZE);
|
||||||
free(ptr);
|
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);
|
int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -106,11 +107,18 @@ static int netbsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcm
|
|||||||
return hypercall->retval;
|
return hypercall->retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *netbsd_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_bulk(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
xen_pfn_t *arr, int num)
|
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;
|
privcmd_mmapbatch_t ioctlx;
|
||||||
void *addr;
|
void *addr;
|
||||||
addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
|
addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
|
||||||
@@ -135,12 +143,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,
|
void *xc_map_foreign_range(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom,
|
||||||
int size, int prot,
|
int size, int prot,
|
||||||
unsigned long mfn)
|
unsigned long mfn)
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmap_t ioctlx;
|
privcmd_mmap_t ioctlx;
|
||||||
privcmd_mmap_entry_t entry;
|
privcmd_mmap_entry_t entry;
|
||||||
void *addr;
|
void *addr;
|
||||||
@@ -167,12 +175,12 @@ static void *netbsd_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *netbsd_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_ranges(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom,
|
||||||
size_t size, int prot, size_t chunksize,
|
size_t size, int prot, size_t chunksize,
|
||||||
privcmd_mmap_entry_t entries[], int nentries)
|
privcmd_mmap_entry_t entries[], int nentries)
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmap_t ioctlx;
|
privcmd_mmap_t ioctlx;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
void *addr;
|
void *addr;
|
||||||
@@ -205,23 +213,6 @@ mmap_failed:
|
|||||||
return NULL;
|
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 */
|
/* Optionally flush file to disk and discard page cache */
|
||||||
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
||||||
{
|
{
|
||||||
@@ -262,23 +253,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
|
|||||||
return valloc(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:
|
* Local variables:
|
||||||
* mode: C
|
* mode: C
|
||||||
|
|||||||
+7
-167
@@ -26,111 +26,12 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef __MINIOS__
|
struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
|
||||||
#include <dlfcn.h>
|
xentoollog_logger *dombuild_logger,
|
||||||
#endif
|
unsigned open_flags)
|
||||||
|
|
||||||
#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 xch_buf, *xch = &xch_buf;
|
struct xc_interface_core xch_buf, *xch = &xch_buf;
|
||||||
|
|
||||||
xch->type = type;
|
|
||||||
xch->flags = open_flags;
|
xch->flags = open_flags;
|
||||||
xch->dombuild_logger_file = 0;
|
xch->dombuild_logger_file = 0;
|
||||||
xc_clear_last_error(xch);
|
xc_clear_last_error(xch);
|
||||||
@@ -148,9 +49,6 @@ static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *log
|
|||||||
xch->hypercall_buffer_cache_misses = 0;
|
xch->hypercall_buffer_cache_misses = 0;
|
||||||
xch->hypercall_buffer_cache_toobig = 0;
|
xch->hypercall_buffer_cache_toobig = 0;
|
||||||
|
|
||||||
xch->ops_handle = XC_OSDEP_OPEN_ERROR;
|
|
||||||
xch->ops = NULL;
|
|
||||||
|
|
||||||
if (!xch->error_handler) {
|
if (!xch->error_handler) {
|
||||||
xch->error_handler = xch->error_handler_tofree =
|
xch->error_handler = xch->error_handler_tofree =
|
||||||
(xentoollog_logger*)
|
(xentoollog_logger*)
|
||||||
@@ -168,40 +66,26 @@ static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *log
|
|||||||
*xch = xch_buf;
|
*xch = xch_buf;
|
||||||
|
|
||||||
if (!(open_flags & XC_OPENFLAG_DUMMY)) {
|
if (!(open_flags & XC_OPENFLAG_DUMMY)) {
|
||||||
if ( xc_osdep_get_info(xch, &xch->osdep) < 0 )
|
if ( osdep_privcmd_open(xch) < 0 )
|
||||||
goto err;
|
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;
|
return xch;
|
||||||
|
|
||||||
err_put_iface:
|
|
||||||
xc_osdep_put(&xch->osdep);
|
|
||||||
err:
|
err:
|
||||||
xtl_logger_destroy(xch->error_handler_tofree);
|
xtl_logger_destroy(xch->error_handler_tofree);
|
||||||
if (xch != &xch_buf) free(xch);
|
if (xch != &xch_buf) free(xch);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xc_interface_close_common(xc_interface *xch)
|
int xc_interface_close(xc_interface *xch)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (!xch)
|
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");
|
if (rc) PERROR("Could not close hypervisor interface");
|
||||||
|
|
||||||
xc__hypercall_buffer_cache_release(xch);
|
xc__hypercall_buffer_cache_release(xch);
|
||||||
@@ -213,42 +97,6 @@ static int xc_interface_close_common(xc_interface *xch)
|
|||||||
return rc;
|
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_key_t errbuf_pkey;
|
||||||
static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT;
|
static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
@@ -335,14 +183,6 @@ void xc_report_error(xc_interface *xch, int code, const char *fmt, ...)
|
|||||||
va_end(args);
|
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 *xc_set_progress_prefix(xc_interface *xch, const char *doing)
|
||||||
{
|
{
|
||||||
const char *old = xch->currently_progress_reporting;
|
const char *old = xch->currently_progress_reporting;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "_paths.h"
|
#include "_paths.h"
|
||||||
#include "xenctrl.h"
|
#include "xenctrl.h"
|
||||||
#include "xenctrlosdep.h"
|
|
||||||
|
|
||||||
#include <xen/sys/privcmd.h>
|
#include <xen/sys/privcmd.h>
|
||||||
|
|
||||||
@@ -88,7 +87,6 @@ struct iovec {
|
|||||||
#define MAX_PAGECACHE_USAGE (4*1024)
|
#define MAX_PAGECACHE_USAGE (4*1024)
|
||||||
|
|
||||||
struct xc_interface_core {
|
struct xc_interface_core {
|
||||||
enum xc_osdep_type type;
|
|
||||||
int flags;
|
int flags;
|
||||||
xentoollog_logger *error_handler, *error_handler_tofree;
|
xentoollog_logger *error_handler, *error_handler_tofree;
|
||||||
xentoollog_logger *dombuild_logger, *dombuild_logger_tofree;
|
xentoollog_logger *dombuild_logger, *dombuild_logger_tofree;
|
||||||
@@ -117,12 +115,21 @@ struct xc_interface_core {
|
|||||||
int hypercall_buffer_cache_misses;
|
int hypercall_buffer_cache_misses;
|
||||||
int hypercall_buffer_cache_toobig;
|
int hypercall_buffer_cache_toobig;
|
||||||
|
|
||||||
/* Low lovel OS interface */
|
/* Privcmd interface */
|
||||||
xc_osdep_info_t osdep;
|
int privcmdfd;
|
||||||
xc_osdep_ops *ops; /* backend operations */
|
|
||||||
xc_osdep_handle ops_handle; /* opaque data for xc_osdep_ops */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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, ...)
|
void xc_report_error(xc_interface *xch, int code, const char *fmt, ...)
|
||||||
__attribute__((format(printf,3,4)));
|
__attribute__((format(printf,3,4)));
|
||||||
void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level,
|
void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level,
|
||||||
|
|||||||
+32
-58
@@ -24,7 +24,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <malloc.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 flags, saved_errno;
|
||||||
int fd = open("/dev/xen/privcmd", O_RDWR);
|
int fd = open("/dev/xen/privcmd", O_RDWR);
|
||||||
@@ -32,7 +32,7 @@ static xc_osdep_handle solaris_privcmd_open(xc_interface *xch)
|
|||||||
if ( fd == -1 )
|
if ( fd == -1 )
|
||||||
{
|
{
|
||||||
PERROR("Could not obtain handle on privileged command interface");
|
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
|
/* Although we return the file handle as the 'xc handle' the API
|
||||||
@@ -51,42 +51,43 @@ static xc_osdep_handle solaris_privcmd_open(xc_interface *xch)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (xc_osdep_handle)fd;
|
xch->privcmdfd = fd;
|
||||||
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = saved_errno;
|
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);
|
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);
|
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);
|
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);
|
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *solaris_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_batch(xc_interface *xch,
|
||||||
uint32_t dom, int prot,
|
uint32_t dom, int prot,
|
||||||
xen_pfn_t *arr, int num)
|
xen_pfn_t *arr, int num)
|
||||||
{
|
{
|
||||||
int fd = (int)h;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmapbatch_t ioctlx;
|
privcmd_mmapbatch_t ioctlx;
|
||||||
void *addr;
|
void *addr;
|
||||||
addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_SHARED, fd, 0);
|
addr = mmap(NULL, num*XC_PAGE_SIZE, prot, MAP_SHARED, fd, 0);
|
||||||
@@ -109,12 +110,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,
|
void *xc_map_foreign_bulk(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom, int prot,
|
||||||
int size, int prot,
|
const xen_pfn_t *arr, int *err, unsigned int num)
|
||||||
unsigned long mfn)
|
|
||||||
{
|
{
|
||||||
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_t ioctlx;
|
||||||
privcmd_mmap_entry_t entry;
|
privcmd_mmap_entry_t entry;
|
||||||
void *addr;
|
void *addr;
|
||||||
@@ -138,12 +146,12 @@ static void *xc_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *solaric_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h,
|
void *xc_map_foreign_ranges(xc_interface *xch,
|
||||||
uint32_t dom,
|
uint32_t dom,
|
||||||
size_t size, int prot, size_t chunksize,
|
size_t size, int prot, size_t chunksize,
|
||||||
privcmd_mmap_entry_t entries[], int nentries)
|
privcmd_mmap_entry_t entries[], int nentries)
|
||||||
{
|
{
|
||||||
int fd = (int)fd;
|
int fd = xch->privcmdfd;
|
||||||
privcmd_mmap_t ioctlx;
|
privcmd_mmap_t ioctlx;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
void *addr;
|
void *addr;
|
||||||
@@ -176,23 +184,6 @@ mmap_failed:
|
|||||||
return NULL;
|
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 */
|
/* Optionally flush file to disk and discard page cache */
|
||||||
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
void discard_file_cache(xc_interface *xch, int fd, int flush)
|
||||||
{
|
{
|
||||||
@@ -204,23 +195,6 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
|
|||||||
return memalign(alignment, 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:
|
* Local variables:
|
||||||
* mode: C
|
* mode: C
|
||||||
|
|||||||
@@ -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:
|
|
||||||
*/
|
|
||||||
@@ -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_open: unit -> handle = "stub_xc_interface_open"
|
||||||
external interface_close: handle -> unit = "stub_xc_interface_close"
|
external interface_close: handle -> unit = "stub_xc_interface_close"
|
||||||
|
|
||||||
external is_fake: unit -> bool = "stub_xc_interface_is_fake"
|
|
||||||
|
|
||||||
let with_intf f =
|
let with_intf f =
|
||||||
let xc = interface_open () in
|
let xc = interface_open () in
|
||||||
let r = try f xc with exn -> interface_close xc; raise exn in
|
let r = try f xc with exn -> interface_close xc; raise exn in
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ external sizeof_vcpu_guest_context : unit -> int
|
|||||||
= "stub_sizeof_vcpu_guest_context"
|
= "stub_sizeof_vcpu_guest_context"
|
||||||
external sizeof_xen_pfn : unit -> int = "stub_sizeof_xen_pfn"
|
external sizeof_xen_pfn : unit -> int = "stub_sizeof_xen_pfn"
|
||||||
external interface_open : unit -> handle = "stub_xc_interface_open"
|
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"
|
external interface_close : handle -> unit = "stub_xc_interface_close"
|
||||||
val with_intf : (handle -> 'a) -> 'a
|
val with_intf : (handle -> 'a) -> 'a
|
||||||
val domain_create : handle -> int32 -> domain_create_flag list -> string -> domid
|
val domain_create : handle -> int32 -> domain_create_flag list -> string -> domid
|
||||||
|
|||||||
@@ -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)
|
CAMLprim value stub_xc_interface_close(value xch)
|
||||||
{
|
{
|
||||||
CAMLparam1(xch);
|
CAMLparam1(xch);
|
||||||
|
|||||||
@@ -65,11 +65,9 @@ let create xc doms domid mfn port =
|
|||||||
Domain.bind_interdomain dom;
|
Domain.bind_interdomain dom;
|
||||||
dom
|
dom
|
||||||
|
|
||||||
let create0 fake doms =
|
let create0 doms =
|
||||||
let port, interface =
|
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
|
let port = Utils.read_file_single_integer Define.xenstored_proc_port
|
||||||
and fd = Unix.openfile Define.xenstored_proc_kva
|
and fd = Unix.openfile Define.xenstored_proc_kva
|
||||||
[ Unix.O_RDWR ] 0o600 in
|
[ Unix.O_RDWR ] 0o600 in
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ let from_channel store cons doms chan =
|
|||||||
if domid > 0 then
|
if domid > 0 then
|
||||||
Domains.create xc doms domid mfn port
|
Domains.create xc doms domid mfn port
|
||||||
else
|
else
|
||||||
Domains.create0 false doms
|
Domains.create0 doms
|
||||||
in
|
in
|
||||||
Connections.add_domain cons ndom;
|
Connections.add_domain cons ndom;
|
||||||
in
|
in
|
||||||
@@ -278,8 +278,7 @@ let _ =
|
|||||||
Store.mkdir store (Perms.Connection.create 0) localpath;
|
Store.mkdir store (Perms.Connection.create 0) localpath;
|
||||||
|
|
||||||
if cf.domain_init then (
|
if cf.domain_init then (
|
||||||
let usingxiu = Xenctrl.is_fake () in
|
Connections.add_domain cons (Domains.create0 domains);
|
||||||
Connections.add_domain cons (Domains.create0 usingxiu domains);
|
|
||||||
Event.bind_dom_exc_virq eventchn
|
Event.bind_dom_exc_virq eventchn
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
|
|||||||