qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure
@ 2016-03-15 14:46 Daniel P. Berrange
  2016-03-15 14:53 ` [Qemu-devel] [PULL v1] io: stronger check for support for IPv4/6 Daniel P. Berrange
  2016-03-15 16:43 ` [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel P. Berrange @ 2016-03-15 14:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 618a5a8bc52ba0f2ecbb3dffd01e657f4d841f75:

  Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2016-03-14 16:22:17 +0000)

are available in the git repository at:

  git://github.com/berrange/qemu tags/pull-io-next-2016-03-15-1

for you to fetch changes up to cfd47a71df51047833d182e9e97244e7816b57da:

  io: stronger check for support for IPv4/6 (2016-03-15 13:55:52 +0000)

----------------------------------------------------------------
Merge I/O fixes

----------------------------------------------------------------

Travis successful build:

  https://travis-ci.org/berrange/qemu/builds/116126369

Daniel P. Berrange (1):
  io: stronger check for support for IPv4/6

 tests/test-io-channel-socket.c | 70 +++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 21 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PULL v1] io: stronger check for support for IPv4/6
  2016-03-15 14:46 [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Daniel P. Berrange
@ 2016-03-15 14:53 ` Daniel P. Berrange
  2016-03-15 16:43 ` [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel P. Berrange @ 2016-03-15 14:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

Instead of just checking for bind(), also check whether
getaddrinfo can resolve IPv6 addresses. This catches
failure when travis runs QEMU builds inside minimal
docker containers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 tests/test-io-channel-socket.c | 70 +++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 21 deletions(-)

diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
index ae665f5..87018ac 100644
--- a/tests/test-io-channel-socket.c
+++ b/tests/test-io-channel-socket.c
@@ -23,44 +23,72 @@
 #include "io/channel-util.h"
 #include "io-channel-helpers.h"
 
-static int check_bind(struct sockaddr *sa, socklen_t salen, bool *has_proto)
+#ifndef AI_ADDRCONFIG
+# define AI_ADDRCONFIG 0
+#endif
+#ifndef AI_V4MAPPED
+# define AI_V4MAPPED 0
+#endif
+#ifndef EAI_ADDRFAMILY
+# define EAI_ADDRFAMILY 0
+#endif
+
+static int check_bind(const char *hostname, bool *has_proto)
 {
-    int fd;
+    int fd = -1;
+    struct addrinfo ai, *res = NULL;
+    int rc;
+    int ret = -1;
+
+    memset(&ai, 0, sizeof(ai));
+    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
+    ai.ai_family = AF_UNSPEC;
+    ai.ai_socktype = SOCK_STREAM;
+
+    /* lookup */
+    rc = getaddrinfo(hostname, NULL, &ai, &res);
+    if (rc != 0) {
+        if (rc == EAI_ADDRFAMILY ||
+            rc == EAI_FAMILY) {
+            *has_proto = false;
+            goto done;
+        }
+        goto cleanup;
+    }
 
-    fd = socket(sa->sa_family, SOCK_STREAM, 0);
+    fd = qemu_socket(res->ai_family, res->ai_socktype, res->ai_protocol);
     if (fd < 0) {
-        return -1;
+        goto cleanup;
     }
 
-    if (bind(fd, sa, salen) < 0) {
-        close(fd);
+    if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {
         if (errno == EADDRNOTAVAIL) {
             *has_proto = false;
-            return 0;
+            goto done;
         }
-        return -1;
+        goto cleanup;
     }
 
-    close(fd);
     *has_proto = true;
-    return 0;
+ done:
+    ret = 0;
+
+ cleanup:
+    if (fd != -1) {
+        close(fd);
+    }
+    if (res) {
+        freeaddrinfo(res);
+    }
+    return ret;
 }
 
 static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
 {
-    struct sockaddr_in sin = {
-        .sin_family = AF_INET,
-        .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },
-    };
-    struct sockaddr_in6 sin6 = {
-        .sin6_family = AF_INET6,
-        .sin6_addr = IN6ADDR_LOOPBACK_INIT,
-    };
-
-    if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) {
+    if (check_bind("127.0.0.1", has_ipv4) < 0) {
         return -1;
     }
-    if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) {
+    if (check_bind("::1", has_ipv6) < 0) {
         return -1;
     }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure
  2016-03-15 14:46 [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Daniel P. Berrange
  2016-03-15 14:53 ` [Qemu-devel] [PULL v1] io: stronger check for support for IPv4/6 Daniel P. Berrange
@ 2016-03-15 16:43 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-03-15 16:43 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: QEMU Developers

On 15 March 2016 at 14:46, Daniel P. Berrange <berrange@redhat.com> wrote:
> The following changes since commit 618a5a8bc52ba0f2ecbb3dffd01e657f4d841f75:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2016-03-14 16:22:17 +0000)
>
> are available in the git repository at:
>
>   git://github.com/berrange/qemu tags/pull-io-next-2016-03-15-1
>
> for you to fetch changes up to cfd47a71df51047833d182e9e97244e7816b57da:
>
>   io: stronger check for support for IPv4/6 (2016-03-15 13:55:52 +0000)
>
> ----------------------------------------------------------------
> Merge I/O fixes
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-15 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15 14:46 [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Daniel P. Berrange
2016-03-15 14:53 ` [Qemu-devel] [PULL v1] io: stronger check for support for IPv4/6 Daniel P. Berrange
2016-03-15 16:43 ` [Qemu-devel] [PULL v1] Merge I/O fix for ipv6/travis failure Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).