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>
This commit is contained in:
Daniel P. Berrange 2017-12-21 12:55:20 +00:00 committed by Daniel P. Berrangé
parent abd983c0e0
commit 58dc31f1a7
6 changed files with 90 additions and 13 deletions

View file

@ -24,19 +24,6 @@
#include "io/channel-socket.h"
static bool fd_is_socket(int fd)
{
int optval;
socklen_t optlen;
optlen = sizeof(optval);
return qemu_getsockopt(fd,
SOL_SOCKET,
SO_TYPE,
(char *)&optval,
&optlen) == 0;
}
QIOChannel *qio_channel_new_fd(int fd,
Error **errp)
{