]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Allow connecting to IPv6 server
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Jan 2026 09:08:29 +0000 (10:08 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Jan 2026 09:26:59 +0000 (10:26 +0100)
When connecting to a VMWare server, the hostname from URI is
resolved using esxUtil_ResolveHostname() which in turn calls
getaddrinfo(). But in the hints argument, we restrict the return
address to be IPv4 (AF_INET) which obviously fails if the address
to resolve is an IPv6 address. Set the hint to AF_UNSPEC which
allows both IPv4 and IPv6. While at it, also allow IPv4 addresses
mapped in IPv6 by setting AI_V4MAPPED flag.

Resolves: https://issues.redhat.com/browse/RHEL-138300
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/esx/esx_util.c

index 88b3dc893ff453bb8cc68d35381fcdb023c65b87..a6275babd5423fb2056e278cfa13ea8bf5f17674 100644 (file)
@@ -275,8 +275,8 @@ esxUtil_ResolveHostname(const char *hostname, char **ipAddress)
     int errcode;
     g_autofree char *address = NULL;
 
-    hints.ai_flags = AI_ADDRCONFIG;
-    hints.ai_family = AF_INET;
+    hints.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED;
+    hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
     hints.ai_protocol = 0;