mirror of
https://github.com/qemu/qemu.git
synced 2026-02-03 21:29:17 +00:00
Revert "gdbstub: Try unlinking the unix socket before binding"
This reverts commit fccb744f41.
This commit introduced dependency of linux-user on qemu-sockets.c.
The latter includes handling of various socket types, while gdbstub
only needs unix sockets. Including different kinds of sockets
makes it more problematic to build linux-user statically.
The original issue - the need to unlink unix socket before binding -
will be addressed in the next change.
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
@@ -314,10 +314,12 @@ static bool gdb_accept_socket(int gdb_fd)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int gdbserver_open_socket(const char *path, Error **errp)
|
||||
static int gdbserver_open_socket(const char *path)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
struct sockaddr_un sockaddr = {};
|
||||
const char *pid_placeholder;
|
||||
int fd, ret;
|
||||
|
||||
pid_placeholder = strstr(path, "%d");
|
||||
if (pid_placeholder != NULL) {
|
||||
@@ -327,7 +329,28 @@ static int gdbserver_open_socket(const char *path, Error **errp)
|
||||
path = buf->str;
|
||||
}
|
||||
|
||||
return unix_listen(path, errp);
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
perror("create socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sockaddr.sun_family = AF_UNIX;
|
||||
pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path);
|
||||
ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
|
||||
if (ret < 0) {
|
||||
perror("bind socket");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
ret = listen(fd, 1);
|
||||
if (ret < 0) {
|
||||
perror("listen socket");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static bool gdb_accept_tcp(int gdb_fd)
|
||||
@@ -483,7 +506,7 @@ bool gdbserver_start(const char *args, Error **errp)
|
||||
if (port > 0) {
|
||||
gdb_fd = gdbserver_open_port(port, errp);
|
||||
} else {
|
||||
gdb_fd = gdbserver_open_socket(port_or_path, errp);
|
||||
gdb_fd = gdbserver_open_socket(port_or_path);
|
||||
}
|
||||
if (gdb_fd < 0) {
|
||||
return false;
|
||||
|
||||
@@ -61,8 +61,6 @@ if have_user
|
||||
if not have_system
|
||||
stub_ss.add(files('qdev.c'))
|
||||
endif
|
||||
|
||||
stub_ss.add(files('monitor-internal.c'))
|
||||
endif
|
||||
|
||||
if have_system
|
||||
|
||||
@@ -83,8 +83,6 @@ if have_block or have_ga
|
||||
util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
|
||||
util_ss.add(files(f'coroutine-@coroutine_backend@.c'))
|
||||
util_ss.add(files('thread-pool.c', 'qemu-timer.c'))
|
||||
endif
|
||||
if have_block or have_ga or have_user
|
||||
util_ss.add(files('qemu-sockets.c'))
|
||||
endif
|
||||
if have_block
|
||||
|
||||
Reference in New Issue
Block a user