Just like virNetSocketNewConnectTCP, but it has one extra parameter
specifying the address family.
---
src/libvirt_private.syms | 1 +
src/rpc/virnetsocket.c | 9 +++++++++
src/rpc/virnetsocket.h | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 21bc615..e36403a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -935,6 +935,7 @@ virNetSocketNewConnectExternal;
virNetSocketNewConnectLibSSH2;
virNetSocketNewConnectSSH;
virNetSocketNewConnectTCP;
+virNetSocketNewConnectTCPHints;
virNetSocketNewConnectUNIX;
virNetSocketNewListenFD;
virNetSocketNewListenTCP;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index c4fd9ee..093f8a0 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -433,6 +433,14 @@ int virNetSocketNewConnectTCP(const char *nodename,
const char *service,
virNetSocketPtr *retsock)
{
+ return virNetSocketNewConnectTCPHints(nodename, service, retsock, AF_UNSPEC);
+}
+
+int virNetSocketNewConnectTCPHints(const char *nodename,
+ const char *service,
+ virNetSocketPtr *retsock,
+ int addressfamily)
+{
struct addrinfo *ai = NULL;
struct addrinfo hints;
int fd = -1;
@@ -449,6 +457,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;
+ hints.ai_family = addressfamily;
int e = getaddrinfo(nodename, service, &hints, &ai);
if (e != 0) {
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index 7392c72..bb8e7fe 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -61,6 +61,10 @@ int virNetSocketNewListenFD(int fd,
int virNetSocketNewConnectTCP(const char *nodename,
const char *service,
virNetSocketPtr *addr);
+int virNetSocketNewConnectTCPHints(const char *nodename,
+ const char *service,
+ virNetSocketPtr *retsock,
+ int addressfamily);
int virNetSocketNewConnectUNIX(const char *path,
bool spawnDaemon,
--
1.8.1.5