[libvirt] [PATCHv2] build: fix build on platforms without ptsname_r

Daniel P. Berrange berrange at redhat.com
Tue Nov 8 09:29:45 UTC 2011


On Fri, Nov 04, 2011 at 08:06:05PM -0600, Eric Blake wrote:
> MacOS lacks ptsname_r, and gnulib doesn't (yet) provide it.
> But we can avoid it altogether, by using gnulib openpty()
> instead.  Note that we do _not_ want the pt_chown module;
> all systems that we currently port to can either properly do
> openpty() and/or grantpt(), or lack ptys altogether; we are
> not porting to any system that requires us to deal with the
> hassle of installing a setuid pt_chown helper just to satisfy
> gnulib's ability to provide openpty() on even more platforms.
> 
> * .gnulib: Update to latest, for openpty fixes
> * bootstrap.conf (gnulib_modules): Add openpty, ttyname_r.
> (gnulib_tool_option_extras): Exclude pt_chown module.
> * src/util/util.c (virFileOpenTty): Rewrite in terms of openpty
> and ttyname_r.
> * src/util/util.h (virFileOpenTtyAt): Delete dead prototype.
> ---
> 
> Alas, this is just complicated enough that I don't feel comfortable
> pushing it under the build-breaker rule, even though I have verified
> that it fixes builds on both FreeBSD and Cygwin, as well as still
> behaves correctly with LXC containers on Linux.  Anyone willing to
> give this a review before 0.9.7 gets released?

Unfortunately it does not build on Mingw:

make[4]: Entering directory `/home/berrange/src/virt/libvirt/gnulib/lib'
  CC     glthread/lock.lo
  CC     openpty.lo
openpty.c:51:46: warning: 'struct winsize' declared inside parameter list
openpty.c:51:46: warning: 'struct termios' declared inside parameter list
openpty.c:50:1: error: conflicting types for 'openpty'
./pty.h:412:1: note: previous declaration of 'openpty' was here
openpty.c: In function 'openpty':
openpty.c:74:3: warning: implicit declaration of function 'grantpt'
openpty.c:79:3: warning: implicit declaration of function 'unlockpt'
openpty.c:83:3: warning: implicit declaration of function 'ptsname'
openpty.c:83:14: warning: assignment makes pointer from integer without a cast
openpty.c:107:5: warning: implicit declaration of function 'tcsetattr'
openpty.c:107:23: error: 'TCSAFLUSH' undeclared (first use in this function)
openpty.c:107:23: note: each undeclared identifier is reported only once for each function it appears in
openpty.c:109:19: error: 'TIOCSWINSZ' undeclared (first use in this function)
make[4]: *** [openpty.lo] Error 1


GNULIB does not even claim to support openpty on Mingw

  https://www.gnu.org/s/hello/manual/gnulib/openpty.html

The problem is that even though it doesn't support it on Mingw, it
still enables its replacement code, which then fails because Mingw
lacks any definition of  struct termios and struct winsize, let
alone the body of the function.

Unless someone spots an easy patch, it looks like we'll need to do
a 0.9.8 release of libvirt to revert this code

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list