libxl: subprocess handling
v8 cover libxl: subprocess handling
This incorporates changes from review.
These have already been acked, apart from 04/25, and could go into the tree very soon:
01/25 libxl: handle POLLERR, POLLHUP, POLLNVAL properly 02/25 libxl: support multiple libxl__ev_fds for the same fd 03/25 libxl: event API: new facilities for waiting for subprocesses
! 04/25 autoconf: trim the configure script; use autoheader
05/25 autoconf: New test for openpty et al.
06/25 libxl: provide libxl__remove_file et al.
07/25 libxl: Introduce libxl__sendmsg_fds and libxl__recvmsg_fds 08/25 libxl: Clean up setdefault in do_domain_create 09/25 libxl: provide libxl__datacopier_*
10/25 libxl: provide libxl__openpty_*
11/25 libxl: ao: Convert libxl_run_bootloader
12/25 libxl: make libxl_create_logfile const-correct 13/25 libxl: log bootloader output
14/25 libxl: Allow AO_GC and EGC_GC even if not used 15/25 libxl: remove ctx->waitpid_instead
These are the remaining meat; all except 19/25 have been posted before and some have been acked:
16/25 libxl: change some structures to unit arrays
17/25 libxl: ao: convert libxl__spawn_*
18/25 libxl: make libxl_create run bootloader via callback
* 19/25 libxl: Fix an ao completion bug; document locking policy 20/25 libxl: provide progress reporting for long-running operations 21/25 libxl: remove malloc failure handling from NEW_EVENT 22/25 libxl: convert console callback to libxl_asyncprogress_how 23/25 libxl: clarify definition of "slow" operation 24/25 libxl: child processes cleanups
25/25 libxl: aborting bootloader invocation when domain dioes
PATCH v8 1/25 libxl: handle POLLERR, POLLHUP, POLLNVAL properly
Pass POLLERR and POLLHUP to fd callbacks, as is necessary. Crash on POLLNVAL since that means our fds are messed up.
Document the behaviour (including the fact that poll sometimes sets POLLHUP or POLLERR even if only POLLIN was requested.
Fix the one current fd callback to do something with POLLERR|POLLHUP.
--- tools/libxl/libxl_event.c | 7 ++++++- tools/libxl/libxl_internal.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletions(-)
tools/libxl/libxl_event.c +6 -1
@@ -335,6 +335,9 @@ static void watchfd_callback(libxl__egc *egc, libxl__ev_fd *ev, {EGC_GC ; +if (revents & (POLLERR |POLLHUP )) +LIBXL__EVENT_DISASTER (egc,"unexpected poll event on watch fd" ,0 ,0 ); +for (;;) {char **event =xs_check_watch (CTX ->xsh);if (!event) {
@@ -739,7 +742,9 @@ static int afterpoll_check_fd(libxl__poller *poller,/* again, stale slot entry */ return 0 ; -int revents = fds[slot].revents & events; +assert (!(fds[slot].revents &POLLNVAL )); + +int revents = fds[slot].revents & (events |POLLERR |POLLHUP );/* we mask in case requested events have changed */ return revents;
tools/libxl/libxl_internal.h +5 -0
@@ -127,6 +127,11 @@ _hidden void libxl__alloc_failed(libxl_ctx *, const char *func,typedef struct libxl__ev_fd libxl__ev_fd ;typedef void libxl__ev_fd_callback (libxl__egc *egc,libxl__ev_fd *ev,int fd,short events,short revents); +/* Note that revents may contain POLLERR or POLLHUP regardless of +* events; otherwise revents contains only bits in events. Contrary +* to the documentation for poll(2), POLLERR and POLLHUP can occur +* even if only POLLIN was set in events. (POLLNVAL is a fatal +* error and will cause libxl event machinery to fail an assertion.) */ struct libxl__ev_fd {/* caller should include this in their own struct */ /* read-only for caller, who may read only when registered: */
Signature · 1 line
1.7.2.5
PATCH v8 2/25 libxl: support multiple libxl__ev_fds for the same fd
In reply to Ian JacksonWe need a slightly more sophisticated data structure to allow this, where we record the slot not just for each fd but also for each (fd,eventbit) where eventbit is POLLIN, POLLPRI, POLLOUT.
Document the new relaxed restriction.
Changes since v6:
* Fix typo
--- tools/libxl/libxl_event.c | 62 +++++++++++++++++++++++------------------ tools/libxl/libxl_internal.h | 10 +++++-- 2 files changed, 42 insertions(+), 30 deletions(-)
tools/libxl/libxl_event.c +35 -27
@@ -635,10 +635,11 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller,/* -* In order to be able to efficiently find the libxl__ev_fd -* for a struct poll during _afterpoll, we maintain a shadow -* data structure in CTX->fd_beforepolled: each slot in -* the fds array corresponds to a slot in fd_beforepolled. +* In order to be able to efficiently find the libxl__ev_fd for a +* struct poll during _afterpoll, we maintain a shadow data +* structure in CTX->fd_rindices: each fd corresponds to a slot in +* fd_rindices, and each element in the rindices is three indices +* into the fd array (for POLLIN, POLLPRI and POLLOUT). */ if (*nfds_io) {
@@ -659,14 +660,16 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, });/* make sure our array is as big as *nfds_io */ -if (poller->fd_rindex_allocd < maxfd) { -assert (maxfd <INT_MAX /sizeof (int ) /2 ); -int *newarray =realloc (poller->fd_rindex,sizeof (int ) * maxfd); -if (!newarray) { rc =ERROR_NOMEM ; goto out; } -memset (newarray + poller->fd_rindex_allocd,0 , -sizeof (int ) * (maxfd - poller->fd_rindex_allocd)); - poller->fd_rindex = newarray; - poller->fd_rindex_allocd = maxfd; +if (poller->fd_rindices_allocd < maxfd) { +assert (ARRAY_SIZE_OK (poller->fd_rindices, maxfd)); + poller->fd_rindices = +libxl__realloc (0 , poller->fd_rindices, + maxfd *sizeof (*poller->fd_rindices)); +memset (poller->fd_rindices + poller->fd_rindices_allocd, +0 , + (maxfd - poller->fd_rindices_allocd) + *sizeof (*poller->fd_rindices)); + poller->fd_rindices_allocd = maxfd; } }
@@ -677,8 +680,10 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, fds[used].fd = req_fd; fds[used].events = req_events; fds[used].revents =0 ; -assert (req_fd < poller->fd_rindex_allocd); - poller->fd_rindex[req_fd] = used; +assert (req_fd < poller->fd_rindices_allocd); +if (req_events &POLLIN ) poller->fd_rindices[req_fd][0 ] = used; +if (req_events &POLLPRI ) poller->fd_rindices[req_fd][1 ] = used; +if (req_events &POLLOUT ) poller->fd_rindices[req_fd][2 ] = used; } used++; });
@@ -706,7 +711,6 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, *timeout_upd = our_timeout; } - out:return rc; }
@@ -728,24 +732,28 @@ static int afterpoll_check_fd(libxl__poller *poller, int fd, int events)/* returns mask of events which were requested and occurred */ { -if (fd >= poller->fd_rindex_allocd) +if (fd >= poller->fd_rindices_allocd)/* added after we went into poll, have to try again */ return 0 ; -int slot = poller->fd_rindex[fd]; +int i, revents =0 ; +for (i=0 ; i<3 ; i++) { +int slot = poller->fd_rindices[fd][i]; -if (slot >= nfds) -/* stale slot entry; again, added afterwards */ -return 0 ; +if (slot >= nfds) +/* stale slot entry; again, added afterwards */ +continue ; -if (fds[slot].fd != fd) -/* again, stale slot entry */ -return 0 ; +if (fds[slot].fd != fd) +/* again, stale slot entry */ +continue ; -assert (!(fds[slot].revents &POLLNVAL )); +assert (!(fds[slot].revents &POLLNVAL )); + revents |= fds[slot].revents; + } -int revents = fds[slot].revents & (events |POLLERR |POLLHUP );/* we mask in case requested events have changed */ + revents &= (events |POLLERR |POLLHUP );return revents; }
@@ -1009,7 +1017,7 @@ int libxl__poller_init(libxl_ctx *ctx, libxl__poller *p) {int r, rc; p->fd_polls =0 ; - p->fd_rindex =0 ; + p->fd_rindices =0 ; r =pipe (p->wakeup_pipe);if (r) {
@@ -1036,7 +1044,7 @@ void libxl__poller_dispose(libxl__poller *p)if (p->wakeup_pipe[1 ] >0 )close (p->wakeup_pipe[1 ]);if (p->wakeup_pipe[0 ] >0 )close (p->wakeup_pipe[0 ]);free (p->fd_polls); -free (p->fd_rindex); +free (p->fd_rindices); }libxl__poller *libxl__poller_get (libxl_ctx *ctx)
tools/libxl/libxl_internal.h +7 -3
@@ -131,7 +131,11 @@ typedef void libxl__ev_fd_callback(libxl__egc *egc, libxl__ev_fd *ev,* events; otherwise revents contains only bits in events. Contrary * to the documentation for poll(2), POLLERR and POLLHUP can occur * even if only POLLIN was set in events. (POLLNVAL is a fatal -* error and will cause libxl event machinery to fail an assertion.) */ +* error and will cause libxl event machinery to fail an assertion.) +* +* It is not permitted to listen for the same or overlapping events +* on the same fd using multiple different libxl__ev_fd's. +*/ struct libxl__ev_fd {/* caller should include this in their own struct */ /* read-only for caller, who may read only when registered: */
@@ -258,8 +262,8 @@ struct libxl__poller {struct pollfd *fd_polls;int fd_polls_allocd; -int fd_rindex_allocd; -int *fd_rindex;/* see libxl_osevent_beforepoll */ +int fd_rindices_allocd; +int (*fd_rindices)[3 ];/* see libxl_osevent_beforepoll */ int wakeup_pipe[2 ];/* 0 means no fd allocated */ };
Signature · 1 line
1.7.2.5
PATCH v8 3/25 libxl: event API: new facilities for waiting for subprocesses
In reply to Ian JacksonThe current arrangements in libxl for spawning subprocesses have two key problems: (i) they make unwarranted (and largely undocumented) assumptions about the caller's use of subprocesses, (ii) they aren't integrated into the event system and can't be made asynchronous etc.
So replace them with a new set of facilities.
Primarily, from the point of view of code inside libxl, this is libxl__ev_child_fork which is both (a) a version of fork() and (b) an event source which generates a callback when the child dies.
Quoted 1 line
From the point of view of the application, we fully document our use
of SIGCHLD. The application can tell us whether it wants to own SIGCHLD or not; if it does, it has to tell us about deaths of our children.
Currently there are no callers in libxl which use these facilities. All code in libxl which forks needs to be converted and libxl_fork needse to be be abolished.
--- tools/libxl/libxl.c | 17 +++- tools/libxl/libxl.h | 1 + tools/libxl/libxl_event.c | 53 +++++++-- tools/libxl/libxl_event.h | 147 +++++++++++++++++++++++- tools/libxl/libxl_fork.c | 255 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 62 ++++++++++- 6 files changed, 515 insertions(+), 20 deletions(-)
tools/libxl/libxl.c +16 -1
@@ -39,7 +39,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version,memset (ctx,0 ,sizeof (libxl_ctx)); ctx->lg = lg; -/* First initialise pointers (cannot fail) */ +/* First initialise pointers etc. (cannot fail) */ LIBXL_TAILQ_INIT (&ctx->occurred);
@@ -58,6 +58,11 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version,LIBXL_TAILQ_INIT (&ctx->death_list);libxl__ev_xswatch_init (&ctx->death_watch); + ctx->childproc_hooks = &libxl__childproc_default_hooks; + ctx->childproc_user =0 ; + + ctx->sigchld_selfpipe[0 ] =-1 ; +/* The mutex is special because we can't idempotently destroy it */ if (libxl__init_recursive_mutex (ctx, &ctx->lock) <0 ) {
@@ -160,6 +165,16 @@ int libxl_ctx_free(libxl_ctx *ctx)discard_events (&ctx->occurred); +/* If we have outstanding children, then the application inherits +* them; we wish the application good luck with understanding +* this if and when it reaps them. */ +libxl__sigchld_removehandler (ctx); + +if (ctx->sigchld_selfpipe[0 ] >=0 ) { +close (ctx->sigchld_selfpipe[0 ]); +close (ctx->sigchld_selfpipe[1 ]); + } +pthread_mutex_destroy (&ctx->lock);GC_FREE ;
tools/libxl/libxl.h +1 -0
@@ -380,6 +380,7 @@ enum {ERROR_NOT_READY =-11 ,ERROR_OSEVENT_REG_FAIL =-12 ,ERROR_BUFFERFULL =-13 , + ERROR_UNKNOWN_CHILD = -14, };
tools/libxl/libxl_event.c +42 -11
85 lines not on this page · raw message
tools/libxl/libxl_event.h +142 -5
159 lines not on this page · raw message
tools/libxl/libxl_fork.c +255 -0
279 lines not on this page · raw message
tools/libxl/libxl_internal.h +59 -3
87 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v8 4/25 autoconf: trim the configure script; use autoheader
In reply to Ian JacksonRemove a lot of unnecessary tests. Specifically, we no longer test for standard POSIX facilities which we expect to be provided everywhere and which we don't in any case have any alternative for.
Switch to generating config.h.in with autoheader.
Changes since v7:
* Removed AX_CHECK_PTYFUNCS (snuck in from previous patch)
--- autogen.sh | 1 + tools/config.h.in | 73 +- tools/configure | 8825 +++++++++++++++++----------------------------------- tools/configure.ac | 60 +- 4 files changed, 2981 insertions(+), 5978 deletions(-)
autogen.sh +1 -0
@@ -1,3 +1,4 @@ #!/bin/sh -e cd tools autoconf +autoheader
tools/config.h.in +59 -14
78 lines not on this page · raw message
tools/configure +3003 -5988
2,918 lines not on this page · raw message
tools/configure.ac +1 -59
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
1.7.2.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Part of the diff is not shown here. View the raw message.
Re: [PATCH 04/25] autoconf: trim the configure script; use autoheader
Quoted 8 lines · Ian Jackson
Remove a lot of unnecessary tests. Specifically, we no longer test for standard POSIX facilities which we expect to be provided everywhere and which we don't in any case have any alternative for.
Switch to generating config.h.in with autoheader.
Signed-off-by Ian Jackson <[email protected]>Cc Roger Pau Monne <[email protected]>
Quoted 10,688 lines
Changes since v7:
* RemovedAX_CHECK_PTYFUNCS(snuck in from previous patch)--- autogen.sh | 1 + tools/config.h.in | 73 +- tools/configure | 8825 +++++++++++++++++----------------------------------- tools/configure.ac | 60 +- 4 files changed, 2981 insertions(+), 5978 deletions(-)autogen.sh +1
-0@@ -1,3 +1,4 @@ #!/bin/sh -e cd tools autoconf +autoheadertools/config.h.in +59
-14@@ -1,19 +1,64 @@ -/* - * Copyright (C) 2012 - * - * 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. - */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + +/* Define to 1 if you have the `yajl' library (-lyajl). */ +#undef HAVE_LIBYAJL + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H /* Define to 1 if you have the <yajl/yajl_version.h> header file. */ #undef HAVE_YAJL_YAJL_VERSION_H -/* Define curses header to include. */ +/* Define curses header to use */ #undef INCLUDE_CURSES_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERStools/configure +3003
-5988@@ -595,12 +595,8 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_header_list= -ac_func_list= ac_subst_vars='LTLIBOBJS -POW_LIB LIBOBJS -ALLOCA libiconv PTHREAD_LIBS PTHREAD_LDFLAGS@@ -616,6 +612,9 @@ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG CURSES_LIBS +EGREP +GREP +CPP pyconfig PYTHONPATH OCAMLBUILD@@ -635,8 +634,13 @@ INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM SET_MAKE -LN_S -SED +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC IASL BCC LD86@@ -665,24 +669,6 @@ xenapi vtpm monitors githttp -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -EGREP -GREP -CPP -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC target_alias host_alias build_alias@@ -740,12 +726,6 @@ enable_debug ac_precious_vars='build_alias host_alias target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP PREPEND_INCLUDES PREPEND_LIB APPEND_INCLUDES@@ -762,6 +742,12 @@ AS86 LD86 BCC IASL +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR@@ -1365,10 +1351,6 @@ Fine tuning of the installation directories: _ACEOF cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi@@ -1399,14 +1381,6 @@ Optional Features: --disable-debug Disable debug build of tools (default is ENABLED) Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a - nonstandard directory <lib dir> - LIBS libraries to pass to the linker, e.g. -l<library> - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if - you have headers in a nonstandard directory <include dir> - CPP C preprocessor PREPEND_INCLUDES List of include folders to prepend to CFLAGS (without -I) PREPEND_LIB List of library folders to prepend to LDFLAGS (without -L)@@ -1425,6 +1399,14 @@ Some influential environment variables: LD86 Path to ld86 tool BCC Path to bcc tool IASL Path to iasl tool + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path@@ -1797,311 +1779,6 @@ fi as_fn_set_status $ac_retval } # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case <limits.h> declares $2. - For example, HP-UX 11i <limits.h> declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - <limits.h> exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_func - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_type - -# ac_fn_c_find_intX_t LINENO BITS VAR -# ----------------------------------- -# Finds a signed integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_intX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 -$as_echo_n "checking for int$2_t... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in int$2_t 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default - enum { N = $2 / 2 - 1 }; -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default - enum { N = $2 / 2 - 1 }; -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) - < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - case $ac_type in #( - int$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if eval test \"x\$"$3"\" = x"no"; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_find_intX_t - -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval "test \"\${$4+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_member - -# ac_fn_c_find_uintX_t LINENO BITS VAR -# ------------------------------------ -# Finds an unsigned integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_uintX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 -$as_echo_n "checking for uint$2_t... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - case $ac_type in #( - uint$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if eval test \"x\$"$3"\" = x"no"; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake.@@ -2386,11 +2063,6 @@ $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi -as_fn_append ac_header_list " sys/time.h" -as_fn_append ac_header_list " unistd.h" -as_fn_append ac_func_list " alarm" -as_fn_append ac_header_list " stdlib.h" -as_fn_append ac_header_list " sys/param.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false@@ -2508,1730 +2180,40 @@ APPEND_INCLUDES and APPEND_LIB instead when possible." >&2;} fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdio.h> -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <string.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ctype.h> -#include <stdlib.h> -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = x""yes; then : - MINIX=yes -else - MINIX= -fi - - - if test "$MINIX" = yes; then - -$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h - - -$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h - - -$as_echo "#define _MINIX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_safe_to_define___extensions__=yes -else - ac_cv_safe_to_define___extensions__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h - - $as_echo "#define _ALL_SOURCE 1" >>confdefs.h - - $as_echo "#define _GNU_SOURCE 1" >>confdefs.h - - $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h - - $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - - -# M4 Macro includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <[email protected]>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- - - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -# PKG_CHECK_MODULES - - - -# We define, separately, PTHREAD_CFLAGS, _LDFLAGS and _LIBS -# even though currently we don't set them very separately. -# This means that the makefiles will not need to change in -# the future if we make the test more sophisticated. - - - -# We invoke AX_PTHREAD_VARS with the name of another macro -# which is then expanded once for each variable. - - - - - - - - -# Enable/disable options - -# Check whether --enable-githttp was given. -if test "${enable_githttp+set}" = set; then : - enableval=$enable_githttp; -fi - - -if test "x$enable_githttp" = "xno"; then : - - ax_cv_githttp="n" - -elif test "x$enable_githttp" = "xyes"; then : - - ax_cv_githttp="y" - -elif test -z $ax_cv_githttp; then : - - ax_cv_githttp="n" - -fi -githttp=$ax_cv_githttp - - - -# Check whether --enable-monitors was given. -if test "${enable_monitors+set}" = set; then : - enableval=$enable_monitors; -fi - - -if test "x$enable_monitors" = "xno"; then : - - ax_cv_monitors="n" - -elif test "x$enable_monitors" = "xyes"; then : - - ax_cv_monitors="y" - -elif test -z $ax_cv_monitors; then : - - ax_cv_monitors="y" - -fi -monitors=$ax_cv_monitors - - - -# Check whether --enable-vtpm was given. -if test "${enable_vtpm+set}" = set; then : - enableval=$enable_vtpm; -fi - - -if test "x$enable_vtpm" = "xno"; then : - - ax_cv_vtpm="n" - -elif test "x$enable_vtpm" = "xyes"; then : - - ax_cv_vtpm="y" - -elif test -z $ax_cv_vtpm; then : - - ax_cv_vtpm="n" - -fi -vtpm=$ax_cv_vtpm - - - -# Check whether --enable-xenapi was given. -if test "${enable_xenapi+set}" = set; then : - enableval=$enable_xenapi; -fi - - -if test "x$enable_xenapi" = "xno"; then : - - ax_cv_xenapi="n" - -elif test "x$enable_xenapi" = "xyes"; then : - - ax_cv_xenapi="y" - -elif test -z $ax_cv_xenapi; then : - - ax_cv_xenapi="n" - -fi -xenapi=$ax_cv_xenapi - - - -# Check whether --enable-pythontools was given. -if test "${enable_pythontools+set}" = set; then : - enableval=$enable_pythontools; -fi - - -if test "x$enable_pythontools" = "xno"; then : - - ax_cv_pythontools="n" - -elif test "x$enable_pythontools" = "xyes"; then : - - ax_cv_pythontools="y" - -elif test -z $ax_cv_pythontools; then : - - ax_cv_pythontools="y" - -fi -pythontools=$ax_cv_pythontools - - - -# Check whether --enable-ocamltools was given. -if test "${enable_ocamltools+set}" = set; then : - enableval=$enable_ocamltools; -fi - - -if test "x$enable_ocamltools" = "xno"; then : - - ax_cv_ocamltools="n" - -elif test "x$enable_ocamltools" = "xyes"; then : - - ax_cv_ocamltools="y" - -elif test -z $ax_cv_ocamltools; then : - - ax_cv_ocamltools="y" - -fi -ocamltools=$ax_cv_ocamltools - - - -# Check whether --enable-miniterm was given. -if test "${enable_miniterm+set}" = set; then : - enableval=$enable_miniterm; -fi - - -if test "x$enable_miniterm" = "xno"; then : - - ax_cv_miniterm="n" - -elif test "x$enable_miniterm" = "xyes"; then : - - ax_cv_miniterm="y" - -elif test -z $ax_cv_miniterm; then : - - ax_cv_miniterm="n" - -fi -miniterm=$ax_cv_miniterm - - - -# Check whether --enable-lomount was given. -if test "${enable_lomount+set}" = set; then : - enableval=$enable_lomount; -fi - - -if test "x$enable_lomount" = "xno"; then : - - ax_cv_lomount="n" - -elif test "x$enable_lomount" = "xyes"; then : - - ax_cv_lomount="y" - -elif test -z $ax_cv_lomount; then : - - ax_cv_lomount="n" - -fi -lomount=$ax_cv_lomount - - - -# Check whether --enable-ovmf was given. -if test "${enable_ovmf+set}" = set; then : - enableval=$enable_ovmf; -fi - - -if test "x$enable_ovmf" = "xno"; then : - - ax_cv_ovmf="n" - -elif test "x$enable_ovmf" = "xyes"; then : - - ax_cv_ovmf="y" - -elif test -z $ax_cv_ovmf; then : - - ax_cv_ovmf="n" - -fi -ovmf=$ax_cv_ovmf +# M4 Macro includes -# Check whether --enable-rombios was given. -if test "${enable_rombios+set}" = set; then : - enableval=$enable_rombios; -fi -if test "x$enable_rombios" = "xno"; then : - ax_cv_rombios="n" -elif test "x$enable_rombios" = "xyes"; then : - ax_cv_rombios="y" -elif test -z $ax_cv_rombios; then : - ax_cv_rombios="y" -fi -rombios=$ax_cv_rombios -# Check whether --enable-seabios was given. -if test "${enable_seabios+set}" = set; then : - enableval=$enable_seabios; -fi -if test "x$enable_seabios" = "xno"; then : - ax_cv_seabios="n" -elif test "x$enable_seabios" = "xyes"; then : - ax_cv_seabios="y" -elif test -z $ax_cv_seabios; then : - ax_cv_seabios="y" -fi -seabios=$ax_cv_seabios -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; -fi -if test "x$enable_debug" = "xno"; then : - ax_cv_debug="n" -elif test "x$enable_debug" = "xyes"; then : - ax_cv_debug="y" -elif test -z $ax_cv_debug; then : - ax_cv_debug="y" -fi -debug=$ax_cv_debug@@ -4240,930 +2222,432 @@ debug=$ax_cv_debug -for cflag in $PREPEND_INCLUDES -do - PREPEND_CFLAGS+=" -I$cflag" -done -for ldflag in $PREPEND_LIB -do - PREPEND_LDFLAGS+=" -L$ldflag" -done -for cflag in $APPEND_INCLUDES -do - APPEND_CFLAGS+=" -I$cflag" -done -for ldflag in $APPEND_LIB -do - APPEND_LDFLAGS+=" -L$ldflag" -done -CFLAGS="$PREPEND_CFLAGS $CFLAGS $APPEND_CFLAGS" -LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPEND_LDFLAGS" +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant <[email protected]>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +# PKG_PROG_PKG_CONFIG +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +# _PKG_CONFIG +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +# _PKG_SHORT_ERRORS_SUPPORTED +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +# PKG_CHECK_MODULES -# Checks for programs. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed +# We define, separately, PTHREAD_CFLAGS, _LDFLAGS and _LIBS +# even though currently we don't set them very separately. +# This means that the makefiles will not need to change in +# the future if we make the test more sophisticated. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +# We invoke AX_PTHREAD_VARS with the name of another macro +# which is then expanded once for each variable. -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +# Enable/disable options + +# Check whether --enable-githttp was given. +if test "${enable_githttp+set}" = set; then : + enableval=$enable_githttp; fi -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +if test "x$enable_githttp" = "xno"; then : -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi + ax_cv_githttp="n" +elif test "x$enable_githttp" = "xyes"; then : - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ax_cv_githttp="y" + +elif test -z $ax_cv_githttp; then : + + ax_cv_githttp="n" fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +githttp=$ax_cv_githttp - test -n "$ac_ct_CC" && break -done - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi +# Check whether --enable-monitors was given. +if test "${enable_monitors+set}" = set; then : + enableval=$enable_monitors; fi -fi +if test "x$enable_monitors" = "xno"; then : -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } + ax_cv_monitors="n" -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done +elif test "x$enable_monitors" = "xyes"; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + ax_cv_monitors="y" -int -main () -{ -#ifndef __GNUC__ - choke me -#endif +elif test -z $ax_cv_monitors; then : - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu + ax_cv_monitors="y" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +monitors=$ax_cv_monitors -int -main () -{ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int -main () -{ +# Check whether --enable-vtpm was given. +if test "${enable_vtpm+set}" = set; then : + enableval=$enable_vtpm; +fi - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +if test "x$enable_vtpm" = "xno"; then : -int -main () -{ + ax_cv_vtpm="n" + +elif test "x$enable_vtpm" = "xyes"; then : + + ax_cv_vtpm="y" + +elif test -z $ax_cv_vtpm; then : + + ax_cv_vtpm="n" - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} +vtpm=$ax_cv_vtpm -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg +# Check whether --enable-xenapi was given. +if test "${enable_xenapi+set}" = set; then : + enableval=$enable_xenapi; fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC + + +if test "x$enable_xenapi" = "xno"; then : + + ax_cv_xenapi="n" + +elif test "x$enable_xenapi" = "xyes"; then : + + ax_cv_xenapi="y" + +elif test -z $ax_cv_xenapi; then : + + ax_cv_xenapi="n" fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
1.7.2.5
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Part of the diff is not shown here. View the raw message.
PATCH v8 5/25 autoconf: New test for openpty et al.
In reply to Ian JacksonWe may need to #include <libutil.h>, and/or link with -lutil, to use openpty, login_tty, and the like. Provide INCLUDE_LIBUTIL_H (preprocessor constant, not always defined) and PTYFUNCS_LIBS (makefile variable).
We link libxl against PTYFUNCS_LIBS (which comes from autoconf) rather than UTIL_LIBS, and #include <libutil.h> where appropriate.
Changes since v7:
* Actually include the call to AX_CHECK_PTYFUNCS in this patch, not the previous one, and regenerate configure accordingly.
Changes since v6:
* Put failure macro call in correct place so it might actually happen.
* Try both with -lutil and without.
* Patch now contains update for config.h.in.
--- config/Tools.mk.in | 2 + tools/config.h.in | 3 ++ tools/configure | 61 ++++++++++++++++++++++++++++++++++++++++ tools/configure.ac | 2 + tools/libxl/Makefile | 2 +- tools/libxl/libxl_bootloader.c | 4 ++ tools/m4/ptyfuncs.m4 | 28 ++++++++++++++++++ 7 files changed, 101 insertions(+), 1 deletions(-) create mode 100644 tools/m4/ptyfuncs.m4
config/Tools.mk.in +2 -0
@@ -30,6 +30,8 @@ PTHREAD_CFLAGS := @PTHREAD_CFLAGS@ PTHREAD_LDFLAGS := @PTHREAD_LDFLAGS@ PTHREAD_LIBS := @PTHREAD_LIBS@ +PTYFUNCS_LIBS := @PTYFUNCS_LIBS@ + # Download GIT repositories via HTTP or GIT's own protocol? # GIT's protocol is faster and more robust, when it works at all (firewalls # may block it). We make it the default, but if your GIT repository downloads
tools/config.h.in +3 -0
@@ -42,6 +42,9 @@ /* Define curses header to use */ #undef INCLUDE_CURSES_H +/* libutil header file name */ +#undef INCLUDE_LIBUTIL_H + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT
tools/configure +61 -0
79 lines not on this page · raw message
tools/configure.ac +2 -0
@@ -32,6 +32,7 @@ m4_include([m4/uuid.m4]) m4_include([m4/pkg.m4]) m4_include([m4/curses.m4]) m4_include([m4/pthread.m4]) +m4_include([m4/ptyfuncs.m4]) # Enable/disable options AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
@@ -132,6 +133,7 @@ AC_SUBST(libext2fs) AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer], [libgcrypt="y"], [libgcrypt="n"]) AC_SUBST(libgcrypt) AX_CHECK_PTHREAD +AX_CHECK_PTYFUNCS AC_CHECK_LIB([yajl], [yajl_alloc], [], [AC_MSG_ERROR([Could not find yajl])]) AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])])
tools/libxl/Makefile +1 -1
@@ -20,7 +20,7 @@ LIBUUID_LIBS += -luuid endif LIBXL_LIBS = -LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS) +LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) CFLAGS += $(PTHREAD_CFLAGS) LDFLAGS += $(PTHREAD_LDFLAGS)
tools/libxl/libxl_bootloader.c +4 -0
@@ -16,6 +16,10 @@#include <termios.h> +#ifdef INCLUDE_LIBUTIL_H +#include INCLUDE_LIBUTIL_H +#endif +#include "libxl_internal.h" #define XENCONSOLED_BUF_SIZE 16
tools/m4/ptyfuncs.m4 new file +28 -0
@@ -0,0 +1,28 @@ +AC_DEFUN([AX_CHECK_PTYFUNCS], [ + AC_CHECK_HEADER([libutil.h],[ + AC_DEFINE([INCLUDE_LIBUTIL_H],[<libutil.h>],[libutil header file name]) + ]) + AC_CACHE_CHECK([for openpty et al], [ax_cv_ptyfuncs_libs], [ + for ax_cv_ptyfuncs_libs in -lutil "" NOT_FOUND; do + if test "x$ax_cv_ptyfuncs_libs" = "xNOT_FOUND"; then + AC_MSG_FAILURE([Unable to find library for openpty and login_tty]) + fi + AX_SAVEVAR_SAVE(LIBS) + LIBS="$LIBS $ax_cv_ptyfuncs_libs" + AC_LINK_IFELSE([ +#ifdef INCLUDE_LIBUTIL_H +#include INCLUDE_LIBUTIL_H +#endif +int main(void) { + openpty(0,0,0,0,0); + login_tty(0); +} +],[ + break + ],[]) + AX_SAVEVAR_RESTORE(LIBS) + done + ]) + PTYFUNCS_LIBS="$ax_cv_ptyfuncs_libs" + AC_SUBST(PTYFUNCS_LIBS) +])
Signature · 1 line
1.7.2.5
PATCH v8 6/25 libxl: provide libxl__remove_file et al.
In reply to Ian JacksonThese utility functions cope with EINTR AND ENOENT, do error logging, and we provide a recursive version to delete whole directory trees.
--- tools/libxl/libxl_internal.h | 7 ++++ tools/libxl/libxl_utils.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 0 deletions(-)
tools/libxl/libxl_internal.h +7 -0
@@ -443,6 +443,13 @@ _hidden char *libxl__strndup(libxl__gc *gc_opt, const char *c, size_t n);* string. (similar to a gc'd dirname(3)). */ _hidden char *libxl__dirname(libxl__gc *gc_opt, const char *s); +/* Each of these logs errors and returns a libxl error code. +* They do not mind if path is already removed. +* For _file, path must not be a directory; for _directory it must be. */ +_hidden int libxl__remove_file(libxl__gc *gc, const char *path); +_hidden int libxl__remove_directory(libxl__gc *gc, const char *path); +_hidden int libxl__remove_file_or_directory(libxl__gc *gc, const char *path); + _hidden char **libxl__xs_kvs_of_flexarray(libxl__gc *gc, flexarray_t *array, int length); _hidden int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
tools/libxl/libxl_utils.c +79 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v8 7/25 libxl: Introduce libxl__sendmsg_fds and libxl__recvmsg_fds
In reply to Ian JacksonWe will want to reuse the fd-sending code, so break it out into its own function, and provide the corresponding sending function.
--- tools/libxl/libxl_internal.h | 11 ++++ tools/libxl/libxl_qmp.c | 31 ++----------- tools/libxl/libxl_utils.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 27 deletions(-)
tools/libxl/libxl_internal.h +11 -0
@@ -1130,6 +1130,17 @@ _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid); _hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid,const libxl_domain_config *guest_config); +/* on failure, logs */ +int libxl__sendmsg_fds (libxl__gc *gc,int carrier, +const void *data,size_t datalen, +int nfds,const int fds[],const char *what); + +/* Insists on receiving exactly nfds and datalen. On failure, logs +* and leaves *fds untouched. */ +int libxl__recvmsg_fds (libxl__gc *gc,int carrier, +void *databuf,size_t datalen, +int nfds,int fds[],const char *what); +/* from libxl_json */ #include <yajl/yajl_gen.h>
tools/libxl/libxl_qmp.c +4 -27
@@ -593,38 +593,15 @@ static int qmp_send_fd(libxl__gc *gc, libxl__qmp_handler *qmp,qmp_request_context *context, int fd) { -struct msghdr msg = {0 }; -struct cmsghdr *cmsg; -char control[CMSG_SPACE (sizeof (fd))]; -struct iovec iov; char *buf = NULL; +int rc; buf =qmp_send_prepare (gc, qmp,"getfd" , args, callback, opaque, context); -/* Response data */ - iov.iov_base = buf; - iov.iov_len =strlen (buf); - -/* compose the message */ - msg.msg_iov = &iov; - msg.msg_iovlen =1 ; - msg.msg_control = control; - msg.msg_controllen =sizeof (control); - -/* attach open fd */ - cmsg =CMSG_FIRSTHDR (&msg); - cmsg->cmsg_level =SOL_SOCKET ; - cmsg->cmsg_type =SCM_RIGHTS ; - cmsg->cmsg_len =CMSG_LEN (sizeof (fd)); - *(int *)CMSG_DATA (cmsg) = fd; - - msg.msg_controllen = cmsg->cmsg_len; + rc =libxl__sendmsg_fds (gc, qmp->qmp_fd, buf,strlen (buf),1 , &fd, +"QMP message to QEMU" ); +if (rc)return rc; -if (sendmsg (qmp->qmp_fd, &msg,0 ) <0 ) { -LIBXL__LOG_ERRNO (qmp->ctx,LIBXL__LOG_ERROR , -"Failed to send a QMP message to QEMU." ); -return ERROR_FAIL ; - }if (libxl_write_exactly (qmp->ctx, qmp->qmp_fd,"\r\n" ,2 ,"CRLF" ,"QMP socket" )) {return ERROR_FAIL ;
tools/libxl/libxl_utils.c +104 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v8 8/25 libxl: Clean up setdefault in do_domain_create
In reply to Ian Jacksondo_domain_create called libxl__domain_create_info_setdefault twice.
--- tools/libxl/libxl_create.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
tools/libxl/libxl_create.c +0 -3
@@ -573,9 +573,6 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info);if (ret) goto error_out; - ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info); -if (ret) goto error_out; - ret =libxl__domain_make (gc, &d_config->c_info, &domid);if (ret) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"cannot make domain: %d" , ret);
Signature · 1 line
1.7.2.5
PATCH v8 9/25 libxl: provide libxl__datacopier_*
In reply to Ian JacksonGeneral facility for ao operations to shovel data between fds.
This will be used by the bootloader machinery.
Changes in v7:
* assert that the ao is non-null on _init.
--- tools/libxl/Makefile | 3 +- tools/libxl/libxl_aoutils.c | 189 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 40 +++++++++ 3 files changed, 231 insertions(+), 1 deletions(-) create mode 100644 tools/libxl/libxl_aoutils.c
tools/libxl/Makefile +2 -1
@@ -64,7 +64,8 @@ LIBXL_LIBS += -lyajl LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \ - libxl_internal.o libxl_utils.o libxl_uuid.o libxl_json.o \ + libxl_internal.o libxl_utils.o libxl_uuid.o \ + libxl_json.o libxl_aoutils.o \ libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl_aoutils.c new file +189 -0
189 lines not on this page · raw message
tools/libxl/libxl_internal.h +40 -0
@@ -835,6 +835,7 @@ _hidden int libxl__ev_devstate_wait(libxl__gc *gc, libxl__ev_devstate *ds,*/ _hidden int libxl__try_phy_backend(mode_t st_mode); +/* from libxl_pci */ _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
@@ -1468,6 +1469,45 @@ _hidden const char *libxl__xen_script_dir_path(void); _hidden const char *libxl__lock_dir_path(void); _hidden const char *libxl__run_dir_path(void); +/*----- datacopier: copies data from one fd to another -----*/ + +typedef struct libxl__datacopier_state libxl__datacopier_state ; +typedef struct libxl__datacopier_buf libxl__datacopier_buf ; + +/* onwrite==1 means failure happened when writing, logged, errnoval is valid +* onwrite==0 means failure happened when reading +* errnoval==0 means we got eof and all data was written +* errnoval!=0 means we had a read error, logged +* onwrite==-1 means some other internal failure, errnoval not valid, logged +* in all cases copier is killed before calling this callback */ +typedef void libxl__datacopier_callback (libxl__egc *egc, +libxl__datacopier_state *dc,int onwrite,int errnoval); + +struct libxl__datacopier_buf { +/* private to datacopier */ +LIBXL_TAILQ_ENTRY (libxl__datacopier_buf) entry; +int used; +char buf[1000 ]; +}; + +struct libxl__datacopier_state { +/* caller must fill these in, and they must all remain valid */ +libxl__ao *ao; +int readfd, writefd; +ssize_t maxsz; +const char *copywhat, *readwhat, *writewhat;/* for error msgs */ +libxl__datacopier_callback *callback; +/* remaining fields are private to datacopier */ +libxl__ev_fd toread, towrite; +ssize_t used; + LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; +}; + +_hidden void libxl__datacopier_init(libxl__datacopier_state *dc); +_hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); +_hidden int libxl__datacopier_start(libxl__datacopier_state *dc); + +/* * Convenience macros. */
Signature · 1 line
1.7.2.5
PATCH v8 10/25 libxl: provide libxl__openpty_*
In reply to Ian JacksonGeneral facility for ao operations to open ptys.
This will be used by the bootloader machinery.
--- tools/libxl/libxl_aoutils.c | 127 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 36 ++++++++++++ 2 files changed, 163 insertions(+), 0 deletions(-)
tools/libxl/libxl_aoutils.c +127 -0
@@ -187,3 +187,130 @@ int libxl__datacopier_start(libxl__datacopier_state *dc)return rc; } +/*----- openpty -----*/ + +/* implementation */ + +static void openpty_cleanup (libxl__openpty_state *op) +{ +int i; + +for (i=0 ; i<op->count; i++) { +libxl__openpty_result *res = &op->results[i]; +libxl__carefd_close (res->master); res->master =0 ; +libxl__carefd_close (res->slave); res->slave =0 ; + } +} + +static void openpty_exited (libxl__egc *egc,libxl__ev_child *child, +pid_t pid,int status) { +libxl__openpty_state *op =CONTAINER_OF (child, *op, child); +STATE_AO_GC (op->ao); + +if (status) { +/* Perhaps the child gave us the fds and then exited nonzero. +* Well that would be odd but we don't really care. */ +libxl_report_child_exitstatus (CTX , op->rc ?LIBXL__LOG_ERROR + :LIBXL__LOG_WARNING , +"openpty child" , pid, status); + } +if (op->rc) +openpty_cleanup (op); + op->callback (egc, op); +} + +int libxl__openptys (libxl__openpty_state *op, +const struct termios *termp, +const struct winsize *winp) { +/* +* This is completely crazy. openpty calls grantpt which the spec +* says may fork, and may not be called with a SIGCHLD handler. +* Now our application may have a SIGCHLD handler so that's bad. +* We could perhaps block it but we'd need to block it on all +* threads. This is just Too Hard. +* +* So instead, we run openpty in a child process. That child +* process then of course has only our own thread and our own +* signal handlers. We pass the fds back. +* +* Since our only current caller actually wants two ptys, we +* support calling openpty multiple times for a single fork. +*/ +STATE_AO_GC (op->ao); +int count = op->count; +int r, i, rc, sockets[2 ], ptyfds[count][2 ]; +libxl__carefd *for_child =0 ; +pid_t pid =-1 ; + +for (i=0 ; i<count; i++) { + ptyfds[i][0 ] = ptyfds[i][1 ] =-1 ; +libxl__openpty_result *res = &op->results[i]; +assert (!res->master); +assert (!res->slave); + } + sockets[0 ] = sockets[1 ] =-1 ;/* 0 is for us, 1 for our child */ + +libxl__carefd_begin (); + r =socketpair (AF_UNIX ,SOCK_STREAM ,0 , sockets); +if (r) { sockets[0 ] = sockets[1 ] =-1 ; } + for_child =libxl__carefd_opened (CTX , sockets[1 ]); +if (r) {LOGE (ERROR ,"socketpair failed" ); rc =ERROR_FAIL ; goto out; } + + pid =libxl__ev_child_fork (gc, &op->child, openpty_exited); +if (pid ==-1 ) { + rc =ERROR_FAIL ; + goto out; + } + +if (!pid) { +/* child */ +close (sockets[0 ]); +signal (SIGCHLD ,SIG_DFL ); + +for (i=0 ; i<count; i++) { + r =openpty (&ptyfds[i][0 ], &ptyfds[i][1 ],NULL , termp, winp); +if (r) {LOGE (ERROR ,"openpty failed" );_exit (-1 ); } + } + rc =libxl__sendmsg_fds (gc, sockets[1 ],"" ,1 , +2 *count, &ptyfds[0 ][0 ],"ptys" ); +if (rc) {LOGE (ERROR ,"sendmsg to parent failed" );_exit (-1 ); } +_exit (0 ); + } + +libxl__carefd_close (for_child); + for_child =0 ; + +/* this should be fast so do it synchronously */ + +libxl__carefd_begin (); +char buf[1 ]; + rc =libxl__recvmsg_fds (gc, sockets[0 ], buf,1 , +2 *count, &ptyfds[0 ][0 ],"ptys" ); +if (!rc) { +for (i=0 ; i<count; i++) { +libxl__openpty_result *res = &op->results[i]; + res->master =libxl__carefd_record (CTX , ptyfds[i][0 ]); + res->slave =libxl__carefd_record (CTX , ptyfds[i][1 ]); + } + } +/* now the pty fds are in the carefds, if they were ever open */ +libxl__carefd_unlock (); +if (rc) + goto out; + + rc =0 ; + + out: +if (sockets[0 ] >=0 )close (sockets[0 ]); +libxl__carefd_close (for_child); +if (libxl__ev_child_inuse (&op->child)) { + op->rc = rc; +/* we will get a callback when the child dies */ +return 0 ; + } + +assert (rc); +openpty_cleanup (op); +return rc; +} +
tools/libxl/libxl_internal.h +36 -0
@@ -1508,6 +1508,42 @@ _hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); _hidden int libxl__datacopier_start(libxl__datacopier_state *dc); +/*----- openpty -----*/ + +/* +* opens count (>0) ptys like count calls to openpty, and then +* calls back. On entry, all op[].master and op[].slave must be +* 0. On callback, either rc==0 and master and slave are non-0, +* or rc is a libxl error and they are both 0. If libxl__openpty +* returns non-0 no callback will happen and everything is left +* cleaned up. +*/ + +typedef struct libxl__openpty_state libxl__openpty_state ; +typedef struct libxl__openpty_result libxl__openpty_result ; +typedef void libxl__openpty_callback (libxl__egc *egc,libxl__openpty_state *op); + +struct libxl__openpty_state { +/* caller must fill these in, and they must all remain valid */ +libxl__ao *ao; +libxl__openpty_callback *callback; +int count; +libxl__openpty_result *results;/* actual size is count, out parameter */ +/* public, result, caller may only read in callback */ +int rc; +/* private for implementation */ +libxl__ev_child child; +}; + +struct libxl__openpty_result { +libxl__carefd *master, *slave; +}; + +int libxl__openptys (libxl__openpty_state *op, +const struct termios *termp, +const struct winsize *winp); + +/* * Convenience macros. */
Signature · 1 line
1.7.2.5
PATCH v8 11/25 libxl: ao: Convert libxl_run_bootloader
In reply to Ian JacksonConvert libxl_run_bootloader to an ao_how-taking function.
It's implemented in terms of libxl__bootloader_run, which can be used internally. The resulting code is pretty much a rewrite.
Significant changes include:
- We direct the bootloader's results to a file, not a pipe. This makes it simpler to deal with as we don't have to read it concurrently along with everything else.
- We now issue a warning if we find unexpected statements in the bootloader results.
- The arrangements for buffering of bootloader input and output are completely changed. Now we have a fixed limit of 64k on output, and 4k on input, and discard the oldest data when this overflows (which it shouldn't). There is no timeout any more.
Changes since v6:
* Use libxl__ev_child_inuse rather than testing pid directly.
* Fix a code style error.
* Properly initialise the sub-operations' aos in _init.
* Bugfixes.
--- tools/libxl/libxl.c | 4 + tools/libxl/libxl.h | 3 +- tools/libxl/libxl_bootloader.c | 713 +++++++++++++++++++++------------------- tools/libxl/libxl_create.c | 8 +- tools/libxl/libxl_internal.h | 34 ++ 5 files changed, 419 insertions(+), 343 deletions(-)
tools/libxl/libxl.c +4 -0
@@ -1748,6 +1748,10 @@ int libxl_device_disk_local_detach(libxl_ctx *ctx, libxl_device_disk *disk)* For other device types assume that the blktap2 process is * needed by the soon to be started domain and do nothing. */ +/* +* FIXME +* This appears to leak the disk in failure paths +*/ return 0 ; }
tools/libxl/libxl.h +2 -1
@@ -495,7 +495,8 @@ int libxl_get_max_cpus(libxl_ctx *ctx);int libxl_run_bootloader (libxl_ctx *ctx,libxl_domain_build_info *info,libxl_device_disk *disk, -uint32_t domid); +uint32_t domid, +libxl_asyncop_how *ao_how);/* 0 means ERROR_ENOMEM, which we have logged */
tools/libxl/libxl_bootloader.c +373 -340
832 lines not on this page · raw message
tools/libxl/libxl_create.c +6 -2
@@ -593,8 +593,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,if (ret) goto error_out; } -if ( restore_fd <0 ) { - ret =libxl_run_bootloader (ctx, &d_config->b_info, d_config->num_disks >0 ? &d_config->disks[0 ] :NULL , domid); +libxl_device_disk *bootdisk = + d_config->num_disks >0 ? &d_config->disks[0 ] :NULL ; + +if (restore_fd <0 && bootdisk) { + ret =libxl_run_bootloader (ctx, &d_config->b_info, bootdisk, domid, +0 /* fixme-ao */ );if (ret) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"failed to run bootloader: %d" , ret);
tools/libxl/libxl_internal.h +34 -0
@@ -42,6 +42,7 @@#include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> +#include <sys/socket.h> #include <xs.h> #include <xenctrl.h>
@@ -450,6 +451,7 @@ _hidden int libxl__remove_file(libxl__gc *gc, const char *path); _hidden int libxl__remove_directory(libxl__gc *gc, const char *path); _hidden int libxl__remove_file_or_directory(libxl__gc *gc, const char *path); + _hidden char **libxl__xs_kvs_of_flexarray(libxl__gc *gc, flexarray_t *array, int length); _hidden int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
@@ -1544,6 +1546,38 @@ int libxl__openptys(libxl__openpty_state *op, const struct winsize *winp); +/*----- bootloader -----*/ + +typedef struct libxl__bootloader_state libxl__bootloader_state ; +typedef void libxl__run_bootloader_callback (libxl__egc *, +libxl__bootloader_state *,int rc); + +struct libxl__bootloader_state { +/* caller must fill these in, and they must all remain valid */ +libxl__ao *ao; +libxl__run_bootloader_callback *callback; +libxl_domain_build_info *info;/* u.pv.{kernel,ramdisk,cmdline} updated */ +libxl_device_disk *disk; +uint32_t domid; +/* private to libxl__run_bootloader */ +char *outputpath, *outputdir; +char *diskpath;/* not from gc, represents actually attached disk */ +libxl__openpty_state openpty; +libxl__openpty_result ptys[2 ];/* [0] is for bootloader */ +libxl__ev_child child; +int nargs, argsspace; +const char **args; +libxl__datacopier_state keystrokes, display; +int rc; +}; + +_hidden void libxl__bootloader_init(libxl__bootloader_state *bl); + +/* Will definitely call st->callback, perhaps reentrantly. +* If callback is passed rc==0, will have updated st->info appropriately */ +_hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); + +/* * Convenience macros. */
Signature · 1 line
1.7.2.5
PATCH v8 12/25 libxl: make libxl_create_logfile const-correct
In reply to Ian Jackson--- tools/libxl/libxl_utils.c | 2 +- tools/libxl/libxl_utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_utils.c +1 -1
@@ -193,7 +193,7 @@ static int logrename(libxl__gc *gc, const char *old, const char *new)return 0 ; } -int libxl_create_logfile (libxl_ctx *ctx,char *name,char **full_name) +int libxl_create_logfile (libxl_ctx *ctx,const char *name,char **full_name) {GC_INIT (ctx);struct stat stat_buf;
tools/libxl/libxl_utils.h +1 -1
@@ -26,7 +26,7 @@ int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, uint32_t *poolid);char *libxl_cpupoolid_to_name (libxl_ctx *ctx,uint32_t poolid);int libxl_get_stubdom_id (libxl_ctx *ctx,int guest_domid);int libxl_is_stubdom (libxl_ctx *ctx,uint32_t domid,uint32_t *target_domid); -int libxl_create_logfile (libxl_ctx *ctx,char *name,char **full_name); +int libxl_create_logfile (libxl_ctx *ctx,const char *name,char **full_name);int libxl_string_to_backend (libxl_ctx *ctx,char *s,libxl_disk_backend *backend); int libxl_read_file_contents(libxl_ctx *ctx, const char *filename,
Signature · 1 line
1.7.2.5
PATCH v8 13/25 libxl: log bootloader output
In reply to Ian JacksonThis involves adding a new log feature to libxl__datacopier, and then using it.
If the bootloader exits nonzero we print the log filename in a log message from libxl.
--- tools/libxl/libxl_aoutils.c | 10 ++++++++++ tools/libxl/libxl_bootloader.c | 24 ++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 3 ++- 3 files changed, 36 insertions(+), 1 deletions(-)
tools/libxl/libxl_aoutils.c +10 -0
@@ -118,6 +118,16 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev,libxl__ev_fd_deregister (gc, &dc->toread);break ; } +if (dc->log) { +int wrote =fwrite (buf->buf + buf->used,1 , r, dc->log); +if (wrote != r) { +assert (ferror (dc->log)); +assert (errno); +LOGE (ERROR ,"error logging %s" , dc->copywhat); +datacopier_callback (egc, dc,0 , errno); +return ; + } + } buf->used += r; dc->used += r;assert (buf->used <=sizeof (buf->buf));
tools/libxl/libxl_bootloader.c +24 -0
@@ -236,6 +236,10 @@ static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl)libxl__carefd_close (bl->ptys[i].master);libxl__carefd_close (bl->ptys[i].slave); } +if (bl->display.log) { +fclose (bl->display.log); + bl->display.log =NULL ; + } }static void bootloader_setpaths (libxl__gc *gc,libxl__bootloader_state *bl)
@@ -258,6 +262,8 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) {STATE_AO_GC (bl->ao);libxl_domain_build_info *info = bl->info; +uint32_t domid = bl->domid; +char *logfile_tmp =NULL ;int rc, r;libxl__bootloader_init (bl);
@@ -269,6 +275,22 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)bootloader_setpaths (gc, bl); +const char *logfile_leaf =GCSPRINTF ("bootloader.%" PRIu32, domid); + rc =libxl_create_logfile (CTX , logfile_leaf, &logfile_tmp); +if (rc) goto out; + +/* Transfer ownership of log filename to bl and the gc */ + bl->logfile = logfile_tmp; +libxl__ptr_add (gc, logfile_tmp); + logfile_tmp =NULL ; + + bl->display.log =fopen (bl->logfile,"a" ); +if (!bl->display.log) { +LOGE (ERROR ,"failed to create bootloader logfile %s" , bl->logfile); + rc =ERROR_FAIL ; + goto out; + } +for (;;) { r =mkdir (bl->outputdir,0600 );if (!r)break ;
@@ -308,6 +330,7 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) out:assert (rc); out_ok: +free (logfile_tmp);bootloader_callback (egc, bl, rc); }
@@ -465,6 +488,7 @@ static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child,libxl__datacopier_kill (&bl->display);if (status) { +LOG (ERROR ,"bootloader failed - consult logfile %s" , bl->logfile);libxl_report_child_exitstatus (CTX ,XTL_ERROR ,"bootloader" , pid, status); rc =ERROR_FAIL ;
tools/libxl/libxl_internal.h +2 -1
@@ -1498,6 +1498,7 @@ struct libxl__datacopier_state {int readfd, writefd;ssize_t maxsz;const char *copywhat, *readwhat, *writewhat;/* for error msgs */ +FILE *log;/* gets a copy of everything */ libxl__datacopier_callback *callback;/* remaining fields are private to datacopier */ libxl__ev_fd toread, towrite;
@@ -1560,7 +1561,7 @@ struct libxl__bootloader_state {libxl_device_disk *disk;uint32_t domid;/* private to libxl__run_bootloader */ -char *outputpath, *outputdir; +char *outputpath, *outputdir, *logfile;char *diskpath;/* not from gc, represents actually attached disk */ libxl__openpty_state openpty;libxl__openpty_result ptys[2 ];/* [0] is for bootloader */
Signature · 1 line
1.7.2.5
PATCH v8 14/25 libxl: Allow AO_GC and EGC_GC even if not used
In reply to Ian JacksonMark the gc produced by AO_GC and EGC_GC with the gcc feature __attribute__((unused)). This allows the use of EGC_INIT and STATE_AO_GC by functions which do actually use the gc.
This is convenient because those functions might want to use the ao or egc, rather than the gc; and also because it means that functions which morally ought to be fishing any gc they use out of an egc or state structure can be written do so regardless of whether the gc is actually used right then.
--- tools/libxl/libxl_internal.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_internal.h +2 -2
@@ -1282,7 +1282,7 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);/* useful for all functions which take an egc: */ #define EGC_GC \ - libxl__gc *const gc = &egc->gc + libxl__gc *const gc __attribute__((unused)) = &egc->gc/* egc initialisation and destruction: */
@@ -1385,7 +1385,7 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); })#define AO_GC \ - libxl__gc *const gc = &ao->gc + libxl__gc *const gc __attribute__((unused)) = &ao->gc#define STATE_AO_GC (op_ao) \ libxl__ao *const ao = (op_ao); \
Signature · 1 line
1.7.2.5
PATCH v8 15/25 libxl: remove ctx->waitpid_instead
In reply to Ian JacksonRemove this obsolete hook. Callers inside libxl which create and reap children should use the mechanisms provided by the event system.
(This has no functional difference since there is no way for ctx->waitpid_instead ever to become set.)
--- tools/libxl/libxl_exec.c | 12 +++--------- tools/libxl/libxl_internal.h | 3 --- 2 files changed, 3 insertions(+), 12 deletions(-)
tools/libxl/libxl_exec.c +3 -9
@@ -19,11 +19,6 @@#include "libxl_internal.h" -static int call_waitpid (pid_t (*waitpid_cb)(pid_t ,int *,int ),pid_t pid,int *status,int options) -{ -return (waitpid_cb) ?waitpid_cb (pid, status, options) :waitpid (pid, status, options); -} -static void check_open_fds (const char *what) {const char *env_debug;
@@ -344,7 +339,7 @@ int libxl__spawn_spawn(libxl__gc *gc,if (!for_spawn)_exit (0 );/* just detach then */ - got =call_waitpid (ctx->waitpid_instead, child, &status,0 ); + got =waitpid (child, &status,0 );assert (got == child); rc = (WIFEXITED(status) ? WEXITSTATUS(status) :
@@ -404,7 +399,7 @@ int libxl__spawn_detach(libxl__gc *gc, (unsigned long)for_spawn->intermediate);abort ();/* things are very wrong */ } - got =call_waitpid (ctx->waitpid_instead, for_spawn->intermediate, &status,0 ); + got =waitpid (for_spawn->intermediate, &status,0 );assert (got == for_spawn->intermediate);if (!(WIFSIGNALED (status) &&WTERMSIG (status) ==SIGKILL )) {report_spawn_intermediate_status (gc, for_spawn, status);
@@ -421,14 +416,13 @@ int libxl__spawn_detach(libxl__gc *gc,int libxl__spawn_check (libxl__gc *gc,libxl__spawn_starting *for_spawn) { -libxl_ctx *ctx =libxl__gc_owner (gc);pid_t got;int status;if (!for_spawn)return 0 ;assert (for_spawn->intermediate); - got =call_waitpid (ctx->waitpid_instead, for_spawn->intermediate, &status,WNOHANG ); + got =waitpid (for_spawn->intermediate, &status,WNOHANG );if (!got)return 0 ;assert (got == for_spawn->intermediate);
tools/libxl/libxl_internal.h +0 -3
@@ -335,9 +335,6 @@ struct libxl__ctx {int sigchld_selfpipe[2 ];/* [0]==-1 means handler not installed */ LIBXL_LIST_HEAD(, libxl__ev_child) children; -/* This is obsolete and must be removed: */ -int (*waitpid_instead)(pid_t pid,int *status,int flags); -libxl_version_info version_info; };
Signature · 1 line
1.7.2.5
PATCH v8 16/25 libxl: change some structures to unit arrays
In reply to Ian JacksonIn the next patch these variables will turn into actual pointers.
To clarify that patch, prepare the ground by changing these variables from "struct foo var" to "struct foo var[1]". This enables accesses to them and their members to be made as if they were pointers.
No functional change.
--- tools/libxl/libxl_create.c | 18 +++++----- tools/libxl/libxl_dm.c | 84 ++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 51 deletions(-)
tools/libxl/libxl_create.c +9 -9
@@ -564,7 +564,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, {libxl_ctx *ctx =libxl__gc_owner (gc);libxl__spawner_starting *dm_starting =0 ; -libxl__domain_build_state state; +libxl__domain_build_state state[1 ];uint32_t domid;int i, ret;
@@ -606,12 +606,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, } } -memset (&state,0 ,sizeof (state)); +memset (state,0 ,sizeof (*state));if ( restore_fd >=0 ) { - ret =domain_restore (gc, &d_config->b_info, domid, restore_fd, &state); + ret =domain_restore (gc, &d_config->b_info, domid, restore_fd, state); }else { - ret =libxl__domain_build (gc, &d_config->b_info, domid, &state); + ret =libxl__domain_build (gc, &d_config->b_info, domid, state); }if (ret) {
@@ -649,7 +649,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, ret =init_console_info (&console,0 );if ( ret ) goto error_out; -libxl__device_console_add (gc, domid, &console, &state); +libxl__device_console_add (gc, domid, &console, state);libxl__device_console_dispose (&console);libxl_device_vkb_init (&vkb);
@@ -657,7 +657,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,libxl_device_vkb_dispose (&vkb); ret =libxl__create_device_model (gc, domid, d_config, - &state, &dm_starting); + state, &dm_starting);if (ret <0 ) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"failed to create device model: %d" , ret);
@@ -686,11 +686,11 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,if (need_qemu) console.consback =LIBXL__CONSOLE_BACKEND_IOEMU ; -libxl__device_console_add (gc, domid, &console, &state); +libxl__device_console_add (gc, domid, &console, state);libxl__device_console_dispose (&console);if (need_qemu) { -libxl__create_xenpv_qemu (gc, domid, d_config, &state, &dm_starting); +libxl__create_xenpv_qemu (gc, domid, d_config, state, &dm_starting); }break ; }
@@ -704,7 +704,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {libxl__qmp_initializations (gc, domid, d_config); } - ret =libxl__confirm_device_model_startup (gc, &state, dm_starting); + ret =libxl__confirm_device_model_startup (gc, state, dm_starting);if (ret <0 ) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"device model did not start: %d" , ret);
tools/libxl/libxl_dm.c +42 -42
144 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v8 17/25 libxl: ao: convert libxl__spawn_*
In reply to Ian Jacksonlibxl__spawn_spawn becomes a callback-style asynchronous function. The implementation is now in terms of libxl__ev_* including libxl_ev_child.
All the callers need to be updated. This includes the device model spawning functions libxl__create_device_model and libxl__create_stubdom; these are replaced with libxl__spawn_local_dm and libxl__spawn_stubdom. libxl__confirm_device_model_startup is abolished; instead the dm spawner calls back.
(The choice of which kind of device model to create is lifted out of what used to be libxl__create_device_model, because that function was indirectly recursive. Recursive callback-style operations are clumsy because they require a pointer indirection for the nested states.)
Waiting for proper device model startup it is no longer notionally optional. Previously the code appeared to tolerate this by passing NULL for various libxl__spawner_starting* parameters to device model spawners. However, this was not used anywhere.
Conversely, the "for_spawn" parameter to libxl__wait_for_offspring is no longer supported. It remains as an unused formal parameter to avoid updating, in this patch, all the call sites which pass NULL. libxl__wait_for_offspring is in any case itself an obsolete function, so this wrinkle will go away when its callers are updated to use the event system. Consequently libxl__spawn_check is also abolished.
The "console ready" callback also remains unchanged in this patch. The API for this needs to be reviewed in the context of the event series and its reentrancy restrictions documented.
Thus their callers need to be updated. These are the domain creation functions libxl_domain_create_new and _restore. These functions now take ao_hows, and have a private state structure.
However domain creation remains not completely converted to the event mechanism; in particular it runs the outward-facing function libxl_run_bootloader with a NULL ao_how, which is quite wrong. As it happens in the current code this is not a bug because none of the rest of the functionality surrounding the bootloader call will mind if the event loop is reentered in the middle of its execution.
The file-scope function libxl__set_fd_flag which was used by the previous spawn arrangements becomes unused and is removed; other places in libxl can use libxl_fd_set_nonblock and libxl_fd_set_cloexec, which of course remain.
Changes since v7:
* Rename libxl__spawn_stubdom to libxl__spawn_stub_dm (and ..._state); rename the state's stubdom_* members to dm_*.
* Eliminate the union between the two dm creation states in libxl__domain_create_state. Instead, the domain creation code simply uses libxl__stub_dm_spawn_state.dm directly, if we're taking the local dm path.
* Remove a spurious "break".
* In domain creation, move the PV non-qemu case into the switch.
* Code style fixes.
* Constify some convenience aliases.
* Improve comments (including typo fixes).
--- tools/libxl/libxl.h | 14 ++- tools/libxl/libxl_create.c | 206 +++++++++++++++++++----- tools/libxl/libxl_dm.c | 219 +++++++++++++++----------- tools/libxl/libxl_exec.c | 354 +++++++++++++++++++++--------------------- tools/libxl/libxl_internal.h | 286 +++++++++++++++++++++++----------- tools/libxl/xl_cmdimpl.c | 6 +- 6 files changed, 683 insertions(+), 402 deletions(-)
tools/libxl/libxl.h +12 -2
@@ -465,8 +465,18 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */);/* domain related functions */ typedef int (*libxl_console_ready )(libxl_ctx *ctx,uint32_t domid,void *priv); -int libxl_domain_create_new (libxl_ctx *ctx,libxl_domain_config *d_config,libxl_console_ready cb,void *priv,uint32_t *domid); -int libxl_domain_create_restore (libxl_ctx *ctx,libxl_domain_config *d_config,libxl_console_ready cb,void *priv,uint32_t *domid,int restore_fd); +/* fixme-ao Need to review this API. If we keep it, the reentrancy +* properties need to be documented but they may turn out to be too +* awkward */ + +int libxl_domain_create_new (libxl_ctx *ctx,libxl_domain_config *d_config, +libxl_console_ready cb,void *priv,uint32_t *domid, +const libxl_asyncop_how *ao_how); +int libxl_domain_create_restore (libxl_ctx *ctx,libxl_domain_config *d_config, +libxl_console_ready cb,void *priv, +uint32_t *domid,int restore_fd, +const libxl_asyncop_how *ao_how); +void libxl_domain_config_init (libxl_domain_config *d_config);void libxl_domain_config_dispose (libxl_domain_config *d_config); int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
tools/libxl/libxl_create.c +162 -44
272 lines not on this page · raw message
tools/libxl/libxl_dm.c +130 -89
312 lines not on this page · raw message
tools/libxl/libxl_exec.c +178 -176
441 lines not on this page · raw message
tools/libxl/libxl_internal.h +198 -88
335 lines not on this page · raw message
tools/libxl/xl_cmdimpl.c +3 -3
@@ -1695,8 +1695,8 @@ start:if ( restore_file ) { ret =libxl_domain_create_restore (ctx, &d_config, - cb, &child_console_pid, - &domid, restore_fd); + cb, &child_console_pid, + &domid, restore_fd,0 );/* * On subsequent reboot etc we should create the domain, not * restore/migrate-receive it again.
@@ -1704,7 +1704,7 @@ start: restore_file =NULL ; }else { ret =libxl_domain_create_new (ctx, &d_config, - cb, &child_console_pid, &domid); + cb, &child_console_pid, &domid,0 ); }if ( ret ) goto error_out;
Signature · 1 line
1.7.2.5
Re: [PATCH 17/25] libxl: ao: convert libxl__spawn_*
Quoted 42 lines · Ian Jackson
libxl__spawn_spawnbecomes a callback-style asynchronous function. The implementation is now in terms of libxl__ev_* includinglibxl_ev_child.All the callers need to be updated. This includes the device model spawning functions
libxl__create_device_modelandlibxl__create_stubdom; these are replaced withlibxl__spawn_local_dmandlibxl__spawn_stubdom.libxl__confirm_device_model_startupis abolished; instead the dm spawner calls back.(The choice of which kind of device model to create is lifted out of what used to be
libxl__create_device_model, because that function was indirectly recursive. Recursive callback-style operations are clumsy because they require a pointer indirection for the nested states.)Waiting for proper device model startup it is no longer notionally optional. Previously the code appeared to tolerate this by passing NULL for various libxl__spawner_starting* parameters to device model spawners. However, this was not used anywhere.
Conversely, the "
for_spawn" parameter tolibxl__wait_for_offspringis no longer supported. It remains as an unused formal parameter to avoid updating, in this patch, all the call sites which pass NULL.libxl__wait_for_offspringis in any case itself an obsolete function, so this wrinkle will go away when its callers are updated to use the event system. Consequentlylibxl__spawn_checkis also abolished.The "console ready" callback also remains unchanged in this patch. The API for this needs to be reviewed in the context of the event series and its reentrancy restrictions documented.
Thus their callers need to be updated. These are the domain creation functions
libxl_domain_create_newand_restore. These functions now takeao_hows, and have a private state structure.However domain creation remains not completely converted to the event mechanism; in particular it runs the outward-facing function
libxl_run_bootloaderwith a NULLao_how, which is quite wrong. As it happens in the current code this is not a bug because none of the rest of the functionality surrounding the bootloader call will mind if the event loop is reentered in the middle of its execution.
Quoted 8 lines
The file-scope function
libxl__set_fd_flagwhich was used by the previous spawn arrangements becomes unused and is removed; other places in libxl can uselibxl_fd_set_nonblockandlibxl_fd_set_cloexec, which of course remain.Signed-off-by Ian Jackson <[email protected]>Changes since v7:
Based on this, and a fairly cursory glance through the new version:
Quoted 19 lines
* Rename
libxl__spawn_stubdomtolibxl__spawn_stub_dm(and ..._state); rename the state's stubdom_* members to dm_*.
* Eliminate the union between the two dm creation states inlibxl__domain_create_state. Instead, the domain creation code simply uses libxl__stub_dm_spawn_state.dm directly, if we're taking the local dm path.
* Remove a spurious "break".
* In domain creation, move the PV non-qemu case into the switch.
* Code style fixes.
* Constify some convenience aliases.
* Improve comments (including typo fixes).--- tools/libxl/libxl.h | 14 ++- tools/libxl/libxl_create.c | 206 +++++++++++++++++++----- tools/libxl/libxl_dm.c | 219 +++++++++++++++----------- tools/libxl/libxl_exec.c | 354 +++++++++++++++++++++--------------------- tools/libxl/libxl_internal.h | 286 +++++++++++++++++++++++----------- tools/libxl/xl_cmdimpl.c | 6 +- 6 files changed, 683 insertions(+), 402 deletions(-)
PATCH v8 18/25 libxl: make libxl_create run bootloader via callback
In reply to Ian JacksonChange initiate_domain_create to properly use libxl__bootloader_run rather than improperly calling libxl_run_bootloader with NULL ao_how.
Changes since v7:
* constify convenience aliases.
Changes since v6:
* Bugfixes from testing.
--- tools/libxl/libxl_create.c | 53 +++++++++++++++++++++++++++++++---------- tools/libxl/libxl_internal.h | 1 + 2 files changed, 41 insertions(+), 13 deletions(-)
tools/libxl/libxl_create.c +40 -13
@@ -571,6 +571,9 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,static void domcreate_devmodel_started (libxl__egc *egc,libxl__dm_spawn_state *dmss,int rc); +static void domcreate_bootloader_done (libxl__egc *egc, +libxl__bootloader_state *bl, +int rc);/* Our own function to clean up and call the user's callback. * The final call in the sequence. */
@@ -591,6 +594,7 @@ static void initiate_domain_create(libxl__egc *egc,const int restore_fd = dcs->restore_fd;const libxl_console_ready cb = dcs->console_cb;void *const priv = dcs->console_cb_priv; +memset (&dcs->build_state,0 ,sizeof (dcs->build_state)); domid =0 ;
@@ -620,21 +624,43 @@ static void initiate_domain_create(libxl__egc *egc,if (ret) goto error_out; } + dcs->bl.ao = ao;libxl_device_disk *bootdisk = d_config->num_disks >0 ? &d_config->disks[0 ] :NULL ;if (restore_fd <0 && bootdisk) { - ret =libxl_run_bootloader (ctx, &d_config->b_info, bootdisk, domid, -0 /* fixme-ao */ ); -if (ret) { -LIBXL__LOG (ctx,LIBXL__LOG_ERROR , -"failed to run bootloader: %d" , ret); - goto error_out; - } + dcs->bl.callback = domcreate_bootloader_done; + dcs->bl.info = &d_config->b_info, + dcs->bl.disk = bootdisk; + dcs->bl.domid = dcs->guest_domid; + +libxl__bootloader_run (egc, &dcs->bl); + }else { +domcreate_bootloader_done (egc, &dcs->bl,0 ); } +return ; -memset (&dcs->build_state,0 ,sizeof (dcs->build_state)); -libxl__domain_build_state *state = &dcs->build_state; +error_out: +assert (ret); +domcreate_complete (egc, dcs, ret); +} + +static void domcreate_bootloader_done (libxl__egc *egc, +libxl__bootloader_state *bl, +int ret) +{ +libxl__domain_create_state *dcs =CONTAINER_OF (bl, *dcs, bl); +STATE_AO_GC (bl->ao); +int i; + +/* convenience aliases */ +const uint32_t domid = dcs->guest_domid; +libxl_domain_config *const d_config = dcs->guest_config; +const int restore_fd = dcs->restore_fd; +libxl__domain_build_state *const state = &dcs->build_state; +libxl_ctx *const ctx =CTX ; + +if (ret) goto error_out;/* We might be going to call libxl__spawn_local_dm, or _spawn_stub_dm. * Fill in any field required by either, including both relevant
@@ -788,12 +814,13 @@ static void domcreate_devmodel_started(libxl__egc *egc,if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_PV &&libxl_defbool_val (d_config->b_info.u.pv.e820_host)) { -int rc; - rc =libxl__e820_alloc (gc, domid, d_config); -if (rc) + ret =libxl__e820_alloc (gc, domid, d_config); +if (ret) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"Failed while collecting E820 with: %d (errno:%d)\n" , - rc, errno); + ret, errno); + goto error_out; + } } if ( cb && (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM || (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
tools/libxl/libxl_internal.h +1 -0
@@ -1680,6 +1680,7 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state; +libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;/* If we're not doing stubdom, we use only dmss.dm, * for the non-stubdom device model. */
Signature · 1 line
1.7.2.5
PATCH v8 19/25 libxl: Fix an ao completion bug; document locking policy
In reply to Ian JacksonDocument the concurrent access policies for libxl__ao and libxl__egc, and their corresponding gcs.
Fix a violation of the policy:
If an ao was submitted and a callback requested, and while the initiating function was still running on the original thread, the ao is completed on another thread, the completing thread would improperly concurrently access the ao with the initiating thread.
--- tools/libxl/libxl_event.c | 7 +++++++ tools/libxl/libxl_internal.h | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletions(-)
tools/libxl/libxl_event.c +7 -0
@@ -897,6 +897,11 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,static void egc_run_callbacks (libxl__egc *egc) { +/* +* The callbacks must happen with the ctx unlocked. +* See the comment near #define EGC_GC in libxl_internal.h and +* those in the definitions of libxl__egc and libxl__ao. +*/ EGC_GC ;libxl_event *ev, *ev_tmp;
@@ -910,9 +915,11 @@ static void egc_run_callbacks(libxl__egc *egc) entry_for_callback, ao_tmp) {LIBXL_TAILQ_REMOVE (&egc->aos_for_callback, ao, entry_for_callback); ao->how.callback (CTX , ao->rc, ao->how.u.for_callback); +CTX_LOCK ; ao->notified =1 ;if (!ao->in_initiator)libxl__ao__destroy (CTX , ao); +CTX_UNLOCK ; } }
tools/libxl/libxl_internal.h +22 -1
@@ -369,7 +369,8 @@ struct libxl__gc { };struct libxl__egc { -/* for event-generating functions only */ +/* For event-generating functions only. +* The egc and its gc may be accessed only on the creating thread. */ struct libxl__gc gc;struct libxl__event_list occurred_for_callback; LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback;
@@ -379,6 +380,20 @@ struct libxl__egc {#define LIBXL__AO_MAGIC_DESTROYED 0xA0DEAD00ulstruct libxl__ao { +/* +* An ao and its gc may be accessed only with the ctx lock held. +* +* Special exception: If an ao has been added to +* egc->aos_for_callback, the thread owning the egc may remove the +* ao from that list and make the callback without holding the +* lock. +* +* Corresponding restriction: An ao may be added only to one +* egc->aos_for_callback, once; rc and how must already have been +* set and may not be subsequently modified. (This restriction is +* easily and obviously met since the ao is queued for callback +* only in libxl__ao_complete.) +*/ uint32_t magic;unsigned constructing:1 , in_initiator:1 , complete:1 , notified:1 ;int rc;
@@ -1356,6 +1371,12 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);* should in any case not find it necessary to call egc-creators from * within libxl. * +* The callbacks must all take place with the ctx unlocked because +* the application is entitled to reenter libxl from them. This +* would be bad not because the lock is not recursive (it is) but +* because the application might make blocking libxl calls which +* would hold the lock unreasonably long. +* * For the same reason libxl__egc_cleanup (or EGC_FREE) must be called * with the ctx *unlocked*. So the right pattern has the EGC_... * macro calls on the outside of the CTX_... ones.
Signature · 1 line
1.7.2.5
Re: [PATCH 19/25] libxl: Fix an ao completion bug; document locking policy
Quoted 11 lines · Ian Jackson
Document the concurrent access policies for
libxl__aoandlibxl__egc, and their corresponding gcs.Fix a violation of the policy:
If an ao was submitted and a callback requested, and while the initiating function was still running on the original thread, the ao is completed on another thread, the completing thread would improperly concurrently access the ao with the initiating thread.
Signed-off-by Ian Jackson <[email protected]>
Quoted 81 lines
--- tools/libxl/libxl_event.c | 7 +++++++ tools/libxl/libxl_internal.h | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletions(-)tools/libxl/libxl_event.c +7
-0@@ -897,6 +897,11 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,static void egc_run_callbacks (libxl__egc *egc) { +/* +* The callbacks must happen with the ctx unlocked. +* See the comment near #define EGC_GC in libxl_internal.h and +* those in the definitions of libxl__egc and libxl__ao. +*/ EGC_GC ;libxl_event *ev, *ev_tmp;@@ -910,9 +915,11 @@ static void egc_run_callbacks(libxl__egc *egc) entry_for_callback, ao_tmp) {LIBXL_TAILQ_REMOVE (&egc->aos_for_callback, ao, entry_for_callback); ao->how.callback (CTX , ao->rc, ao->how.u.for_callback); +CTX_LOCK ; ao->notified =1 ;if (!ao->in_initiator)libxl__ao__destroy (CTX , ao); +CTX_UNLOCK ; } }tools/libxl/libxl_internal.h +22
-1@@ -369,7 +369,8 @@ struct libxl__gc { };struct libxl__egc { -/* for event-generating functions only */ +/* For event-generating functions only. +* The egc and its gc may be accessed only on the creating thread. */ struct libxl__gc gc;struct libxl__event_list occurred_for_callback; LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback;@@ -379,6 +380,20 @@ struct libxl__egc {#define LIBXL__AO_MAGIC_DESTROYED 0xA0DEAD00ulstruct libxl__ao { +/* +* An ao and its gc may be accessed only with the ctx lock held. +* +* Special exception: If an ao has been added to +* egc->aos_for_callback, the thread owning the egc may remove the +* ao from that list and make the callback without holding the +* lock. +* +* Corresponding restriction: An ao may be added only to one +* egc->aos_for_callback, once; rc and how must already have been +* set and may not be subsequently modified. (This restriction is +* easily and obviously met since the ao is queued for callback +* only in libxl__ao_complete.) +*/ uint32_t magic;unsigned constructing:1 , in_initiator:1 , complete:1 , notified:1 ;int rc;@@ -1356,6 +1371,12 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);* should in any case not find it necessary to call egc-creators from * within libxl. * +* The callbacks must all take place with the ctx unlocked because +* the application is entitled to reenter libxl from them. This +* would be bad not because the lock is not recursive (it is) but +* because the application might make blocking libxl calls which +* would hold the lock unreasonably long. +* * For the same reason libxl__egc_cleanup (or EGC_FREE) must be called * with the ctx *unlocked*. So the right pattern has the EGC_... * macro calls on the outside of the CTX_... ones.
PATCH v8 20/25 libxl: provide progress reporting for long-running operations
In reply to Ian JacksonThis will be used for reporting, during domain creation, that the console is ready.
Changes since v7:
* If aop->how.callback, actually add the aop to the for_callback list (!)
* Document the threadsafety of aop's, and make appropriate cross-references.
* Allocate the actual aop from its thread's egc; do not free it.
* Remove pointless code motion of libxl__ao_create.
* Minor formatting fixes.
--- tools/libxl/libxl.h | 45 ++++++++++++++++++++++++++ tools/libxl/libxl_event.c | 72 ++++++++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_internal.h | 35 ++++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +45 -0
@@ -435,6 +435,51 @@ typedef struct { } u; } libxl_asyncop_how; +/* +* Some more complex asynchronous operations can report intermediate +* progress. How this is to be reported is controlled, for each +* function, by a parameter +* libxl_asyncprogress_how *aop_FOO_how; +* for each kind of progress FOO supported by that function. Each +* such kind of progress is associated with an event type. +* +* The function description will document whether, when, and how +* many times, the intermediate progress will be reported, and +* what the corresponding event type(s) are. +* +* If aop_FOO_how==NULL, intermediate progress reports are discarded. +* +* If aop_FOO_how->callback==NULL, intermediate progress reports +* generate libxl events which can be obtained from libxl_event_wait +* or libxl_event_check. +* +* If aop_FOO_how->callback!=NULL, libxl will report intermediate +* progress by calling callback(ctx, &event, for_callback). +* +* The rules for these events are otherwise the same as those for +* ordinary events. The reentrancy and threading rules for the +* callback are the same as those for ao completion callbacks. +* +* Note that the callback, if provided, is responsible for freeing +* the event. +* +* If callbacks are requested, they will be made, and returned, before +* the long-running libxl operation is considered finished (so if the +* long-running libxl operation was invoked with ao_how==NULL then any +* callbacks will occur strictly before the long-running operation +* returns). However, the callbacks may occur on any thread. +* +* In general, otherwise, no promises are made about the relative +* order of callbacks in a multithreaded program. In particular +* different callbacks relating to the same long-running operation may +* be delivered out of order. +*/ + +typedef struct { +void (*callback)(libxl_ctx *ctx,libxl_event *,void *for_callback); +libxl_ev_user for_event;/* always used */ +void *for_callback;/* passed to callback */ +}libxl_asyncprogress_how ;#define LIBXL_VERSION 0
tools/libxl/libxl_event.c +69 -3
111 lines not on this page · raw message
tools/libxl/libxl_internal.h +35 -0
@@ -118,6 +118,7 @@ _hidden void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,typedef struct libxl__gc libxl__gc ;typedef struct libxl__egc libxl__egc ;typedef struct libxl__ao libxl__ao ; +typedef struct libxl__aop_occurred libxl__aop_occurred ; _hidden void libxl__alloc_failed(libxl_ctx *, const char *func,size_t nmemb,size_t size) __attribute__((noreturn));
@@ -374,6 +375,21 @@ struct libxl__egc {struct libxl__gc gc;struct libxl__event_list occurred_for_callback; LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback; + LIBXL_TAILQ_HEAD(, libxl__aop_occurred) aops_for_callback; +}; + +struct libxl__aop_occurred { +/* +* An aop belongs to, and may be accessed only on, the thread +* which created it. It normally lives in that thread's egc. +* +* While an aop exists, it corresponds to one refcount in +* ao->progress_reports_outstanding, preventing ao destruction. +*/ +LIBXL_TAILQ_ENTRY (libxl__aop_occurred) entry; +libxl__ao *ao; +libxl_event *ev; +const libxl_asyncprogress_how *how; };#define LIBXL__AO_MAGIC 0xA0FACE00ul
@@ -396,6 +412,7 @@ struct libxl__ao {*/ uint32_t magic; unsigned constructing:1, in_initiator:1, complete:1, notified:1; +int progress_reports_outstanding;int rc;libxl__gc gc;libxl_asyncop_how how;
@@ -1393,6 +1410,7 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);LIBXL_INIT_GC ((egc).gc,ctx); \LIBXL_TAILQ_INIT (&(egc).occurred_for_callback); \LIBXL_TAILQ_INIT (&(egc).aos_for_callback); \ +LIBXL_TAILQ_INIT (&(egc).aops_for_callback); \ }while (0 ) _hidden void libxl__egc_cleanup(libxl__egc *egc);
@@ -1439,6 +1457,9 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc);* pointer to the internal event generation request routines * libxl__evgen_FOO, so that at some point a CALLBACK will be * made when the operation is complete. +* - if the operation provides progress reports, the aop_how(s) +* must be copied into the per-operation structure using +* libxl__ao_progress_gethow. * * - If initiation is successful, the initiating function needs * to run libxl__ao_inprogress right before unlocking and
@@ -1448,6 +1469,10 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc);* call libxl__ao_abort before unlocking and returning whatever * error code is appropriate (AO_ABORT macro). * +* - If the operation supports progress reports, it may generate +* suitable events with NEW_EVENT and report them with +* libxl__ao_progress_report (with the ctx locked). +* * - Later, some callback function, whose callback has been requested * directly or indirectly, should call libxl__ao_complete (with the * ctx locked, as it will generally already be in any event callback
@@ -1503,8 +1528,18 @@ _hidden int libxl__ao_inprogress(libxl__ao *ao); /* temporarily unlocks */ _hidden void libxl__ao_abort(libxl__ao *ao); _hidden void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc); +/* Can be called at any time. Use is essential for any aop user. */ +_hidden void libxl__ao_progress_gethow(libxl_asyncprogress_how *in_state, +const libxl_asyncprogress_how *from_app); + +/* Must be called with the ctx locked. Will fill in ev->for_user, +* so caller need not do that. */ +_hidden void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao, +const libxl_asyncprogress_how *how,libxl_event *ev/* consumed */ ); +/* For use by ao machinery ONLY */ _hidden void libxl__ao__destroy(libxl_ctx*, libxl__ao *ao); +_hidden void libxl__ao_complete_check_progress_reports(libxl__egc*, libxl__ao*);/*
Signature · 1 line
1.7.2.5
Re: [PATCH 20/25] libxl: provide progress reporting for long-running operations
Quoted 4 lines · Ian Jackson
This will be used for reporting, during domain creation, that the console is ready.
Signed-off-by Ian Jackson <[email protected]>
Quoted 7 lines
Changes since v7:
* Ifaop->how.callback, actually add the aop to thefor_callbacklist (!)
* Document the threadsafety of aop's, and make appropriate cross-references.
* Allocate the actual aop from its thread's egc; do not free it.
* Remove pointless code motion oflibxl__ao_create.
* Minor formatting fixes.
PATCH v8 21/25 libxl: remove malloc failure handling from NEW_EVENT
In reply to Ian JacksonChange to use libxl__zalloc, where allocation failure is fatal.
Also remove a spurious semicolon from the helper macro.
--- tools/libxl/libxl.c | 2 -- tools/libxl/libxl_event.c | 8 +------- tools/libxl/libxl_internal.h | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-)
tools/libxl/libxl.c +0 -2
@@ -779,7 +779,6 @@ static void domain_death_occurred(libxl__egc *egc, *evg_upd = evg_next;libxl_event *ev =NEW_EVENT (egc,DOMAIN_DEATH , evg->domid); -if (!ev)return ;libxl__event_occurred (egc, ev);
@@ -866,7 +865,6 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,if (!evg->shutdown_reported && (got->flags & XEN_DOMINF_shutdown)) {libxl_event *ev =NEW_EVENT (egc,DOMAIN_SHUTDOWN , got->domain); -if (!ev) goto out;LIBXL__LOG (CTX ,LIBXL__LOG_DEBUG ," shutdown reporting" );
tools/libxl/libxl_event.c +1 -7
@@ -985,13 +985,7 @@ libxl_event *libxl__event_new(libxl__egc *egc, {libxl_event *ev; - ev =malloc (sizeof (*ev)); -if (!ev) { -LIBXL__EVENT_DISASTER (egc,"allocate new event" , errno, type); -return NULL ; - } - -memset (ev,0 ,sizeof (*ev)); + ev =libxl__zalloc (0 ,sizeof (*ev)); ev->type = type; ev->domid = domid;
tools/libxl/libxl_internal.h +2 -2
@@ -664,10 +664,10 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type, uint32_t domid);/* Convenience function. * Allocates a new libxl_event, fills in domid and type. -* If allocation fails, calls _disaster, and returns NULL. */ +* Cannot fail. */ #define NEW_EVENT (egc, type, domid) \ - libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid)); + libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid))/* Convenience macro. */ /*
Signature · 1 line
1.7.2.5
PATCH v8 22/25 libxl: convert console callback to libxl_asyncprogress_how
In reply to Ian JacksonRemove the old console callback. (Its reentrancy properties were
troublesome: in principle, the event loop might be reentered during the callback, and the libxl__domain_create_state swept out from under the feet of the domain creation.)
As a side effect of the new code arrangements, the console callback for non-bootloader-using PV guests now occurs near the end of domain creation, in the same place as for HVM guests, rather than near the start.
The new arrangements should in principle mean that by the time the console is described as ready by the callback, the xenstore key is indeed ready. So in the future the timeout might be removed from the console client.
--- tools/libxl/libxl.h | 17 ++++++----- tools/libxl/libxl_bootloader.c | 3 ++ tools/libxl/libxl_create.c | 59 +++++++++++++++++++++++----------------- tools/libxl/libxl_internal.h | 6 +++- tools/libxl/libxl_types.idl | 2 + tools/libxl/xl_cmdimpl.c | 25 ++++++++++------- 6 files changed, 67 insertions(+), 45 deletions(-)
tools/libxl/libxl.h +9 -8
@@ -509,18 +509,19 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version,int libxl_ctx_free (libxl_ctx *ctx/* 0 is OK */ );/* domain related functions */ -typedef int (*libxl_console_ready )(libxl_ctx *ctx,uint32_t domid,void *priv); -/* fixme-ao Need to review this API. If we keep it, the reentrancy -* properties need to be documented but they may turn out to be too -* awkward */ int libxl_domain_create_new (libxl_ctx *ctx,libxl_domain_config *d_config, -libxl_console_ready cb,void *priv,uint32_t *domid, -const libxl_asyncop_how *ao_how); +uint32_t *domid, +const libxl_asyncop_how *ao_how, +const libxl_asyncprogress_how *aop_console_how);int libxl_domain_create_restore (libxl_ctx *ctx,libxl_domain_config *d_config, -libxl_console_ready cb,void *priv,uint32_t *domid,int restore_fd, -const libxl_asyncop_how *ao_how); +const libxl_asyncop_how *ao_how, +const libxl_asyncprogress_how *aop_console_how); +/* A progress report will be made via ao_console_how, of type +* domain_create_console_available, when the domain's primary +* console is available and can be connected to. +*/ void libxl_domain_config_init (libxl_domain_config *d_config);void libxl_domain_config_dispose (libxl_domain_config *d_config);
tools/libxl/libxl_bootloader.c +3 -0
@@ -377,6 +377,9 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op) goto out; } +if (bl->console_available) + bl->console_available (egc, bl); +int bootloader_master =libxl__carefd_fd (bl->ptys[0 ].master);int xenconsole_master =libxl__carefd_fd (bl->ptys[1 ].master);
tools/libxl/libxl_create.c +34 -25
131 lines not on this page · raw message
tools/libxl/libxl_internal.h +4 -2
@@ -1690,11 +1690,14 @@ int libxl__openptys(libxl__openpty_state *op,typedef struct libxl__bootloader_state libxl__bootloader_state ;typedef void libxl__run_bootloader_callback (libxl__egc *,libxl__bootloader_state *,int rc); +typedef void libxl__bootloader_console_callback (libxl__egc *, +libxl__bootloader_state *);struct libxl__bootloader_state {/* caller must fill these in, and they must all remain valid */ libxl__ao *ao;libxl__run_bootloader_callback *callback; +libxl__bootloader_console_callback *console_available;libxl_domain_build_info *info;/* u.pv.{kernel,ramdisk,cmdline} updated */ libxl_device_disk *disk;uint32_t domid;
@@ -1730,9 +1733,8 @@ struct libxl__domain_create_state {libxl__ao *ao;libxl_domain_config *guest_config;int restore_fd; -libxl_console_ready console_cb; -void *console_cb_priv;libxl__domain_create_cb *callback; +libxl_asyncprogress_how aop_console_how;/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state;
tools/libxl/libxl_types.idl +2 -0
@@ -459,6 +459,7 @@ libxl_event_type = Enumeration("event_type", [ (2, "DOMAIN_DEATH"), (3, "DISK_EJECT"), (4, "OPERATION_COMPLETE"), + (5, "DOMAIN_CREATE_CONSOLE_AVAILABLE"), ]) libxl_ev_user = UInt(64)
@@ -484,4 +485,5 @@ libxl_event = Struct("event",[ ("operation_complete", Struct(None, [ ("rc", integer), ])), + ("domain_create_console_available", Struct(None, [])), ]))])
tools/libxl/xl_cmdimpl.c +15 -10
@@ -1457,16 +1457,18 @@ static int freemem(libxl_domain_build_info *b_info)return ERROR_NOMEM ; } -static int autoconnect_console (libxl_ctx *ctx,uint32_t domid,void *priv) +static void autoconnect_console (libxl_ctx *ctx,libxl_event *ev,void *priv) {pid_t *pid = priv; +libxl_event_free (ctx, ev); + *pid =fork ();if (*pid <0 ) {perror ("unable to fork xenconsole" ); -return ERROR_FAIL ; +return ; }else if (*pid >0 ) -return 0 ; +return ;postfork ();
@@ -1533,7 +1535,7 @@ static int create_domain(struct domain_create *dom_info)int config_len =0 ;int restore_fd =-1 ;int status =0 ; -libxl_console_ready cb; +const libxl_asyncprogress_how *autoconnect_console_how;pid_t child_console_pid =-1 ;struct save_file_header hdr;
@@ -1687,24 +1689,27 @@ start: goto error_out; } +libxl_asyncprogress_how autoconnect_console_how_buf;if ( dom_info->console_autoconnect ) { - cb = autoconnect_console; + autoconnect_console_how_buf.callback = autoconnect_console; + autoconnect_console_how_buf.for_callback = &child_console_pid; + autoconnect_console_how = &autoconnect_console_how_buf; }else { - cb =NULL ; + autoconnect_console_how =0 ; }if ( restore_file ) { ret =libxl_domain_create_restore (ctx, &d_config, - cb, &child_console_pid, - &domid, restore_fd,0 ); + &domid, restore_fd, +0 , autoconnect_console_how);/* * On subsequent reboot etc we should create the domain, not * restore/migrate-receive it again. */ restore_file =NULL ; }else { - ret =libxl_domain_create_new (ctx, &d_config, - cb, &child_console_pid, &domid,0 ); + ret =libxl_domain_create_new (ctx, &d_config, &domid, +0 , autoconnect_console_how); }if ( ret ) goto error_out;
Signature · 1 line
1.7.2.5
PATCH v8 23/25 libxl: clarify definition of "slow" operation
In reply to Ian JacksonUpdate the comment in libxl_internal.h to be clearer about which application-facing libxl operations need to take an ao_how.
--- tools/libxl/libxl_internal.h | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-)
tools/libxl/libxl_internal.h +23 -6
@@ -1430,17 +1430,34 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc);/* * Machinery for asynchronous operations ("ao") * -* All "slow" functions (includes anything that might block on a -* guest or an external script) need to use the asynchronous -* operation ("ao") machinery. The function should take a parameter -* const libxl_asyncop_how *ao_how and must start with a call to -* AO_INITIATOR_ENTRY. These functions MAY NOT be called from -* inside libxl, because they can cause reentrancy callbacks. +* All "slow" functions (see below for the exact definition) need to +* use the asynchronous operation ("ao") machinery. The function +* should take a parameter const libxl_asyncop_how *ao_how and must +* start with a call to AO_INITIATOR_ENTRY. These functions MAY NOT +* be called from inside libxl, because they can cause reentrancy +* callbacks. * * For the same reason functions taking an ao_how may make themselves * an egc with EGC_INIT (and they will generally want to, to be able * to immediately complete an ao during its setup). * +* +* "Slow" functions includes any that might block on a guest or an +* external script. More broadly, it includes any operations which +* are sufficiently slow that an application might reasonably want to +* initiate them, and then carry on doing something else, while the +* operation completes. That is, a "fast" function must be fast +* enough that we do not mind blocking all other management operations +* on the same host while it completes. +* +* There are certain primitive functions which make a libxl operation +* necessarily "slow" for API reasons. These are: +* - awaiting xenstore watches (although read-modify-write xenstore +* transactions are OK for fast functions) +* - spawning subprocesses +* - anything with a timeout +* +* * Lifecycle of an ao: * * - Created by libxl__ao_create (or the AO_CREATE convenience macro).
Signature · 1 line
1.7.2.5
PATCH v8 24/25 libxl: child processes cleanups
In reply to Ian JacksonAbolish libxl_fork. Its only callers were in xl. Its functionality is now moved elsewhere, as follows:
* The "logging version of fork", which is what it was billed as, is now xl_fork, which also dies on failure.
* Closing the xenstore handle in the child is now done in libxl__ev_child_fork, which is the only remaining place where fork is called in libxl.
* We provide a new function libxl__ev_child_xenstore_reopen for in-libxl children to make the ctx useable for xenstore again.
* Consequently libxl__spawn_record_pid now no longer needs to mess about with its own xenstore handle. As a bonus it can now just use libxl__xs_write.
Also, since we have now converted all the forkers in libxl, we can always honour the fork_replacement childproc hook - so do so.
--- tools/libxl/libxl_exec.c | 35 ++++++++++++++++------------------- tools/libxl/libxl_fork.c | 25 ++++++++++++++++++++++++- tools/libxl/libxl_internal.h | 5 +++++ tools/libxl/libxl_utils.c | 21 --------------------- tools/libxl/libxl_utils.h | 3 +-- tools/libxl/xl.c | 12 ++++++++++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 5 ++--- 8 files changed, 61 insertions(+), 46 deletions(-)
tools/libxl/libxl_exec.c +16 -19
@@ -127,34 +127,23 @@ void libxl_report_child_exitstatus(libxl_ctx *ctx, } } -int libxl__spawn_record_pid (libxl__gc *gc,libxl__spawn_state *spawn, -pid_t innerchild) +int libxl__spawn_record_pid (libxl__gc *gc,libxl__spawn_state *spawn,pid_t pid) { -struct xs_handle *xsh =NULL ; -const char *pid =NULL ; -int rc, xsok; +int r, rc; - pid =GCSPRINTF ("%d" , innerchild); + rc =libxl__ev_child_xenstore_reopen (gc, spawn->what); +if (rc) goto out; -/* we mustn't use the parent's handle in the child */ - xsh =xs_daemon_open (); -if (!xsh) { -LOGE (ERROR ,"write %s = %s: xenstore reopen failed" , - spawn->pidpath, pid); - rc =ERROR_FAIL ; goto out; - } - - xsok =xs_write (xsh,XBT_NULL , spawn->pidpath, pid,strlen (pid)); -if (!xsok) { + r =libxl__xs_write (gc,XBT_NULL , spawn->pidpath,"%d" , pid); +if (r) {LOGE (ERROR , -"write %s = %s: xenstore write failed" , spawn->pidpath, pid); +"write %s = %d: xenstore write failed" , spawn->pidpath, pid); rc =ERROR_FAIL ; goto out; } rc =0 ; out: -if (xsh)xs_daemon_close (xsh);return rc ?SIGTERM :0 ; }
@@ -302,7 +291,15 @@ int libxl__spawn_spawn(libxl__egc *egc, libxl__spawn_state *ss)/* we are now the middle process */ - child =fork (); +pid_t (*fork_replacement)(void *) = +CTX ->childproc_hooks + ?CTX ->childproc_hooks->fork_replacement + :0 ; + child = + fork_replacement + ?fork_replacement (CTX ->childproc_user) + :fork (); +if (child ==-1 )exit (255 );if (!child) {
tools/libxl/libxl_fork.c +24 -1
@@ -347,7 +347,12 @@ pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *ch,if (!pid) {/* woohoo! */ -return 0 ;/* Yes, CTX is left locked in the child. */ +if (CTX ->xsh) { +xs_daemon_destroy_postfork (CTX ->xsh); +CTX ->xsh =NULL ;/* turns mistakes into crashes */ + } +/* Yes, CTX is left locked in the child. */ +return 0 ; } ch->pid = pid;
@@ -395,6 +400,24 @@ const libxl_childproc_hooks libxl__childproc_default_hooks = { libxl_sigchld_owner_libxl, 0, 0 }; +int libxl__ev_child_xenstore_reopen (libxl__gc *gc,const char *what) { +int rc; + +assert (!CTX ->xsh); +CTX ->xsh =xs_daemon_open (); +if (!CTX ->xsh) { +LOGE (ERROR ,"%s: xenstore reopen failed" , what); + rc =ERROR_FAIL ; goto out; + } + +libxl_fd_set_cloexec (CTX ,xs_fileno (CTX ->xsh),1 ); + +return 0 ; + + out: +return rc; +} +/* * Local variables: * mode: C
tools/libxl/libxl_internal.h +5 -0
@@ -650,6 +650,11 @@ static inline void libxl__ev_child_init(libxl__ev_child *childw_out)static inline int libxl__ev_child_inuse (libxl__ev_child *childw_out) {return childw_out->pid >=0 ; } +/* Useable (only) in the child to once more make the ctx useable for +* xenstore operations. logs failure in the form "what: <error +* message>". */ +_hidden int libxl__ev_child_xenstore_reopen(libxl__gc *gc, const char *what); +/* * Other event-handling support provided by the libxl event core to
tools/libxl/libxl_utils.c +0 -21
@@ -444,27 +444,6 @@ int libxl__remove_directory(libxl__gc *gc, const char *dirpath)return rc; } -pid_t libxl_fork (libxl_ctx *ctx) -{ -pid_t pid; - - pid =fork (); -if (pid ==-1 ) { -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"fork failed" ); -return -1 ; - } - -if (!pid) { -if (ctx->xsh)xs_daemon_destroy_postfork (ctx->xsh); - ctx->xsh =0 ; -/* This ensures that anyone who forks but doesn't exec, -* and doesn't reinitialise the libxl_ctx, is OK. -* It also means they can safely call libxl_ctx_free. */ - } - -return pid; -} -int libxl_pipe (libxl_ctx *ctx,int pipes[2 ]) {if (pipe (pipes) <0 ) {
tools/libxl/libxl_utils.h +1 -2
@@ -47,9 +47,8 @@ int libxl_write_exactly(libxl_ctx *ctx, int fd, const void *data,* logged using filename (which is only used for logging) and what * (which may be 0). */ -pid_t libxl_fork (libxl_ctx *ctx);int libxl_pipe (libxl_ctx *ctx,int pipes[2 ]); -/* Just like fork(2), pipe(2), but log errors. */ +/* Just like pipe(2), but log errors. */ void libxl_report_child_exitstatus (libxl_ctx *ctx,xentoollog_level ,const char *what,pid_t pid,int status);
tools/libxl/xl.c +12 -0
@@ -105,6 +105,18 @@ void postfork(void) } } +pid_t xl_fork (libxl_ctx *ctx) { +pid_t pid; + + pid =fork (); +if (pid ==-1 ) { +perror ("fork failed" ); +exit (-1 ); + } + +return pid; +} +int main (int argc,char **argv) {int opt =0 ;
tools/libxl/xl.h +1 -0
@@ -104,6 +104,7 @@ struct cmd_spec *cmdtable_lookup(const char *s);extern libxl_ctx *ctx;extern xentoollog_logger_stdiostream *logger; +pid_t xl_fork (libxl_ctx *ctx);/* like fork, but prints and dies if it fails */ void postfork (void );/* global options */
tools/libxl/xl_cmdimpl.c +2 -3
@@ -1736,7 +1736,7 @@ start:pid_t child1, got_child;int nullfd; - child1 =libxl_fork (ctx); + child1 =xl_fork (ctx);if (child1) {printf ("Daemon running with PID %d\n" , child1);
@@ -2775,8 +2775,7 @@ static void migrate_domain(const char *domain_spec, const char *rune,MUST (libxl_pipe (ctx, sendpipe) );MUST (libxl_pipe (ctx, recvpipe) ); - child =libxl_fork (ctx); -if (child==-1 )exit (1 ); + child =xl_fork (ctx);if (!child) {dup2 (sendpipe[0 ],0 );
Signature · 1 line
1.7.2.5
Re: [PATCH 24/25] libxl: child processes cleanups
Quoted 13 lines · Ian Jackson
Abolish
libxl_fork. Its only callers were in xl. Its functionality is now moved elsewhere, as follows:* The "logging version of fork", which is what it was billed as, is now
xl_fork, which also dies on failure.* Closing the xenstore handle in the child is now done in
libxl__ev_child_fork, which is the only remaining place where fork is called in libxl.* We provide a new function
libxl__ev_child_xenstore_reopenfor in-libxl children to make the ctx useable for xenstore again.
Quoted 8 lines
* Consequently
libxl__spawn_record_pidnow no longer needs to mess about with its own xenstore handle. As a bonus it can now just uselibxl__xs_write.Also, since we have now converted all the forkers in libxl, we can always honour the
fork_replacementchildproc hook - so do so.Signed-off-by Ian Jackson <[email protected]>
PATCH v8 25/25 libxl: aborting bootloader invocation when domain dioes
In reply to Ian JacksonCancel the bootloader (specifically, by sending it a signal) if the domain is seen to disappear from xenstore.
We use a new utility event source libxl__domaindeathcheck which provides a convenient wrapper for the xenstore watch.
Changes since v7:
* Add a comment explaining why we use a watch on the domain's xenstore path rather than @releaseDomain.
* Fix typo in error message.
--- tools/libxl/libxl_bootloader.c | 43 ++++++++++++++++++++++++++++-------- tools/libxl/libxl_event.c | 47 ++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 29 +++++++++++++++++++++++- 3 files changed, 108 insertions(+), 11 deletions(-)
tools/libxl/libxl_bootloader.c +33 -10
@@ -31,6 +31,7 @@ static void bootloader_keystrokes_copyfail(libxl__egc *egc, libxl__datacopier_state *dc, int onwrite, int errnoval);static void bootloader_display_copyfail (libxl__egc *egc,libxl__datacopier_state *dc,int onwrite,int errnoval); +static void bootloader_domaindeath (libxl__egc *,libxl__domaindeathcheck *dc);static void bootloader_finished (libxl__egc *egc,libxl__ev_child *child,pid_t pid,int status);
@@ -213,6 +214,7 @@ void libxl__bootloader_init(libxl__bootloader_state *bl) bl->ptys[0 ].master = bl->ptys[0 ].slave =0 ; bl->ptys[1 ].master = bl->ptys[1 ].slave =0 ;libxl__ev_child_init (&bl->child); +libxl__domaindeathcheck_init (&bl->deathcheck); bl->keystrokes.ao = bl->ao;libxl__datacopier_init (&bl->keystrokes); bl->display.ao = bl->ao;libxl__datacopier_init (&bl->display); }
@@ -230,6 +232,7 @@ static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl)free (bl->diskpath); bl->diskpath =0 ; } +libxl__domaindeathcheck_stop (gc,&bl->deathcheck);libxl__datacopier_kill (&bl->keystrokes);libxl__datacopier_kill (&bl->display);for (i=0 ; i<2 ; i++) {
@@ -256,6 +259,23 @@ static void bootloader_callback(libxl__egc *egc, libxl__bootloader_state *bl, bl->callback (egc, bl, rc); } +/* might be called at any time, provided it's init'd */ +static void bootloader_abort (libxl__egc *egc, +libxl__bootloader_state *bl,int rc) +{ +STATE_AO_GC (bl->ao); +int r; + +libxl__datacopier_kill (&bl->keystrokes); +libxl__datacopier_kill (&bl->display); +if (libxl__ev_child_inuse (&bl->child)) { + r =kill (bl->child.pid,SIGTERM ); +if (r)LOGE (WARN ,"after failure, failed to kill bootloader [%lu]" , + (unsigned long )bl->child.pid); + } + bl->rc = rc; +} +/*----- main flow of control -----*/ void libxl__bootloader_run (libxl__egc *egc,libxl__bootloader_state *bl)
@@ -377,6 +397,12 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op) goto out; } + bl->deathcheck.what ="stopping bootloader" ; + bl->deathcheck.domid = bl->domid; + bl->deathcheck.callback = bootloader_domaindeath; + rc =libxl__domaindeathcheck_start (gc, &bl->deathcheck); +if (rc) goto out; +if (bl->console_available) bl->console_available (egc, bl);
@@ -454,18 +480,9 @@ static void bootloader_copyfail(libxl__egc *egc, const char *which, libxl__bootloader_state *bl, int onwrite, int errnoval) { STATE_AO_GC(bl->ao); -int r; -if (!onwrite && !errnoval)LOG (ERROR ,"unexpected eof copying %s" , which); -libxl__datacopier_kill (&bl->keystrokes); -libxl__datacopier_kill (&bl->display); -if (libxl__ev_child_inuse (&bl->child)) { - r =kill (bl->child.pid,SIGTERM ); -if (r)LOGE (WARN ,"after failure, failed to kill bootloader [%lu]" , - (unsigned long )bl->child.pid); - } - bl->rc =ERROR_FAIL ; +bootloader_abort (egc, bl,ERROR_FAIL ); }static void bootloader_keystrokes_copyfail (libxl__egc *egc,libxl__datacopier_state *dc,int onwrite,int errnoval)
@@ -480,6 +497,12 @@ static void bootloader_display_copyfail(libxl__egc *egc,bootloader_copyfail (egc,"bootloader output" , bl, onwrite, errnoval); } +static void bootloader_domaindeath (libxl__egc *egc,libxl__domaindeathcheck *dc) +{ +libxl__bootloader_state *bl =CONTAINER_OF (dc, *bl, deathcheck); +bootloader_abort (egc, bl,ERROR_FAIL ); +} +static void bootloader_finished (libxl__egc *egc,libxl__ev_child *child,pid_t pid,int status) {
tools/libxl/libxl_event.c +47 -0
53 lines not on this page · raw message
tools/libxl/libxl_internal.h +28 -1
@@ -861,6 +861,33 @@ _hidden int libxl__ev_devstate_wait(libxl__gc *gc, libxl__ev_devstate *ds,const char *state_path, int state, int milliseconds); +/* +* libxl__ev_domaindeathcheck_register - arranges to call back (once) +* if the domain is destroyed. If the domain dies, we log a message +* of the form "<what>: <explanation of the situation, including the domid>". +*/ + +typedef struct libxl__domaindeathcheck libxl__domaindeathcheck ; +typedef void libxl___domaindeathcheck_callback (libxl__egc *egc, +libxl__domaindeathcheck *); + +struct libxl__domaindeathcheck { +/* must be filled in by caller, and remain valid: */ +const char *what; +uint32_t domid; +libxl___domaindeathcheck_callback *callback; +/* private */ +libxl__ev_xswatch watch; +}; + +_hidden int libxl__domaindeathcheck_start(libxl__gc *gc, +libxl__domaindeathcheck *dc); + +static inline void libxl__domaindeathcheck_init + (libxl__domaindeathcheck *dc) {libxl__ev_xswatch_init (&dc->watch); } +static inline void libxl__domaindeathcheck_stop (libxl__gc *gc, +libxl__domaindeathcheck *dc) {libxl__ev_xswatch_deregister (gc,&dc->watch); } +/* * libxl__try_phy_backend - Check if there's support for the passed
@@ -1729,6 +1756,7 @@ struct libxl__bootloader_state {libxl__openpty_state openpty;libxl__openpty_result ptys[2 ];/* [0] is for bootloader */ libxl__ev_child child; +libxl__domaindeathcheck deathcheck;int nargs, argsspace;const char **args;libxl__datacopier_state keystrokes, display;
@@ -1741,7 +1769,6 @@ _hidden void libxl__bootloader_init(libxl__bootloader_state *bl);* If callback is passed rc==0, will have updated st->info appropriately */ _hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); -/*----- Domain creation -----*/ typedef struct libxl__domain_create_state libxl__domain_create_state ;
Signature · 1 line
1.7.2.5
Quoted 3 lines · Ian Jackson
This incorporates changes from review.
These have already been acked, apart from 04/25,
I just acked it, I remember it from last time and was happy with it apart from the stray PTYFUNC test.
Quoted 1 line
and could go into the tree very soon:
Yes.
Quoted 36 lines
01/25 libxl: handle POLLERR, POLLHUP, POLLNVAL properly 02/25 libxl: support multiple
libxl__ev_fdsfor the same fd 03/25 libxl: event API: new facilities for waiting for subprocesses
! 04/25 autoconf: trim the configure script; use autoheader
05/25 autoconf: New test for openpty et al.
06/25 libxl: providelibxl__remove_fileet al.
07/25 libxl: Introducelibxl__sendmsg_fdsandlibxl__recvmsg_fds08/25 libxl: Clean up setdefault indo_domain_create09/25 libxl: provide libxl__datacopier_*
10/25 libxl: provide libxl__openpty_*
11/25 libxl: ao: Convertlibxl_run_bootloader
12/25 libxl: makelibxl_create_logfileconst-correct 13/25 libxl: log bootloader output
14/25 libxl: AllowAO_GCandEGC_GCeven if not used 15/25 libxl: removectx->waitpid_insteadThese are the remaining meat; all except 19/25 have been posted before and some have been acked:
16/25 libxl: change some structures to unit arrays
17/25 libxl: ao: convert libxl__spawn_*
18/25 libxl: makelibxl_createrun bootloader via callback
* 19/25 libxl: Fix an ao completion bug; document locking policy 20/25 libxl: provide progress reporting for long-running operations 21/25 libxl: remove malloc failure handling fromNEW_EVENT22/25 libxl: convert console callback tolibxl_asyncprogress_how23/25 libxl: clarify definition of "slow" operation 24/25 libxl: child processes cleanups
25/25 libxl: aborting bootloader invocation when domain dioes_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel