From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/2] io: move fd_is_socket() into common sockets code
Date: Thu, 21 Dec 2017 15:59:04 +0000 [thread overview]
Message-ID: <20171221155905.3793-2-berrange@redhat.com> (raw)
In-Reply-To: <20171221155905.3793-1-berrange@redhat.com>
The fd_is_socket() helper method is useful in a few places, so put it in
the common sockets code.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
include/qemu/sockets.h | 1 +
io/channel-util.c | 13 -------------
util/qemu-sockets.c | 13 +++++++++++++
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 4f7311b52a..5680880f5a 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -12,6 +12,7 @@ int inet_aton(const char *cp, struct in_addr *ia);
#include "qapi-types.h"
/* misc helpers */
+bool fd_is_socket(int fd);
int qemu_socket(int domain, int type, int protocol);
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int socket_set_cork(int fd, int v);
diff --git a/io/channel-util.c b/io/channel-util.c
index 0fb4bd0837..423d79845a 100644
--- a/io/channel-util.c
+++ b/io/channel-util.c
@@ -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)
{
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index af4f01211a..1d23f0b742 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -91,6 +91,19 @@ NetworkAddressFamily inet_netfamily(int family)
return NETWORK_ADDRESS_FAMILY_UNKNOWN;
}
+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;
+}
+
+
/*
* Matrix we're trying to apply
*
--
2.14.3
next prev parent reply other threads:[~2017-12-21 15:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 15:59 [Qemu-devel] [PATCH v2 0/2] Enable passing pre-opened chardev socket FDs Daniel P. Berrange
2017-12-21 15:59 ` Daniel P. Berrange [this message]
2017-12-21 18:47 ` [Qemu-devel] [PATCH v2 1/2] io: move fd_is_socket() into common sockets code Eric Blake
2017-12-22 8:55 ` Markus Armbruster
2017-12-22 10:57 ` Daniel P. Berrange
2017-12-21 15:59 ` [Qemu-devel] [PATCH v2 2/2] char: allow passing pre-opened socket file descriptor at startup Daniel P. Berrange
2017-12-21 18:56 ` Eric Blake
2017-12-22 10:06 ` Markus Armbruster
2017-12-22 10:26 ` Daniel P. Berrange
2017-12-22 13:21 ` Markus Armbruster
2017-12-21 16:17 ` [Qemu-devel] [PATCH v2 0/2] Enable passing pre-opened chardev socket FDs no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221155905.3793-2-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).