]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
Revert "gdbstub: Try unlinking the unix socket before binding"
authorMichael Tokarev <mjt@tls.msk.ru>
Thu, 25 Dec 2025 06:14:42 +0000 (09:14 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 Jan 2026 11:21:06 +0000 (14:21 +0300)
This reverts commit fccb744f41c69fec6fd92225fe907c6e69de5d44.

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>
gdbstub/user.c
stubs/meson.build
util/meson.build

index e233c598165ca1b10a5f2a89c87136df9af636ca..5e920a9b510a067a96696624a2ac757de88be075 100644 (file)
@@ -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;
index d3b551f4def6b85800a87b9b985073cb27016292..2b5fd8a88af59f9cf78837ac3a16676f6c624e10 100644 (file)
@@ -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
index 59e835a8d3f00b643560de524b7618ccf68691e2..a0cfdc30ba61c2ea7cfd85ec822005eaa04e67e4 100644 (file)
@@ -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