[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info



From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

This allows programs which use the bulk of libxc to link.  We use
/dev/xenevt for event channels, the raw minios functions for privcmd
and gnttab, and the netbsd versions of discard_file_cache and
xc_memalign.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>

[ wei: wrap long lines, adapt to changes in previous patch ]

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxc/Makefile             |  2 ++
 tools/libxc/xc_minios_privcmd.c  | 36 +++++++++++++++++++++--
 tools/libxc/xc_netbsd_rumpkern.c | 62 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+), 2 deletions(-)
 create mode 100644 tools/libxc/xc_netbsd_rumpkern.c

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 0f3396c..bce2dd2 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -48,6 +48,8 @@ CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
 CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c xc_netbsd_user.c
 CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c
+CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd_rumpkern.c xc_netbsd_user.c
+CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_minios_privcmd.c
 
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c xc_suspend.c
diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c
index 27d9076..a8b1102 100644
--- a/tools/libxc/xc_minios_privcmd.c
+++ b/tools/libxc/xc_minios_privcmd.c
@@ -41,9 +41,19 @@
 
 #include "xc_private.h"
 
-#ifdef __RUMPRUN___
+#ifdef __RUMPRUN__
 # define map_frames_ex minios_map_frames_ex
-#endif /* __RUMPRUN__ */
+
+static xc_osdep_handle minios_privcmd_open(xc_interface *xch)
+{
+    return 1;
+}
+static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h)
+{
+    return 0;
+}
+
+#else /* !__RUMPRUN__ */
 
 void minios_interface_close_fd(int fd);
 void minios_gnttab_close_fd(int fd);
@@ -69,6 +79,8 @@ void minios_interface_close_fd(int fd)
     files[fd].type = FTYPE_NONE;
 }
 
+#endif /* !__RUMPRUN__ */
+
 static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch,
                                                   xc_osdep_handle h,
                                                   int npages)
@@ -208,6 +220,24 @@ struct xc_osdep_ops xc_privcmd_ops = {
     },
 };
 
+#ifdef __RUMPRUN__
+
+static struct gntmap static_gntmap;
+
+#define GNTMAP(h) static_gntmap
+
+static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
+{
+    return 1;
+}
+
+static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h)
+{
+    return 0;
+}
+
+#else /* !__RUMPRUN__ */
+
 #define GNTMAP(h) (files[(int)(h)].gntmap)
 
 static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
@@ -231,6 +261,8 @@ void minios_gnttab_close_fd(int fd)
     files[fd].type = FTYPE_NONE;
 }
 
+#endif /* !__RUMPRUN__ */
+
 static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h,
                                      uint32_t count, int flags, int prot,
                                      uint32_t *domids, uint32_t *refs,
diff --git a/tools/libxc/xc_netbsd_rumpkern.c b/tools/libxc/xc_netbsd_rumpkern.c
new file mode 100644
index 0000000..11d4a63
--- /dev/null
+++ b/tools/libxc/xc_netbsd_rumpkern.c
@@ -0,0 +1,62 @@
+/******************************************************************************
+ *
+ * Copyright 2013 Citrix.
+ * Use is subject to license terms.
+ *
+ * xc_gnttab functions:
+ * Copyright (c) 2007-2008, D G Murray <Derek.Murray@xxxxxxxxxxxx>
+ *
+ * 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
+ */
+
+#include "xc_private.h"
+
+#include <xen/sys/evtchn.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <malloc.h>
+#include <sys/mman.h>
+
+static struct xc_osdep_ops *rumpxen_osdep_init(xc_interface *xch,
+                                               enum xc_osdep_type type)
+{
+    switch ( type )
+    {
+    case XC_OSDEP_PRIVCMD:
+        return &xc_privcmd_ops;
+    case XC_OSDEP_EVTCHN:
+        return &xc_evtchn_ops;
+    case XC_OSDEP_GNTTAB:
+        return &xc_gnttab_ops;
+    default:
+        return NULL;
+    }
+}
+
+xc_osdep_info_t xc_osdep_info = {
+    .name = "Rump kernel OS interface",
+    .init = &rumpxen_osdep_init,
+    .fake = 0,
+};
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.