tools: Allow building XenServer's blktap 2.5 as an external tree.
v2 cover tools: Allow building XenServer's blktap 2.5 as an external tree.
For some time, the blktap2 in-tree has bitrotted. Many years ago the XenServer team at Citrix forked the code into a separate repository; several attempts have been made to upstream those changes back into Xen, to no avail.
The blktap code at the moment is the only source of performant vhd format integration. It's additionally in use by projects like the COLO project.
This patch series removes the in-tree blktap2 code and enables xen to detect and build against the XenServer blktap tree. I've gotten agreement from the XenServer team to act as an upstream -- to accept patches fixing bugs, to help track down errors, and to attempt to help fix build breakages introduced by development.
At the moment this patch is against the "blktap2" branch of XenServer's blktap.git. (This has been sometimes known as "blktap 2.5".) This branch is maintianed in order to provide a buildroot for OpenStack, and has also been used by the CentOS xen packages for several years now.
The series consists of three patches:
1/3 Remove the blktap2 tree and temporarily disable it in config
2/3 Port libxl to use the upstream blktap2.
3/3 Detect blktap2 and enable it by default if detected.
The first patch is pretty massive and mostly not very interesting; I'll be sending a modified patch with the interesting bits. The full patch series can be found here:
git://xenbits.xen.org/people/gdunlap/xen.git out/blktap25/rfc-v2
This series has some niggles (noted in the patches themselves), and so it not yet ready to apply as-is.
One of the big ones is that the blktap headers are borked: you can't actually include them from where they get installed. This is something I'm going to try to address upstream.
-George Dunlap
George Dunlap (3):
tools: Remove in-tree blktap2
libxl: Port libxl_blktap2.c to blktap2.5 API. tools/configure: Detect out-of-tree blktap2 and use by default if
available
tools/Makefile | 1 - tools/Rules.mk | 10 +- [tools/blktap2 tree removed] tools/config.h.in | 4 +- tools/configure | 2125 ++++++++++-------- tools/configure.ac | 30 +- tools/libxl/libxl.c | 6 +- tools/libxl/libxl_blktap2.c | 58 +- tools/libxl/libxl_dm.c | 3 +- tools/libxl/libxl_internal.h | 3 +- 135 files changed, 1221 insertions(+), 41148 deletions(-)
Signature · 1 line
1.9.1
RFC PATCH v2 1/3 tools: Remove in-tree blktap2
Remove and temporarily disable the in-tree blktap2 while we pivot to using an external blktap2 library.
The reason for removing first is to be able to port libxl_blktap2.c to the upstream blktap2.5 API (which is incompatible with the in-tree bltkap) in a separate patch to the code linking the external blktap2 tree.
---
This patch modifies tools/configure.ac; autogen.sh should be re-run.
--- tools/Makefile | 1 - [tools/blktap2/* deleted] tools/config.h.in | 3 - tools/configure | 26 +- tools/configure.ac | 12 +- 130 files changed, 9 insertions(+), 40162 deletions(-) delete mode 100644 tools/blktap2/[*]
tools/Makefile +0 -1
@@ -16,7 +16,6 @@ SUBDIRS-y += console SUBDIRS-y += xenmon SUBDIRS-y += xenstat SUBDIRS-$(CONFIG_Linux) += memshr -SUBDIRS-$(CONFIG_BLKTAP2) += blktap2 SUBDIRS-$(CONFIG_NetBSD) += xenbackendd SUBDIRS-y += libfsimage SUBDIRS-$(CONFIG_Linux) += libvchan
tools/blktap2/Makefile deleted +0 -0
tools/config.h.in +0 -3
@@ -1,8 +1,5 @@ /* config.h.in. Generated from configure.ac by autoheader. */ -/* Blktap2 enabled */ -#undef HAVE_BLKTAP2 - /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H
tools/configure +7 -19
@@ -3222,7 +3222,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
@@ -3268,7 +3268,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
@@ -3292,7 +3292,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
@@ -3337,7 +3337,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
@@ -3361,7 +3361,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
@@ -4043,24 +4043,12 @@ if test "${enable_blktap2+set}" = set; then : enableval=$enable_blktap2; else - case "$host_os" in - linux*) - enable_blktap2="yes";; - *) enable_blktap2="no";; - esac - + enable_blktap2="no" fi if test "x$enable_blktap2" = "xyes"; then : - -$as_echo "#define HAVE_BLKTAP2 1" >>confdefs.h - - blktap2=y -else - - blktap2=n - + as_fn_error $? "blktap2 support temporarily unavailable" "$LINENO" 5 fi
tools/configure.ac +2 -10
@@ -118,17 +118,9 @@ 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 -]) + enable_blktap2="no"]) AS_IF([test "x$enable_blktap2" = "xyes"], [ -AC_DEFINE([HAVE_BLKTAP2], [1], [Blktap2 enabled]) - blktap2=y],[ - blktap2=n -]) + AC_MSG_ERROR([blktap2 support temporarily unavailable])]) AC_SUBST(blktap2)
Signature · 1 line
1.9.1
Re: [PATCH RFC v2 1/3] tools: Remove in-tree blktap2
George Dunlap writes ("[PATCH RFC v2 1/3] tools: Remove in-tree blktap2"):
Quoted 7 lines
Remove and temporarily disable the in-tree blktap2 while we pivot to using an external blktap2 library.
The reason for removing first is to be able to port
libxl_blktap2.cto the upstream blktap2.5 API (which is incompatible with the in-tree bltkap) in a separate patch to the code linking the external blktap2 tree.
RFC PATCH v2 2/3 libxl: Port libxl_blktap2.c to blktap2.5 API.
In reply to George DunlapThis is code is in preparation for building against an external blktap tree.
tap_ctl_find() has gone away, so in some cases we use tap_ctl_find_minor(), and in other cases we use a locally-reimplemented version of tap_ctl_find().
tap_ctl_create() has an extra three parameters, including a flags parameter which can be used to designate a disk image as read-only. Pass the readwrite disk flag here so we can now open backends on read-only storage.
tap_ctl_destroy() now has two extra arguments as well; add sensible default values.
---
--- tools/libxl/libxl.c | 6 +++-- tools/libxl/libxl_blktap2.c | 58 ++++++++++++++++++++++++++++++++++++-------- tools/libxl/libxl_dm.c | 3 ++- tools/libxl/libxl_internal.h | 3 ++- 4 files changed, 56 insertions(+), 14 deletions(-)
tools/libxl/libxl.c +4 -2
@@ -2484,7 +2484,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,case LIBXL_DISK_BACKEND_TAP :if (dev ==NULL ) { dev =libxl__blktap_devpath (gc, disk->pdev_path, - disk->format); + disk->format, + disk->readwrite);if (!dev) {LOG (ERROR ,"failed to get blktap devpath for %p\n" , disk->pdev_path);
@@ -3078,7 +3079,8 @@ void libxl__device_disk_local_initiate_attach(libxl__egc *egc,break ;case LIBXL_DISK_FORMAT_VHD : dev =libxl__blktap_devpath (gc, disk->pdev_path, - disk->format); + disk->format, + disk->readwrite);break ;case LIBXL_DISK_FORMAT_QCOW :case LIBXL_DISK_FORMAT_QCOW2 :
tools/libxl/libxl_blktap2.c +48 -10
100 lines not on this page · raw message
tools/libxl/libxl_dm.c +2 -1
@@ -835,7 +835,8 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,if (disks[i].backend ==LIBXL_DISK_BACKEND_TAP ) { format =qemu_disk_format_string (LIBXL_DISK_FORMAT_RAW ); pdev_path =libxl__blktap_devpath (gc, disks[i].pdev_path, - disks[i].format); + disks[i].format, + disks[i].readwrite); }else { pdev_path = disks[i].pdev_path; }
tools/libxl/libxl_internal.h +2 -1
@@ -1574,7 +1574,8 @@ _hidden int libxl__blktap_enabled(libxl__gc *gc);*/ _hidden char *libxl__blktap_devpath(libxl__gc *gc,const char *disk, -libxl_disk_format format); +libxl_disk_format format, +int readwrite);/* libxl__device_destroy_tapdisk: * Destroys any tapdisk process associated with the backend represented
Signature · 1 line
1.9.1
Re: [PATCH RFC v2 2/3] libxl: Port libxl_blktap2.c to blktap2.5 API.
George Dunlap writes ("[PATCH RFC v2 2/3] libxl: Port libxl_blktap2.c to blktap2.5 API."):
Quoted 2 lines
This is code is in preparation for building against an external blktap tree.
(NB I'm not really familiar with the tapdisk API. I guess we'll want an ack from some blktap2.5 person ?)
tools/libxl/libxl_blktap2.c int libxl__blktap_enabled(libxl__gc *gc) · line 27
Quoted 2 lines
tools/libxl/libxl_blktap2.c +2
-0+static int tap_ctl_find (const char *type,const char *disk,tap_list_t *tap) +{
What does this function return ?
tools/libxl/libxl_blktap2.c int libxl__blktap_enabled(libxl__gc *gc) · line 36
Quoted 9 lines
tools/libxl/libxl_blktap2.c +9
-0+int err; +struct list_head list =LIST_HEAD_INIT (list); +tap_list_t *entry; + + err =tap_ctl_list (&list); +if (err) +return err; + + err =ERROR_FAIL ;
...
But later,
tools/libxl/libxl_blktap2.c int libxl__device_destroy_tapdisk(libxl__gc *gc, const char *params) · line 110
Quoted 4 lines
err = tap_ctl_find(type, disk, &tap);tools/libxl/libxl_blktap2.c +1
-1-if (err <0 ) { +if (err) {/* returns -errno */
Also if it fails to find an entry it simply returns ERROR_FAIL without logging anything, which seems unhelpfully opaque.
Quoted 5 lines
char *libxl__blktap_devpath(libxl__gc *gc,
const char *disk,tools/libxl/libxl_blktap2.c +2
-1- libxl_disk_format format) +libxl_disk_format format, + int readwrite)
...
Quoted 1 line
+
fprintf(stderr, "DEBUG %s %d %s\n", __func__, __LINE__, params);
Mistakenly left in ?
tools/libxl/libxl_blktap2.c int libxl__device_destroy_tapdisk(libxl__gc *gc, const char *params) · line 94
Quoted 6 lines
tools/libxl/libxl_blktap2.c +1
-1@@ -55,7 +91,8 @@ int libxl__device_destroy_tapdisk(libxl__gc *gc, const char *params) {char *type, *disk;int err; -tap_list_t tap; +struct list_head list =LIST_HEAD_INIT (list);
Where is this variable `list' used ?
Thanks,
Ian.
RFC PATCH v2 3/3 tools/configure: Detect out-of-tree blktap2 and use by default if available
In reply to George DunlapSet the {CFLAGS,LDLIBS,SHLIBS}_libblktapctl conditionally so that if someone is building blkttap out-of-tree but not installing it in the build environment, they can specify the path thus:
CFLAGS="-I$INST_DIR/$PREFIX/include/blktap -I$INST_DIR/$PREFIX/include/vhd" \
LDFLAGS="-L$INST_DIR/$PREFIX/lib -Wl,-rpath-link=$INST_DIR/$PREFIX/lib" \
./configure --prefix=$PREFIX --with-system-qemu=/usr/bin/qemu-system-i386
CFLAGS_libblktapctl="-I$INST_DIR/$PREFIX/include/blktap -I$INST_DIR/$PREFIX/include/vhd" \
LDLIBS_libblktapctl="-L$INST_DIR/$PREFIX/lib -lblktapctl" \
SHLIB_libblktapctl="-Wl,-rpath-link=$INST_DIR/$PREFIX/lib" \
make
---
NOTES:
1. blktap doesn't have any proper versioning, so these checks may need to be made more complete to make sure we have a compatible version of the library.
2. The blktap header files at the moment are borked wrt paths. "make install" will separate them into /usr/include/blktap and /usr/include/vhd; but in the header files themselves they include one another by using #include "filename.h". This means that using them after install doesn't work unless you add -I/usr/include/blktap and -I/usr/include/vhd.
Rules.mk at the moment handles this by including both paths in CFLAGS_libblktapctl; but for configure to correctly detect it, at the moment it means passing an extra CFLAGS, like this:
CFLAGS="-I/usr/include/blktap -I/usr/include/vhd" ./configure
I'll try to sort out #2 before getting this committed.
This patch modifies tools/configure.ac; autogen.sh should be re-run.
--- tools/Rules.mk | 10 +- tools/config.h.in | 7 +- tools/configure | 2013 ++++++++++++++++++++++++++++------------------------ tools/configure.ac | 32 +- 4 files changed, 1123 insertions(+), 939 deletions(-)
tools/Rules.mk +6 -4
@@ -14,7 +14,6 @@ XEN_LIBXC = $(XEN_ROOT)/tools/libxc XEN_XENLIGHT = $(XEN_ROOT)/tools/libxl XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore XEN_LIBXENSTAT = $(XEN_ROOT)/tools/xenstat/libxenstat/src -XEN_BLKTAP2 = $(XEN_ROOT)/tools/blktap2 XEN_LIBVCHAN = $(XEN_ROOT)/tools/libvchan CFLAGS_xeninclude = -I$(XEN_INCLUDE)
@@ -63,10 +62,13 @@ endif LIBXL_BLKTAP ?= $(CONFIG_BLKTAP2) +# If you build blktap out-of-tree but don't install it in your +# buildroot, set these environment variables to let the build system +# know where to find the headers and libraries. ifeq ($(LIBXL_BLKTAP),y) -CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include $(CFLAGS_xeninclude) -LDLIBS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl -SHLIB_libblktapctl = -Wl,-rpath-link=$(XEN_BLKTAP2)/control +CFLAGS_libblktapctl ?= -I$(INCLUDEDIR)/blktap -I$(INCLUDEDIR)/vhd $(CFLAGS_xeninclude) +LDLIBS_libblktapctl ?= -lblktapctl +SHLIB_libblktapctl ?= -Wl,-rpath-link=$(LIBDIR) else CFLAGS_libblktapctl = LDLIBS_libblktapctl =
tools/config.h.in +5 -2
@@ -1,10 +1,13 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Blktap2 enabled */ +#undef HAVE_BLKTAP2 + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `aio' library (-laio). */ -#undef HAVE_LIBAIO +/* Define to 1 if you have the `blktapctl' library (-lblktapctl). */ +#undef HAVE_LIBBLKTAPCTL /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO
tools/configure +1088 -925
2,328 lines not on this page · raw message
tools/configure.ac +24 -8
@@ -114,13 +114,33 @@ esac]) LINUX_BACKEND_MODULES="`eval echo $LINUX_BACKEND_MODULES`" AC_SUBST(LINUX_BACKEND_MODULES) -dnl Enable blktap2 on Linux only. +# Check for blktap2 +blktap2_present="yes" +AC_CHECK_HEADER([tap-ctl.h],,[blktap2_present="no"]) +AC_CHECK_LIB([blktapctl], [tap_ctl_list],,[blktap2_present="no"]) +AC_CHECK_LIB([blktapctl], [tap_ctl_find_minor],,[blktap2_present="no"]) +AC_CHECK_LIB([blktapctl], [tap_ctl_create],,[blktap2_present="no"]) +AC_CHECK_LIB([blktapctl], [tap_ctl_destroy],,[blktap2_present="no"]) + AC_ARG_ENABLE([blktap2], AS_HELP_STRING([--enable-blktap2], - [Enable blktap2, (DEFAULT is on for Linux, otherwise off)]),,[ - enable_blktap2="no"]) + [Enable blktap2, (DEFAULT is on for Linux, otherwise off)]), + [AS_IF([test "$enable_blktap2" = "yes"], + [AS_IF([test "$blktap2_present" = "no"], + [AC_MSG_ERROR([blktap2 enabled, but cannot find blktap2])])])], + [ + case "$blktap2_present" in + yes) + enable_blktap2="yes";; + no) + enable_blktap2="no";; + esac + ]) AS_IF([test "x$enable_blktap2" = "xyes"], [ - AC_MSG_ERROR([blktap2 support temporarily unavailable])]) +AC_DEFINE([HAVE_BLKTAP2], [1], [Blktap2 enabled]) + blktap2=y],[ + blktap2=n +]) AC_SUBST(blktap2)
@@ -327,10 +347,6 @@ 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_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 AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer], [libgcrypt="y"], [libgcrypt="n"])
Signature · 1 line
1.9.1
Quoted 33 lines · George Dunlap
For some time, the blktap2 in-tree has bitrotted. Many years ago the XenServer team at Citrix forked the code into a separate repository; several attempts have been made to upstream those changes back into Xen, to no avail.
The blktap code at the moment is the only source of performant vhd format integration. It's additionally in use by projects like the COLO project.
This patch series removes the in-tree blktap2 code and enables xen to detect and build against the XenServer blktap tree. I've gotten agreement from the XenServer team to act as an upstream -- to accept patches fixing bugs, to help track down errors, and to attempt to help fix build breakages introduced by development.
At the moment this patch is against the "blktap2" branch of XenServer's blktap.git. (This has been sometimes known as "blktap 2.5".) This branch is maintianed in order to provide a buildroot for OpenStack, and has also been used by the CentOS xen packages for several years now.
The series consists of three patches:
1/3 Remove the blktap2 tree and temporarily disable it in config
2/3 Port libxl to use the upstream blktap2.
3/3 Detect blktap2 and enable it by default if detected.
The first patch is pretty massive and mostly not very interesting; I'll be sending a modified patch with the interesting bits. The full patch series can be found here:
Quoted 8 lines
git://xenbits.xen.org/people/gdunlap/xen.gitout/blktap25/rfc-v2This series has some niggles (noted in the patches themselves), and so it not yet ready to apply as-is.
One of the big ones is that the blktap headers are borked: you can't actually include them from where they get installed. This is something I'm going to try to address upstream.
I forgot to add,
Difference vs v1: build as an external library, rather than cloning and building it internally.
-George