diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2017-12-21 12:55:20 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2018-03-13 18:06:06 +0000 |
commit | 58dc31f1a7dc6cd0f21bd51a34011ba366d36e53 (patch) | |
tree | 9bd13cbc470c53428618096546c042590ebbdc2f /util | |
parent | abd983c0e0beb4b15326e51a837e1b5177df0e08 (diff) |
sockets: move fd_is_socket() into common sockets code
The fd_is_socket() helper method is useful in a few places, so put it in
the common sockets code. Make the code more compact while moving it.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-sockets.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 7f13e8a338..fa79471647 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -91,6 +91,14 @@ NetworkAddressFamily inet_netfamily(int family) return NETWORK_ADDRESS_FAMILY_UNKNOWN; } +bool fd_is_socket(int fd) +{ + int optval; + socklen_t optlen = sizeof(optval); + return !qemu_getsockopt(fd, SOL_SOCKET, SO_TYPE, &optval, &optlen); +} + + /* * Matrix we're trying to apply * |