aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-04-05 11:03:18 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-04-05 11:03:18 +0100
commitcc621a9838cb045a370717a764907a6d6c47fa76 (patch)
treeb793ec320c34e4b9baccffdff724d14f916f797e /util
parent972e3ca3c1272419578627a107bdbc19a066c6ee (diff)
parent2354bebaa408b97adf008d3e07f439300b0a5c06 (diff)
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* FreeBSD build fixes (atomics, qapi/error.h) * x86 KVM fixes (SynIC, KVM_GET/SET_MSRS) * Memory API doc fix * checkpatch fix * Chardev and socket fixes * NBD fixes * exec.c SEGV fix # gpg: Signature made Tue 05 Apr 2016 10:47:49 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: net: fix missing include of qapi/error.h in netmap.c nbd: Fix poor debug message include/qemu/atomic: add compile time asserts cpus: don't use atomic_read for vm_clock_warp_start nbd: don't request FUA on FLUSH doc/memory: update MMIO section char: ensure all clients are in non-blocking mode char: fix broken EAGAIN retry on OS-X due to errno clobbering util: retry getaddrinfo if getting EAI_BADFLAGS with AI_V4MAPPED checkpatch: add target_ulong to typelist target-i386: assert that KVM_GET/SET_MSRS can set all requested MSRs target-i386: do not pass MSR_TSC_AUX to KVM ioctls if CPUID bit is not set memory: fix segv on qemu_ram_free(block=0x0) target-i386/kvm: Hyper-V VMBus hypercalls blank handlers update Linux headers to 4.6 Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-sockets.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b87e17fa56..0d536911c9 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -29,6 +29,7 @@
#ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0
#endif
+
#ifndef AI_V4MAPPED
# define AI_V4MAPPED 0
#endif
@@ -354,10 +355,14 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
struct addrinfo ai, *res;
int rc;
Error *err = NULL;
+ static int useV4Mapped = 1;
memset(&ai, 0, sizeof(ai));
- ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
+ ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+ if (atomic_read(&useV4Mapped)) {
+ ai.ai_flags |= AI_V4MAPPED;
+ }
ai.ai_family = inet_ai_family_from_address(saddr, &err);
ai.ai_socktype = SOCK_STREAM;
@@ -373,6 +378,18 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
/* lookup */
rc = getaddrinfo(saddr->host, saddr->port, &ai, &res);
+
+ /* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but
+ * then don't implement it in their getaddrinfo(). Detect
+ * this and retry without the flag since that's preferrable
+ * to a fatal error
+ */
+ if (rc == EAI_BADFLAGS &&
+ (ai.ai_flags & AI_V4MAPPED)) {
+ atomic_set(&useV4Mapped, 0);
+ ai.ai_flags &= ~AI_V4MAPPED;
+ rc = getaddrinfo(saddr->host, saddr->port, &ai, &res);
+ }
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s",
saddr->host, saddr->port, gai_strerror(rc));