On 11/02/2011 02:57 PM, Guido Günther wrote:
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.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@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-listFrom: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@xxxxxxxxxxx> 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; } } -- 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 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 |
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list