[libvirt] Start of freeze for libvirt-0.9.7 and availability of rc1

We are now entering the freeze for libvirt-0.9.7 . We may make an exception for patch set which got a few round of reviews though, like Stefan's ones (v4 IIRC), and anything which we know may need fixing in the API before the release. I have made a release candidate 1 tarball (and associated rpms) at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc1.tar.gz I think I will make an rc2 on Wed or Thu and then try to make the release around Friday of the end of the week if things looks good. Please give it a try ! thanks in advance, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

2011/10/31 Daniel Veillard <veillard@redhat.com>:
We are now entering the freeze for libvirt-0.9.7 . We may make an exception for patch set which got a few round of reviews though, like Stefan's ones (v4 IIRC), and anything which we know may need fixing in the API before the release.
I have made a release candidate 1 tarball (and associated rpms) at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc1.tar.gz
I think I will make an rc2 on Wed or Thu and then try to make the release around Friday of the end of the week if things looks good.
Please give it a try !
thanks in advance,
Daniel
Compiles fine on MinGW. I also did a quick test with VirtualBox 4.1 on Windows and that works as well. -- Matthias Bolte http://photron.blogspot.com

On 31/10/2011, at 8:51 PM, Daniel Veillard wrote:
We are now entering the freeze for libvirt-0.9.7 . We may make an exception for patch set which got a few round of reviews though, like Stefan's ones (v4 IIRC), and anything which we know may need fixing in the API before the release.
I have made a release candidate 1 tarball (and associated rpms) at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc1.tar.gz
I think I will make an rc2 on Wed or Thu and then try to make the release around Friday of the end of the week if things looks good.
Please give it a try !
Fails on OSX 10.6.8, with this: make all-am CC libvirt_util_la-authhelper.lo CC libvirt_util_la-bitmap.lo CC libvirt_util_la-bridge.lo ... CCLD libvirt_driver_storage.la CCLD libvirt_iohelper CCLD libvirt_driver_remote.la Undefined symbols: "_ptsname_r", referenced from: _virFileOpenTty in libvirt_util.a(libvirt_util_la-util.o) ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [libvirt_iohelper] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Anyone feel like investigating? :) Regards and best wishes, Justin Clift -- Aeolus Community Manager http://www.aeolusproject.org

On 11/01/2011 04:44 AM, Justin Clift wrote:
Fails on OSX 10.6.8, with this:
make all-am
Undefined symbols: "_ptsname_r", referenced from: _virFileOpenTty in libvirt_util.a(libvirt_util_la-util.o) ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [libvirt_iohelper] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
Anyone feel like investigating? :)
Yeah, ptsname_r is not standardized, but is very useful; it sounds like something gnulib should be able to fix. I'll take a crack at it this week. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, Nov 01, 2011 at 08:20:16AM -0600, Eric Blake thus spake:
On 11/01/2011 04:44 AM, Justin Clift wrote:
Fails on OSX 10.6.8, with this:
make all-am
Undefined symbols: "_ptsname_r", referenced from: _virFileOpenTty in libvirt_util.a(libvirt_util_la-util.o) ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [libvirt_iohelper] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
Anyone feel like investigating? :)
Yeah, ptsname_r is not standardized, but is very useful; it sounds like something gnulib should be able to fix. I'll take a crack at it this week.
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
I received a similar build error for FreeBSD: storage/storage_driver.c:507: warning: null format string [-Wformat] CC libvirt_driver_storage_la-storage_backend.lo CC libvirt_driver_storage_la-storage_backend_fs.lo CC libvirt_driver_storage_la-storage_backend_scsi.lo CCLD libvirt_driver_storage.la CCLD libvirt_test.la CC libvirt_iohelper-iohelper.o CCLD libvirt_iohelper ./.libs/libvirt_util.a(libvirt_util_la-util.o)(.text+0x2249): In function `virFileOpenTty': : undefined reference to `ptsname_r' gmake[3]: *** [libvirt_iohelper] Error 1 gmake[3]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.7/src' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.7/src' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.7' gmake: *** [all] Error 2 *** Error code 1 -jgh -- Jason Helfman System Administrator experts-exchange.com http://www.experts-exchange.com/M_4830110.html E4AD 7CF1 1396 27F6 79DD 4342 5E92 AD66 8C8C FBA5

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. Reported by Justin Clift. --- I compile-tested this on Linux, but haven't yet tested this on MacOS, which is the driving force behind this patch. Meanwhile, it would be nice to run some LXC tests to ensure this all still works. I'm posting it now, to get the review started while I figure out how to run further tests. Gnulib changes are: * .gnulib 2394a60...84c3f9c (78):
New module 'unlinkat', split off from module 'openat'. New module 'fchmodat', split off from module 'openat'. putenv: indent #definition of "environ" to placate cppi gitlog-to-changelog: provide a ChangeLog-repair mechanism gitlog-to-changelog: avoid an infloop * MODULES.html.sh: Fix sed-script shell quoting and locale issues. fchownat: Improve description. * tests/test-stdalign.c (TEST_ALIGNMENT): Shrink back to 8. Fix my old ChangeLog entry to properly cite Bruno's email. alignof: Avoid collision with stdalign module. New module 'fchownat', split off from module 'openat'. stdalign: port better to MSVC and to Sun C 5.11 doc about some IRIX 5.3 problems. gitlog-to-changelog: fix git-log invocation gitlog-to-changelog: new option --append-dot ffsl, ffsll: Avoid compilation error due to 'restrict'. GNUmakefile: reenable "make syntax-check" for most projects gitlog-to-changelog: treat a message with only blank lines as empty test-parse-datetime.c: avoid new DST-related false positive test failure autoupdate fstat: Tweak documentation. Update documentation regarding 'largefile' module. maint.mk: don't maintain a second build-aux variable. Adjust to Bruno's comments. sys_socket: use stdalign, not alignof crypto libraries: use stdalign argp: use stdalign stdalign-tests: new module stdalign: new module raise test: Avoid a test failure on Linux/MIPS. nonblocking tests: Fix test failure on Linux/MIPS. utimensat: Work around problem on Linux/hppa. maint.mk: fix a bug in sc_prohibit_stddef_without_use maint.mk: exempt ENODATA from a syntax-check rule fts: close parent dir FD before returning from post-traversal fts_read autoupdate readme-release: improve safety of release prep instructions. errno, strerror-override: Support for MSVC 10. perror: Recognize when test program crashes. perror: Fix indentation. isfinite, isinf, isnan, signbit: Don't define as a macro in C++. relocatable-prog-wrapper: Don't leave object files behind. openpty, posix_openpt: Remove code duplication. unlockpt: Detect invalid argument. openpty: Avoid compilation error on AIX 6.1. autoupdate posix_openpt: Support for OpenBSD. posix_openpt test: Coding style. grantpt: Support --avoid=pt_chown. posix_openpt: Fix autoconf macro. openpty: Update comments. openpty: relax license pt_chown: use configmake to simplify build ptsname and others: relax license update from texinfo posix_openpt: remove spurious #endif maint.mk: Respect $(build_aux) in web-manual rule. posix_openpt: Fix compilation error. Support for old NeXTstep 3.3 frexp(). Support for old NeXTstep 3.3 sed. Support for old NeXTstep 3.3 gcc. posix_openpt: new module xstrtoll: Fix compilation failure. vasnprintf: Optimize bit search operation. vasnprintf: Fix comments. Tests for module 'integer_length_ll'. New module 'integer_length_ll'. Tests for module 'integer_length_l'. New module 'integer_length_l'. Tests for module 'integer_length'. New module 'integer_length'. popen: Fix dependency conditions. perror: Fix autoconf test. ffsl: Optimize on 64-bit platforms. autoupdate ffsl: Optimize on 32-bit platforms. ffsl, ffsll: Optimize for GCC. ffs, bcopy, memset: Support symbol renaming via config.h.
.gnulib | 2 +- bootstrap.conf | 3 ++ src/util/util.c | 62 ++++++++++++++++++++++++++++++++++++------------------ src/util/util.h | 5 ---- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/.gnulib b/.gnulib index 2394a60..84c3f9c 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit 2394a603e7586e671226478e5b15d924c3841f42 +Subproject commit 84c3f9cf54eaa688c5a1a26925886535079a91de diff --git a/bootstrap.conf b/bootstrap.conf index 0faa2e2..4557d2d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -68,6 +68,7 @@ mkstemps mktempd netdb nonblocking +openpty passfd perror physmem @@ -101,6 +102,7 @@ sys_wait termios time_r timegm +ttyname_r uname useless-if-before-free usleep @@ -168,6 +170,7 @@ tests_base=gnulib/tests gnulib_tool_option_extras="\ --lgpl=2\ --with-tests\ + --avoid=pt_chown\ " # Convince bootstrap to use multiple m4 directories. diff --git a/src/util/util.c b/src/util/util.c index bd52b21..5130403 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -45,10 +45,11 @@ #include <string.h> #include <signal.h> #include <termios.h> +#include <pty.h> + #if HAVE_LIBDEVMAPPER_H # include <libdevmapper.h> #endif -#include "c-ctype.h" #ifdef HAVE_PATHS_H # include <paths.h> @@ -65,6 +66,7 @@ # include <mntent.h> #endif +#include "c-ctype.h" #include "dirname.h" #include "virterror_internal.h" #include "logging.h" @@ -1177,47 +1179,65 @@ int virFileOpenTty(int *ttymaster, char **ttyName, int rawmode) { - int rc = -1; - - if ((*ttymaster = posix_openpt(O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0) - goto cleanup; - - if (unlockpt(*ttymaster) < 0) - goto cleanup; + int ret = -1; + int slave = -1; + char *name = NULL; - if (grantpt(*ttymaster) < 0) - goto cleanup; + /* Unfortunately, we can't use the name argument of openpty, since + * there is no guarantee on how large the buffer has to be. + * Likewise, we can't use the termios argument: we have to use + * read-modify-write since there is no portable way to initialize + * a struct termios without use of tcgetattr. */ + if (openpty(ttymaster, &slave, NULL, NULL, NULL) < 0) + return -1; + /* While Linux supports tcgetattr on either the master or the + * slave, Solaris requires it to be on the slave. */ if (rawmode) { struct termios ttyAttr; - if (tcgetattr(*ttymaster, &ttyAttr) < 0) + if (tcgetattr(slave, &ttyAttr) < 0) goto cleanup; cfmakeraw(&ttyAttr); - if (tcsetattr(*ttymaster, TCSADRAIN, &ttyAttr) < 0) + if (tcsetattr(slave, TCSADRAIN, &ttyAttr) < 0) goto cleanup; } + /* ttyname_r on the slave is required by POSIX, while ptsname_r on + * the master is a glibc extension, and the POSIX ptsname is not + * thread-safe. Since openpty gave us both descriptors, guess + * which way we will determine the name? :) */ if (ttyName) { - if (VIR_ALLOC_N(*ttyName, PATH_MAX) < 0) { - errno = ENOMEM; + /* Initial guess of 64 is generally sufficient; rely on ERANGE + * to tell us if we need to grow. */ + size_t len = 64; + int rc; + + if (VIR_ALLOC_N(name, len) < 0) goto cleanup; - } - if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) != 0) { - VIR_FREE(*ttyName); + while ((rc = ttyname_r(slave, name, len)) == ERANGE) { + if (VIR_RESIZE_N(name, len, len, len) < 0) + goto cleanup; + } + if (rc != 0) { + errno = rc; goto cleanup; } + *ttyName = name; + name = NULL; } - rc = 0; + ret = 0; cleanup: - if (rc != 0) + if (ret != 0) VIR_FORCE_CLOSE(*ttymaster); + VIR_FORCE_CLOSE(slave); + VIR_FREE(name); - return rc; + return ret; } #else /* WIN32 */ int virFileOpenTty(int *ttymaster ATTRIBUTE_UNUSED, diff --git a/src/util/util.h b/src/util/util.h index e869f1b..d8176a8 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -121,11 +121,6 @@ int virFileAbsPath(const char *path, int virFileOpenTty(int *ttymaster, char **ttyName, int rawmode); -int virFileOpenTtyAt(const char *ptmx, - int *ttymaster, - char **ttyName, - int rawmode); - char *virArgvToString(const char *const *argv); -- 1.7.4.4

On 11/03/2011 03:03 PM, 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. Reported by Justin Clift. ---
I compile-tested this on Linux, but haven't yet tested this on MacOS, which is the driving force behind this patch. Meanwhile, it would be nice to run some LXC tests to ensure this all still works. I'm posting it now, to get the review started while I figure out how to run further tests.
I've now confirmed that this patch is sufficient to get compilation working on FreeBSD 8.2; presumably, since MacOS is BSD-based, it will also help compilation there (although I haven't yet been able to test that). However, I also finally managed to test an LXC guest on Linux, and found out this patch is incorrect:
@@ -1177,47 +1179,65 @@ int virFileOpenTty(int *ttymaster, char **ttyName, int rawmode) { - int rc = -1; - - if ((*ttymaster = posix_openpt(O_RDWR|O_NOCTTY|O_NONBLOCK))< 0)
The old code set O_NONBLOCK on the master, but the new code fails to do that, because openpty() lacks a flag argument. Furthermore, neither the old nor new code was setting FD_CLOEXEC on the resulting fd; in general a good thing to do in a multi-threaded app. I've opened a glibc bug requesting that openpty be extended to give a flags variant that could allow O_NONBLOCK and O_CLOEXEC. Meanwhile, I'm working up a quick gnulib patch to provide the same functionality (although gnulib will eventually want to match the glibc naming convention, if Ulrich agrees to add it to glibc). But getting a new interface in place is not a pre-req to 0.9.7; so for now, I'll just post a v2 that sets the O_NONBLOCK flag properly. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Mon, Oct 31, 2011 at 05:51:55PM +0800, Daniel Veillard wrote:
We are now entering the freeze for libvirt-0.9.7 . We may make an exception for patch set which got a few round of reviews though, like Stefan's ones (v4 IIRC), and anything which we know may need fixing in the API before the release.
I have made a release candidate 1 tarball (and associated rpms) at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc1.tar.gz
I think I will make an rc2 on Wed or Thu and then try to make the release around Friday of the end of the week if things looks good.
Please give it a try ! Built fine on most Debian architectures:
https://buildd.debian.org/status/package.php?p=libvirt&suite=experimental The built failure on amd64 is due to virnetsockettest failing with: 5) Socket UNIX Accept... libvir: RPC error : Path /build/buildd-libvirt_0.9.7~rc1-1-amd64-EGXZTE/libvirt-0.9.7~rc1/debian/build/tests/virnetsockettest-test.sock too long for unix socket: Cannot allocate memory since the socket path doesn't fit in UNIX_PATH_MAX. Since exceeding the path shouldn't't be fatal I'm using the attached patch. Cheers, -- Guido

On 11/02/2011 12:57 PM, Guido Günther wrote:
Built fine on most Debian architectures:
https://buildd.debian.org/status/package.php?p=libvirt&suite=experimental
The built failure on amd64 is due to virnetsockettest failing with:
5) Socket UNIX Accept... libvir: RPC error : Path /build/buildd-libvirt_0.9.7~rc1-1-amd64-EGXZTE/libvirt-0.9.7~rc1/debian/build/tests/virnetsockettest-test.sock too long for unix socket: Cannot allocate memory
since the socket path doesn't fit in UNIX_PATH_MAX. Since exceeding the path shouldn't't be fatal I'm using the attached patch.
From: =?UTF-8?q?Guido=20G=C3=BCnther?=<agx@sigxcpu.org> Date: Wed, 2 Nov 2011 19:02:42 +0100 Subject: Skip socket test if we exceed UNIX_PATH_MAX.
As seen on the amd64 buildd with:
s/buildd/build/
+++ b/tests/virnetsockettest.c @@ -205,11 +205,13 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) if (progname[0] == '/') { if (virAsprintf(&path, "%s-test.sock", progname)< 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; }
Wrong place to be checking - virAsprintf() only fails on OOM (malloc failure), not on size fit, so your skip is unlikely to be hit. I agree that it's okay to skip the test if run in a subdirectory so deep that a Unix socket cannot be created with a name that long, but that should be done strlen() check just before virNetSocketNewListenUNIX, not by looking for malloc failure. And since we're most likely not out of memory, that may mean we also have a bug to fix in our error reporting quality within virNetSocketNewListenUNIX. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Nov 02, 2011 at 02:19:07PM -0600, Eric Blake wrote:
On 11/02/2011 12:57 PM, Guido Günther wrote:
Built fine on most Debian architectures:
https://buildd.debian.org/status/package.php?p=libvirt&suite=experimental
The built failure on amd64 is due to virnetsockettest failing with:
5) Socket UNIX Accept... libvir: RPC error : Path /build/buildd-libvirt_0.9.7~rc1-1-amd64-EGXZTE/libvirt-0.9.7~rc1/debian/build/tests/virnetsockettest-test.sock too long for unix socket: Cannot allocate memory
since the socket path doesn't fit in UNIX_PATH_MAX. Since exceeding the path shouldn't't be fatal I'm using the attached patch.
From: =?UTF-8?q?Guido=20G=C3=BCnther?=<agx@sigxcpu.org> Date: Wed, 2 Nov 2011 19:02:42 +0100 Subject: Skip socket test if we exceed UNIX_PATH_MAX.
As seen on the amd64 buildd with:
s/buildd/build/
This one was actually intentional. It's the build daemon, short buildd.
+++ b/tests/virnetsockettest.c @@ -205,11 +205,13 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) if (progname[0] == '/') { if (virAsprintf(&path, "%s-test.sock", progname)< 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; }
Wrong place to be checking - virAsprintf() only fails on OOM (malloc failure), not on size fit, so your skip is unlikely to be hit. I agree that it's okay to skip the test if run in a subdirectory so deep that a Unix socket cannot be created with a name that long, but that should be done strlen() check just before virNetSocketNewListenUNIX, not by looking for malloc failure. And since we're most likely not out of memory, that may mean we also have a bug to fix in our error reporting quality within virNetSocketNewListenUNIX.
Yes - the analysis was correct, the patch was horribly broken though. New versions attached. I wen't for a tempdir though to make sure the test can succeed. -- Guido

--- src/rpc/virnetsocket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index ab88e19..d832c53 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -327,7 +327,8 @@ int virNetSocketNewListenUNIX(const char *path, addr.data.un.sun_family = AF_UNIX; if (virStrcpyStatic(addr.data.un.sun_path, path) == NULL) { - virReportSystemError(ENOMEM, _("Path %s too long for unix socket"), path); + virReportSystemError(ENAMETOOLONG, + _("Path %s too long for unix socket"), path); goto error; } if (addr.data.un.sun_path[0] == '@') -- 1.7.7

On 11/02/2011 03:30 PM, Guido Günther wrote:
--- src/rpc/virnetsocket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index ab88e19..d832c53 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -327,7 +327,8 @@ int virNetSocketNewListenUNIX(const char *path,
addr.data.un.sun_family = AF_UNIX; if (virStrcpyStatic(addr.data.un.sun_path, path) == NULL) { - virReportSystemError(ENOMEM, _("Path %s too long for unix socket"), path); + virReportSystemError(ENAMETOOLONG, + _("Path %s too long for unix socket"), path);
ACK. [In fact, I had the exact same patch in my sandbox, but you beat me in posting it!] -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Nov 02, 2011 at 03:35:05PM -0600, Eric Blake wrote:
On 11/02/2011 03:30 PM, Guido Günther wrote:
--- src/rpc/virnetsocket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index ab88e19..d832c53 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -327,7 +327,8 @@ int virNetSocketNewListenUNIX(const char *path,
addr.data.un.sun_family = AF_UNIX; if (virStrcpyStatic(addr.data.un.sun_path, path) == NULL) { - virReportSystemError(ENOMEM, _("Path %s too long for unix socket"), path); + virReportSystemError(ENAMETOOLONG, + _("Path %s too long for unix socket"), path);
ACK. [In fact, I had the exact same patch in my sandbox, but you beat me in posting it!] Pushed. Thanks, -- Guido

to avoid exceeding UNIX_PATH_MAX --- tests/virnetsockettest.c | 60 ++++++++++++++++++++++++++++++--------------- 1 files changed, 40 insertions(+), 20 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 6320ce0..aeb4f3f 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -202,16 +202,23 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) int ret = -1; char *path; - if (progname[0] == '/') { - if (virAsprintf(&path, "%s-test.sock", progname) < 0) { - virReportOOMError(); - goto cleanup; - } - } else { - if (virAsprintf(&path, "%s/%s-test.sock", abs_builddir, progname) < 0) { - virReportOOMError(); - goto cleanup; - } + char *template; + char *tmpdir = NULL; + + template = strdup("/tmp/libvirt_XXXXXX"); + if (template == NULL) { + virReportOOMError(); + goto cleanup; + } + tmpdir = mkdtemp(template); + if (tmpdir == NULL) { + virReportSystemError(errno, "%s", + _("Failed to create temporary directory")); + goto cleanup; + } + if (virAsprintf(&path, "%s/test.sock", tmpdir) < 0) { + virReportOOMError(); + goto cleanup; } if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0) @@ -239,6 +246,9 @@ cleanup: VIR_FREE(path); virNetSocketFree(lsock); virNetSocketFree(ssock); + if (tmpdir) + rmdir(tmpdir); + VIR_FREE(template); return ret; } @@ -251,16 +261,23 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) int ret = -1; char *path; - if (progname[0] == '/') { - if (virAsprintf(&path, "%s-test.sock", progname) < 0) { - virReportOOMError(); - goto cleanup; - } - } else { - if (virAsprintf(&path, "%s/%s-test.sock", abs_builddir, progname) < 0) { - virReportOOMError(); - goto cleanup; - } + char *template; + char *tmpdir = NULL; + + template = strdup("/tmp/libvirt_XXXXXX"); + if (template == NULL) { + virReportOOMError(); + goto cleanup; + } + tmpdir = mkdtemp(template); + if (tmpdir == NULL) { + virReportSystemError(errno, "%s", + _("Failed to create temporary directory")); + goto cleanup; + } + if (virAsprintf(&path, "%s/test.sock", tmpdir) < 0) { + virReportOOMError(); + goto cleanup; } if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0) @@ -317,6 +334,9 @@ cleanup: virNetSocketFree(lsock); virNetSocketFree(ssock); virNetSocketFree(csock); + if (tmpdir) + rmdir(tmpdir); + VIR_FREE(template); return ret; } -- 1.7.7

On 11/02/2011 03:31 PM, Guido Günther wrote:
to avoid exceeding UNIX_PATH_MAX --- tests/virnetsockettest.c | 60 ++++++++++++++++++++++++++++++--------------- 1 files changed, 40 insertions(+), 20 deletions(-)
I like this better than Stefan's proposal (a temporary directory is better than unlink() on an open fd). ACK with one nit:
+ char *template; + char *tmpdir = NULL; + + template = strdup("/tmp/libvirt_XXXXXX");
No need to malloc() the template. Just do: char template[] = "/tmp/libvirt_XXXXXX";
+ if (template == NULL) { + virReportOOMError(); + goto cleanup; + }
then ditch this clause,
+ tmpdir = mkdtemp(template); + if (tmpdir == NULL) { + virReportSystemError(errno, "%s", + _("Failed to create temporary directory")); + goto cleanup; + } + if (virAsprintf(&path, "%s/test.sock", tmpdir)< 0) { + virReportOOMError(); + goto cleanup; }
if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(),&lsock)< 0) @@ -239,6 +246,9 @@ cleanup: VIR_FREE(path); virNetSocketFree(lsock); virNetSocketFree(ssock); + if (tmpdir) + rmdir(tmpdir); + VIR_FREE(template);
and drop this free, in both places. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Nov 02, 2011 at 03:39:54PM -0600, Eric Blake wrote:
On 11/02/2011 03:31 PM, Guido Günther wrote:
to avoid exceeding UNIX_PATH_MAX --- tests/virnetsockettest.c | 60 ++++++++++++++++++++++++++++++--------------- 1 files changed, 40 insertions(+), 20 deletions(-)
I like this better than Stefan's proposal (a temporary directory is better than unlink() on an open fd).
ACK with one nit:
+ char *template; + char *tmpdir = NULL; + + template = strdup("/tmp/libvirt_XXXXXX");
No need to malloc() the template. Just do:
char template[] = "/tmp/libvirt_XXXXXX";
This was actually the first version I had but it didn't seem to match libvirt's style (in the non-const form and I didn't find it in HACKING) so I went for the explicit strdup. New version attached. Cheers, -- Guido

On 11/02/2011 04:00 PM, Guido Günther wrote:
+ template = strdup("/tmp/libvirt_XXXXXX");
No need to malloc() the template. Just do:
char template[] = "/tmp/libvirt_XXXXXX";
This was actually the first version I had but it didn't seem to match libvirt's style (in the non-const form and I didn't find it in HACKING)
For something short-lived and cleanly scoped, stack allocation of less than 4k bytes is fine; in fact it is even preferable (more efficient, fewer failure points). Perhaps most existing uses of mk[ds]temp in libvirt.git happened to malloc, but that's probably because they are in situations where the final name must survive the scope of the function creating the file. I don't know that HACKING has to specifically speak to this, but I'll review any patch if you want to tweak it to make that clear.
so I went for the explicit strdup. New version attached.
ACK to this version. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Nov 02, 2011 at 04:28:54PM -0600, Eric Blake wrote:
On 11/02/2011 04:00 PM, Guido Günther wrote:
+ template = strdup("/tmp/libvirt_XXXXXX");
No need to malloc() the template. Just do:
char template[] = "/tmp/libvirt_XXXXXX";
This was actually the first version I had but it didn't seem to match libvirt's style (in the non-const form and I didn't find it in HACKING)
For something short-lived and cleanly scoped, stack allocation of less than 4k bytes is fine; in fact it is even preferable (more efficient, fewer failure points). Perhaps most existing uses of mk[ds]temp in libvirt.git happened to malloc, but that's probably because they are in situations where the final name must survive the scope of the function creating the file. I don't know that HACKING has to specifically speak to this, but I'll review any patch if you want to tweak it to make that clear.
I think it's fine as is, I was just wondering about only finding a single other usage.
so I went for the explicit strdup. New version attached.
ACK to this version.
Pushed now. Thanks, -- Guido

On Mon, Oct 31, 2011 at 05:51:55PM +0800, Daniel Veillard wrote:
We are now entering the freeze for libvirt-0.9.7 . We may make an exception for patch set which got a few round of reviews though, like Stefan's ones (v4 IIRC), and anything which we know may need fixing in the API before the release.
I have made a release candidate 1 tarball (and associated rpms) at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc1.tar.gz
I think I will make an rc2 on Wed or Thu and then try to make the release around Friday of the end of the week if things looks good.
Please give it a try ! Built fine on most Debian architectures:
https://buildd.debian.org/status/package.php?p=libvirt&suite=experimental
The built failure on amd64 is due to virnetsockettest failing with:
5) Socket UNIX Accept... libvir: RPC error : Path /build/buildd-libvirt_0.9.7~rc1-1-amd64-EGXZTE/libvirt-0.9.7~rc1/debian/build/tests/virnetsockettest-test.sock too long for unix socket: Cannot allocate memory
since the socket path doesn't fit in UNIX_PATH_MAX. Since exceeding the path shouldn't't be fatal I'm using the attached patch. Cheers, -- Guido
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org> Date: Wed, 2 Nov 2011 19:02:42 +0100 Subject: Skip socket test if we exceed UNIX_PATH_MAX. As seen on the amd64 buildd with: 5) Socket UNIX Accept... libvir: RPC error : Path /build/buildd-libvirt_0.9.7~rc1-1-amd64-EGXZTE/libvirt-0.9.7~rc1/debian/build/tests/virnetsockettest-test.sock too long for unix socket: Cannot allocate memory --- tests/virnetsockettest.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 1b88605..d7c0c4f 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -205,11 +205,13 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) if (progname[0] == '/') { if (virAsprintf(&path, "%s-test.sock", progname) < 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; } } else { if (virAsprintf(&path, "%s/%s-test.sock", abs_builddir, progname) < 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; } } @@ -254,11 +256,13 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) if (progname[0] == '/') { if (virAsprintf(&path, "%s-test.sock", progname) < 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; } } else { if (virAsprintf(&path, "%s/%s-test.sock", abs_builddir, progname) < 0) { virReportOOMError(); + ret = EXIT_AM_SKIP; goto cleanup; } } -- This patch is not correct. The code is failing further below when calling virNetSocketNewListenUNIX. I am surprised if this makes it work for your test env since it shouldn't run out of memory there. The problem is obviously that the path exceeds 108 (UNIX_PATH_MAX) characters, the max. for the UnixIO socket path. The solution may either be to fall back to a path in /tmp (but why not do this always then) or to cut down the progname + abs_builddir pair to a max of ~97 chars or to
On 11/02/2011 02:57 PM, Guido Günther wrote: try to build in a shorter path... Maybe the following one works: diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 6320ce0..b5c14a1 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -25,6 +25,9 @@ #ifdef HAVE_IFADDRS_H # include <ifaddrs.h> #endif +#ifndef WIN32 +# include <sys/un.h> +#endif #include "testutils.h" #include "util.h" @@ -200,6 +203,8 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) virNetSocketPtr ssock = NULL; /* Server socket */ virNetSocketPtr csock = NULL; /* Client socket */ int ret = -1; + int tmpfd = -1; + struct sockaddr_un sun; char *path; if (progname[0] == '/') { @@ -214,6 +219,19 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) } } + if (strlen(path) >= sizeof(sun.sun_path)) { + if (!virStrcpy(path, "/tmp/test.sock.XXXXXX", sizeof(sun.sun_path))) { + VIR_DEBUG("Unexpected error using virStrcpyStatic"); + goto cleanup; + } + tmpfd = mkostemp(path, 0700); + if (tmpfd < 0) { + virReportSystemError(errno, "%s", + _("Failed to create temporary file")); + goto cleanup; + } + } + if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0) goto cleanup; @@ -236,6 +254,10 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) ret = 0; cleanup: + if (tmpfd >= 0) { + unlink(path); + VIR_FORCE_CLOSE(tmpfd); + } VIR_FREE(path); virNetSocketFree(lsock); virNetSocketFree(ssock); @@ -249,6 +271,8 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) virNetSocketPtr ssock = NULL; /* Server socket */ virNetSocketPtr csock = NULL; /* Client socket */ int ret = -1; + int tmpfd = -1; + struct sockaddr_un sun; char *path; if (progname[0] == '/') { @@ -263,6 +287,19 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) } } + if (strlen(path) >= sizeof(sun.sun_path)) { + if (!virStrcpy(path, "/tmp/test.sock.XXXXXX", sizeof(sun.sun_path))) { + VIR_DEBUG("Unexpected error using virStrcpyStatic"); + goto cleanup; + } + tmpfd = mkostemp(path, 0700); + if (tmpfd < 0) { + virReportSystemError(errno, "%s", + _("Failed to create temporary file")); + goto cleanup; + } + } + if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0) goto cleanup; @@ -313,6 +350,10 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) ret = 0; cleanup: + if (tmpfd >= 0) { + unlink(path); + VIR_FORCE_CLOSE(tmpfd); + } VIR_FREE(path); virNetSocketFree(lsock); virNetSocketFree(ssock); Stefan

On 11/02/2011 02:24 PM, Stefan Berger wrote:
@@ -214,6 +219,19 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED) } }
+ if (strlen(path) >= sizeof(sun.sun_path)) { + if (!virStrcpy(path, "/tmp/test.sock.XXXXXX", sizeof(sun.sun_path))) { + VIR_DEBUG("Unexpected error using virStrcpyStatic"); + goto cleanup; + } + tmpfd = mkostemp(path, 0700); + if (tmpfd < 0) { + virReportSystemError(errno, "%s", + _("Failed to create temporary file")); + goto cleanup; + } + } + if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0)
This relies on the guts of NewListenUNIX to do an unlink() of the file that we still have an open fd on, and create a socket in its place; which is slightly racy, not to mention non-portable to platforms where unlink() fails with open fds (then again, Unix sockets don't exist on those platforms - specifically mingw). But we already have precedence of skipping tests in deep hierarchies: TEST: daemon-conf .................................../../../../../tests/daemon-conf: skipping test: CWD too long SKIP: daemon-conf Maybe we should just skip instead of playing around with /tmp in that case? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Thanks to everybody who provided feedback and patches on rc1, I have made an rc2 available at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc2.tar.gz there is also the rpms rebuilds for Fedora 14. One think I noted while the rpm was building is the following warnings: CCLD libvirt_test.la *** Warning: Linking the shared library libvirt_test.la against the non-libtool *** objects probes.o is not portable! *** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable! CCLD libvirt-qemu.la I also get *** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable! when I build from the tree. I assume it's related to src/Makefile.am if WITH_DTRACE libvirt_la_BUILT_LIBADD += probes.o and maybe it expects some .lo instead, but I'm not sure how to tweak this correctly :) Anyway, please check that rc2 too. Eric do you think you will be able to fix the missing 'ptsname_r' in gnulib in time or should we make a small workaround for platforms lacking it for the release ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, Nov 03, 2011 at 06:19:25PM +0800, Daniel Veillard wrote:
Thanks to everybody who provided feedback and patches on rc1, I have made an rc2 available at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc2.tar.gz there is also the rpms rebuilds for Fedora 14. One think I noted while the rpm was building is the following warnings:
CCLD libvirt_test.la *** Warning: Linking the shared library libvirt_test.la against the non-libtool *** objects probes.o is not portable!
*** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable! CCLD libvirt-qemu.la
I also get
*** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable!
when I build from the tree. I assume it's related to src/Makefile.am
if WITH_DTRACE libvirt_la_BUILT_LIBADD += probes.o
and maybe it expects some .lo instead, but I'm not sure how to tweak this correctly :)
This is just libtool getting annoyed that it didn't create the .o file itself - it is created directly by dtrace, so there is no .lo file. There is no actual problem here. 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 :|

On 11/03/2011 04:19 AM, Daniel Veillard wrote:
Thanks to everybody who provided feedback and patches on rc1, I have made an rc2 available at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc2.tar.gz
*** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable!
when I build from the tree.
and maybe it expects some .lo instead, but I'm not sure how to tweak this correctly :)
Nothing to fix, unless you're willing to hack libtool to tell it that we specifically know that this is non-portable, but we are only doing it on Linux, where we know it works.
Anyway, please check that rc2 too. Eric do you think you will be able to fix the missing 'ptsname_r' in gnulib in time or should we make a small workaround for platforms lacking it for the release ?
I just posted a proposed patch for that: https://www.redhat.com/archives/libvir-list/2011-November/msg00210.html -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Nov 03, 2011 at 06:19:25PM +0800, Daniel Veillard wrote:
Thanks to everybody who provided feedback and patches on rc1, I have made an rc2 available at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc2.tar.gz there is also the rpms rebuilds for Fedora 14.
Builds fine now on Debian: https://buildd.debian.org/status/package.php?p=libvirt&suite=experimental packages will be available with the next mirror pulse. Cheers, -- Guido

On Thu, Nov 03, 2011 at 06:19:25PM +0800, Daniel Veillard wrote:
Thanks to everybody who provided feedback and patches on rc1, I have made an rc2 available at ftp://libvirt.org/libvirt/libvirt-0.9.7-rc2.tar.gz there is also the rpms rebuilds for Fedora 14.
I've discovered a problem with the file descriptor passing code we added to the remote protocol. Becaused the gnulib passfd() / recvfd() functions secretly send a single byte of data, as well as the FD, we need to handle EAGAIN when sending or receiving. Currently we don't, so when passing FDs we randomly get EAGAIN and the client connection gets killed off. Fixing this might require an RPC protocol change, which should obviously be done before the final release. 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 :|
participants (8)
-
Daniel P. Berrange
-
Daniel Veillard
-
Eric Blake
-
Guido Günther
-
Jason Helfman
-
Justin Clift
-
Matthias Bolte
-
Stefan Berger