[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 20/20] libxl: ao: Convert libxl_run_bootloader



Ian Jackson writes ("Re: [Xen-devel] [PATCH 20/20] libxl: ao: Convert 
libxl_run_bootloader"):
> Ian Campbell writes ("Re: [Xen-devel] [PATCH 20/20] libxl: ao: Convert 
> libxl_run_bootloader"):
> > Could this stuff be usefully pushed into libxl__openpty?
> 
> Hmm.  This is a bit of a can of worms I think.  When I wrote my patch
> I left it well alone.  TBH I think the current code is arguably wrong.
> I can see no reason why we would try to do termios operations on the
> pty master at all.  I think these functions should be performed on the
> slave on all platforms.
> 
> But I don't want to introduce a perhaps-not-wonderfully-portable
> change like that in this series.

Just to be clear: I left all of this pty termios code alone in my
series; it just shuffles about a bit but is otherwise unchanged as far
as possible.  The only intentional difference is that I replaced
forkpty with our own fork + openpty + login_tty.

> > login_tty is a new one to me. When I lookup up the manpage I happened to
> > notice:
> >        Link with -lutil.
> 
> Hmm.  The BSD manpage is more forthcoming and suggests we need
> something different there.  (This isn't a particularly portable
> function.)
> 
> I think we need some more autoconfery.

Like the below.  Previously libxl was linking with -lutil by virtue of
using UTIL_LIBS which came from config/StdGNU.mk.

Ian.

From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Subject: [PATCH] autoconf: New test for openpty et al.

We 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.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

---
 config/Tools.mk.in             |    2 +
 tools/configure                |   57 ++++++++++++++++++++++++++++++++++++++++
 tools/configure.ac             |    2 +
 tools/libxl/Makefile           |    2 +-
 tools/libxl/libxl_bootloader.c |    4 +++
 tools/m4/ptyfuncs.m4           |   24 +++++++++++++++++
 6 files changed, 90 insertions(+), 1 deletions(-)

diff --git a/config/Tools.mk.in b/config/Tools.mk.in
index 8247e4a..ddcb10e 100644
--- a/config/Tools.mk.in
+++ b/config/Tools.mk.in
@@ -27,6 +27,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
diff --git a/tools/configure b/tools/configure
index 7ee4e3e..e35eaa0 100755
--- a/tools/configure
+++ b/tools/configure
@@ -602,6 +602,7 @@ POW_LIB
 LIBOBJS
 ALLOCA
 libiconv
+PTYFUNCS_LIBS
 PTHREAD_LIBS
 PTHREAD_LDFLAGS
 PTHREAD_CFLAGS
@@ -3913,9 +3914,17 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 
's/ /-/g'`;; esac
 
 
 
+# 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.
+
+
 
 
 
@@ -7091,6 +7100,54 @@ $as_echo "$ax_cv_pthread_flags" >&6; }
 
 
 
+
+    ac_fn_c_check_header_mongrel "$LINENO" "libutil.h" 
"ac_cv_header_libutil_h" "$ac_includes_default"
+if test "x$ac_cv_header_libutil_h" = x""yes; then :
+
+
+$as_echo "#define INCLUDE_LIBUTIL_H <libutil.h>" >>confdefs.h
+
+
+fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openpty et al" >&5
+$as_echo_n "checking for openpty et al... " >&6; }
+if test "${ax_cv_ptyfuncs_libs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        ax_cv_ptyfuncs_libs=-lutil
+
+    saved_LIBS="$LIBS"
+
+        LIBS="$LIBS $ax_cv_ptyfuncs_libs"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef INCLUDE_LIBUTIL_H
+#include INCLUDE_LIBUTIL_H
+#endif
+int main(void) {
+  openpty(0,0,0,0,0);
+  login_tty(0);
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+    LIBS="$saved_LIBS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_ptyfuncs_libs" >&5
+$as_echo "$ax_cv_ptyfuncs_libs" >&6; }
+    PTYFUNCS_LIBS="$ax_cv_ptyfuncs_libs"
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" 
>&5
 $as_echo_n "checking for clock_gettime in -lrt... " >&6; }
 if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then :
diff --git a/tools/configure.ac b/tools/configure.ac
index 3da0c82..936a192 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -36,6 +36,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_ENABLE_AND_EXPORT([githttp], [Download GIT repositories via HTTP])
@@ -126,6 +127,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([rt], [clock_gettime])
 AC_CHECK_LIB([yajl], [yajl_alloc], [],
     [AC_MSG_ERROR([Could not find yajl])])
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index a88827a..2c9aebf 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -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)
diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c
index 2774062..b50944a 100644
--- a/tools/libxl/libxl_bootloader.c
+++ b/tools/libxl/libxl_bootloader.c
@@ -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
diff --git a/tools/m4/ptyfuncs.m4 b/tools/m4/ptyfuncs.m4
new file mode 100644
index 0000000..2846a6d
--- /dev/null
+++ b/tools/m4/ptyfuncs.m4
@@ -0,0 +1,24 @@
+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], [
+        ax_cv_ptyfuncs_libs=-lutil
+        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);
+}
+])
+        AX_SAVEVAR_RESTORE(LIBS)],
+    [],[
+        AC_MSG_FAILURE([Unable to find -lutil for openpty and login_tty])
+    ])
+    PTYFUNCS_LIBS="$ax_cv_ptyfuncs_libs"
+    AC_SUBST(PTYFUNCS_LIBS)
+])
-- 
tg: (154e097..) t/xen/tools/ptyfuncs (depends on: t/xen/xl.event.children)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.