@@ -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));
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(-) connect_state->callback = callback;