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

2015-03-03 Thread Wei Liu
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.jack...@eu.citrix.com
Signed-off-by: Wei Liu wei.l...@citrix.com
---
 tools/libxc/Makefile |  2 ++
 tools/libxc/xc_minios_common.c   | 34 ++-
 tools/libxc/xc_netbsd_rumpkern.c | 59 
 3 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxc/xc_netbsd_rumpkern.c

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 8bf7344..c8a5442 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_evtchn.c
 CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_common.c
+CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd_rumpkern.c xc_netbsd_evtchn.c
+CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_minios_common.c
 
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c xc_suspend.c
diff --git a/tools/libxc/xc_minios_common.c b/tools/libxc/xc_minios_common.c
index c38b5f2..fd201fd 100644
--- a/tools/libxc/xc_minios_common.c
+++ b/tools/libxc/xc_minios_common.c
@@ -43,7 +43,17 @@
 
 #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 000..882374a
--- /dev/null
+++ b/tools/libxc/xc_netbsd_rumpkern.c
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2013 Citrix.
+ * Use is subject to license terms.
+ *
+ * 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@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Samuel Thibault
Wei Liu, le Tue 03 Mar 2015 15:57:21 +, a écrit :
 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.jack...@eu.citrix.com
 Signed-off-by: Wei Liu wei.l...@citrix.com

Acked-by: Samuel Thibault samuel.thiba...@ens-lyon.org

 +static xc_osdep_handle minios_privcmd_open(xc_interface *xch)
 +{
 +return 1;
 +}
 +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
 +{
 +return 1;
 +}

Perhaps return a different fd number?

Samuel

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


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Wei Liu
On Tue, Mar 03, 2015 at 04:41:23PM +, Wei Liu wrote:
 On Tue, Mar 03, 2015 at 05:05:29PM +0100, Samuel Thibault wrote:
  Wei Liu, le Tue 03 Mar 2015 15:57:21 +, a écrit :
   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.jack...@eu.citrix.com
   Signed-off-by: Wei Liu wei.l...@citrix.com
  
  Acked-by: Samuel Thibault samuel.thiba...@ens-lyon.org
  
   +static xc_osdep_handle minios_privcmd_open(xc_interface *xch)
   +{
   +return 1;
   +}
   +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
   +{
   +return 1;
   +}
  
  Perhaps return a different fd number?
  
 
 After thinking a bit more I think we should use alloc_fd(FTYPE_*) for
 all file descriptor allocation.
 

(Sorry for speaking to myself)

Just tried that, failed.

Rump kernel doesn't use mini-os's fd management facility so there is no
alloc_fd etc. On the other hand this makes me think number 1 is as good
as any other number we can use.

Wei.

 Wei.
 
  Samuel

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


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Samuel Thibault
Wei Liu, le Tue 03 Mar 2015 16:41:23 +, a écrit :
 On Tue, Mar 03, 2015 at 05:05:29PM +0100, Samuel Thibault wrote:
  Wei Liu, le Tue 03 Mar 2015 15:57:21 +, a écrit :
   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.jack...@eu.citrix.com
   Signed-off-by: Wei Liu wei.l...@citrix.com
  
  Acked-by: Samuel Thibault samuel.thiba...@ens-lyon.org
  
   +static xc_osdep_handle minios_privcmd_open(xc_interface *xch)
   +{
   +return 1;
   +}
   +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
   +{
   +return 1;
   +}
  
  Perhaps return a different fd number?
  
 
 After thinking a bit more I think we should use alloc_fd(FTYPE_*) for
 all file descriptor allocation.

That would make sense, yes.

Samuel

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


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Wei Liu
On Tue, Mar 03, 2015 at 05:05:29PM +0100, Samuel Thibault wrote:
 Wei Liu, le Tue 03 Mar 2015 15:57:21 +, a écrit :
  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.jack...@eu.citrix.com
  Signed-off-by: Wei Liu wei.l...@citrix.com
 
 Acked-by: Samuel Thibault samuel.thiba...@ens-lyon.org
 
  +static xc_osdep_handle minios_privcmd_open(xc_interface *xch)
  +{
  +return 1;
  +}
  +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg)
  +{
  +return 1;
  +}
 
 Perhaps return a different fd number?
 

After thinking a bit more I think we should use alloc_fd(FTYPE_*) for
all file descriptor allocation.

Wei.

 Samuel

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


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Samuel Thibault
Wei Liu, le Tue 03 Mar 2015 16:58:07 +, a écrit :
 Rump kernel doesn't use mini-os's fd management facility so there is no
 alloc_fd etc. On the other hand this makes me think number 1 is as good
 as any other number we can use.

Does Rump have not fd at all?  It'd probably still be good to have
different, even if hardcoded, fd numbers, for potentially easier
debugging.

Samuel

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


Re: [Xen-devel] [PATCH v2 5/5] libxc: rumpxen: provide xc_osdep_info

2015-03-03 Thread Wei Liu
On Tue, Mar 03, 2015 at 05:59:39PM +0100, Samuel Thibault wrote:
 Wei Liu, le Tue 03 Mar 2015 16:58:07 +, a écrit :
  Rump kernel doesn't use mini-os's fd management facility so there is no
  alloc_fd etc. On the other hand this makes me think number 1 is as good
  as any other number we can use.
 
 Does Rump have not fd at all?  It'd probably still be good to have

AIUI it's using NetBSD's facility or it just doesn't care.

The mini-os fork (!) in rump kernel doesn't have alloc_fd etc.

 different, even if hardcoded, fd numbers, for potentially easier
 debugging.

Fair enough. I'm going to use ... 0xff (and probably comes with a
#define in code).

Wei.

 
 Samuel

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