Fix error: array subscript has type 'char'
PATCH v2 1/1 Fix error: array subscript has type 'char'
Use unsigned char variable, or cast to (unsigned char), for tolower()/islower() and friends. Fix compiler error array subscript has type 'char' [-Werror=char-subscripts]
--- tools/libs/light/libxl_qmp.c | 2 +- tools/xentrace/xentrace.c | 2 +- xen/tools/symbols.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/libs/light/libxl_qmp.c +1 -1
@@ -1249,7 +1249,7 @@ static int qmp_error_class_to_libxl_error_code(libxl__gc *gc, se++;continue ; } -if (tolower (*s) !=tolower (*se)) +if (tolower ((unsigned char )*s) !=tolower ((unsigned char )*se))break ; s++, se++; }
tools/xentrace/xentrace.c +1 -1
@@ -957,7 +957,7 @@ static int parse_cpumask_range(const char *mask_str, xc_cpumap_t map) {unsigned int a, b;int nmaskbits; -char c; +unsigned char c;int in_range;const char *s;
xen/tools/symbols.c +2 -2
@@ -173,11 +173,11 @@ static int read_symbol(FILE *in, struct sym_entry *s)/* include the type field in the symbol name, so that it gets * compressed together */ s->len =strlen (str) +1 ; -if (islower (stype) && filename) +if (islower ((unsigned char )stype) && filename) s->len +=strlen (filename) +1 ; s->sym =malloc (s->len +1 ); sym =SYMBOL_NAME (s); -if (islower (stype) && filename) { +if (islower ((unsigned char )stype) && filename) { sym =stpcpy (sym, filename); *sym++ ='#' ; }
Signature · 1 line
2.29.2
PATCH v2 1/1 NetBSD hotplug: Introduce locking functions
On NetBSD, some block device configuration requires serialisation. Introcuce locking functions (derived from the Linux version), and use them in the block script where appropriate.
--- tools/hotplug/NetBSD/Makefile | 1 + tools/hotplug/NetBSD/block | 5 +- tools/hotplug/NetBSD/locking.sh | 121 ++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 tools/hotplug/NetBSD/locking.sh
tools/hotplug/NetBSD/Makefile +1 -0
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk # Xen script dir and scripts to go there. XEN_SCRIPTS = +XEN_SCRIPTS += locking.sh XEN_SCRIPTS += block XEN_SCRIPTS += vif-bridge XEN_SCRIPTS += vif-ip
tools/hotplug/NetBSD/block +4 -1
@@ -5,6 +5,7 @@ DIR=$(dirname "$0") . "${DIR}/hotplugpath.sh" +. "${DIR}/locking.sh" PATH=${bindir}:${sbindir}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin export PATH
@@ -52,6 +53,7 @@ case $xstatus in available_disks="$available_disks $disk" eval $disk=free done + claim_lock block # Mark the used vnd(4) devices as ``used''. for disk in `sysctl hw.disknames`; do case $disk in
@@ -67,6 +69,7 @@ case $xstatus in break fi done + release_lock block if [ x$device = x ] ; then error "no available vnd device" fi
@@ -76,7 +79,7 @@ case $xstatus in device=$xparams ;; esac - physical_device=$(stat -f '%r' "$device") + physical_device=$(stat -L -f '%r' "$device") xenstore-write $xpath/physical-device $physical_device xenstore-write $xpath/hotplug-status connected exit 0
tools/hotplug/NetBSD/locking.sh new file +121 -0
121 lines not on this page · raw message
Signature · 1 line
2.29.2
PATCH v2 1/1 libs/foreignmemory: Implement on NetBSD
In reply to Manuel BouyerImplement foreignmemory interface on NetBSD. The compat interface is now used only on __sun__
--- tools/libs/foreignmemory/Makefile | 2 +- tools/libs/foreignmemory/netbsd.c | 66 +++++++++++++++++++++++++----- tools/libs/foreignmemory/private.h | 6 +-- 3 files changed, 60 insertions(+), 14 deletions(-)
tools/libs/foreignmemory/Makefile +1 -1
@@ -8,7 +8,7 @@ SRCS-y += core.c SRCS-$(CONFIG_Linux) += linux.c SRCS-$(CONFIG_FreeBSD) += freebsd.c SRCS-$(CONFIG_SunOS) += compat.c solaris.c -SRCS-$(CONFIG_NetBSD) += compat.c netbsd.c +SRCS-$(CONFIG_NetBSD) += netbsd.c SRCS-$(CONFIG_MiniOS) += minios.c include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/foreignmemory/netbsd.c +56 -10
96 lines not on this page · raw message
tools/libs/foreignmemory/private.h +3 -3
@@ -36,9 +36,9 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,int osdep_xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t num); -#if defined(__NetBSD__) || defined(__sun__) +#if defined(__sun__)/* Strictly compat for those two only only */ -void *compat_mapforeign_batch (xenforeignmem_handle *fmem,uint32_t dom, +void *osdep_map_foreign_batch (xenforeignmemory_handle *fmem,uint32_t dom,void *addr,int prot,int flags,xen_pfn_t *arr,int num);#endif
@@ -54,7 +54,7 @@ struct xenforeignmemory_resource_handle {int flags; }; -#if !defined(__linux__) && !defined(__FreeBSD__) +#ifdef __sun__static inline int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem,domid_t domid) {
Signature · 1 line
2.29.2
Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD
Quoted 4 lines · Manuel Bouyer
Implement foreignmemory interface on NetBSD. The compat interface is now used only on
__sun__Signed-off-by Manuel Bouyer <[email protected]>
Just as a note. I've also got a bugfix for this library (as well as every other level of the stack), which will need an incremental change in osdep_xenforeignmemory_map_resource().
See
https://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=commitdiff;h=3768453802baece85140e579814af9c27f70d99a
for the details, but you may also need to bugfix the kernel side of the IOCTL if you borrowed the FreeBSD copy to begin with.
What is probably easiest is for this patch to be committed first, then I will rework the resource size fix() to make the same delta to NetBSD's copy as Linux/FreeBSD.
~Andrew
Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD
In reply to Manuel BouyerQuoted 114 lines · Manuel Bouyer
Implement foreignmemory interface on NetBSD. The compat interface is now used only on
__sun__Signed-off-by Manuel Bouyer <[email protected]>--- tools/libs/foreignmemory/Makefile | 2 +- tools/libs/foreignmemory/netbsd.c | 66 +++++++++++++++++++++++++----- tools/libs/foreignmemory/private.h | 6 +-- 3 files changed, 60 insertions(+), 14 deletions(-)tools/libs/foreignmemory/Makefile +1
-1@@ -8,7 +8,7 @@ SRCS-y += core.c SRCS-$(CONFIG_Linux) += linux.c SRCS-$(CONFIG_FreeBSD) += freebsd.c SRCS-$(CONFIG_SunOS) += compat.c solaris.c -SRCS-$(CONFIG_NetBSD) += compat.c netbsd.c +SRCS-$(CONFIG_NetBSD) += netbsd.c SRCS-$(CONFIG_MiniOS) += minios.c include $(XEN_ROOT)/tools/libs/libs.mktools/libs/foreignmemory/netbsd.c +46
-10@@ -19,7 +19,9 @@#include <unistd.h> #include <fcntl.h> +#include <errno.h> #include <sys/mman.h> +#include <sys/ioctl.h> #include "private.h" @@ -66,15 +68,17 @@ int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem)return close (fd); } -void *osdep_map_foreign_batch (xenforeignmem_handle *fmem,uint32_t dom, -void *addr,int prot,int flags, -xen_pfn_t *arr,int num) +void *osdep_xenforeignmemory_map (xenforeignmemory_handle *fmem, +uint32_t dom,void *addr, +int prot,int flags,size_t num, +const xen_pfn_t arr[/*num*/ ],int err[/*num*/ ]) + {int fd = fmem->fd; -privcmd_mmapbatch_t ioctlx; - addr =mmap (addr, num*XC_PAGE_SIZE , prot, flags |MAP_ANON |MAP_SHARED ,-1 ,0 ); +privcmd_mmapbatch_v2_t ioctlx; + addr =mmap (addr, num*PAGE_SIZE , prot, flags |MAP_ANON |MAP_SHARED ,-1 ,0 );if ( addr ==MAP_FAILED ) { -PERROR ("osdep_map_foreign_batch: mmap failed" ); +PERROR ("osdep_xenforeignmemory_map: mmap failed" );return NULL ; }@@ -82,11 +86,12 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom, ioctlx.dom=dom; ioctlx.addr=(unsigned long )addr; ioctlx.arr=arr; -if (ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx) <0 ) + ioctlx.err=err; +if (ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH_V2 , &ioctlx) <0 ) {int saved_errno = errno; -PERROR ("osdep_map_foreign_batch: ioctl failed" ); - (void )munmap (addr, num*XC_PAGE_SIZE ); +PERROR ("osdep_xenforeignmemory_map: ioctl failed" ); + (void )munmap (addr, num*PAGE_SIZE ); errno = saved_errno;return NULL ; }@@ -97,7 +102,48 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,int osdep_xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t num) { -return munmap (addr, num*XC_PAGE_SIZE ); +return munmap (addr, num*PAGE_SIZE ); +} + +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno =EOPNOTSUPP ; +return -1 ; +} + +int osdep_xenforeignmemory_unmap_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +return fres ?munmap (fres->addr, fres->nr_frames <<PAGE_SHIFT ) :0 ; +} + +int osdep_xenforeignmemory_map_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +privcmd_mmap_resource_t mr = { + .dom = fres->domid, + .type = fres->type, + .id = fres->id, + .idx = fres->frame, + .num = fres->nr_frames, + }; +int rc; + + fres->addr =mmap (fres->addr, fres->nr_frames <<PAGE_SHIFT , + fres->prot, fres->flags |MAP_ANON |MAP_SHARED ,-1 ,0 ); +if ( fres->addr ==MAP_FAILED ) +return -1 ;
tools/libs/foreignmemory/netbsd.c void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom, · line 146
Quoted 10 lines
tools/libs/foreignmemory/netbsd.c +10
-0+ + mr.addr = (uintptr_t )fres->addr; + + rc =ioctl (fmem->fd,IOCTL_PRIVCMD_MMAP_RESOURCE , &mr); +if ( rc ) + { +PERROR ("ioctl failed" ); + } + +return 0 ;
You need to return rc here, or else the failure won't be propagated to the caller.
If you agree I don't think I have further comments:
Thanks, Roger.
Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD
In reply to Manuel BouyerQuoted 38 lines · Manuel Bouyer
tools/libs/foreignmemory/netbsd.c +29
-1@@ -97,7 +102,48 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,int osdep_xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t num) { -return munmap (addr, num*XC_PAGE_SIZE ); +return munmap (addr, num*PAGE_SIZE ); +} + +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno =EOPNOTSUPP ; +return -1 ; +} + +int osdep_xenforeignmemory_unmap_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +return fres ?munmap (fres->addr, fres->nr_frames <<PAGE_SHIFT ) :0 ; +} + +int osdep_xenforeignmemory_map_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +privcmd_mmap_resource_t mr = { + .dom = fres->domid, + .type = fres->type, + .id = fres->id, + .idx = fres->frame, + .num = fres->nr_frames, + }; +int rc; + + fres->addr = mmap(fres->addr, fres->nr_frames << PAGE_SHIFT,
tools/libs/foreignmemory/netbsd.c void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom, · line 143
Quoted 10 lines
tools/libs/foreignmemory/netbsd.c +10
-0+ fres->prot, fres->flags | MAP_ANON | MAP_SHARED, -1, 0); +if ( fres->addr ==MAP_FAILED ) +return -1 ; + + mr.addr = (uintptr_t )fres->addr; + + rc =ioctl (fmem->fd,IOCTL_PRIVCMD_MMAP_RESOURCE , &mr); +if ( rc ) + { +PERROR ("ioctl failed" );
return -1;
I was rebasing my resource_size fix over this patch.
It would be easiest for me if I fix up and commit this patch, if everyone is happy with that.
~Andrew
Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD
Quoted 51 lines · Andrew Cooper
Quoted 38 lines · Manuel Bouyer
tools/libs/foreignmemory/netbsd.c +29
-1@@ -97,7 +102,48 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,int osdep_xenforeignmemory_unmap (xenforeignmemory_handle *fmem,void *addr,size_t num) { -return munmap (addr, num*XC_PAGE_SIZE ); +return munmap (addr, num*PAGE_SIZE ); +} + +int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem, +domid_t domid) +{ + errno =EOPNOTSUPP ; +return -1 ; +} + +int osdep_xenforeignmemory_unmap_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +return fres ?munmap (fres->addr, fres->nr_frames <<PAGE_SHIFT ) :0 ; +} + +int osdep_xenforeignmemory_map_resource ( +xenforeignmemory_handle *fmem,xenforeignmemory_resource_handle *fres) +{ +privcmd_mmap_resource_t mr = { + .dom = fres->domid, + .type = fres->type, + .id = fres->id, + .idx = fres->frame, + .num = fres->nr_frames, + }; +int rc; + + fres->addr = mmap(fres->addr, fres->nr_frames << PAGE_SHIFT,tools/libs/foreignmemory/netbsd.c void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom, · line 143
Quoted 10 lines
tools/libs/foreignmemory/netbsd.c +10
-0+ fres->prot, fres->flags | MAP_ANON | MAP_SHARED, -1, 0); +if ( fres->addr ==MAP_FAILED ) +return -1 ; + + mr.addr = (uintptr_t )fres->addr; + + rc =ioctl (fmem->fd,IOCTL_PRIVCMD_MMAP_RESOURCE , &mr); +if ( rc ) + { +PERROR ("ioctl failed" );return -1;
Quoted 4 lines
I was rebasing my
resource_sizefix over this patch.It would be easiest for me if I fix up and commit this patch, if everyone is happy with that.
FAOD I've committed a fixed up version of this patch as discussed.
~Andrew
Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD
Quoted 1 line · Andrew Cooper
FAOD I've committed a fixed up version of this patch as discussed.
thanks !
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
PATCH v2 1/1 NetBSD: use system-provided headers
In reply to Manuel BouyerOn NetBSD use the system-provided headers for ioctl and related definitions, they are up to date and have more chances to match the kernel's idea of the ioctls and structures.
Remove now-unused NetBSD/evtchn.h and NetBSD/privcmd.h.
Don't fail install if xen/sys/*.h are not present.
--- tools/debugger/gdbsx/xg/xg_main.c | 4 + tools/include/Makefile | 2 + tools/include/xen-sys/NetBSD/evtchn.h | 86 -------------------- tools/include/xen-sys/NetBSD/privcmd.h | 106 ------------------------- tools/libs/call/private.h | 4 + tools/libs/ctrl/xc_private.h | 4 + tools/libs/foreignmemory/private.h | 6 ++ 7 files changed, 20 insertions(+), 192 deletions(-) delete mode 100644 tools/include/xen-sys/NetBSD/evtchn.h delete mode 100644 tools/include/xen-sys/NetBSD/privcmd.h
tools/debugger/gdbsx/xg/xg_main.c +4 -0
@@ -49,7 +49,11 @@#include "xg_public.h" #include <xen/version.h> #include <xen/domctl.h> +#ifdef __NetBSD__ +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #include <xen/foreign/x86_32.h> #include <xen/foreign/x86_64.h>
tools/include/Makefile +2 -0
@@ -68,7 +68,9 @@ install: all $(INSTALL_DATA) xen/foreign/*.h $(DESTDIR)$(includedir)/xen/foreign $(INSTALL_DATA) xen/hvm/*.h $(DESTDIR)$(includedir)/xen/hvm $(INSTALL_DATA) xen/io/*.h $(DESTDIR)$(includedir)/xen/io +ifeq ($(wildcard xen/sys/.),) $(INSTALL_DATA) xen/sys/*.h $(DESTDIR)$(includedir)/xen/sys +endif $(INSTALL_DATA) xen/xsm/*.h $(DESTDIR)$(includedir)/xen/xsm .PHONY: uninstall
tools/include/xen-sys/NetBSD/evtchn.h deleted +0 -86
86 lines not on this page · raw message
tools/include/xen-sys/NetBSD/privcmd.h deleted +0 -106
106 lines not on this page · raw message
tools/libs/call/private.h +4 -0
@@ -7,7 +7,11 @@#include <xencall.h> #include <xen/xen.h> +#ifdef __NetBSD__ +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #ifndef PAGE_SHIFT /* Mini-os, Yukk */ #define PAGE_SHIFT 12
tools/libs/ctrl/xc_private.h +4 -0
@@ -39,7 +39,11 @@#include <xenforeignmemory.h> #include <xendevicemodel.h> +#ifdef __NetBSD__ +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #include <xen-tools/libs.h>
tools/libs/foreignmemory/private.h +6 -0
@@ -8,7 +8,13 @@#include <xentoolcore_internal.h> #include <xen/xen.h> + +#ifdef __NetBSD__ +#include <xen/xen.h> +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #ifndef PAGE_SHIFT /* Mini-os, Yukk */ #define PAGE_SHIFT 12
Signature · 1 line
2.29.2
Re: [PATCH v2] NetBSD: use system-provided headers
Quoted 40 lines · Manuel Bouyer
On NetBSD use the system-provided headers for ioctl and related definitions, they are up to date and have more chances to match the kernel's idea of the ioctls and structures.
Remove now-unusedNetBSD/evtchn.handNetBSD/privcmd.h.
Don't fail install if xen/sys/*.h are not present.Signed-off-by Manuel Bouyer <[email protected]>--- tools/debugger/gdbsx/xg/xg_main.c | 4 + tools/include/Makefile | 2 + tools/include/xen-sys/NetBSD/evtchn.h | 86 -------------------- tools/include/xen-sys/NetBSD/privcmd.h | 106 ------------------------- tools/libs/call/private.h | 4 + tools/libs/ctrl/xc_private.h | 4 + tools/libs/foreignmemory/private.h | 6 ++ 7 files changed, 20 insertions(+), 192 deletions(-) delete mode 100644 tools/include/xen-sys/NetBSD/evtchn.h delete mode 100644 tools/include/xen-sys/NetBSD/privcmd.htools/debugger/gdbsx/xg/xg_main.c +4
-0@@ -49,7 +49,11 @@#include "xg_public.h" #include <xen/version.h> #include <xen/domctl.h> +#ifdef __NetBSD__ +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #include <xen/foreign/x86_32.h> #include <xen/foreign/x86_64.h> tools/include/Makefile +0
-0
tools/include/Makefile install: all · line 71
Quoted 4 lines
tools/include/Makefile +1
-0@@ -68,7 +68,9 @@ install: all $(INSTALL_DATA) xen/foreign/*.h $(DESTDIR)$(includedir)/xen/foreign $(INSTALL_DATA) xen/hvm/*.h $(DESTDIR)$(includedir)/xen/hvm $(INSTALL_DATA) xen/io/*.h $(DESTDIR)$(includedir)/xen/io +ifeq ($(wildcard xen/sys/.),)
Maybe I'm confused, but doesn't this need to be ifneq? So that if wildcard returns any output the command is executed?
I would also use $(wildcard xen/sys/*.h) because that matches exactly the pattern used below.
Thanks, Roger.
Re: [PATCH v2] NetBSD: use system-provided headers
Quoted 49 lines · Roger Pau Monné
Quoted 40 lines · Manuel Bouyer
On NetBSD use the system-provided headers for ioctl and related definitions, they are up to date and have more chances to match the kernel's idea of the ioctls and structures.
Remove now-unusedNetBSD/evtchn.handNetBSD/privcmd.h.
Don't fail install if xen/sys/*.h are not present.Signed-off-by Manuel Bouyer <[email protected]>--- tools/debugger/gdbsx/xg/xg_main.c | 4 + tools/include/Makefile | 2 + tools/include/xen-sys/NetBSD/evtchn.h | 86 -------------------- tools/include/xen-sys/NetBSD/privcmd.h | 106 ------------------------- tools/libs/call/private.h | 4 + tools/libs/ctrl/xc_private.h | 4 + tools/libs/foreignmemory/private.h | 6 ++ 7 files changed, 20 insertions(+), 192 deletions(-) delete mode 100644 tools/include/xen-sys/NetBSD/evtchn.h delete mode 100644 tools/include/xen-sys/NetBSD/privcmd.htools/debugger/gdbsx/xg/xg_main.c +4
-0@@ -49,7 +49,11 @@#include "xg_public.h" #include <xen/version.h> #include <xen/domctl.h> +#ifdef __NetBSD__ +#include <xen/xenio.h> +#else #include <xen/sys/privcmd.h> +#endif #include <xen/foreign/x86_32.h> #include <xen/foreign/x86_64.h> tools/include/Makefile +0
-0tools/include/Makefile install: all · line 71
Quoted 4 lines
tools/include/Makefile +1
-0@@ -68,7 +68,9 @@ install: all $(INSTALL_DATA) xen/foreign/*.h $(DESTDIR)$(includedir)/xen/foreign $(INSTALL_DATA) xen/hvm/*.h $(DESTDIR)$(includedir)/xen/hvm $(INSTALL_DATA) xen/io/*.h $(DESTDIR)$(includedir)/xen/io +ifeq ($(wildcard xen/sys/.),)Maybe I'm confused, but doesn't this need to be ifneq? So that if wildcard returns any output the command is executed?
Quoted 2 lines
I would also use $(wildcard xen/sys/*.h) because that matches exactly the pattern used below.
You're right. It's strange that I didn't get an error at install time. Will send a fixed version
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
PATCH v2 1/1 libs/gnttab: implement on NetBSD
In reply to Manuel BouyerImplement gnttab interface on NetBSD.
The kernel interface is different from FreeBSD so we can't use the FreeBSD version
--- tools/libs/gnttab/Makefile | 2 +- tools/libs/gnttab/netbsd.c | 267 +++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 tools/libs/gnttab/netbsd.c
tools/libs/gnttab/Makefile +1 -1
@@ -10,7 +10,7 @@ SRCS-GNTSHR += gntshr_core.c SRCS-$(CONFIG_Linux) += $(SRCS-GNTTAB) $(SRCS-GNTSHR) linux.c SRCS-$(CONFIG_MiniOS) += $(SRCS-GNTTAB) gntshr_unimp.c minios.c SRCS-$(CONFIG_FreeBSD) += $(SRCS-GNTTAB) $(SRCS-GNTSHR) freebsd.c +SRCS-$(CONFIG_NetBSD) += $(SRCS-GNTTAB) $(SRCS-GNTSHR) netbsd.c SRCS-$(CONFIG_SunOS) += gnttab_unimp.c gntshr_unimp.c -SRCS-$(CONFIG_NetBSD) += gnttab_unimp.c gntshr_unimp.c include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/gnttab/netbsd.c new file +267 -0
267 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2] libs/gnttab: implement on NetBSD
tools/libs/gnttab/netbsd.c line 232
Quoted 9 lines · Manuel Bouyer
tools/libs/gnttab/netbsd.c new file +9
-0+int osdep_gntshr_unshare (xengntshr_handle *xgs, +void *start_address,uint32_t count) +{ +return munmap (start_address, count *PAGE_SIZE ); +} + +/* +* The functions below are Linux-isms that will likely never be implemented +* on FreeBSD unless FreeBSD also implements something akin to Linux dmabuf.
You might want to s/FreeBSD/NetBSD/ in the line above.
Thanks, Roger
PATCH v2 1/1 xenpmd.c: use dynamic allocation
In reply to Manuel BouyerOn NetBSD, d_name is larger than 256, so file_name[284] may not be large enough (and gcc emits a format-truncation error).
Use asprintf() instead of snprintf() on a static on-stack buffer.
--- tools/xenpmd/xenpmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/xenpmd/xenpmd.c +4 -4
@@ -101,7 +101,7 @@ FILE *get_next_battery_file(DIR *battery_dir, {FILE *file =0 ;struct dirent *dir_entries; -char file_name[284 ]; +char *file_name;int ret; do
@@ -112,16 +112,16 @@ FILE *get_next_battery_file(DIR *battery_dir,if (strlen (dir_entries->d_name) <4 )continue ;if ( battery_info_type ==BIF ) - ret =snprintf (file_name,sizeof (file_name),BATTERY_INFO_FILE_PATH , + ret =asprintf (&file_name,BATTERY_INFO_FILE_PATH , dir_entries->d_name);else - ret =snprintf (file_name,sizeof (file_name),BATTERY_STATE_FILE_PATH , + ret =asprintf (&file_name,BATTERY_STATE_FILE_PATH , dir_entries->d_name);/* This should not happen but is needed to pass gcc checks */ if (ret <0 )continue ; - file_name[sizeof (file_name) -1 ] ='\0' ; file =fopen (file_name,"r" ); +free (file_name); }while ( !file );return file;
Signature · 1 line
2.29.2
Re: [PATCH v2] xenpmd.c: use dynamic allocation
Quoted 5 lines · Manuel Bouyer
On NetBSD,
d_nameis larger than 256, so file_name[284] may not be large enough (and gcc emits a format-truncation error).
Useasprintf()instead ofsnprintf()on a static on-stack buffer.Signed-off-by Manuel Bouyer <[email protected]>
Quoted 24 lines
--- tools/xenpmd/xenpmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/xenpmd/xenpmd.c +2
-2@@ -101,7 +101,7 @@ FILE *get_next_battery_file(DIR *battery_dir, {FILE *file =0 ;struct dirent *dir_entries; -char file_name[284 ]; +char *file_name;int ret; do@@ -112,16 +112,16 @@ FILE *get_next_battery_file(DIR *battery_dir,if (strlen (dir_entries->d_name) <4 )continue ;if ( battery_info_type ==BIF ) - ret =snprintf (file_name,sizeof (file_name),BATTERY_INFO_FILE_PATH , + ret =asprintf (&file_name,BATTERY_INFO_FILE_PATH , dir_entries->d_name);
tools/xenpmd/xenpmd.c FILE *get_next_battery_file(DIR *battery_dir, · line 124
Quoted 10 lines
tools/xenpmd/xenpmd.c +2
-2else - ret =snprintf (file_name,sizeof (file_name),BATTERY_STATE_FILE_PATH , + ret =asprintf (&file_name,BATTERY_STATE_FILE_PATH , dir_entries->d_name);/* This should not happen but is needed to pass gcc checks */ if (ret <0 )continue ; - file_name[sizeof (file_name) -1 ] ='\0' ; file =fopen (file_name,"r" ); +free (file_name);
Hard tab. May I ask whether this can be fixed on commit so that there's no need to resend a new version?
Thanks, Roger.
PATCH v2 1/1 libs/store: make build without PTHREAD_STACK_MIN
In reply to Manuel BouyerOn NetBSD, PTHREAD_STACK_MIN is not available.
If PTHREAD_STACK_MIN is not defined, define it to 0 so that we fallback to DEFAULT_THREAD_STACKSIZE
--- tools/libs/store/xs.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/libs/store/xs.c +5 -0
@@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)#ifdef USE_PTHREAD #define DEFAULT_THREAD_STACKSIZE (16 * 1024) +/* NetBSD doesn't have PTHREAD_STACK_MIN. */ +#ifndef PTHREAD_STACK_MIN +# define PTHREAD_STACK_MIN 0 +#endif +#define READ_THREAD_STACKSIZE \ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
Signature · 1 line
2.29.2
Re: [PATCH v2] libs/store: make build without PTHREAD_STACK_MIN
Quoted 4 lines · Manuel Bouyer
On NetBSD,
PTHREAD_STACK_MINis not available.
IfPTHREAD_STACK_MINis not defined, define it to 0 so that we fallback toDEFAULT_THREAD_STACKSIZE
I would add:
Quoted 1 line
Signed-off-by Manuel Bouyer <[email protected]>
Quoted 10 lines
--- tools/libs/store/xs.c | 5 +++++ 1 file changed, 5 insertions(+)tools/libs/store/xs.c +0
-0@@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
tools/libs/store/xs.c bool xs_watch(struct xs_handle *h, const char *path, const char *token) · line 821
Quoted 10 lines
tools/libs/store/xs.c +5
-0#ifdef USE_PTHREAD #define DEFAULT_THREAD_STACKSIZE (16 * 1024) +/* NetBSD doesn't have PTHREAD_STACK_MIN. */ +#ifndef PTHREAD_STACK_MIN +# define PTHREAD_STACK_MIN 0 +#endif +#define READ_THREAD_STACKSIZE \ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
There was also a suggestion to use MAX(PTHREAD_STACK_MIN, DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?
Thanks, Roger.
Re: [PATCH v2] libs/store: make build without PTHREAD_STACK_MIN
Quoted 22 lines · Roger Pau Monné
Quoted 4 lines · Manuel Bouyer
On NetBSD,
PTHREAD_STACK_MINis not available.
IfPTHREAD_STACK_MINis not defined, define it to 0 so that we fallback toDEFAULT_THREAD_STACKSIZEI would add:
Suggested-by Andrew Cooper <[email protected]>Quoted 1 line
Signed-off-by Manuel Bouyer <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>Quoted 10 lines
--- tools/libs/store/xs.c | 5 +++++ 1 file changed, 5 insertions(+)tools/libs/store/xs.c +0
-0@@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
Quoted 12 lines
tools/libs/store/xs.c bool xs_watch(struct xs_handle *h, const char *path, const char *token) · line 821
Quoted 10 lines
tools/libs/store/xs.c +5
-0#ifdef USE_PTHREAD #define DEFAULT_THREAD_STACKSIZE (16 * 1024) +/* NetBSD doesn't have PTHREAD_STACK_MIN. */ +#ifndef PTHREAD_STACK_MIN +# define PTHREAD_STACK_MIN 0 +#endif +#define READ_THREAD_STACKSIZE \ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)There was also a suggestion to use
MAX(PTHREAD_STACK_MIN, DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?
TBH, I was planning to submit an incremental cleanup doing this separately. It would be cleaner than putting cleanup into the "fix NetBSD" patch.
~Andrew
Re: [PATCH v2] libs/store: make build without PTHREAD_STACK_MIN
Quoted 36 lines · Andrew Cooper
Quoted 22 lines · Roger Pau Monné
Quoted 4 lines · Manuel Bouyer
On NetBSD,
PTHREAD_STACK_MINis not available.
IfPTHREAD_STACK_MINis not defined, define it to 0 so that we fallback toDEFAULT_THREAD_STACKSIZEI would add:
Suggested-by Andrew Cooper <[email protected]>Quoted 1 line
Signed-off-by Manuel Bouyer <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>Quoted 10 lines
--- tools/libs/store/xs.c | 5 +++++ 1 file changed, 5 insertions(+)tools/libs/store/xs.c +0
-0@@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)Quoted 12 lines
tools/libs/store/xs.c bool xs_watch(struct xs_handle *h, const char *path, const char *token) · line 821
Quoted 10 lines
tools/libs/store/xs.c +5
-0#ifdef USE_PTHREAD #define DEFAULT_THREAD_STACKSIZE (16 * 1024) +/* NetBSD doesn't have PTHREAD_STACK_MIN. */ +#ifndef PTHREAD_STACK_MIN +# define PTHREAD_STACK_MIN 0 +#endif +#define READ_THREAD_STACKSIZE \ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)There was also a suggestion to use
MAX(PTHREAD_STACK_MIN, DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?
Quoted 3 lines
TBH, I was planning to submit an incremental cleanup doing this separately. It would be cleaner than putting cleanup into the "fix NetBSD" patch.
yes, that was my idea too
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
PATCH v2 1/1 libs/light: fix uuid on NetBSD
In reply to Manuel BouyerNetBSD uses the same uuid library as FreeBSD. As this is in a __FreeBSD__ || __NetBSD__ block, just drop the #ifdef __FreeBSD__ and dead code.
--- tools/libs/light/libxl_uuid.c | 21 --------------------- 1 file changed, 21 deletions(-)
tools/libs/light/libxl_uuid.c +0 -21
@@ -82,7 +82,6 @@ void libxl_uuid_generate(libxl_uuid *uuid)uuid_enc_be (uuid->uuid, &nat_uuid); } -#ifdef __FreeBSD__int libxl_uuid_from_string (libxl_uuid *uuid,const char *in) {uint32_t status;
@@ -95,19 +94,6 @@ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in)return 0 ; } -#else -#define LIBXL__UUID_PTRS (uuid) &uuid[0], &uuid[1], &uuid[2], &uuid[3], \ - &uuid[4], &uuid[5], &uuid[6], &uuid[7], \ - &uuid[8], &uuid[9], &uuid[10],&uuid[11], \ - &uuid[12],&uuid[13],&uuid[14],&uuid[15] -int libxl_uuid_from_string (libxl_uuid *uuid,const char *in) -{ -if (sscanf (in,LIBXL_UUID_FMT ,LIBXL__UUID_PTRS (uuid->uuid)) !=sizeof (uuid->uuid) ) -return -1 ; -return 0 ; -} -#undef LIBXL__UUID_PTRS -#endif void libxl_uuid_copy (libxl_ctx *ctx_opt,libxl_uuid *dst,const libxl_uuid *src)
@@ -120,7 +106,6 @@ void libxl_uuid_clear(libxl_uuid *uuid)memset (&uuid->uuid,0 ,sizeof (uuid->uuid)); } -#ifdef __FreeBSD__int libxl_uuid_compare (const libxl_uuid *uuid1,const libxl_uuid *uuid2) {uuid_t nat_uuid1, nat_uuid2;
@@ -130,12 +115,6 @@ int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2)return uuid_compare (&nat_uuid1, &nat_uuid2,NULL ); } -#else -int libxl_uuid_compare (const libxl_uuid *uuid1,const libxl_uuid *uuid2) -{ -return memcmp (uuid1->uuid, uuid2->uuid,sizeof (uuid1->uuid)); -} -#endif const uint8_t *libxl_uuid_bytearray_const (const libxl_uuid *uuid) {
Signature · 1 line
2.29.2
PATCH v2 1/1 libs/light: make it build without setresuid()
In reply to Manuel BouyerNetBSD doesn't have setresuid(). introcuce libxl__setresuid(), which on NetBSD assert() that it's never called (it should not be called when dm restriction is off, and NetBSD doesn't support dm restriction at this time).
On linux and FreeBSD it just calls setresuid().
--- tools/libs/light/Makefile | 4 ++-- tools/libs/light/libxl_dm.c | 2 +- tools/libs/light/libxl_internal.h | 3 +++ tools/libs/light/libxl_netbsd.c | 5 +++++ tools/libs/light/libxl_setresuid.c | 23 +++++++++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tools/libs/light/libxl_setresuid.c
tools/libs/light/Makefile +2 -2
@@ -64,8 +64,8 @@ SRCS-$(CONFIG_ARM) += libxl_arm_no_acpi.c endif SRCS-OS-$(CONFIG_NetBSD) = libxl_netbsd.c -SRCS-OS-$(CONFIG_Linux) = libxl_linux.c -SRCS-OS-$(CONFIG_FreeBSD) = libxl_freebsd.c +SRCS-OS-$(CONFIG_Linux) = libxl_linux.c libxl_setresuid.c +SRCS-OS-$(CONFIG_FreeBSD) = libxl_freebsd.c libxl_setresuid.c ifeq ($(SRCS-OS-y),) $(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)
tools/libs/light/libxl_dm.c +1 -1
@@ -3655,7 +3655,7 @@ static int kill_device_model_uid_child(libxl__destroy_devicemodel_state *ddms,LOGD (DEBUG , domid,"DM reaper: calling setresuid(%d, %d, 0)" , reaper_uid, dm_kill_uid); - r =setresuid (reaper_uid, dm_kill_uid,0 ); + r =libxl__setresuid (reaper_uid, dm_kill_uid,0 );if (r) {LOGED (ERROR , domid,"setresuid to (%d, %d, 0)" , reaper_uid, dm_kill_uid);
tools/libs/light/libxl_internal.h +3 -0
@@ -4845,6 +4845,9 @@ _hidden int libxl__domain_pvcontrol(libxl__egc *egc,/* Check whether a domid is recent */ int libxl__is_domid_recent (libxl__gc *gc,uint32_t domid,bool *recent); +/* os-specific implementation of setresuid() */ +int libxl__setresuid (uid_t ruid,uid_t euid,uid_t suid); +#endif /*
tools/libs/light/libxl_netbsd.c +5 -0
@@ -124,3 +124,8 @@ int libxl__local_dm_preexec_restrict(libxl__gc *gc) {return 0 ; } + +int libxl__setresuid (uid_t ruid,uid_t euid,uid_t suid) +{ +assert (!"setresuid is not available on NetBSD, and dm restrction is not supported, so this code path should not have been reached" ); +}
tools/libs/light/libxl_setresuid.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2021 +* Author Manuel Bouyer <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program 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. +*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" + +int libxl__setresuid (uid_t ruid,uid_t euid,uid_t suid) +{ +setresuid (ruid, euid, suid); +}
Signature · 1 line
2.29.2
Re: [PATCH v2] libs/light: make it build without setresuid()
Manuel Bouyer writes ("[PATCH v2] libs/light: make it build without setresuid()"):
Quoted 5 lines
NetBSD doesn't have
setresuid(). introcucelibxl__setresuid(), which on NetBSDassert()that it's never called (it should not be called when dm restriction is off, and NetBSD doesn't support dm restriction at this time).
On linux and FreeBSD it just callssetresuid().
Re: [PATCH v2] libs/light: make it build without setresuid()
In reply to Manuel BouyerQuoted 19 lines · Manuel Bouyer
tools/libs/light/libxl_setresuid.c new file +13
-0@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2021 +* Author Manuel Bouyer <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program 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.
tools/libs/light/libxl_setresuid.c line 23
Quoted 10 lines
tools/libs/light/libxl_setresuid.c new file +10
-0+*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" + +int libxl__setresuid (uid_t ruid,uid_t euid,uid_t suid) +{ +setresuid (ruid, euid, suid); +}
Given the freeze, and discussions on IRC, I have committed most of this series.
This particular patch doesn't compile, but I fixed it up.
Still outstanding are "NetBSD: use system-provided headers", the followon patches requested in "libs/light: pass some infos to qemu", and "xenpmd.c: use dynamic allocation" which failed like this:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/996140268
This latter one I didn't feel confident fixing in a way which didn't break NetBSD, particularly at this point when I'm also racing to get other content ready as well.
~Andrew
Re: [PATCH v2] libs/light: make it build without setresuid()
Quoted 3 lines · Andrew Cooper
Given the freeze, and discussions on IRC, I have committed most of this series.
thanks
Quoted 4 lines
This particular patch doesn't compile, but I fixed it up.
Still outstanding are "NetBSD: use system-provided headers", the
I just sent a v3 of this patch
Quoted 1 line
followon patches requested in "libs/light: pass some infos to qemu", and
will try to get at it tomorow
Quoted 3 lines
"
xenpmd.c: use dynamic allocation" which failed like this:https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/996140268
It looks like I don't have access to this page, could you share the content ?
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: make it build without setresuid()
Quoted 9 lines · Manuel Bouyer
Quoted 2 lines · Andrew Cooper
Given the freeze, and discussions on IRC, I have committed most of this series.
thanks
Quoted 3 lines
This particular patch doesn't compile, but I fixed it up.
Still outstanding are "NetBSD: use system-provided headers", the
I just sent a v3 of this patch
You accidentally labelled it v2, but I'm sure we can cope.
Quoted 9 lines
Quoted 2 lines
followon patches requested in "libs/light: pass some infos to qemu", and
will try to get at it tomorow
Quoted 3 lines
"
xenpmd.c: use dynamic allocation" which failed like this:https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/996140268
It looks like I don't have access to this page, could you share the content ?
urgh - have the permissions broken themselves again...
xenpmd.c:115:13: error: implicit declaration of function 'asprintf' [-Werror=implicit-function-declaration]
It needs an include of stdio.h, and/or some form of #define _GNU_SOURCE.
~Andrew
Re: [PATCH v2] libs/light: make it build without setresuid()
Quoted 23 lines · Andrew Cooper
Quoted 9 lines · Manuel Bouyer
Quoted 2 lines · Andrew Cooper
Given the freeze, and discussions on IRC, I have committed most of this series.
thanks
Quoted 3 lines
This particular patch doesn't compile, but I fixed it up.
Still outstanding are "NetBSD: use system-provided headers", the
I just sent a v3 of this patch
You accidentally labelled it v2, but I'm sure we can cope.
Quoted 9 lines
Quoted 2 lines
followon patches requested in "libs/light: pass some infos to qemu", and
will try to get at it tomorow
Quoted 3 lines
"
xenpmd.c: use dynamic allocation" which failed like this:https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/996140268
It looks like I don't have access to this page, could you share the content ?
Quoted 6 lines
urgh - have the permissions broken themselves again...
xenpmd.c:115:13: error: implicit declaration of function 'asprintf' [-Werror=implicit-function-declaration]
It needs an include of
stdio.h, and/or some form of #define_GNU_SOURCE.
stdio.h is there.
I'll look at this closer tomorow.
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: make it build without setresuid()
In reply to Andrew CooperQuoted 23 lines · Andrew Cooper
Quoted 9 lines · Manuel Bouyer
Quoted 2 lines · Andrew Cooper
Given the freeze, and discussions on IRC, I have committed most of this series.
thanks
Quoted 3 lines
This particular patch doesn't compile, but I fixed it up.
Still outstanding are "NetBSD: use system-provided headers", the
I just sent a v3 of this patch
You accidentally labelled it v2, but I'm sure we can cope.
Quoted 9 lines
Quoted 2 lines
followon patches requested in "libs/light: pass some infos to qemu", and
will try to get at it tomorow
Quoted 3 lines
"
xenpmd.c: use dynamic allocation" which failed like this:https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/996140268
It looks like I don't have access to this page, could you share the content ?
Quoted 6 lines
urgh - have the permissions broken themselves again...
xenpmd.c:115:13: error: implicit declaration of function 'asprintf' [-Werror=implicit-function-declaration]
It needs an include of
stdio.h, and/or some form of #define_GNU_SOURCE.
I added the #define, it builds on NetBSD and Linux.
I just sent a v3 (as 2 separate patches, sorry I don't know how to easily make it otherwise with git) that should fix it.
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
PATCH v2 1/1 NetBSD hotplug: fix block unconfigure on destroy
In reply to Manuel BouyerWhen a domain is destroyed, xparams may not be available any more when the block script is called to unconfigure the vnd.
Check xparam only at configure time, and just unconfigure any vnd present in the xenstore.
--- tools/hotplug/NetBSD/block | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-)
tools/hotplug/NetBSD/block +14 -23
@@ -20,37 +20,28 @@ error() { xpath=$1 xstatus=$2 xparams=$(xenstore-read "$xpath/params") -if [ -b "$xparams" ]; then - xtype="phy" -elif [ -f "$xparams" ]; then - xtype="file" -elif [ -z "$xparams" ]; then - error "$xpath/params is empty, unable to attach block device." -else - error "$xparams is not a valid file type to use as block device." \ - "Only block and regular image files accepted." -fi case $xstatus in 6) # device removed - case $xtype in - file) - vnd=$(xenstore-read "$xpath/vnd" || echo none) - if [ $vnd != none ]; then - vnconfig -u $vnd - fi - ;; - phy) - ;; - *) - echo "unknown type $xtype" >&2 - ;; - esac + vnd=$(xenstore-read "$xpath/vnd" || echo none) + if [ $vnd != none ]; then + vnconfig -u $vnd + fi xenstore-rm $xpath exit 0 ;; 2) + if [ -b "$xparams" ]; then + xtype="phy" + elif [ -f "$xparams" ]; then + xtype="file" + elif [ -z "$xparams" ]; then + error "$xpath/params is empty, unable to attach block device." + else + error "$xparams is not a valid file type to use as block device." \ + "Only block and regular image files accepted." + fi case $xtype in file) # Store the list of available vnd(4) devices in
Signature · 1 line
2.29.2
Re: [PATCH v2] NetBSD hotplug: fix block unconfigure on destroy
Quoted 4 lines · Manuel Bouyer
When a domain is destroyed, xparams may not be available any more when the block script is called to unconfigure the vnd.
Check xparam only at configure time, and just unconfigure any vnd present in the xenstore.
Can you paste the output of xl -vvv destroy ... when this happens? I'm puzzled as to why the nodes would be removed before hotplug script execution. Could this somehow be done by NetBSD blkback?
Thanks, Roger.
Re: [PATCH v2] NetBSD hotplug: fix block unconfigure on destroy
Quoted 9 lines · Roger Pau Monné
Quoted 4 lines · Manuel Bouyer
When a domain is destroyed, xparams may not be available any more when the block script is called to unconfigure the vnd.
Check xparam only at configure time, and just unconfigure any vnd present in the xenstore.Can you paste the output of
xl -vvv destroy ...when this happens? I'm puzzled as to why the nodes would be removed before hotplug script execution. Could this somehow be done by NetBSD blkback?
I'll try. I've seen it mostly while running automated tests, so I'm not sure I can reliably reproduce it.
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
PATCH v2 1/1 libs/light: fix tv_sec printf format
In reply to Manuel BouyerDon't assume tv_sec is a unsigned long, it is 64 bits on NetBSD 32 bits. Use %jd and cast to (intmax_t) instead
--- tools/libs/light/libxl_create.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/libs/light/libxl_create.c +4 -4
@@ -496,7 +496,7 @@ int libxl__domain_build(libxl__gc *gc, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =GCSPRINTF ("%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =GCSPRINTF ("%jd.%02d" , (intmax_t )start_time.tv_sec,(int )start_time.tv_usec/10000 ); localents =libxl__calloc (gc,13 ,sizeof (char *)); i =0 ;
@@ -535,7 +535,7 @@ int libxl__domain_build(libxl__gc *gc, vments[i++] ="image/kernel" ; vments[i++] = (char *) state->pv_kernel.path; vments[i++] ="start_time" ; - vments[i++] =GCSPRINTF ("%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =GCSPRINTF ("%jd.%02d" , (intmax_t )start_time.tv_sec,(int )start_time.tv_usec/10000 );if (state->pv_ramdisk.path) { vments[i++] ="image/ramdisk" ; vments[i++] = (char *) state->pv_ramdisk.path;
@@ -1502,7 +1502,7 @@ static void domcreate_stream_done(libxl__egc *egc, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =GCSPRINTF ("%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =GCSPRINTF ("%jd.%02d" , (intmax_t )start_time.tv_sec,(int )start_time.tv_usec/10000 );break ;case LIBXL_DOMAIN_TYPE_PV : vments =libxl__calloc (gc,11 ,sizeof (char *));
@@ -1512,7 +1512,7 @@ static void domcreate_stream_done(libxl__egc *egc, vments[i++] ="image/kernel" ; vments[i++] = (char *) state->pv_kernel.path; vments[i++] ="start_time" ; - vments[i++] =GCSPRINTF ("%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =GCSPRINTF ("%jd.%02d" , (intmax_t )start_time.tv_sec,(int )start_time.tv_usec/10000 );if (state->pv_ramdisk.path) { vments[i++] ="image/ramdisk" ; vments[i++] = (char *) state->pv_ramdisk.path;
Signature · 1 line
2.29.2
PATCH v2 1/1 libs/call: fix build on NetBSD
In reply to Manuel BouyerDefine PAGE_* if not already defined
Catch up with osdep interface change.
--- tools/libs/call/netbsd.c | 19 +++++++++++-------- tools/libs/call/private.h | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-)
tools/libs/call/netbsd.c +11 -8
@@ -19,12 +19,15 @@* Split from xc_netbsd.c */ -#include "xc_private.h" #include <unistd.h> #include <fcntl.h> #include <malloc.h> +#include <errno.h> #include <sys/mman.h> +#include <sys/ioctl.h> + +#include "private.h" int osdep_xencall_open (xencall_handle *xcall) {
@@ -69,12 +72,13 @@ int osdep_xencall_close(xencall_handle *xcall)return close (fd); } -void *osdep_alloc_hypercall_buffer (xencall_handle *xcall,size_t npages) +void *osdep_alloc_pages (xencall_handle *xcall,size_t npages) { -size_t size = npages *XC_PAGE_SIZE ; +size_t size = npages *PAGE_SIZE ;void *p; +int ret; - ret =posix_memalign (&p,XC_PAGE_SIZE , size); + ret =posix_memalign (&p,PAGE_SIZE , size);if ( ret !=0 || !p )return NULL ;
@@ -86,14 +90,13 @@ void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages)return p; } -void osdep_free_hypercall_buffer (xencall_handle *xcall,void *ptr, -size_t npages) +void osdep_free_pages (xencall_handle *xcall,void *ptr,size_t npages) { - (void )munlock (ptr, npages *XC_PAGE_SIZE ); +munlock (ptr, npages *PAGE_SIZE );free (ptr); } -int do_xen_hypercall (xencall_handle *xcall,privcmd_hypercall_t *hypercall) +int osdep_hypercall (xencall_handle *xcall,privcmd_hypercall_t *hypercall) {int fd = xcall->fd;int error =ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall);
tools/libs/call/private.h +3 -1
@@ -12,8 +12,10 @@#ifndef PAGE_SHIFT /* Mini-os, Yukk */ #define PAGE_SHIFT 12#endif -#ifndef __MINIOS__/* Yukk */ +#ifndef PAGE_SIZE #define PAGE_SIZE (1UL << PAGE_SHIFT) +#endif +#ifndef PAGE_MASK #define PAGE_MASK (~(PAGE_SIZE-1))#endif
Signature · 1 line
2.29.2
PATCH v2 1/1 libs/light: Switch NetBSD to QEMU_XEN
In reply to Manuel BouyerSwitch NetBSD to QEMU_XEN.
All 3 versions of libxl__default_device_model() now return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN, so remove it and just set b_info->device_model_version to LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN in libxl__domain_build_info_setdefault().
--- tools/libs/light/libxl_create.c | 2 +- tools/libs/light/libxl_freebsd.c | 5 ----- tools/libs/light/libxl_internal.h | 2 -- tools/libs/light/libxl_linux.c | 5 ----- tools/libs/light/libxl_netbsd.c | 5 ----- 5 files changed, 1 insertion(+), 18 deletions(-)
tools/libs/light/libxl_create.c +1 -1
@@ -102,7 +102,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->device_model_version =LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ; }else { - b_info->device_model_version =libxl__default_device_model (gc); + b_info->device_model_version =LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ; } }else { b_info->device_model_version =
tools/libs/light/libxl_freebsd.c +0 -5
@@ -229,11 +229,6 @@ out:return rc; } -libxl_device_model_version libxl__default_device_model (libxl__gc *gc) -{ -return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ; -} -int libxl__pci_numdevs (libxl__gc *gc) {return ERROR_NI ;
tools/libs/light/libxl_internal.h +0 -2
@@ -2309,8 +2309,6 @@ _hidden char *libxl__json_object_to_json(libxl__gc *gc,/* Based on /local/domain/$domid/dm-version xenstore key * default is qemu xen traditional */ _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); -/* Return the system-wide default device model */ -_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);static inline bool libxl__stubdomain_is_linux_running (libxl__gc *gc,uint32_t domid)
tools/libs/light/libxl_linux.c +0 -5
@@ -241,11 +241,6 @@ out:return rc; } -libxl_device_model_version libxl__default_device_model (libxl__gc *gc) -{ -return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ; -} -int libxl__pci_numdevs (libxl__gc *gc) {DIR *dir;
tools/libs/light/libxl_netbsd.c +0 -5
@@ -108,11 +108,6 @@ out:return rc; } -libxl_device_model_version libxl__default_device_model (libxl__gc *gc) -{ -return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ; -} -int libxl__pci_numdevs (libxl__gc *gc) {return ERROR_NI ;
Signature · 1 line
2.29.2
PATCH v2 1/1 libs/light: pass some infos to qemu
In reply to Manuel BouyerPass bridge name to qemu as command line option
When starting qemu, set an environnement variable XEN_DOMAIN_ID, to be used by qemu helper scripts
The only functional difference of using the br parameter is that the bridge name gets passed to the QEMU script.
NetBSD doesn't have the ioctl to rename network interfaces implemented, and thus cannot rename the interface from tapX to vifX.Y-emu. Only qemu knowns the tap interface name, so we need to use the qemu script from qemu itself.
--- tools/libs/light/libxl_dm.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/libs/light/libxl_dm.c +6 -0
@@ -761,6 +761,8 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,int nr_set_cpus =0 ;char *s; +flexarray_append_pair (dm_envs,"XEN_DOMAIN_ID" ,GCSPRINTF ("%d" , domid)); +if (b_info->kernel) {LOGD (ERROR , domid,"HVM direct kernel boot is not supported by " "qemu-xen-traditional" );
@@ -1547,8 +1549,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,flexarray_append (dm_args,"-netdev" );flexarray_append (dm_args,GCSPRINTF ("type=tap,id=net%d,ifname=%s," +"br=%s," "script=%s,downscript=%s" , nics[i].devid, ifname, + nics[i].bridge,libxl_tapif_script (gc),libxl_tapif_script (gc)));
@@ -1825,6 +1829,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,flexarray_append (dm_args,GCSPRINTF ("%" PRId64, ram_size));if (b_info->type ==LIBXL_DOMAIN_TYPE_HVM ) { +flexarray_append_pair (dm_envs,"XEN_DOMAIN_ID" ,GCSPRINTF ("%d" , guest_domid)); +if (b_info->u.hvm.hdtype ==LIBXL_HDTYPE_AHCI )flexarray_append_pair (dm_args,"-device" ,"ahci,id=ahci0" );for (i =0 ; i < num_disks; i++) {
Signature · 1 line
2.29.2
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 10 lines · Manuel Bouyer
Pass bridge name to qemu as command line option
When starting qemu, set an environnement variableXEN_DOMAIN_ID, to be used by qemu helper scripts
The only functional difference of using the br parameter is that the bridge name gets passed to the QEMU script.
NetBSD doesn't have the ioctl to rename network interfaces implemented, and thus cannot rename the interface from tapX to vifX.Y-emu. Only qemu knowns the tap interface name, so we need to use the qemu script from qemu itself.Signed-off-by Manuel Bouyer <[email protected]>
If you have a moment might be worth adding a note in xl-network-configuration.5.pod that NetBSD in HVM mode requires bridged networking I think?
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?
I certainly don't mind adding those extra parameters/env variables, but might be nice to clarify the expectations, that can be done in a separate patch.
Thanks, Roger.
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 10 lines · Roger Pau Monné
Quoted 9 lines · Manuel Bouyer
Pass bridge name to qemu as command line option
When starting qemu, set an environnement variableXEN_DOMAIN_ID, to be used by qemu helper scripts
The only functional difference of using the br parameter is that the bridge name gets passed to the QEMU script.
NetBSD doesn't have the ioctl to rename network interfaces implemented, and thus cannot rename the interface from tapX to vifX.Y-emu. Only qemu knowns the tap interface name, so we need to use the qemu script from qemu itself.
Quoted 7 lines
Quoted 1 line
Signed-off-by Manuel Bouyer <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>If you have a moment might be worth adding a note in xl-network-configuration.5.pod that NetBSD in HVM mode requires bridged networking I think?
With the default qemu-ifup script only. As you can do whatever you want in the script, you can support whatever network configuration you want. It's quite easy to do IP routing for example.
Quoted 4 lines
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?
Ha maybe I overlooked this. I'll add it, but maybe it can be submitted in a separate patch ?
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 15 lines · Manuel Bouyer
Quoted 14 lines · Roger Pau Monné
Quoted 10 lines · Manuel Bouyer
Pass bridge name to qemu as command line option
When starting qemu, set an environnement variableXEN_DOMAIN_ID, to be used by qemu helper scripts
The only functional difference of using the br parameter is that the bridge name gets passed to the QEMU script.
NetBSD doesn't have the ioctl to rename network interfaces implemented, and thus cannot rename the interface from tapX to vifX.Y-emu. Only qemu knowns the tap interface name, so we need to use the qemu script from qemu itself.Signed-off-by Manuel Bouyer <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
Quoted 7 lines
Quoted 3 lines
If you have a moment might be worth adding a note in xl-network-configuration.5.pod that NetBSD in HVM mode requires bridged networking I think?
With the default qemu-ifup script only. As you can do whatever you want in the script, you can support whatever network configuration you want. It's quite easy to do IP routing for example.
Right, but the default script provided will do bridging mode only, and even if you add 'script=vif-ip' to the network configuration line it won't do what you expect. Instead it will try to add the tap network interface to the default xenbr0 bridge.
I'm not opposed to having it this way right now, as it's better to have this than no support at all, but we should have the shortcoming documented somewhere. Can be done as a separate patch.
Quoted 7 lines
Quoted 4 lines
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?
Ha maybe I overlooked this. I'll add it, but maybe it can be submitted in a separate patch ?
Yes, that's fine, can be added as a separate patch.
Thanks, Roger.
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 9 lines · Roger Pau Monné
Right, but the default script provided will do bridging mode only, and even if you add 'script=vif-ip' to the network configuration line it won't do what you expect. Instead it will try to add the tap network interface to the default xenbr0 bridge.
I'm not opposed to having it this way right now, as it's better to have this than no support at all, but we should have the shortcoming documented somewhere. Can be done as a separate patch.
I just sent a v3, with a patch to xl-network-configuration.5.pod
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: pass some infos to qemu
In reply to Roger Pau MonnéQuoted 4 lines · Roger Pau Monné
[...]
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?
Actually, the script is part of qemu-xen-traditional:tools/qemu-xen-traditional/i386-dm/qemu-ifup-NetBSD
and it's installed as part of 'make install'. The same script can be used for both qemu-xen-traditional and qemu-xen as long as we support only bridged mode by default.
qemu-xen-traditional did call the script with the bridge name. This patch makes qemu-xen call the script with the same parameters, and add the XEN_DOMAIN_ID environnement variable.
Is it OK to keep the script from qemu-xen-traditional (and installed as part of qemu-xen-traditional) for now ?
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 13 lines · Manuel Bouyer
Quoted 4 lines · Roger Pau Monné
[...]
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?Actually, the script is part of qemu-xen-traditional:
tools/qemu-xen-traditional/i386-dm/qemu-ifup-NetBSDand it's installed as part of 'make install'. The same script can be used for both qemu-xen-traditional and qemu-xen as long as we support only bridged mode by default.
Quoted 6 lines
qemu-xen-traditional did call the script with the bridge name. This patch makes qemu-xen call the script with the same parameters, and add the
XEN_DOMAIN_IDenvironnement variable.Is it OK to keep the script from qemu-xen-traditional (and installed as part of qemu-xen-traditional) for now ?
I think you want to move the script into hotplug/NetBSD/ because it should be possible to install a system without qemu-xen-traditional (--disable-qemu-traditional) and only qemu-upstream, and the script will still be needed in that case.
Thanks, Roger.
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Manuel Bouyer
Quoted 4 lines · Roger Pau Monné
[...]
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?Actually, the script is part of qemu-xen-traditional:
tools/qemu-xen-traditional/i386-dm/qemu-ifup-NetBSDand it's installed as part of 'make install'. The same script can be used for both qemu-xen-traditional and qemu-xen as long as we support only bridged mode by default.
qemu-xen-traditional did call the script with the bridge name. This patch makes qemu-xen call the script with the same parameters, and add the
XEN_DOMAIN_IDenvironnement variable.
Quoted 7 lines
Quoted 2 lines
Is it OK to keep the script from qemu-xen-traditional (and installed as part of qemu-xen-traditional) for now ?
I think you want to move the script into hotplug/NetBSD/ because it should be possible to install a system without qemu-xen-traditional (--disable-qemu-traditional) and only qemu-upstream, and the script will still be needed in that case.
I can, but how do I get the ecript removed from qemu-traditional ? It's a different repo, isn't it ?
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 22 lines · Manuel Bouyer
Quoted 21 lines · Roger Pau Monné
Quoted 19 lines · Manuel Bouyer
Quoted 4 lines · Roger Pau Monné
[...]
Also, the qemu-ifup script doesn't seem to be part of the NetBSD scripts that are upstream, is this something carried by the NetBSD package?Actually, the script is part of qemu-xen-traditional:
tools/qemu-xen-traditional/i386-dm/qemu-ifup-NetBSDand it's installed as part of 'make install'. The same script can be used for both qemu-xen-traditional and qemu-xen as long as we support only bridged mode by default.
qemu-xen-traditional did call the script with the bridge name. This patch makes qemu-xen call the script with the same parameters, and add the
XEN_DOMAIN_IDenvironnement variable.Is it OK to keep the script from qemu-xen-traditional (and installed as part of qemu-xen-traditional) for now ?
Quoted 7 lines
Quoted 4 lines
I think you want to move the script into hotplug/NetBSD/ because it should be possible to install a system without qemu-xen-traditional (--disable-qemu-traditional) and only qemu-upstream, and the script will still be needed in that case.
I can, but how do I get the ecript removed from qemu-traditional ? It's a different repo, isn't it ?
Yes, it's:
http://xenbits.xen.org/gitweb/?p=qemu-xen-traditional.git;a=summary
I would remove it from qemu-trad and then only install from hotplug/NetBSD if it's not already there? Or maybe just force-install it from hotplug/NetBSD even if it's already present?
Thanks, Roger.
Re: [PATCH v2] libs/light: pass some infos to qemu
Quoted 10 lines · Roger Pau Monné
Quoted 2 lines
I can, but how do I get the ecript removed from qemu-traditional ? It's a different repo, isn't it ?
Yes, it's:
http://xenbits.xen.org/gitweb/?p=qemu-xen-traditional.git;a=summary
I would remove it from qemu-trad and then only install from hotplug/NetBSD if it's not already there? Or maybe just force-install it from hotplug/NetBSD even if it's already present?
OK will try that
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --
Quoted 11 lines · Manuel Bouyer
Use unsigned char variable, or cast to (unsigned char), for tolower()/islower() and friends. Fix compiler error array subscript has type 'char' [-Werror=char-subscripts]
Signed-off-by Manuel Bouyer <[email protected]>Reviewed-by Ian Jackson <[email protected]>Release-Acked-by Ian Jackson <[email protected]>--- tools/libs/light/libxl_qmp.c | 2 +- tools/xentrace/xentrace.c | 2 +- xen/tools/symbols.c | 4 ++--
This is totally ugly, but it is a well known totally ugly corner case of C. Non-freestanding bits have to play by C's rules to be compatible.
~Andrew