On Thu, Jun 27, 2019 at 10:54:34AM +0100, Daniel P. Berrangé wrote:
The getservent() APIs are not re-entrant safe so cannot be used in any threaded program. Add a wrapper around getaddrinfo() for resolving the service names to a port number.Signed-off-by: Daniel P. Berrangé <berra...@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virsocketaddr.c | 51 ++++++++++++++++++++++++++++++++++++++++ src/util/virsocketaddr.h | 2 ++ 3 files changed, 54 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ce614e04bd..1adf735a38 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2919,6 +2919,7 @@ virSocketAddrParseIPv4; virSocketAddrParseIPv6; virSocketAddrPrefixToNetmask; virSocketAddrPTRDomain; +virSocketAddrResolveService; virSocketAddrSetIPv4Addr; virSocketAddrSetIPv4AddrNetOrder; virSocketAddrSetIPv6Addr; diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 7a50cbe040..790bc0ebec 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -235,6 +235,57 @@ virSocketAddrParseIPv6(virSocketAddrPtr addr, const char *val) return virSocketAddrParse(addr, val, AF_INET6); } +/** + * virSocketAddrResolveService: + * @service: a service name or port number + * + * Resolve a service, which might be a plain port or service name, + * into a port number for IPv4/IPv6 usage + * + * Returns a numberic port number
or -1 on error
+ */
Reviewed-by: Ján Tomko <jto...@redhat.com> Jano
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list