int socket_connect(SocketAddress *addr, Error **errp, NonBlockingConnectHandler *callback, void *opaque) { int fd; switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: fd = inet_connect_saddr(addr->u.inet.data, errp, callback, opaque); break; case SOCKET_ADDRESS_KIND_UNIX: fd = unix_connect_saddr(addr->u.q_unix.data, errp, callback, opaque); break; case SOCKET_ADDRESS_KIND_FD: fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp); if (fd >= 0 && callback) { qemu_set_nonblock(fd); callback(fd, NULL, opaque); } break; case SOCKET_ADDRESS_KIND_VSOCK: fd = vsock_connect_saddr(addr->u.vsock.data, errp, callback, opaque); break; default: abort(); } return fd; }
int socket_connect(SocketAddress *addr, Error **errp) { int fd; switch (addr->type) { case SOCKET_ADDRESS_TYPE_INET: fd = inet_connect_saddr(&addr->u.inet, errp); break; case SOCKET_ADDRESS_TYPE_UNIX: fd = unix_connect_saddr(&addr->u.q_unix, errp); break; case SOCKET_ADDRESS_TYPE_FD: fd = monitor_get_fd(cur_mon, addr->u.fd.str, errp); break; case SOCKET_ADDRESS_TYPE_VSOCK: fd = vsock_connect_saddr(&addr->u.vsock, errp); break; default: abort(); } return fd; }
int unix_connect(const char *path, Error **errp) { UnixSocketAddress *saddr; int sock; saddr = g_new0(UnixSocketAddress, 1); saddr->path = g_strdup(path); sock = unix_connect_saddr(saddr, errp); qapi_free_UnixSocketAddress(saddr); return sock; }
int unix_nonblocking_connect(const char *path, NonBlockingConnectHandler *callback, void *opaque, Error **errp) { UnixSocketAddress *saddr; int sock = -1; g_assert(callback != NULL); saddr = g_new0(UnixSocketAddress, 1); saddr->path = g_strdup(path); sock = unix_connect_saddr(saddr, errp, callback, opaque); qapi_free_UnixSocketAddress(saddr); return sock; }