summaryrefslogtreecommitdiff
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 0d6cd1f4ef..5d03695d10 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -997,6 +997,24 @@ int socket_listen(SocketAddress *addr, Error **errp)
return fd;
}
+void socket_listen_cleanup(int fd, Error **errp)
+{
+ SocketAddress *addr;
+
+ addr = socket_local_address(fd, errp);
+
+ if (addr->type == SOCKET_ADDRESS_KIND_UNIX
+ && addr->u.q_unix.data->path) {
+ if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
+ error_setg_errno(errp, errno,
+ "Failed to unlink socket %s",
+ addr->u.q_unix.data->path);
+ }
+ }
+
+ g_free(addr);
+}
+
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
{
int fd;