@@ -939,6 +939,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
struct sockaddr_un un;
int sock, rc;
size_t pathlen;
+ socklen_t serverlen;
if (saddr->path == NULL) {
error_setg(errp, "unix connect: no path specified");
@@ -963,10 +964,18 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
un.sun_family = AF_UNIX;
memcpy(un.sun_path, saddr->path, pathlen);
+ if (saddr->path[0] == '@') {
+ un.sun_path[0] = '\0';
+ serverlen = strlen(saddr->path) + offsetof(struct sockaddr_un, sun_path);
+ }
+ else {
+ serverlen = sizeof(un);
+ }
+
/* connect to peer */
do {
rc = 0;
- if (connect(sock, (struct sockaddr *) &un, sizeof(un)) < 0) {
+ if (connect(sock, (struct sockaddr *) &un, serverlen) < 0) {
rc = -errno;
}
} while (rc == -EINTR);
unix_connect_saddr now support abstract address type By default qemu does not support abstract UNIX domain socket address. Add this ability to make qemu handy when abstract address is needed. Abstract address is marked by prefixing the address name with a '@'. Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> --- util/qemu-sockets.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)