tools: add support for FreeBSD
v3 cover tools: add support for FreeBSD
This are the remaining bits regarding FreeBSD support in the tools.
Thanks, Roger.
PATCH v3 1/5 configure: set blktap2 availability on configure
blktap2 will be enabled by default on Linux systems only, also give the oportunity to disable it from configure.
Remove the gate in the Makefile that only allows enabling blktap{1,2} on Linux, since this is now done in a more flexible way on configure.
Please re-run autoconf after applying this patch.
--- config/Tools.mk.in | 1 + tools/Makefile | 5 +---- tools/configure.ac | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-)
config/Tools.mk.in +1 -0
@@ -54,6 +54,7 @@ CONFIG_SEABIOS := @seabios@ CONFIG_QEMU_TRAD := @qemu_traditional@ CONFIG_QEMU_XEN := @qemu_xen@ CONFIG_BLKTAP1 := @blktap1@ +CONFIG_BLKTAP2 := @blktap2@ CONFIG_VTPM := @vtpm@ CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
tools/Makefile +1 -4
@@ -16,11 +16,8 @@ SUBDIRS-y += console SUBDIRS-y += xenmon SUBDIRS-y += xenstat SUBDIRS-$(CONFIG_Linux) += memshr -ifeq ($(CONFIG_X86)$(CONFIG_Linux),yy) SUBDIRS-$(CONFIG_BLKTAP1) += blktap -endif -SUBDIRS-$(CONFIG_Linux) += blktap2 -SUBDIRS-$(CONFIG_NetBSD) += blktap2 +SUBDIRS-$(CONFIG_BLKTAP2) += blktap2 SUBDIRS-$(CONFIG_NetBSD) += xenbackendd SUBDIRS-y += libfsimage SUBDIRS-$(CONFIG_Linux) += libvchan
tools/configure.ac +18 -0
@@ -58,6 +58,24 @@ AX_ARG_DEFAULT_ENABLE([seabios], [Disable SeaBIOS]) AX_ARG_DEFAULT_ENABLE([debug], [Disable debug build of tools]) AX_ARG_DEFAULT_DISABLE([blktap1], [Enable blktap1 tools]) +dnl Enable blktap2 on Linux only. +AC_ARG_ENABLE([blktap2], + AS_HELP_STRING([--enable-blktap2], + [Enable blktap2, (DEFAULT is on for Linux, otherwise off)]),,[ + case "$host_os" in + linux*) + enable_blktap2="yes";; + *) enable_blktap2="no";; + esac +]) +AS_IF([test "x$enable_blktap2" = "xyes"], [ +AC_DEFINE([HAVE_BLKTAP2], [1], [Blktap2 enabled]) + blktap2=y],[ + blktap2=n +]) +AC_SUBST(blktap2) + + AC_ARG_ENABLE([qemu-traditional], AS_HELP_STRING([--enable-qemu-traditional], [Enable qemu traditional device model, (DEFAULT is on for Linux or NetBSD x86, otherwise off)]),,[
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v3 1/5] configure: set blktap2 availability on configure
Quoted 2 lines · Roger Pau Monne
blktap2 will be enabled by default on Linux systems only, also give the oportunity to disable it from configure.
I think it should be disabled by blktap2 on Linux as well. It requires a non-upstream driver to work.
David
Re: [PATCH v3 1/5] configure: set blktap2 availability on configure
Quoted 6 lines · David Vrabel
Quoted 2 lines · Roger Pau Monne
blktap2 will be enabled by default on Linux systems only, also give the oportunity to disable it from configure.
I think it should be disabled by blktap2 on Linux as well. It requires a non-upstream driver to work.
This was my original intention, but after discussion with Ian C he felt that it would be better to leave it out of the FreeBSD support series:
http://marc.info/?l=xen-devel&m=140204739305306
If there's consensus about disabling blktap2 globally I can send a patch for it, but I would prefer to leave it out of the FreeBSD support series.
Roger.
Re: [PATCH v3 1/5] configure: set blktap2 availability on configure
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · David Vrabel
Quoted 2 lines · Roger Pau Monne
blktap2 will be enabled by default on Linux systems only, also give the oportunity to disable it from configure.
I think it should be disabled by blktap2 on Linux as well. It requires a non-upstream driver to work.
Quoted 7 lines
This was my original intention, but after discussion with Ian C he felt that it would be better to leave it out of the FreeBSD support series:
http://marc.info/?l=xen-devel&m=140204739305306
If there's consensus about disabling blktap2 globally I can send a patch for it, but I would prefer to leave it out of the FreeBSD support series.
Oh, that sounds fine.
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 2/5 configure: make the libaio test conditional on blktap{1, 2}
In reply to Roger Pau Monnelibaio is only required for blktap{1,2}, so make the check conditional on whether the user has requested blktap{1,2} or not.
---
Please re-run autoconf after applying this patch.
---
Changes since v2:
- Make libaio test conditional on whether blktap2 is also enabled.
--- tools/configure.ac | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
tools/configure.ac +2 -0
@@ -262,7 +262,9 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [ AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"]) ]) AC_SUBST(zlib) +AS_IF([test "x$enable_blktap1" = "xyes" || test "x$enable_blktap2" = "xyes"], [ AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])]) +]) 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
Re: [PATCH v3 2/5] configure: make the libaio test conditional on blktap{1, 2}
Quoted 20 lines · Roger Pau Monne
libaio is only required for blktap{1,2}, so make the check conditional on whether the user has requested blktap{1,2} or not.
Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Ian Campbell <[email protected]>---
Please re-run autoconf after applying this patch.
---
Changes since v2:
- Make libaio test conditional on whether blktap2 is also enabled.--- tools/configure.ac | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)tools/configure.ac +0
-0
tools/configure.ac AC_CHECK_HEADER([lzo/lzo1x.h], [ · line 267
Quoted 6 lines
tools/configure.ac +2
-0@@ -262,7 +262,9 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [ AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"]) ]) AC_SUBST(zlib) +AS_IF([test "x$enable_blktap1" = "xyes" || test "x$enable_blktap2" = "xyes"], [ AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])]) +])
Libaio is needed by QEMU as well.
Wei.
Re: [PATCH v3 2/5] configure: make the libaio test conditional on blktap{1, 2}
Quoted 16 lines · Wei Liu
Quoted 15 lines · Roger Pau Monne
libaio is only required for blktap{1,2}, so make the check conditional on whether the user has requested blktap{1,2} or not.
Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Ian Campbell <[email protected]>---
Please re-run autoconf after applying this patch.
---
Changes since v2:
- Make libaio test conditional on whether blktap2 is also enabled.--- tools/configure.ac | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 13 lines
tools/configure.ac AC_CHECK_HEADER([lzo/lzo1x.h], [ · line 267
Quoted 11 lines
tools/configure.ac +2
-0@@ -262,7 +262,9 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [ AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"]) ]) AC_SUBST(zlib) +AS_IF([test "x$enable_blktap1" = "xyes" || test "x$enable_blktap2" = "xyes"], [ AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])]) +])Libaio is needed by QEMU as well.
Not on FreeBSD, and Qemu already runs it's own configure script, so I don't think we need to check for everything that Qemu needs here.
Roger.
Re: [PATCH v3 2/5] configure: make the libaio test conditional on blktap{1, 2}
Quoted 31 lines · Roger Pau Monné
Quoted 16 lines · Wei Liu
Quoted 15 lines · Roger Pau Monne
libaio is only required for blktap{1,2}, so make the check conditional on whether the user has requested blktap{1,2} or not.
Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Ian Campbell <[email protected]>---
Please re-run autoconf after applying this patch.
---
Changes since v2:
- Make libaio test conditional on whether blktap2 is also enabled.--- tools/configure.ac | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Quoted 13 lines
tools/configure.ac AC_CHECK_HEADER([lzo/lzo1x.h], [ · line 267
Quoted 11 lines
tools/configure.ac +2
-0@@ -262,7 +262,9 @@ AC_CHECK_HEADER([lzo/lzo1x.h], [ AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"]) ]) AC_SUBST(zlib) +AS_IF([test "x$enable_blktap1" = "xyes" || test "x$enable_blktap2" = "xyes"], [ AC_CHECK_LIB([aio], [io_setup], [], [AC_MSG_ERROR([Could not find libaio])]) +])Libaio is needed by QEMU as well.
Quoted 2 lines
Not on FreeBSD, and Qemu already runs it's own configure script, so I don't think we need to check for everything that Qemu needs here.
We do check for some stuff because qemu needs it, so we can fail sooner. I'm happy to ack and accept this patch as it is though.
I'd really like to see if we could pull the clone of external trees earlier so we can run qemu's configure sooner and perhaps fail sooner. I'm even wondering if we can cause things to be cloned at configure time.
Anyway, one for another day, I reckon.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 3/5 libxl: add support for FreeBSD uuid implementation
In reply to Roger Pau MonneAdd 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.
---
Changes since v2:
- Unify the FreeBSD and NetBSD uuid implementations as much as possible.
--- tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_uuid.c | 40 ++++++++++++++++++++++++++++++++-------- tools/libxl/libxl_uuid.h | 12 +++++++----- 3 files changed, 43 insertions(+), 13 deletions(-)
tools/libxl/libxl_internal.h +4 -0
@@ -3179,6 +3179,10 @@ int libxl__uint64_parse_json(libxl__gc *gc, const libxl__json_object *o, void *p);int libxl__string_parse_json (libxl__gc *gc,const libxl__json_object *o,char **p); +/* +* Compile time assertion +*/ +#define BUILD_BUG_ON (p) ((void)sizeof(char[1 - 2 * !!(p)]))#endif
tools/libxl/libxl_uuid.c +32 -8
@@ -59,21 +59,35 @@ uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid)return uuid->uuid; } -#elif defined(__NetBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__)int libxl_uuid_is_nil (const libxl_uuid *uuid) {uint32_t status; -return uuid_is_nil ((uuid_t *)uuid->uuid, &status); + +return uuid_is_nil (&uuid->uuid, &status); }void libxl_uuid_generate (libxl_uuid *uuid) {uint32_t status; -uuid_create ((uuid_t *)uuid->uuid, &status); + +BUILD_BUG_ON (sizeof (libxl_uuid) !=sizeof (uuid_t)); +uuid_create (&uuid->uuid, &status);assert (status == uuid_s_ok); } +#ifdef __FreeBSD__ +int libxl_uuid_from_string (libxl_uuid *uuid,const char *in) +{ +uint32_t status; + +uuid_from_string (in, &uuid->uuid, &status); +if (status != uuid_s_ok) +return -1 ; +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], \
@@ -85,33 +99,43 @@ int libxl_uuid_from_string(libxl_uuid *uuid, const char *in)return 0 ; }#undef LIBXL__UUID_PTRS +#endif void libxl_uuid_copy (libxl_ctx *ctx_opt,libxl_uuid *dst,const libxl_uuid *src) { -memcpy (dst->uuid, src->uuid,sizeof (dst->uuid)); +memcpy (&dst->uuid, &src->uuid,sizeof (dst->uuid)); }void libxl_uuid_clear (libxl_uuid *uuid) { -memset (uuid->uuid,0 ,sizeof (uuid->uuid)); +memset (&uuid->uuid,0 ,sizeof (uuid->uuid)); } +#ifdef __FreeBSD__ +int libxl_uuid_compare (const libxl_uuid *uuid1,const libxl_uuid *uuid2) +{ + +return uuid_compare (&uuid1->uuid, &uuid2->uuid,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) { -return uuid->uuid; + +return uuid->uuid_raw; }uint8_t *libxl_uuid_bytearray (libxl_uuid *uuid) { -return uuid->uuid; -} +return uuid->uuid_raw; +}#else #error "Please update libxl_uuid.c for your OS"
tools/libxl/libxl_uuid.h +7 -5
@@ -33,20 +33,22 @@ typedef struct {#define LIBXL_UUID_BYTES (arg) LIBXL__UUID_BYTES(((uint8_t *)arg.uuid)) -#elif defined(__NetBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__)#include <uuid.h> +#include <stdint.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> -#define LIBXL_UUID_BYTES (arg) LIBXL__UUID_BYTES(arg.uuid) - -typedef struct { -uint8_t uuid[16 ]; +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
Re: [PATCH v3 3/5] libxl: add support for FreeBSD uuid implementation
Quoted 26 lines · Roger Pau Monne
Add the FreeBSD specific uuid implementation. Since
uuid_tis 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_tis the same as the union used in libxl.Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Ian Campbell <[email protected]>---
Changes since v2:
- Unify the FreeBSD and NetBSD uuid implementations as much as possible.--- tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_uuid.c | 40 ++++++++++++++++++++++++++++++++-------- tools/libxl/libxl_uuid.h | 12 +++++++----- 3 files changed, 43 insertions(+), 13 deletions(-)tools/libxl/libxl_internal.h +0
-0
tools/libxl/libxl_internal.h int libxl__uint64_parse_json(libxl__gc *gc, const libxl__json_object *o, · line 3186
Quoted 8 lines
tools/libxl/libxl_internal.h +4
-0@@ -3179,6 +3179,10 @@ int libxl__uint64_parse_json(libxl__gc *gc, const libxl__json_object *o, void *p);int libxl__string_parse_json (libxl__gc *gc,const libxl__json_object *o,char **p); +/* +* Compile time assertion +*/ +#define BUILD_BUG_ON (p) ((void)sizeof(char[1 - 2 * !!(p)]))
Please prefer _Static_assert if available.
c/s d5a3bc1a214 is the way I did this for libxc.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 4/5 libxl: remove the gate that only allows block or regular backing images
In reply to Roger Pau MonneOn FreeBSD ZVOLs/disks/partitions are char devices, so libxl must allow it's usage. This is already taken care in the OS-specific bits of libxl by libxl__try_phy_backend, so remove the generic gate.
---
Changes since v2:
- Remove the generic gate instead of adding support for char devices.
--- tools/libxl/libxl_device.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
tools/libxl/libxl_device.c +0 -6
@@ -265,12 +265,6 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) { disk->vdev, disk->pdev_path);return ERROR_INVAL ; } -if (!S_ISBLK (a.stab.st_mode) & - !S_ISREG (a.stab.st_mode)) { -LOG (ERROR ,"Disk vdev=%s phys path is not a block dev or file: %s" , - disk->vdev, disk->pdev_path); -return ERROR_INVAL ; - } }if (disk->backend !=LIBXL_DISK_BACKEND_UNKNOWN ) {
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 5/5 libxc: fix printf formatting error surfaced by 66f8c6
In reply to Roger Pau MonneThe privcmd hypercall op and arguments on BSDs are unsigned long, so use the proper printf format especifiers.
--- tools/libxc/xenctrl_osdep_ENOSYS.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
tools/libxc/xenctrl_osdep_ENOSYS.c +4 -0
@@ -27,7 +27,11 @@ static int ENOSYS_privcmd_close(xc_interface *xch, xc_osdep_handle h)static int ENOSYS_privcmd_hypercall (xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall) { +#if defined(__FreeBSD__) || defined(__NetBSD__) +IPRINTF (xch,"ENOSYS_privcmd %lx: hypercall: %02lu(%#lx,%#lx,%#lx,%#lx,%#lx)\n" , +#elseIPRINTF (xch,"ENOSYS_privcmd %lx: hypercall: %02lld(%#llx,%#llx,%#llx,%#llx,%#llx)\n" , +#endif h, hypercall->op, hypercall->arg[0 ], hypercall->arg[1 ], hypercall->arg[2 ], hypercall->arg[3], hypercall->arg[4]);
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 1 line · Roger Pau Monne
This are the remaining bits regarding FreeBSD support in the tools.
Acked + applied all but the UUID one, the _Static_assert thing seems like a good idea.
Ian.