* [Qemu-devel] [RFC Patch 3/3] sockets: replace creating a new socket with the record one
[not found] <1464712247-11655-4-git-send-email-wexu@redhat.com>
@ 2016-06-22 15:27 ` Wei Xu
0 siblings, 0 replies; only message in thread
From: Wei Xu @ 2016-06-22 15:27 UTC (permalink / raw)
To: qemu-devel
There has been comments on this patch, but i forgot adding this patch to
the list, just forward it again.
Both server mode and client mode are supported.
Signed-off-by: Wei Xu <wexu@redhat.com>
---
util/qemu-sockets.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 0d6cd1f..e6429d7 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -713,10 +713,14 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
struct sockaddr_un un;
int sock, fd;
- sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
- error_setg_errno(errp, errno, "Failed to create Unix socket");
- return -1;
+ if (saddr->sockfd) {
+ sock = saddr->sockfd;
+ } else {
+ sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
+ if (sock < 0) {
+ error_setg_errno(errp, errno, "Failed to create Unix socket");
+ return -1;
+ }
}
memset(&un, 0, sizeof(un));
@@ -786,11 +790,16 @@ static int unix_connect_saddr(UnixSocketAddress
*saddr, Error **errp,
return -1;
}
- sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
- error_setg_errno(errp, errno, "Failed to create socket");
- return -1;
+ if (saddr->sockfd) {
+ sock = saddr->sockfd;
+ } else {
+ sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
+ if (sock < 0) {
+ error_setg_errno(errp, errno, "Failed to create socket");
+ return -1;
+ }
}
+
if (callback != NULL) {
connect_state = g_malloc0(sizeof(*connect_state));
connect_state->callback = callback;
--
2.7.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-22 15:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1464712247-11655-4-git-send-email-wexu@redhat.com>
2016-06-22 15:27 ` [Qemu-devel] [RFC Patch 3/3] sockets: replace creating a new socket with the record one Wei Xu
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).