Skip to contentSkip to conversation

tools: add support for FreeBSD

RFC PATCH Superseded Roger Pau Monne 5 participants 91 messages Apr 16, 2014 – Jun 2, 2014

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover tools: add support for FreeBSD

The following series enables building (and using) the Xen toolstack on a FreeBSD PVH Dom0.

The FreeBSD sources used to test this series can be found at:

git://xenbits.xen.org/people/royger/freebsd.git branch pvh_dom0_v3
http://xenbits.xen.org/gitweb/?p=people/royger/freebsd.git;a=shortlog;h=refs/heads/pvh_dom0_v3

I've successfully tested PV and HVM domains, but right now only qemu-xen (aka qemu-upstream) is supported on FreeBSD (in order to avoid the build system from trying to compile qemu-trad pass the following option to configure: --disable-qemu-traditional). I'm not sure if there's any gain from also having qemu-trad, so I would suggest to automatically disable it on FreeBSD (like we do for ARM).

Some patches for Qemu and SeaBIOS are needed, which are still pending approval from their respective upstreams:

http://marc.info/?l=xen-devel&m=139763253311569
http://marc.info/?l=xen-devel&m=139755086616838&w=2

Thanks for the review, Roger.

#1 lore raw

RFC PATCH 1/23 build: set FreeBSD specific build variables

This is very similar to what we do in order to build on NetBSD.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 config/FreeBSD.mk |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
config/FreeBSD.mk +7 -0
index b421a1c..1b4c74c 100644
@@ -1 +1,8 @@
 include $(XEN_ROOT)/config/StdGNU.mk
+
+DLOPEN_LIBS =
+
+# No wget on FreeBSD base system
+WGET = ftp
+
+CONFIG_DIR = $(PREFIX)/etc
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 1/23
#3 lore raw

Re: [PATCH RFC 01/23] build: set FreeBSD specific build variables

In reply to Roger Pau Monne
Quoted 4 lines · Roger Pau Monne

This is very similar to what we do in order to build on NetBSD.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

RFC PATCH 2/23 configure: make the libaio test non-fatal on OSes different than Linux

In reply to Roger Pau Monne

libaio is only present on Linux systems, so make the configure test that checks for libaio non-fatal is the host OS is different than Linux.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

---
Please re-run autoconf after applying this patch.

---
 tools/configure.ac |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
tools/configure.ac +7 -1
index a62faf8..eb54098 100644
@@ -220,7 +220,13 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [
 AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"])
 ])
 AC_SUBST(zlib)
-AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])])
+AC_CHECK_LIB([aio], [io_setup], [], [
+    case "$host_os" in
+    linux*)
+        AC_MSG_ERROR([Could not find libaio])
+        ;;
+    esac
+])
 AC_SUBST(system_aio)
 AC_CHECK_LIB([crypto], [MD5], [], [AC_MSG_ERROR([Could not find libcrypto])])
 AX_CHECK_EXTFS
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#5 lore raw

RFC PATCH 2/23 configure: make the libaio test non-fatal on OSes different than Linux

Roger Pau Monne writes ("[PATCH RFC 02/23] configure: make the libaio test non-fatal on OSes different than Linux"):

Quoted 5 lines

libaio is only present on Linux systems, so make the configure test that checks for libaio non-fatal is the host OS is different than Linux.

Quoted 1 line

Please re-run autoconf after applying this patch.

Can you move that just before, rather than just after, the S-o-b ? That will make it less likely to be overlooked I think.

Thanks,
Ian.

#6 lore raw

Re: [PATCH RFC 02/23] configure: make the libaio test non-fatal on OSes different than Linux

Quoted 5 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 02/23] configure: make the libaio test non-fatal on OSes different than Linux"):

Quoted 4 lines

libaio is only present on Linux systems, so make the configure test that checks for libaio non-fatal is the host OS is different than Linux.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Please re-run autoconf after applying this patch.

Can you move that just before, rather than just after, the S-o-b ? That will make it less likely to be overlooked I think.

Sure, I usually put those kind of notes after the S-o-b, so it's not included in the actual commit message.

Roger.

#7 lore raw

Re: [PATCH RFC 02/23] configure: make the libaio test non-fatal on OSes different than Linux

In reply to Roger Pau Monne
Quoted 19 lines · Roger Pau Monne

libaio is only present on Linux systems, so make the configure test that checks for libaio non-fatal is the host OS is different than Linux.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

---
Please re-run autoconf after applying this patch.

---
 tools/configure.ac |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
tools/configure.ac +0 -0
index a62faf8..eb54098 100644
@@ -220,7 +220,13 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [
 AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"])

tools/configure.ac AC_CHECK_HEADER([lzo/lzo1x.h], [ · line 229

Quoted 10 lines
tools/configure.ac +7 -1
 ])
 AC_SUBST(zlib)
-AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])])
+AC_CHECK_LIB([aio], [io_setup], [], [
+    case "$host_os" in
+    linux*)
+        AC_MSG_ERROR([Could not find libaio])
+        ;;
+    esac
+])

AFAICT aio is used only by blktap (1 and 2), so you could make this entire test conditional on either of those being enabled and by extension it would then be dependent on Linux.

Ian.

tools/configure.ac AC_CHECK_HEADER([lzo/lzo1x.h], [ · line 232

Quoted 3 lines
tools/configure.ac +0 -0
 AC_SUBST(system_aio)
 AC_CHECK_LIB([crypto], [MD5], [], [AC_MSG_ERROR([Could not find libcrypto])])
 AX_CHECK_EXTFS

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

RFC PATCH 3/23 include: import FreeBSD headers for evtchn and privcmd devices

In reply to Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/include/xen-sys/FreeBSD/evtchn.h  |   87 +++++++++++++++++++++++++++++++
 tools/include/xen-sys/FreeBSD/privcmd.h |   64 ++++++++++++++++++++++
 2 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 tools/include/xen-sys/FreeBSD/evtchn.h
 create mode 100644 tools/include/xen-sys/FreeBSD/privcmd.h
tools/include/xen-sys/FreeBSD/evtchn.h new file +87 -0
new file mode 100644
index 0000000..00fa67e
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Interface to /dev/xen/evtchn.
+ * 
+ * Copyright (c) 2003-2005, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __XEN_EVTCHN_H__
+#define __XEN_EVTCHN_H__
+
+/*
+ * Bind a fresh port to VIRQ @virq.
+ */
+#define IOCTL_EVTCHN_BIND_VIRQ				\
+	_IOWR('E', 4, struct ioctl_evtchn_bind_virq)
+struct ioctl_evtchn_bind_virq {
+	unsigned int virq;
+	unsigned int port;
+};
+
+/*
+ * Bind a fresh port to remote <@remote_domain, @remote_port>.
+ */
+#define IOCTL_EVTCHN_BIND_INTERDOMAIN			\
+	_IOWR('E', 5, struct ioctl_evtchn_bind_interdomain)
+struct ioctl_evtchn_bind_interdomain {
+	unsigned int remote_domain, remote_port;
+	unsigned int port;
+};
+
+/*
+ * Allocate a fresh port for binding to @remote_domain.
+ */
+#define IOCTL_EVTCHN_BIND_UNBOUND_PORT			\
+	_IOWR('E', 6, struct ioctl_evtchn_bind_unbound_port)
+struct ioctl_evtchn_bind_unbound_port {
+	unsigned int remote_domain;
+	unsigned int port;
+};
+
+/*
+ * Unbind previously allocated @port.
+ */
+#define IOCTL_EVTCHN_UNBIND				\
+	_IOW('E', 7, struct ioctl_evtchn_unbind)
+struct ioctl_evtchn_unbind {
+	unsigned int port;
+};
+
+/*
+ * Send event to previously allocated @port.
+ */
+#define IOCTL_EVTCHN_NOTIFY				\
+	_IOW('E', 8, struct ioctl_evtchn_notify)
+struct ioctl_evtchn_notify {
+	unsigned int port;
+};
+
+/* Clear and reinitialise the event buffer. Clear error condition. */
+#define IOCTL_EVTCHN_RESET				\
+	_IO('E', 9)
+
+#endif /* __XEN_EVTCHN_H__ */
tools/include/xen-sys/FreeBSD/privcmd.h new file +64 -0

64 lines not on this page · raw message

Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#9 lore raw

Re: [PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices

Roger Pau Monne writes ("[PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices"):

Quoted 3 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

Is it usual, then in the FreeBSD world, for an application program to take a copy of kernel headers defining ioctls etc. ? This seems surprising to me. It would seem more sensible for the application to use the headers installed on the build host.

Ian.

#10 lore raw

Re: [PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices

Quoted 9 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices"):

Quoted 3 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

Is it usual, then in the FreeBSD world, for an application program to take a copy of kernel headers defining ioctls etc. ? This seems surprising to me. It would seem more sensible for the application to use the headers installed on the build host.

I would say it's certainly not common, but every OS with Dom0 support seems to do it (take a look at tools/include/xen-sys).

Not sure if this was done in the past to allow compiling the toolstack on a host without a xen-classic kernel (which I guess was the only one to have the proper headers for user-space devices).

Roger.

#11 lore raw

Re: [PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices

Quoted 10 lines · Roger Pau Monné
Quoted 9 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 03/23] include: import FreeBSD headers for evtchn and privcmd devices"):

Quoted 3 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

Is it usual, then in the FreeBSD world, for an application program to take a copy of kernel headers defining ioctls etc. ? This seems surprising to me. It would seem more sensible for the application to use the headers installed on the build host.

Normally such headers come from the libc rather than the kernel directly. We could upstream our ioctl definitions into glibc I suppose.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

RFC PATCH 4/23 libxc: add support for FreeBSD

In reply to Roger Pau Monne

Add the FreeBSD implementation of the privcmd and evtchn devices interface.

The evtchn device interface is the same as the Linux one, while the privcmd map interface is simplified because FreeBSD only supports IOCTL_PRIVCMD_MMAPBATCH.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxc/Makefile           |    1 +
 tools/libxc/xc_freebsd.c       |   72 +++++++
 tools/libxc/xc_freebsd_osdep.c |  405 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 478 insertions(+), 0 deletions(-)
 create mode 100644 tools/libxc/xc_freebsd.c
 create mode 100644 tools/libxc/xc_freebsd_osdep.c
tools/libxc/Makefile +1 -0
index 2cca2b2..7f9b672 100644
@@ -36,6 +36,7 @@ CTRL_SRCS-y       += xtl_core.c
 CTRL_SRCS-y       += xtl_logger_stdio.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c
+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
 CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
tools/libxc/xc_freebsd.c new file +72 -0

72 lines not on this page · raw message

tools/libxc/xc_freebsd_osdep.c new file +405 -0

405 lines not on this page · raw message

Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#14 lore raw

Re: [PATCH RFC 04/23] libxc: add support for FreeBSD

Roger Pau Monne writes ("[PATCH RFC 04/23] libxc: add support for FreeBSD"):

Quoted 6 lines

Add the FreeBSD implementation of the privcmd and evtchn devices interface.

The evtchn device interface is the same as the Linux one, while the privcmd map interface is simplified because FreeBSD only supports IOCTL_PRIVCMD_MMAPBATCH.

...

tools/libxc/xc_freebsd.c line 25

Quoted 3 lines
tools/libxc/xc_freebsd.c new file +3 -0
+/* Optionally flush file to disk and discard page cache */
+void discard_file_cache(xc_interface *xch, int fd, int flush) 
+{

My main criticism of this is that much of this file is a (nearly) verbatim copy of the Linux functions. I think we should have a conversation about other approaches that would allow us to share more of the code.

Two options I can think of (which could perhaps be combined):
xc_posix.c containing some "standard" versions #ifdeffery

Now, prompted by your patch to look at this function:

tools/libxc/xc_freebsd.c line 30

Quoted 5 lines
tools/libxc/xc_freebsd.c new file +5 -0
+    off_t cur = 0;
+    int saved_errno = errno;
+
+    if ( flush && (fsync(fd) < 0) )
+        goto out;

This function has truly demented error behaviour, but this is not your fault - you're just copying what the Linux one does.

I'm pretty sure that many of the callers expect this function to do its thing and that if it doesn't work we might get corruption in the guest.

tools/libxc/xc_freebsd.c line 46

Quoted 3 lines
tools/libxc/xc_freebsd.c new file +3 -0
+    /* Discard from the buffer cache. */
+    if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 )
+        goto out;

Which also means that the use of posix_fadvise is hardly safe. fadvise can quite legally be a noop.

tools/libxc/xc_freebsd_osdep.c line 56

Quoted 10 lines
tools/libxc/xc_freebsd_osdep.c new file +10 -0
+static xc_osdep_handle freebsd_privcmd_open(xc_interface *xch)
+{
+    int flags, saved_errno;
+    int fd = open(PRIVCMD_DEV, O_RDWR);
+
+    if ( fd == -1 )
+    {
+        PERROR("Could not obtain handle on privileged command interface "
+               PRIVCMD_DEV);
+        return XC_OSDEP_OPEN_ERROR;

I think it would be better to use the "goto out" error handling style. Of course this function is a clone so really I'm complaining about an existing function.

Maybe I should stop looking under this rock before I discover any more rotting yak hair.

Ian.

#15 lore raw

Re: [PATCH RFC 04/23] libxc: add support for FreeBSD

Quoted 6 lines · Ian Jackson

tools/libxc/xc_freebsd.c line 46

Quoted 3 lines
tools/libxc/xc_freebsd.c new file +3 -0
+    /* Discard from the buffer cache. */
+    if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 )
+        goto out;

Which also means that the use of posix_fadvise is hardly safe. fadvise can quite legally be a noop.

I think that's ok, it's for "reducing the impact on dom0" not correctness, according to the commit which added it:

commit e0b421d24279d3cce426c0df4bf6d8734c6ce325

Author: Keir Fraser <[email protected]>
Date:   Sat Feb 24 14:48:17 2007 +0000

Reduce impact of saving/restoring/dumping large domains on Dom0 memory usage by means of fadvise64() to tell the OS to discard the cache pages used for the save/dump file.

(I presume fadvise implemented as a nop should still return success)

Ian.

#16 lore raw

Re: [PATCH RFC 04/23] libxc: add support for FreeBSD

Ian Campbell writes ("Re: [PATCH RFC 04/23] libxc: add support for FreeBSD"):

Quoted 10 lines · Ian Jackson
Quoted 6 lines

tools/libxc/xc_freebsd.c line 46

Quoted 3 lines
tools/libxc/xc_freebsd.c new file +3 -0
+    /* Discard from the buffer cache. */
+    if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 )
+        goto out;

Which also means that the use of posix_fadvise is hardly safe. fadvise can quite legally be a noop.

I think that's ok, it's for "reducing the impact on dom0" not correctness, according to the commit which added it:

Oh, good. Thanks for digging that up.

Ian.

#17 lore raw

RFC PATCH 5/23 libxc: remove usage of "daylight" variable

In reply to Roger Pau Monne

FreeBSD doesn't implement the XSI extension that mandates the presence of the daylight variable as described in:

http://pubs.opengroup.org/onlinepubs/009696799/functions/tzset.html

So avoid using it for portability reasons. Use tm_isdst instead to decide if daylight savings time conversions should be used or not.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxc/xtl_logger_stdio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxc/xtl_logger_stdio.c +1 -1
index 47ee257..d8646e0 100644
@@ -64,7 +64,7 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in,
         fprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ",
                 lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
                 lt->tm_hour, lt->tm_min, lt->tm_sec,
-                tzname[daylight ? !!lt->tm_isdst : 0]);
+                tzname[!!lt->tm_isdst]);
     }
     if (lg->flags & XTL_STDIOSTREAM_SHOW_PID)
         fprintf(lg->f, "[%lu] ", (unsigned long)getpid());
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 5/23
#18 lore raw

Re: [PATCH RFC 05/23] libxc: remove usage of "daylight" variable

Roger Pau Monne writes ("[PATCH RFC 05/23] libxc: remove usage of "daylight" variable"):

Quoted 9 lines

FreeBSD doesn't implement the XSI extension that mandates the presence of the daylight variable as described in:

http://pubs.opengroup.org/onlinepubs/009696799/functions/tzset.html

So avoid using it for portability reasons. Use tm_isdst instead to decide if daylight savings time conversions should be used or not.

Ian.

Acked-by on v1 5/23
#19 lore raw

Re: [PATCH RFC 05/23] libxc: remove usage of "daylight" variable

In reply to Roger Pau Monne
Quoted 4 lines · Roger Pau Monne

FreeBSD doesn't implement the XSI extension that mandates the presence of the daylight variable as described in:

http://pubs.opengroup.org/onlinepubs/009696799/functions/tzset.html

Wow, what an interesting thing to expose.

Quoted 5 lines

So avoid using it for portability reasons. Use tm_isdst instead to decide if daylight savings time conversions should be used or not.

Quoted 9 lines
---
 tools/libxc/xtl_logger_stdio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxc/xtl_logger_stdio.c +0 -0
index 47ee257..d8646e0 100644

tools/libxc/xtl_logger_stdio.c static void stdiostream_vmessage(xentoollog_logger *logger_in, · line 70

Quoted 8 lines
tools/libxc/xtl_logger_stdio.c +1 -1
@@ -64,7 +64,7 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in,
         fprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ",
                 lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday,
                 lt->tm_hour, lt->tm_min, lt->tm_sec,
-                tzname[daylight ? !!lt->tm_isdst : 0]);
+                tzname[!!lt->tm_isdst]);
     }
     if (lg->flags & XTL_STDIOSTREAM_SHOW_PID)
         fprintf(lg->f, "[%lu] ", (unsigned long)getpid());

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#20 lore raw

RFC PATCH 6/23 libxc: remove include of malloc.h

In reply to Roger Pau Monne

The malloc set of functions should have their prototypes in stdlib.h according to:

http://pubs.opengroup.org/onlinepubs/009695399/functions/malloc.html

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxc/xg_private.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
tools/libxc/xg_private.c +0 -1
index a914068..c52cb44 100644
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <zlib.h>
-#include <malloc.h>
 
 #include "xg_private.h"
 
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#22 lore raw

RFC PATCH 7/23 libelf: add defines for bswap_* functions for FreeBSD

In reply to Roger Pau Monne

This maps bswap_* functions used in libelf to their FreeBSD counterparts.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 xen/common/libelf/libelf-private.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
xen/common/libelf/libelf-private.h +5 -0
index f4b79c7..854a0d7 100644
@@ -61,6 +61,11 @@
 #define bswap_16(x) swap16(x)
 #define bswap_32(x) swap32(x)
 #define bswap_64(x) swap64(x)
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#define bswap_16(x) bswap16(x)
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
 #elif defined(__linux__) || defined(__Linux__) || defined(__MINIOS__)
 #include <byteswap.h>
 #else
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 7/23
#23 lore raw

Re: [PATCH RFC 07/23] libelf: add defines for bswap_* functions for FreeBSD

Roger Pau Monne writes ("[PATCH RFC 07/23] libelf: add defines for bswap_* functions for FreeBSD"):

Quoted 4 lines

This maps bswap_* functions used in libelf to their FreeBSD counterparts.

Looks plausible, although I haven't chased up any docs.

Ian.

Acked-by on v1 7/23
#24 lore raw

Re: [PATCH RFC 07/23] libelf: add defines for bswap_* functions for FreeBSD

In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

This maps bswap_* functions used in libelf to their FreeBSD counterparts.

Bit you could consider combining with the identical NetBSD case #elif defined(ONE thing) || defined(ANOTHER)

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#25 lore raw

RFC PATCH 8/23 configure: add checks for endian.h and sys/endian.h

In reply to Roger Pau Monne

In order to know which one to include when building xc_dom_decompress_lz4.c

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>

---
Please run autoconf after applying this patch.

---
 tools/config.h.in                   |    6 ++++++
 tools/configure.ac                  |    2 +-
 tools/libxc/Makefile                |    1 +
 tools/libxc/xc_dom_decompress_lz4.c |    4 ++++
 4 files changed, 12 insertions(+), 1 deletions(-)
tools/config.h.in +6 -0
index 015f2a1..283cee7 100644
@@ -51,6 +51,12 @@
 /* Define to 1 if you have the <yajl/yajl_version.h> header file. */
 #undef HAVE_YAJL_YAJL_VERSION_H
 
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
 /* Define curses header to use */
 #undef INCLUDE_CURSES_H
 
tools/configure.ac +1 -1
index eb54098..3b8db0a 100644
@@ -247,7 +247,7 @@ AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])])
 esac
 
 # Checks for header files.
-AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h])
+AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h endian.h sys/endian.h])
 
 AC_OUTPUT()
 
tools/libxc/Makefile +1 -0
index 7f9b672..3e3678f 100644
@@ -90,6 +90,7 @@ OSDEP_SRCS-y                 += xenctrl_osdep_ENOSYS.c
 
 CFLAGS   += -Werror -Wmissing-prototypes
 CFLAGS   += -I. $(CFLAGS_xeninclude)
+CFLAGS   += -include $(XEN_ROOT)/tools/config.h
 
 # Needed for posix_fadvise64() in xc_linux.c
 CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
tools/libxc/xc_dom_decompress_lz4.c +4 -0
index 08272fe..7f97364 100644
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
+#if defined(HAVE_ENDIAN_H)
 #include <endian.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#endif
 #include <stdint.h>
 
 #include "xg_private.h"
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#26 lore raw

RFC PATCH 8/23 configure: add checks for endian.h and sys/endian.h

Roger Pau Monne writes ("[PATCH RFC 08/23] configure: add checks for endian.h and sys/endian.h"):

Quoted 2 lines

In order to know which one to include when building xc_dom_decompress_lz4.c

Does BSD's sys/endian.h define the same things as endian.h ?

Ian.

#27 lore raw

RFC PATCH 9/23 lz4: add support for OSes that don't have asm/unaligned.h

In reply to Roger Pau Monne

Add a configure check for asm/unaligned.h presence, and if it's not available open-code the necessary functions for lz4.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/config.h.in     |    3 +++
 tools/configure.ac    |    2 +-
 xen/common/lz4/defs.h |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletions(-)
tools/config.h.in +3 -0
index 283cee7..709a51d 100644
@@ -57,6 +57,9 @@
 /* Define to 1 if you have the <sys/endian.h> header file. */
 #undef HAVE_SYS_ENDIAN_H
 
+/* Define to 1 if you have the <asm/unaligned.h> header file. */
+#undef HAVE_ASM_UNALIGNED_H
+
 /* Define curses header to use */
 #undef INCLUDE_CURSES_H
 
tools/configure.ac +1 -1
index 3b8db0a..cf30254 100644
@@ -247,7 +247,7 @@ AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])])
 esac
 
 # Checks for header files.
-AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h endian.h sys/endian.h])
+AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h endian.h sys/endian.h asm/unaligned.h])
 
 AC_OUTPUT()
 
xen/common/lz4/defs.h +42 -0

49 lines not on this page · raw message

Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#28 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Roger Pau Monne writes ("[PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h"):

Quoted 2 lines

Add a configure check for asm/unaligned.h presence, and if it's not available open-code the necessary functions for lz4.

Where did this code come from ?

Is there nothing in the FreeBSD environment that we could reuse ?

xen/common/lz4/defs.h static inline u32 INIT get_unaligned_le32(const void *p) · line 42

Quoted 2 lines
xen/common/lz4/defs.h +2 -0
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };

Are you sure this actually works ? I can't see anything in the GCC 4.4 docs which requires the compiler to generate special code to access such a variable.

Ian.

#29 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 5 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h"):

Quoted 2 lines

Add a configure check for asm/unaligned.h presence, and if it's not available open-code the necessary functions for lz4.

Where did this code come from ?

This came from the Linux kernel, see:

http://lxr.free-electrons.com/source/include/asm-generic/unaligned.h?v=2.6.25#L80

Quoted 2 lines

Is there nothing in the FreeBSD environment that we could reuse ?

I think there's nothing in FreeBSD that we could use to replace this functions.

Quoted 7 lines

xen/common/lz4/defs.h static inline u32 INIT get_unaligned_le32(const void *p) · line 42

Quoted 3 lines
xen/common/lz4/defs.h +2 -0
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };

Are you sure this actually works ? I can't see anything in the GCC 4.4 docs which requires the compiler to generate special code to access such a variable.

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

I'm CCing the people that added the LZ4 support to Xen, let's see if they can shed some light on this.

Roger.

#30 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Roger Pau Monné writes ("Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h"):

Quoted 10 lines · Ian Jackson
Quoted 5 lines

Roger Pau Monne writes ("[PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h"):

Quoted 2 lines

Add a configure check for asm/unaligned.h presence, and if it's not available open-code the necessary functions for lz4.

Where did this code come from ?

This came from the Linux kernel, see:

http://lxr.free-electrons.com/source/include/asm-generic/unaligned.h?v=2.6.25#L80

I think you should mention this in the commit message. (Including mentioning the specific Linux version or changeset the file came from.)

Quoted 7 lines

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

I'm CCing the people that added the LZ4 support to Xen, let's see if they can shed some light on this.

OK.

Thanks,
Ian.

#31 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

In reply to Roger Pau Monné
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

Quoted 6 lines

I'm CCing the people that added the LZ4 support to Xen, let's see if they can shed some light on this.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#32 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 9 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression code, but we are using some non-standard functions, like __get_unaligned, which are only defined in Linux's asm/unaligned.h. IMHO, we should get rid of the include of asm/unaligned.h and code whatever functions we need from that file in a portable way.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#33 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Not sure about which version of lz4 source code is used, so my comment may be out of context,

but for your information,
the C code provided at https://code.google.com/p/lz4/
already handles unaligned access on strict align CPU.

The method is close or the same as the one described into asm/unaligned.h :

typedef struct { U16 v; }  _PACKED U16_S;
typedef struct { U32 v; }  _PACKED U32_S;
typedef struct { U64 v; }  _PACKED U64_S;

typedef struct {size_t v;} _PACKED size_t_S;

but directly integrated into lz4.c source file.

The method rely on the compiler to automatically determine if the target system requires extra-caution for unaligned access, but sometimes, the compiler can be over-cautious (typically for ARM target). Therefore, a manual override is also provided, near the top of the lz4.c source file :

/*
* Unaligned memory access is automatically enabled for "common" CPU, such
as x86.
* For others CPU, such as ARM, the compiler may be more cautious,
inserting unnecessary extra code to ensure aligned access property
* If you know your target CPU supports unaligned memory access, you want
to force this option manually to improve performance
*/
#if defined(__ARM_FEATURE_UNALIGNED)
# define LZ4_FORCE_UNALIGNED_ACCESS 1
#endif

Hope it helps.

Regards

2014-04-22 18:40 GMT+02:00 Roger Pau Monné <[email protected]>:

Quoted 11 lines · Ian Campbell
Quoted 9 lines · Roger Pau Monné
Quoted 4 lines

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

Quoted 9 lines

No, I don't think we are using Linux kernel's built in decompression code, but we are using some non-standard functions, like __get_unaligned, which are only defined in Linux's asm/unaligned.h. IMHO, we should get rid of the include of asm/unaligned.h and code whatever functions we need from that file in a portable way.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#34 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

In reply to Roger Pau Monné
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Quoted 6 lines
Quoted 3 lines

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression code,

Which library provides lz4_decompress_unknownoutputsize then?

It looks to me like xc_dom_decompress_lz4 gets it from #include "../../xen/common/lz4/decompress.c" even in the !__MINIOS__ case and:

        $ head -n2 xen/common/lz4/decompress.c
        /*
         * LZ4 Decompressor for Linux kernel

i.e. this is Linux code (which Linux uses to decompress itself on boot) copied into the hypervisor.

Since this is imported code we don't really want to rewrite it so we can resync easily in the future. It's up to Xen and libxc to provide the necessary scaffolding (in terms of helpers the unaligned accessors) to make this code compile.

Quoted 7 lines

but we are using some non-standard functions, like
__get_unaligned, which are only defined in Linux's asm/unaligned.h. IMHO, we should get rid of the include of asm/unaligned.h and code whatever functions we need from that file in a portable way.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#35 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 23 lines · Ian Campbell
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Quoted 6 lines
Quoted 3 lines

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression code,

Which library provides lz4_decompress_unknownoutputsize then?

It looks to me like xc_dom_decompress_lz4 gets it from #include "../../xen/common/lz4/decompress.c" even in the !__MINIOS__ case and:

        $ head -n2 xen/common/lz4/decompress.c
        /*
         * LZ4 Decompressor for Linux kernel
Quoted 7 lines

i.e. this is Linux code (which Linux uses to decompress itself on boot) copied into the hypervisor.

Since this is imported code we don't really want to rewrite it so we can resync easily in the future. It's up to Xen and libxc to provide the necessary scaffolding (in terms of helpers the unaligned accessors) to make this code compile.

Yes, sorry I misunderstood you, I though you were saying that somehow Xen (or the tools), were relying on the Linux kernel to perform the decompression (which makes no sense).

That's my plan, but instead of adding some crappy hack for OSes that don't have asm/unaligned.h, I would like to get rid of that dependency and code the helpers that we need.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#36 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 27 lines · Roger Pau Monné
Quoted 26 lines · Ian Campbell
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Quoted 6 lines
Quoted 3 lines

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression code,

Which library provides lz4_decompress_unknownoutputsize then?

It looks to me like xc_dom_decompress_lz4 gets it from #include "../../xen/common/lz4/decompress.c" even in the !__MINIOS__ case and:

        $ head -n2 xen/common/lz4/decompress.c
        /*
         * LZ4 Decompressor for Linux kernel

i.e. this is Linux code (which Linux uses to decompress itself on boot) copied into the hypervisor.

Quoted 8 lines
Quoted 4 lines

Since this is imported code we don't really want to rewrite it so we can resync easily in the future. It's up to Xen and libxc to provide the necessary scaffolding (in terms of helpers the unaligned accessors) to make this code compile.

Yes, sorry I misunderstood you, I though you were saying that somehow Xen (or the tools), were relying on the Linux kernel to perform the decompression

Ah yes, I can see how that was confusing, sorry!

Quoted 1 line

(which makes no sense).

Indeed.

Quoted 3 lines

That's my plan, but instead of adding some crappy hack for OSes that don't have asm/unaligned.h, I would like to get rid of that dependency and code the helpers that we need.

In the scaffolding and not by modifying the imported code I pressume? In which case, good thanks!

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#37 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 41 lines · Ian Campbell
Quoted 27 lines · Roger Pau Monné
Quoted 26 lines · Ian Campbell
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

Anyway, I think this patch and the preceding one are plain wrong, what we should do is completely remove the bogus dependence on asm/unaligned.h, which is a Linux specific header file, and open-code what we need.

Quoted 6 lines
Quoted 3 lines

Am I right that for libxc's lz4 support we are using the Linux kernel's built in decompression code, instead of the relevant userspace library as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression code,

Which library provides lz4_decompress_unknownoutputsize then?

It looks to me like xc_dom_decompress_lz4 gets it from #include "../../xen/common/lz4/decompress.c" even in the !__MINIOS__ case and:

        $ head -n2 xen/common/lz4/decompress.c
        /*
         * LZ4 Decompressor for Linux kernel

i.e. this is Linux code (which Linux uses to decompress itself on boot) copied into the hypervisor.

Quoted 8 lines
Quoted 4 lines

Since this is imported code we don't really want to rewrite it so we can resync easily in the future. It's up to Xen and libxc to provide the necessary scaffolding (in terms of helpers the unaligned accessors) to make this code compile.

Yes, sorry I misunderstood you, I though you were saying that somehow Xen (or the tools), were relying on the Linux kernel to perform the decompression

Ah yes, I can see how that was confusing, sorry!

Quoted 1 line

(which makes no sense).

Quoted 8 lines

Indeed.

Quoted 3 lines

That's my plan, but instead of adding some crappy hack for OSes that don't have asm/unaligned.h, I would like to get rid of that dependency and code the helpers that we need.

In the scaffolding and not by modifying the imported code I pressume? In which case, good thanks!

While working around this issue, I've noticed that xen/common/lz4/defs.h has one branch for little endian and another one for big endian, but while compiling libxc, "__LITTLE_ENDIAN" is not defined and we fall into big endian, which seems wrong, because we don't have support for any big endian arch.

Would it be OK to get rid of the big endian case, and only support little endian by default?

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#38 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 11 lines · Roger Pau Monné
Quoted 2 lines

In the scaffolding and not by modifying the imported code I pressume? In which case, good thanks!

While working around this issue, I've noticed that xen/common/lz4/defs.h has one branch for little endian and another one for big endian, but while compiling libxc, "__LITTLE_ENDIAN" is not defined and we fall into big endian, which seems wrong, because we don't have support for any big endian arch.

Would it be OK to get rid of the big endian case, and only support little endian by default?

I think it would be better to #define __LITTLE_ENDIAN than to diverge from the upstream of this file.

gcc has some built #defines for this see [0], but I'd have thought this would be something autoconf could assist with. Or we could probably get away with a static #define in tools/libxc/xc_dom_decompress_lz4.c.

Ian.

[0] http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros

          /* Test for a little-endian machine */
          #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__     
Quoted 3 lines

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#39 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 11 lines · Ian Campbell
Quoted 9 lines · Roger Pau Monné
Quoted 2 lines

In the scaffolding and not by modifying the imported code I pressume? In which case, good thanks!

While working around this issue, I've noticed that xen/common/lz4/defs.h has one branch for little endian and another one for big endian, but while compiling libxc, "__LITTLE_ENDIAN" is not defined and we fall into big endian, which seems wrong, because we don't have support for any big endian arch.

Quoted 5 lines
Quoted 2 lines

Would it be OK to get rid of the big endian case, and only support little endian by default?

I think it would be better to #define __LITTLE_ENDIAN than to diverge from the upstream of this file.

We have already diverged from upstream by adding those __LITTLE_ENDIAN checks, the upstream file doesn't seem to contain them in any of the versions:

http://lxr.free-electrons.com/source/lib/lz4/lz4defs.h

The following patch removes this cruft, but I'm unsure if we want to keep this endianness differentiation:

tools/libxc/xc_dom_decompress_lz4.c +0 -1
index 08272fe..490ec56 100644
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include <endian.h>
 #include <stdint.h>
 
 #include "xg_private.h"
xen/common/lz4/defs.h +0 -14
index f46df08..d886a4e 100644
@@ -12,7 +12,6 @@
 #include <asm/byteorder.h>
 #endif
 
-#ifdef __LITTLE_ENDIAN
 static inline u16 INIT get_unaligned_le16(const void *p)
 {
 	return le16_to_cpup(p);
@@ -22,19 +21,6 @@ static inline u32 INIT get_unaligned_le32(const void *p)
 {
 	return le32_to_cpup(p);
 }
-#else
-#include <asm/unaligned.h>
-
-static inline u16 INIT get_unaligned_le16(const void *p)
-{
-	return le16_to_cpu(__get_unaligned(p, 2));
-}
-
-static inline u32 INIT get_unaligned_le32(void *p)
-{
-	return le32_to_cpu(__get_unaligned(p, 4));
-}
-#endif
 
 /*
  * Detects 64 bits mode

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#40 lore raw

Re: [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h

Quoted 15 lines · Roger Pau Monné
Quoted 14 lines · Ian Campbell
Quoted 11 lines · Roger Pau Monné
Quoted 2 lines

In the scaffolding and not by modifying the imported code I pressume? In which case, good thanks!

While working around this issue, I've noticed that xen/common/lz4/defs.h has one branch for little endian and another one for big endian, but while compiling libxc, "__LITTLE_ENDIAN" is not defined and we fall into big endian, which seems wrong, because we don't have support for any big endian arch.

Would it be OK to get rid of the big endian case, and only support little endian by default?

Quoted 8 lines
Quoted 2 lines

I think it would be better to #define __LITTLE_ENDIAN than to diverge from the upstream of this file.

We have already diverged from upstream by adding those __LITTLE_ENDIAN checks, the upstream file doesn't seem to contain them in any of the versions:

http://lxr.free-electrons.com/source/lib/lz4/lz4defs.h

Ah, those blocks are part of our shimming to make things work (i.e. trying and failing to do what I was suggesting).

Actually the two cases are pretty weird. they differ only in their use of the unaligned macros for big endian -- which seems rather orthogonal to the test for __LITTLE_ENDIAN.

Quoted 2 lines

The following patch removes this cruft, but I'm unsure if we want to keep this endianness differentiation:

I think this would be ok, if the alignedness really matters then that should be what is tested for I think...

Quoted 36 lines
tools/libxc/xc_dom_decompress_lz4.c +0 -1
index 08272fe..490ec56 100644
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include <endian.h>
 #include <stdint.h>
 
 #include "xg_private.h"
xen/common/lz4/defs.h +0 -7
index f46df08..d886a4e 100644
@@ -12,7 +12,6 @@
 #include <asm/byteorder.h>
 #endif
 
-#ifdef __LITTLE_ENDIAN
 static inline u16 INIT get_unaligned_le16(const void *p)
 {
 	return le16_to_cpup(p);
@@ -22,19 +21,6 @@ static inline u32 INIT get_unaligned_le32(const void *p)
 {
 	return le32_to_cpup(p);
 }
-#else
-#include <asm/unaligned.h>
-
-static inline u16 INIT get_unaligned_le16(const void *p)
-{
-	return le16_to_cpu(__get_unaligned(p, 2));

xen/common/lz4/defs.h static inline u32 INIT get_unaligned_le32(const void *p) · line 26

Quoted 10 lines
xen/common/lz4/defs.h +0 -7
-}
-
-static inline u32 INIT get_unaligned_le32(void *p)
-{
-	return le32_to_cpu(__get_unaligned(p, 4));
-}
-#endif
 
 /*
  * Detects 64 bits mode

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#41 lore raw

RFC PATCH 10/23 xenstored: add the FreeBSD xenstored interface

In reply to Roger Pau Monne

This patch adds FreeBSD support to xenstored, by implementing the FreeBSD interface to /dev/xen/xenstored.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/xenstore/Makefile            |    1 +
 tools/xenstore/xenstored_freebsd.c |   72 ++++++++++++++++++++++++++++++++++++
 tools/xenstore/xs_lib.c            |    2 +
 3 files changed, 75 insertions(+), 0 deletions(-)
 create mode 100644 tools/xenstore/xenstored_freebsd.c
tools/xenstore/Makefile +1 -0
index 262f401..0b2b2c7 100644
@@ -14,6 +14,7 @@ CLIENTS += xenstore-write xenstore-ls xenstore-watch
 XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o
 
 XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o xenstored_posix.o
+XENSTORED_OBJS_$(CONFIG_FreeBSD) = xenstored_freebsd.o xenstored_posix.o
 XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o xenstored_posix.o xenstored_probes.o
 XENSTORED_OBJS_$(CONFIG_NetBSD) = xenstored_netbsd.o xenstored_posix.o
 XENSTORED_OBJS_$(CONFIG_MiniOS) = xenstored_minios.o
tools/xenstore/xenstored_freebsd.c new file +72 -0

72 lines not on this page · raw message

tools/xenstore/xs_lib.c +2 -0
index f7076cc..dfbeff1 100644
@@ -84,6 +84,8 @@ const char *xs_domain_dev(void)
 	return "/proc/xen/xenbus";
 #elif defined(__NetBSD__)
 	return "/kern/xen/xenbus";
+#elif defined(__FreeBSD__)
+	return "/dev/xen/xenstore";
 #else
 	return "/dev/xen/xenbus";
 #endif
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#42 lore raw

Re: [PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface

Roger Pau Monne writes ("[PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface"):

Quoted 2 lines

This patch adds FreeBSD support to xenstored, by implementing the FreeBSD interface to /dev/xen/xenstored.

Again, this is very similar to xenstored_linux.c. As is xenstored_netbsd.c :-/.

TBH I'm not sure it's fair to ask you to drain this swamp as part of sending in a new port...

Ian.

#43 lore raw

Re: [PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface

Quoted 6 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface"):

Quoted 2 lines

This patch adds FreeBSD support to xenstored, by implementing the FreeBSD interface to /dev/xen/xenstored.

Again, this is very similar to xenstored_linux.c. As is xenstored_netbsd.c :-/.

Yes, the main difference is that both Linux and NetBSD seem to use two different devices in order to get the evtchn port and to map xenstored memory. On the other hand, FreeBSD uses the same device in order to obtain the port and do the mmap.

IMHO all this implementations could be easily folded into a single file with very little ifdefery, I will take a look at it.

Roger.

#44 lore raw

Re: [PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface

Roger Pau Monné writes ("Re: [PATCH RFC 10/23] xenstored: add the FreeBSD xenstored interface"):

Quoted 2 lines

IMHO all this implementations could be easily folded into a single file with very little ifdefery, I will take a look at it.

That would be excellent, thank you.

Ian.

#45 lore raw

RFC PATCH 11/23 xenstore: add some missing headers

In reply to Roger Pau Monne

xs_tdb_dump.c was including tdb.h, which makes use of dev_t and ino_t, which are defined in sys/types.h.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/xenstore/xs_tdb_dump.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
tools/xenstore/xs_tdb_dump.c +1 -0
index 7aa7158..b91cdef 100644
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
+#include <sys/types.h>
 #include "xenstore_lib.h"
 #include "tdb.h"
 #include "talloc.h"
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#46 lore raw

RFC PATCH 11/23 xenstore: add some missing headers

Roger Pau Monne writes ("[PATCH RFC 11/23] xenstore: add some missing headers"):

Quoted 2 lines

xs_tdb_dump.c was including tdb.h, which makes use of dev_t and ino_t, which are defined in sys/types.h.

I was going to say "can't we put this in tdb.h" but after looking at tdb.h I see why you didn't want to do that :-/.

Thanks,
Ian.

#47 lore raw

RFC PATCH 12/23 console: add FreeBSD includes

In reply to Roger Pau Monne

Add FreeBSD specific includes to the console daemon.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/console/daemon/io.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
tools/console/daemon/io.c +5 -0
index 007ecf4..255a6a3 100644
@@ -43,6 +43,11 @@
 #include <pty.h>
 #elif defined(__sun__)
 #include <stropts.h>
+#elif defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <libutil.h>
 #endif
 
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#48 lore raw

Re: [PATCH RFC 12/23] console: add FreeBSD includes

Roger Pau Monne writes ("[PATCH RFC 12/23] console: add FreeBSD includes"):

Quoted 1 line

Add FreeBSD specific includes to the console daemon.

...

tools/console/daemon/io.c line 51

Quoted 7 lines

#include <stropts.h>

tools/console/daemon/io.c +5 -0
+#elif defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <libutil.h>
 #endif

<termios.h> is already there earlier. <sys/types.h> can probably be outside the #ifdef.

Ian.

#49 lore raw

RFC PATCH 13/23 init: add FreeBSD xencommons init script

In reply to Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/hotplug/FreeBSD/Makefile        |   43 ++++++++++++
 tools/hotplug/FreeBSD/rc.d/xencommons |  121 +++++++++++++++++++++++++++++++++
 tools/hotplug/Makefile                |    1 +
 3 files changed, 165 insertions(+), 0 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/Makefile
 create mode 100644 tools/hotplug/FreeBSD/rc.d/xencommons
tools/hotplug/FreeBSD/Makefile new file +43 -0
new file mode 100644
index 0000000..c7ffc51
@@ -0,0 +1,43 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+# Xen script dir and scripts to go there.
+XEN_SCRIPTS =
+
+XEN_SCRIPT_DATA =
+
+XEN_RCD_PROG = rc.d/xencommons
+
+.PHONY: all
+all:
+
+.PHONY: build
+build:
+
+.PHONY: install
+install: all install-scripts install-rcd
+
+.PHONY: install-scripts
+install-scripts:
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
+	set -e; for i in $(XEN_SCRIPTS); \
+	   do \
+	   $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
+	done
+	set -e; for i in $(XEN_SCRIPT_DATA); \
+	   do \
+	   $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
+	done
+
+.PHONY: install-rcd
+install-rcd:
+	$(INSTALL_DIR) $(DESTDIR)$(CONFIG_DIR)/rc.d
+	set -e; for i in $(XEN_RCD_PROG); \
+	   do \
+	   $(INSTALL_PROG) $$i $(DESTDIR)$(CONFIG_DIR)/rc.d; \
+	   sed -i '' 's,@xen_script_dir@,$(DESTDIR)$(XEN_SCRIPT_DIR),g' $(DESTDIR)$(CONFIG_DIR)/$$i; \
+	done
+	$(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(XEN_SCRIPT_DIR)
+
+.PHONY: clean
+clean:
tools/hotplug/FreeBSD/rc.d/xencommons new file +121 -0

121 lines not on this page · raw message

tools/hotplug/Makefile +1 -0
index f147b59..14ae9a8 100644
@@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 SUBDIRS-y := common
 SUBDIRS-$(CONFIG_NetBSD) += NetBSD
 SUBDIRS-$(CONFIG_Linux) += Linux
+SUBDIRS-$(CONFIG_FreeBSD) += FreeBSD
 
 .PHONY: all clean install
 all clean install: %: subdirs-%
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#50 lore raw

Re: [PATCH RFC 13/23] init: add FreeBSD xencommons init script

On Wed, 2014-04-16 at 16:13 +0200, Roger Pau Monne wrote:

Is this new or a clone of NetBSD?

#51 lore raw

Re: [PATCH RFC 13/23] init: add FreeBSD xencommons init script

Quoted 3 lines · Ian Campbell

On Wed, 2014-04-16 at 16:13 +0200, Roger Pau Monne wrote:

Is this new or a clone of NetBSD?

It's pretty much a clone of the NetBSD one, with some very minor modifications.

Roger.

#52 lore raw

Re: [PATCH RFC 13/23] init: add FreeBSD xencommons init script

Quoted 7 lines · Roger Pau Monné
Quoted 3 lines · Ian Campbell

On Wed, 2014-04-16 at 16:13 +0200, Roger Pau Monne wrote:

Is this new or a clone of NetBSD?

It's pretty much a clone of the NetBSD one, with some very minor modifications.

OK, then I shan't bother to read it too closely, can you mention the provenance in the commit log though please.

This duplication is unfortunate but there is lots of similar duplication already and I don't think we can expect you to drain that swamp as part of this series.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#53 lore raw

RFC PATCH 14/23 hotplug: add FreeBSD vif-bridge

In reply to Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/hotplug/FreeBSD/Makefile   |    2 +-
 tools/hotplug/FreeBSD/vif-bridge |   41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/vif-bridge
tools/hotplug/FreeBSD/Makefile +1 -1
index c7ffc51..6480aa5 100644
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS =
+XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
tools/hotplug/FreeBSD/vif-bridge new file +41 -0

41 lines not on this page · raw message

Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#54 lore raw

Re: [PATCH RFC 14/23] hotplug: add FreeBSD vif-bridge

Quoted 2 lines · Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Compared with the Linux one it lacks the handling of the vifname property and the attempt to provide a default if no bridge was specified. This is probably acceptable I suppose.

Quoted 39 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/hotplug/FreeBSD/Makefile   |    2 +-
 tools/hotplug/FreeBSD/vif-bridge |   41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/vif-bridge
tools/hotplug/FreeBSD/Makefile +1 -1
index c7ffc51..6480aa5 100644
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS =
+XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
tools/hotplug/FreeBSD/vif-bridge new file +10 -0
new file mode 100644
index 0000000..b36d075
@@ -0,0 +1,41 @@
+#!/bin/sh -e
+#
+# FreeBSD hotplug script for attaching xnb* interfaces to bridges
+#
+# Parameters:
+#	$1: xenstore backend path of the vif
+#	$2: action, either "add" or "remove"
+#
+# Environment variables:
+#	$iface_dev: name of the backend device (xnb<domid>.<handle>)

tools/hotplug/FreeBSD/vif-bridge line 20

Quoted 10 lines
tools/hotplug/FreeBSD/vif-bridge new file +10 -0
+#
+
+DIR=$(dirname "$0")
+. "${DIR}/hotplugpath.sh"
+
+PATH=${BINDIR}:${SBINDIR}:${LIBEXEC}:${PRIVATE_BINDIR}:/bin:/usr/bin:/sbin:/usr/sbin
+export PATH
+
+xpath=$1
+xaction=$2

OOI why the x prefixes everywhere?

Quoted 11 lines
tools/hotplug/FreeBSD/vif-bridge new file +11 -0
+
+case $xaction in
+add)
+	xbridge=$(xenstore-read "$xpath/bridge")
+	ifconfig $xbridge addm $iface_dev
+	ifconfig $iface_dev up
+	exit 0
+	;;
+remove)
+	if [ "$emulated" -eq 1 ]; then
+		xbridge=$(xenstore-read "$xpath/bridge")

tools/hotplug/FreeBSD/vif-bridge line 41

Quoted 10 lines
tools/hotplug/FreeBSD/vif-bridge new file +10 -0
+		ifconfig $iface_dev down
+		ifconfig $xbridge deletem $iface_dev
+		ifconfig $iface_dev destroy
+	fi
+	exit 0
+	;;
+*)
+	exit 0
+	;;
+esac

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#55 lore raw

Re: [PATCH RFC 14/23] hotplug: add FreeBSD vif-bridge

Quoted 7 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Compared with the Linux one it lacks the handling of the vifname property and the attempt to provide a default if no bridge was specified. This is probably acceptable I suppose.

I would like to explicitly avoid providing a default bridge if no bridge was specified, I think this should probably be done in the global xl configuration file.

Quoted 43 lines
Quoted 43 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/hotplug/FreeBSD/Makefile   |    2 +-
 tools/hotplug/FreeBSD/vif-bridge |   41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/vif-bridge
tools/hotplug/FreeBSD/Makefile +1 -1
index c7ffc51..6480aa5 100644
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS =
+XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
tools/hotplug/FreeBSD/vif-bridge new file +14 -0
new file mode 100644
index 0000000..b36d075
@@ -0,0 +1,41 @@
+#!/bin/sh -e
+#
+# FreeBSD hotplug script for attaching xnb* interfaces to bridges
+#
+# Parameters:
+#	$1: xenstore backend path of the vif
+#	$2: action, either "add" or "remove"
+#
+# Environment variables:
+#	$iface_dev: name of the backend device (xnb<domid>.<handle>)
+#
+
+DIR=$(dirname "$0")
+. "${DIR}/hotplugpath.sh"
Quoted 8 lines

tools/hotplug/FreeBSD/vif-bridge line 20

Quoted 6 lines
tools/hotplug/FreeBSD/vif-bridge new file +6 -0
+
+PATH=${BINDIR}:${SBINDIR}:${LIBEXEC}:${PRIVATE_BINDIR}:/bin:/usr/bin:/sbin:/usr/sbin
+export PATH
+
+xpath=$1
+xaction=$2

OOI why the x prefixes everywhere?

Because they were there on the NetBSD version, but I will remove them in the next version of the series.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#56 lore raw

Re: [PATCH RFC 14/23] hotplug: add FreeBSD vif-bridge

Quoted 5 lines · Roger Pau Monné
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Quoted 7 lines
Quoted 3 lines

Compared with the Linux one it lacks the handling of the vifname property and the attempt to provide a default if no bridge was specified. This is probably acceptable I suppose.

I would like to explicitly avoid providing a default bridge if no bridge was specified, I think this should probably be done in the global xl configuration file.

Is that what NetBSD does? I know Linux provides one, so FreeBSD should either be the same as NetBSD or Linux (so if NetBSD provides a default so should FreeBSD).

Quoted 4 lines
Quoted 1 line

OOI why the x prefixes everywhere?

Because they were there on the NetBSD version, but I will remove them in the next version of the series.

Feel free to leave them if you would rather not diverge (with the aim of eventually merging). Up to you though.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#57 lore raw

Re: [PATCH RFC 14/23] hotplug: add FreeBSD vif-bridge

Quoted 10 lines · Ian Campbell
Quoted 9 lines · Roger Pau Monné
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Compared with the Linux one it lacks the handling of the vifname property and the attempt to provide a default if no bridge was specified. This is probably acceptable I suppose.

Quoted 7 lines
Quoted 3 lines

I would like to explicitly avoid providing a default bridge if no bridge was specified, I think this should probably be done in the global xl configuration file.

Is that what NetBSD does? I know Linux provides one, so FreeBSD should either be the same as NetBSD or Linux (so if NetBSD provides a default so should FreeBSD).

NetBSD doesn't seem to provide a default bridge, here is what NetBSD does in vif-bridge:

xbridge=$(xenstore-read "$xpath/bridge")
[...]
brconfig $xbridge add $iface

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

OOI why the x prefixes everywhere?

Because they were there on the NetBSD version, but I will remove them in the next version of the series.

Feel free to leave them if you would rather not diverge (with the aim of eventually merging). Up to you though.

I've removed the "x" prefixes, since I think they are not helpful. Later on we can remove them from the NetBSD script if there's interest in merging them.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#58 lore raw

Re: [PATCH RFC 14/23] hotplug: add FreeBSD vif-bridge

Quoted 19 lines · Roger Pau Monné
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Roger Pau Monné
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Add a simple vif-bridge script, that takes care of adding network backends (tap or xnb) to a pre-configured bridge.

Compared with the Linux one it lacks the handling of the vifname property and the attempt to provide a default if no bridge was specified. This is probably acceptable I suppose.

Quoted 7 lines
Quoted 3 lines

I would like to explicitly avoid providing a default bridge if no bridge was specified, I think this should probably be done in the global xl configuration file.

Is that what NetBSD does? I know Linux provides one, so FreeBSD should either be the same as NetBSD or Linux (so if NetBSD provides a default so should FreeBSD).

Quoted 6 lines

NetBSD doesn't seem to provide a default bridge, here is what NetBSD does in vif-bridge:

xbridge=$(xenstore-read "$xpath/bridge")
[...]
brconfig $xbridge add $iface

OK, then I'm fine with FreeBSD not having a default either.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

OOI why the x prefixes everywhere?

Because they were there on the NetBSD version, but I will remove them in the next version of the series.

Quoted 6 lines
Quoted 2 lines

Feel free to leave them if you would rather not diverge (with the aim of eventually merging). Up to you though.

I've removed the "x" prefixes, since I think they are not helpful. Later on we can remove them from the NetBSD script if there's interest in merging them.

Sure.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#59 lore raw

RFC PATCH 15/23 libxl: add support for OS-specific names to backend interfaces

In reply to Roger Pau Monne

libxl__device_nic_devname used to hardcode backend network interfaces as "vif<domid>.<handle>", remove this limitation and allow libxl to deal with OS-specific interface names.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxl/libxl.c        |    4 ++--
 tools/libxl/libxl_osdeps.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl.c +2 -2
index 30b0b06..2249265 100644
@@ -3171,9 +3171,9 @@ const char *libxl__device_nic_devname(libxl__gc *gc,
 {
     switch (type) {
     case LIBXL_NIC_TYPE_VIF:
-        return GCSPRINTF("vif%u.%d", domid, devid);
+        return GCSPRINTF(NETBACK_NIC_NAME, domid, devid);
     case LIBXL_NIC_TYPE_VIF_IOEMU:
-        return GCSPRINTF("vif%u.%d" TAP_DEVICE_SUFFIX, domid, devid);
+        return GCSPRINTF(NETBACK_NIC_NAME TAP_DEVICE_SUFFIX, domid, devid);
     default:
         abort();
     }
tools/libxl/libxl_osdeps.h +2 -0
index f91bc79..aea83ee 100644
@@ -26,12 +26,14 @@
 #if defined(__NetBSD__)
 #define SYSFS_PCI_DEV          "/sys/bus/pci/devices"
 #define SYSFS_PCIBACK_DRIVER   "/kern/xen/pci"
+#define NETBACK_NIC_NAME       "xvif%ui%d"
 #include <util.h>
 #elif defined(__OpenBSD__)
 #include <util.h>
 #elif defined(__linux__)
 #define SYSFS_PCI_DEV          "/sys/bus/pci/devices"
 #define SYSFS_PCIBACK_DRIVER   "/sys/bus/pci/drivers/pciback"
+#define NETBACK_NIC_NAME       "vif%u.%d"
 #include <pty.h>
 #elif defined(__sun__)
 #include <stropts.h>
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 15/23
#60 lore raw

Re: [PATCH RFC 15/23] libxl: add support for OS-specific names to backend interfaces

Roger Pau Monne writes ("[PATCH RFC 15/23] libxl: add support for OS-specific names to backend interfaces"):

Quoted 3 lines

libxl__device_nic_devname used to hardcode backend network interfaces as "vif<domid>.<handle>", remove this limitation and allow libxl to deal with OS-specific interface names.

#61 lore raw

RFC PATCH 16/23 libxl: add FreeBSD OS support

In reply to Roger Pau Monne

Create a new libxl_freebsd.c file that contains OS-specific bits used by libxl.

This currently defines which backend to use to handle disks, and which hotplug scripts to execute.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxl/Makefile        |    4 +
 tools/libxl/libxl_freebsd.c |  133 +++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_osdeps.h  |    5 ++
 3 files changed, 142 insertions(+), 0 deletions(-)
 create mode 100644 tools/libxl/libxl_freebsd.c
tools/libxl/Makefile +4 -0
index 755b666..ee8cf00 100644
@@ -52,10 +52,14 @@ else
 ifeq ($(CONFIG_Linux),y)
 LIBXL_OBJS-y += libxl_linux.o
 else
+ifeq ($(CONFIG_FreeBSD),y)
+LIBXL_OBJS-y += libxl_freebsd.o
+else
 $(error Your Operating System is not supported by libxenlight, \
 please check libxl_linux.c and libxl_netbsd.c to see how to get it ported)
 endif
 endif
+endif
 
 ifeq ($(FLEX),)
 %.c %.h:: %.l
tools/libxl/libxl_freebsd.c new file +133 -0

133 lines not on this page · raw message

tools/libxl/libxl_osdeps.h +5 -0
index aea83ee..08eaf0c 100644
@@ -37,6 +37,11 @@
 #include <pty.h>
 #elif defined(__sun__)
 #include <stropts.h>
+#elif defined(__FreeBSD__)
+#define SYSFS_PCI_DEV          "/dev/null"
+#define SYSFS_PCIBACK_DRIVER   "/dev/null"
+#define NETBACK_NIC_NAME       "xnb%u.%d"
+#include <libutil.h>
 #endif
 
 #ifndef SYSFS_PCIBACK_DRIVER
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#62 lore raw

Re: [PATCH RFC 16/23] libxl: add FreeBSD OS support

Roger Pau Monne writes ("[PATCH RFC 16/23] libxl: add FreeBSD OS support"):

Quoted 5 lines

Create a new libxl_freebsd.c file that contains OS-specific bits used by libxl.

This currently defines which backend to use to handle disks, and which hotplug scripts to execute.

Are there no disk scripts on FreeBSD ?

Ian.

#63 lore raw

Re: [PATCH RFC 16/23] libxl: add FreeBSD OS support

Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 16/23] libxl: add FreeBSD OS support"):

Quoted 5 lines

Create a new libxl_freebsd.c file that contains OS-specific bits used by libxl.

This currently defines which backend to use to handle disks, and which hotplug scripts to execute.

Are there no disk scripts on FreeBSD ?

Not yet, I will look into adding hotplug script support for disks, but it's something that I was planning to do after getting initial tools support.

Roger.

#64 lore raw

RFC PATCH 17/23 libxl: add support for FreeBSD uuid implementation

In reply to Roger Pau Monne

Add the FreeBSD specific uuid implementation. Since uuid_t is not defined as an array, but as a struct on FreeBSD, use a union with a array in order to be able to return the uuid as a bytearray.

Also, added a libxl internal compile time assert macro, that is used to assert that the size of uuid_t is the same as the union used in libxl.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/libxl/libxl_internal.h |    4 +++
 tools/libxl/libxl_uuid.c     |   51 ++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_uuid.h     |   12 ++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
tools/libxl/libxl_internal.h +4 -0
index c2b73c4..9f8ab49 100644
@@ -3085,6 +3085,10 @@ void libxl__numa_candidate_put_nodemap(libxl__gc *gc,
  */
 #define CTYPE(isfoo,c) (isfoo((unsigned char)(c)))
 
+/*
+ * Compile time assertion
+ */
+#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
 
 #endif
 
tools/libxl/libxl_uuid.c +51 -0

57 lines not on this page · raw message

tools/libxl/libxl_uuid.h +12 -0
index 93c65a7..3604180 100644
@@ -47,6 +47,18 @@ typedef struct {
     uint8_t uuid[16];
 } libxl_uuid;
 
+#elif defined(__FreeBSD__)
+
+#include <uuid.h>
+#include <stdint.h>
+
+typedef union {
+    uuid_t uuid;
+    uint8_t uuid_raw[16];
+} libxl_uuid;
+
+#define LIBXL_UUID_BYTES(arg) LIBXL__UUID_BYTES(arg.uuid_raw)
+
 #else
 
 #error "Please update libxl_uuid.h for your OS"
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#65 lore raw

Re: [PATCH RFC 17/23] libxl: add support for FreeBSD uuid implementation

Roger Pau Monne writes ("[PATCH RFC 17/23] libxl: add support for FreeBSD uuid implementation"):

Quoted 3 lines

Add the FreeBSD specific uuid implementation. Since uuid_t is not defined as an array, but as a struct on FreeBSD, use a union with a array in order to be able to return the uuid as a bytearray.

I don't have a FreeBSD machine here to hand, but if it's a struct full of >1-byte objects, aren't there endian problems with this approach ?

Ian.

#66 lore raw

Re: [PATCH RFC 17/23] libxl: add support for FreeBSD uuid implementation

Quoted 7 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 17/23] libxl: add support for FreeBSD uuid implementation"):

Quoted 3 lines

Add the FreeBSD specific uuid implementation. Since uuid_t is not defined as an array, but as a struct on FreeBSD, use a union with a array in order to be able to return the uuid as a bytearray.

I don't have a FreeBSD machine here to hand, but if it's a struct full of >1-byte objects, aren't there endian problems with this approach ?

I'm frankly not familiar at all with uuid or how it's supposed to work, but from what I saw, the NetBSD and FreeBSD implementations of uuid are very similar (most of FreeBSD code seems to be picked from NetBSD).

I'm not sure what endian problems can come out of it, NetBSD uses the same approach. The only difference is that NetBSD directly defines the uuid field as an array, but on FreeBSD I've preferred to use a union of the native type with an array (so native functions get called by passing the right type, which is uuid_t), while libxl can still make use of the byte array.

Roger.

#67 lore raw

RFC PATCH 18/23 libxl: only include utmp.h if it's present

In reply to Roger Pau Monne

Add a configure check for utmp.h presence, and gate the usage of utmp.h in libxl to the result of the test.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/config.h.in              |    3 +++
 tools/configure.ac             |    2 +-
 tools/libxl/libxl_bootloader.c |    2 ++
 3 files changed, 6 insertions(+), 1 deletions(-)
tools/config.h.in +3 -0
index 709a51d..842e766 100644
@@ -60,6 +60,9 @@
 /* Define to 1 if you have the <asm/unaligned.h> header file. */
 #undef HAVE_ASM_UNALIGNED_H
 
+/* Define to 1 if you have the <utmp.h> header file. */
+#undef HAVE_UTMP_H
+
 /* Define curses header to use */
 #undef INCLUDE_CURSES_H
 
tools/configure.ac +1 -1
index cf30254..2a4a729 100644
@@ -247,7 +247,7 @@ AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])])
 esac
 
 # Checks for header files.
-AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h endian.h sys/endian.h asm/unaligned.h])
+AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h endian.h sys/endian.h asm/unaligned.h utmp.h])
 
 AC_OUTPUT()
 
tools/libxl/libxl_bootloader.c +2 -0
index 3287bf7..c3ec782 100644
@@ -15,7 +15,9 @@
 #include "libxl_osdeps.h" /* must come before any other headers */
 
 #include <termios.h>
+#ifdef HAVE_UTMP_H
 #include <utmp.h>
+#endif
 
 #ifdef INCLUDE_LIBUTIL_H
 #include INCLUDE_LIBUTIL_H
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#68 lore raw

Re: [PATCH RFC 18/23] libxl: only include utmp.h if it's present

Roger Pau Monne writes ("[PATCH RFC 18/23] libxl: only include utmp.h if it's present"):

Quoted 2 lines

Add a configure check for utmp.h presence, and gate the usage of utmp.h in libxl to the result of the test.

I don't object to this, but: on FreeBSD, which header defines login_tty then ?

Ian.

#69 lore raw

Re: [PATCH RFC 18/23] libxl: only include utmp.h if it's present

Quoted 6 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 18/23] libxl: only include utmp.h if it's present"):

Quoted 2 lines

Add a configure check for utmp.h presence, and gate the usage of utmp.h in libxl to the result of the test.

I don't object to this, but: on FreeBSD, which header defines login_tty then ?

It's in libutil.h:

http://www.freebsd.org/cgi/man.cgi?query=login_tty&apropos=0&sektion=0&manpath=FreeBSD+10.0-RELEASE&arch=default&format=html

which is already included by libxl_osdeps.h.

Roger.

Acked-by
#70 lore raw

Re: [PATCH RFC 18/23] libxl: only include utmp.h if it's present

Roger Pau Monné writes ("Re: [PATCH RFC 18/23] libxl: only include utmp.h if it's present"):

Quoted 9 lines · Ian Jackson
Quoted 2 lines

I don't object to this, but: on FreeBSD, which header defines login_tty then ?

It's in libutil.h:

http://www.freebsd.org/cgi/man.cgi?query=login_tty&apropos=0&sektion=0&manpath=FreeBSD+10.0-RELEASE&arch=default&format=html

which is already included by libxl_osdeps.h.

OK, good.

Thanks,
Ian.

#71 lore raw

RFC PATCH 19/23 hvmloader: remove size_t typedef and include stddef.h

In reply to Roger Pau Monne

The open coded typedef of size_t was clashing with the typedef in FreeBSD headers. Remove the typedef and include the proper header where size_t is defined (stddef.h).

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/hvmloader/util.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/hvmloader/util.h +1 -1
index 9ccb905..46d32b9 100644
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <stddef.h>
 #include <xen/xen.h>
 #include <xen/hvm/hvm_info_table.h>
 
@@ -174,7 +175,6 @@ int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 int vprintf(const char *fmt, va_list ap);
 
 /* Buffer output */
-typedef unsigned long size_t;
 int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
 
 /* Populate specified memory hole with RAM. */
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#72 lore raw

Re: [PATCH RFC 19/23] hvmloader: remove size_t typedef and include stddef.h

Quoted 17 lines · Roger Pau Monne

The open coded typedef of size_t was clashing with the typedef in FreeBSD headers. Remove the typedef and include the proper header where size_t is defined (stddef.h).

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/hvmloader/util.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/hvmloader/util.h +0 -0
index 9ccb905..46d32b9 100644

tools/firmware/hvmloader/util.h line 6

Quoted 4 lines
tools/firmware/hvmloader/util.h +1 -0
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <stddef.h>

This isn't really userspace code, it's essentially a little kernel. So I'm not sure what the impact of including stddef.h is. I suppose it is probably OK.

Xen itself seems to use "typedef __SIZE_TYPE__ size_t" without ill-affects, on *BSD too I suppose.

tools/firmware/hvmloader/util.h int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); · line 180

Quoted 11 lines
tools/firmware/hvmloader/util.h +0 -1
 #include <xen/xen.h>
 #include <xen/hvm/hvm_info_table.h>
 
@@ -174,7 +175,6 @@ int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 int vprintf(const char *fmt, va_list ap);
 
 /* Buffer output */
-typedef unsigned long size_t;
 int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
 
 /* Populate specified memory hole with RAM. */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#73 lore raw

Re: [PATCH RFC 19/23] hvmloader: remove size_t typedef and include stddef.h

Quoted 27 lines · Ian Campbell
Quoted 17 lines · Roger Pau Monne

The open coded typedef of size_t was clashing with the typedef in FreeBSD headers. Remove the typedef and include the proper header where size_t is defined (stddef.h).

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/hvmloader/util.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/hvmloader/util.h +0 -0
index 9ccb905..46d32b9 100644

tools/firmware/hvmloader/util.h line 6

Quoted 4 lines
tools/firmware/hvmloader/util.h +1 -0
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <stddef.h>

This isn't really userspace code, it's essentially a little kernel. So I'm not sure what the impact of including stddef.h is. I suppose it is probably OK.

Quoted 2 lines

Xen itself seems to use "typedef __SIZE_TYPE__ size_t" without ill-affects, on *BSD too I suppose.

I don't have a strong opinion regarding what to do, but hvmloader/util.h already includes stdarg.h and stdint.h, so adding also stddef.h seemed the best way. I plan to resend this as-is unless someone clearly objects.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#74 lore raw

Re: [PATCH RFC 19/23] hvmloader: remove size_t typedef and include stddef.h

Quoted 28 lines · Roger Pau Monné
Quoted 27 lines · Ian Campbell
Quoted 17 lines · Roger Pau Monne

The open coded typedef of size_t was clashing with the typedef in FreeBSD headers. Remove the typedef and include the proper header where size_t is defined (stddef.h).

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/hvmloader/util.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/hvmloader/util.h +0 -0
index 9ccb905..46d32b9 100644

tools/firmware/hvmloader/util.h line 6

Quoted 4 lines
tools/firmware/hvmloader/util.h +1 -0
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <stddef.h>

This isn't really userspace code, it's essentially a little kernel. So I'm not sure what the impact of including stddef.h is. I suppose it is probably OK.

Quoted 6 lines
Quoted 2 lines

Xen itself seems to use "typedef __SIZE_TYPE__ size_t" without ill-affects, on *BSD too I suppose.

I don't have a strong opinion regarding what to do, but hvmloader/util.h already includes stdarg.h and stdint.h, so adding also stddef.h seemed the best way. I plan to resend this as-is unless someone clearly objects.

Hrm, that probably ought to be fixed, but I suppose that is for another time. So for now: Acked-by: Ian Campbell <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#75 lore raw

RFC PATCH 20/23 xenstat: add a dummy FreeBSD implementation

In reply to Roger Pau Monne

Add an empty FreeBSD implementation so xenstat can compile on FreeBSD.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/xenstat/libxenstat/Makefile              |    1 +
 tools/xenstat/libxenstat/src/xenstat_freebsd.c |   47 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
 create mode 100644 tools/xenstat/libxenstat/src/xenstat_freebsd.c
tools/xenstat/libxenstat/Makefile +1 -0
index 21aad89..15dc22d 100644
@@ -32,6 +32,7 @@ OBJECTS-y=src/xenstat.o
 OBJECTS-$(CONFIG_Linux) += src/xenstat_linux.o
 OBJECTS-$(CONFIG_SunOS) += src/xenstat_solaris.o
 OBJECTS-$(CONFIG_NetBSD) += src/xenstat_netbsd.o
+OBJECTS-$(CONFIG_FreeBSD) += src/xenstat_freebsd.o
 SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR)
 
 WARN_FLAGS=-Wall -Werror
tools/xenstat/libxenstat/src/xenstat_freebsd.c new file +47 -0

47 lines not on this page · raw message

Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#76 lore raw

Re: [PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation

Roger Pau Monne writes ("[PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation"):

Quoted 1 line

Add an empty FreeBSD implementation so xenstat can compile on FreeBSD.

Not an area I'm very familiar with.

Have you tried running xentop with this patch and seen what it does ?

Thanks,
Ian.

#77 lore raw

Re: [PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation

Quoted 6 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation"):

Quoted 1 line

Add an empty FreeBSD implementation so xenstat can compile on FreeBSD.

Not an area I'm very familiar with.

Have you tried running xentop with this patch and seen what it does ?

Yes, disk and network stats are not reported, here is a sample output:

NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR VBD_RSECT VBD_WSECT SSID

  Domain-0 -----r        697    0.0    1048568   16.7   no limit       n/a     2    0        0     0    0        0        0        0          0          0    0
      test --b---          7    0.0     524288    8.3     525312       8.4     1    0        0     0    0        0        0        0          0          0    0

Roger.

Acked-by
#78 lore raw

Re: [PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation

Roger Pau Monné writes ("Re: [PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation"):

Quoted 4 lines · Ian Jackson
Quoted 1 line

Have you tried running xentop with this patch and seen what it does ?

Yes, disk and network stats are not reported, here is a sample output:

Great. Thanks.

Ian.

#79 lore raw

Re: [PATCH RFC 20/23] xenstat: add a dummy FreeBSD implementation

In reply to Roger Pau Monne
Quoted 16 lines · Roger Pau Monne

Add an empty FreeBSD implementation so xenstat can compile on FreeBSD.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/xenstat/libxenstat/Makefile              |    1 +
 tools/xenstat/libxenstat/src/xenstat_freebsd.c |   47 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
 create mode 100644 tools/xenstat/libxenstat/src/xenstat_freebsd.c
tools/xenstat/libxenstat/Makefile +0 -0
index 21aad89..15dc22d 100644

tools/xenstat/libxenstat/Makefile OBJECTS-y=src/xenstat.o · line 35

Quoted 4 lines
tools/xenstat/libxenstat/Makefile +1 -0
@@ -32,6 +32,7 @@ OBJECTS-y=src/xenstat.o
 OBJECTS-$(CONFIG_Linux) += src/xenstat_linux.o
 OBJECTS-$(CONFIG_SunOS) += src/xenstat_solaris.o
 OBJECTS-$(CONFIG_NetBSD) += src/xenstat_netbsd.o
+OBJECTS-$(CONFIG_FreeBSD) += src/xenstat_freebsd.o

How about doing this as a xenstat_unimplemented.c?

On the other hand I suppose this will go away before too long and be replaced with a proper one.

Quoted 9 lines
tools/xenstat/libxenstat/Makefile +0 -0
 SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR)
 
 WARN_FLAGS=-Wall -Werror
tools/xenstat/libxenstat/src/xenstat_freebsd.c new file +0 -0
new file mode 100644
index 0000000..0c488df

tools/xenstat/libxenstat/src/xenstat_freebsd.c line 5

Quoted 5 lines
tools/xenstat/libxenstat/src/xenstat_freebsd.c new file +5 -0
@@ -0,0 +1,47 @@
+/* libxenstat: statistics-collection library for Xen
+ * Copyright (C) International Business Machines Corp., 2005
+ * Authors: Josh Triplett <[email protected]>
+ *          Judy Fischbach <[email protected]>
+ *          David Hendricks <[email protected]>

Truely?

Quoted 5 lines
tools/xenstat/libxenstat/src/xenstat_freebsd.c new file +5 -0
+ *
+ * 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; either
+ * version 2.1 of the License, or (at your option) any later version.

tools/xenstat/libxenstat/src/xenstat_freebsd.c line 20

Quoted 10 lines
tools/xenstat/libxenstat/src/xenstat_freebsd.c new file +10 -0
+ *
+ * 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.
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.

Really?

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#80 lore raw

RFC PATCH 21/23 gdbsx: remove cast from ioctl

In reply to Roger Pau Monne

The ulong type is not defined on FreeBSD, and the cast seems pointless, so just remove it.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/debugger/gdbsx/xg/xg_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/debugger/gdbsx/xg/xg_main.c +2 -2
index 0fc3f82..c95e4ed 100644
@@ -180,7 +180,7 @@ _domctl_hcall(uint32_t cmd,            /* which domctl hypercall */
     hypercall.op = __HYPERVISOR_domctl;
     hypercall.arg[0] = (unsigned long)&domctl;
 
-    rc = ioctl(_dom0_fd, IOCTL_PRIVCMD_HYPERCALL, (ulong)&hypercall);
+    rc = ioctl(_dom0_fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
     if (domctlarg && sz)
         munlock(domctlarg, sz);
     return rc;
@@ -220,7 +220,7 @@ _check_hyp(int guest_bitness)
     hypercall.arg[0] = (unsigned long)XENVER_capabilities;
     hypercall.arg[1] = (unsigned long)&xen_caps;
 
-    rc = ioctl(_dom0_fd, IOCTL_PRIVCMD_HYPERCALL, (ulong)&hypercall);
+    rc = ioctl(_dom0_fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
     munlock(&xen_caps, sizeof(xen_caps));
     XGTRC("XENCAPS:%s\n", xen_caps);
 
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 21/23
#81 lore raw

Re: [PATCH RFC 21/23] gdbsx: remove cast from ioctl

Roger Pau Monne writes ("[PATCH RFC 21/23] gdbsx: remove cast from ioctl"):

Quoted 2 lines

The ulong type is not defined on FreeBSD, and the cast seems pointless, so just remove it.

I think this is very likely to be correct.

#82 lore raw

Re: [PATCH RFC 21/23] gdbsx: remove cast from ioctl

Quoted 5 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 21/23] gdbsx: remove cast from ioctl"):

Quoted 2 lines

The ulong type is not defined on FreeBSD, and the cast seems pointless, so just remove it.

I think this is very likely to be correct.

The danger is systems where sizeof(ulong) != sizeof(struct somehing *). I think we can sleep easy and not worry about that.

Quoted 1 line

Agreed. Acked-by: Ian Campbell <[email protected]>

Ian.

Acked-by
#83 lore raw

Re: [PATCH RFC 21/23] gdbsx: remove cast from ioctl

Quoted 8 lines · On Mon, 28 Apr 2014 15:46:26 +0100 Ian Campbell <[email protected]> wrote:
Quoted 6 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH RFC 21/23] gdbsx: remove cast from ioctl"):

Quoted 2 lines

The ulong type is not defined on FreeBSD, and the cast seems pointless, so just remove it.

I think this is very likely to be correct.

Quoted 8 lines

The danger is systems where sizeof(ulong) != sizeof(struct somehing *). I think we can sleep easy and not worry about that.

Quoted 1 line

Agreed. Acked-by: Ian Campbell <[email protected]>

Ian.

#84 lore raw

RFC PATCH 22/23 build: export CC value to SeaBIOS

In reply to Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/Makefile +1 -1
index cb13212..dcb56e5 100644
@@ -36,7 +36,7 @@ ifeq ($(CONFIG_ROMBIOS),y)
 	false ; \
 	fi
 endif
-	$(MAKE) PYTHON=$(PYTHON) subdirs-$@
+	$(MAKE) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@
 
 
 .PHONY: install
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 22/23
#85 lore raw

Re: [PATCH RFC 22/23] build: export CC value to SeaBIOS

Quoted 12 lines · Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/firmware/Makefile +0 -0
index cb13212..dcb56e5 100644

tools/firmware/Makefile ifeq ($(CONFIG_ROMBIOS),y) · line 39

Quoted 5 lines
tools/firmware/Makefile +1 -1
@@ -36,7 +36,7 @@ ifeq ($(CONFIG_ROMBIOS),y)
 	false ; \
 	fi
 endif
-	$(MAKE) PYTHON=$(PYTHON) subdirs-$@
+	$(MAKE) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@

I'm a bit surprised this isn't either already exported or that this construct isn't more prevalent, but whatever:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#86 lore raw

RFC PATCH 23/23 build: export linker emulation parameter to SeaBIOS

In reply to Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/Makefile |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/firmware/Makefile +5 -1
index dcb56e5..092f1bc 100644
@@ -17,6 +17,10 @@ SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
 SUBDIRS-$(CONFIG_ROMBIOS) += etherboot
 SUBDIRS-y += hvmloader
 
+LD32BIT-$(CONFIG_FreeBSD) := -melf_i386_fbsd
+LD32BIT-$(CONFIG_NetBSD) := -melf_i386
+LD32BIT-$(CONFIG_Linux) := -melf_i386
+
 ovmf-dir:
 	GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir
 	cp ovmf-makefile ovmf-dir/Makefile;
@@ -36,7 +40,7 @@ ifeq ($(CONFIG_ROMBIOS),y)
 	false ; \
 	fi
 endif
-	$(MAKE) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@
+	$(MAKE) LD32BIT_FLAG=$(LD32BIT-y) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@
 
 
 .PHONY: install
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#87 lore raw

Re: [PATCH RFC 23/23] build: export linker emulation parameter to SeaBIOS

Quoted 12 lines · Roger Pau Monne
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
---
 tools/firmware/Makefile |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/firmware/Makefile +0 -0
index dcb56e5..092f1bc 100644

tools/firmware/Makefile SUBDIRS-$(CONFIG_ROMBIOS) += vgabios · line 22

Quoted 6 lines
tools/firmware/Makefile +3 -0
@@ -17,6 +17,10 @@ SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
 SUBDIRS-$(CONFIG_ROMBIOS) += etherboot
 SUBDIRS-y += hvmloader
 
+LD32BIT-$(CONFIG_FreeBSD) := -melf_i386_fbsd
+LD32BIT-$(CONFIG_NetBSD) := -melf_i386
+LD32BIT-$(CONFIG_Linux) := -melf_i386

Can we do this as

LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-m....

Then pass $(LD32BIT-y) to $(MAKE).

IOW avoid needlessly overriding it.

Given that most OSes seem to support melf as well as their native emulation I don't suppose you want to take this up with the FreeBSD folks?

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#88 lore raw
In reply to Roger Pau Monne
Quoted 15 lines · Roger Pau Monne

The following series enables building (and using) the Xen toolstack on a FreeBSD PVH Dom0.

The FreeBSD sources used to test this series can be found at:

git://xenbits.xen.org/people/royger/freebsd.git branch pvh_dom0_v3
http://xenbits.xen.org/gitweb/?p=people/royger/freebsd.git;a=shortlog;h=refs/heads/pvh_dom0_v3

I've successfully tested PV and HVM domains, but right now only qemu-xen (aka qemu-upstream) is supported on FreeBSD (in order to avoid the build system from trying to compile qemu-trad pass the following option to configure: --disable-qemu-traditional). I'm not sure if there's any gain from also having qemu-trad, so I would suggest to automatically disable it on FreeBSD (like we do for ARM).

Quoted 5 lines

Some patches for Qemu and SeaBIOS are needed, which are still pending approval from their respective upstreams:

http://marc.info/?l=xen-devel&m=139763253311569
http://marc.info/?l=xen-devel&m=139755086616838&w=2

Forgot to mention the series can also be found on my git repo:

git://xenbits.xen.org/people/royger/xen.git branch freebsd_tools_rfc

http://xenbits.xen.org/gitweb/?p=people/royger/xen.git;a=shortlog;h=refs/heads/freebsd_tools_rfc

Roger.

#89 lore raw
In reply to Roger Pau Monne
Quoted 2 lines · Roger Pau Monne

The following series enables building (and using) the Xen toolstack on a FreeBSD PVH Dom0.

Applied:
01/23] build: set FreeBSD specific build variables
05/23] libxc: remove usage of "daylight" variable
06/23] libxc: remove include of malloc.h
07/23] libelf: add defines for bswap_* functions for FreeBSD 11/23] xenstore: add some missing headers
15/23] libxl: add support for OS-specific names to backend interfaces 20/23] xenstat: add a dummy FreeBSD implementation
21/23] gdbsx: remove cast from ioctl
22/23] build: export CC value to SeaBIOS

Didn't apply when I tried:
18/23] libxl: only include utmp.h if it's present

#90 lore raw
In reply to Roger Pau Monne
Quoted 2 lines · Roger Pau Monne

The following series enables building (and using) the Xen toolstack on a FreeBSD PVH Dom0.

Applied:
01/23] build: set FreeBSD specific build variables
05/23] libxc: remove usage of "daylight" variable
06/23] libxc: remove include of malloc.h
07/23] libelf: add defines for bswap_* functions for FreeBSD 11/23] xenstore: add some missing headers
15/23] libxl: add support for OS-specific names to backend interfaces 20/23] xenstat: add a dummy FreeBSD implementation
21/23] gdbsx: remove cast from ioctl
22/23] build: export CC value to SeaBIOS

Didn't apply when I tried:
18/23] libxl: only include utmp.h if it's present