summaryrefslogtreecommitdiffstats
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
authorDaniel P. Berrange2017-12-21 13:55:20 +0100
committerDaniel P. Berrangé2018-03-13 19:06:06 +0100
commit58dc31f1a7dc6cd0f21bd51a34011ba366d36e53 (patch)
tree9bd13cbc470c53428618096546c042590ebbdc2f /util/qemu-sockets.c
parentsockets: strengthen test suite IP protocol availability checks (diff)
downloadqemu-58dc31f1a7dc6cd0f21bd51a34011ba366d36e53.tar.gz
qemu-58dc31f1a7dc6cd0f21bd51a34011ba366d36e53.tar.xz
qemu-58dc31f1a7dc6cd0f21bd51a34011ba366d36e53.zip
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/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c8
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
*