master
c 59 lines 1.4 KB
Raw
1 /*
2 * Standalone VNC server connecting to QEMU via D-Bus display interface.
3 *
4 * Copyright (C) 2026 Red Hat, Inc.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #include "qemu/osdep.h"
10
11 #include "qemu/error-report.h"
12 #include "qemu-vnc.h"
13
14 static GDBusConnection *
15 dbus_p2p_from_fd(int fd)
16 {
17 g_autoptr(GError) err = NULL;
18 g_autoptr(GSocket) socket = NULL;
19 g_autoptr(GSocketConnection) socketc = NULL;
20 GDBusConnection *conn;
21
22 socket = g_socket_new_from_fd(fd, &err);
23 if (!socket) {
24 error_report("Failed to create socket: %s", err->message);
25 return NULL;
26 }
27
28 socketc = g_socket_connection_factory_create_connection(socket);
29 if (!socketc) {
30 error_report("Failed to create socket connection");
31 return NULL;
32 }
33
34 conn = g_dbus_connection_new_sync(
35 G_IO_STREAM(socketc), NULL,
36 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
37 G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING,
38 NULL, NULL, &err);
39 if (!conn) {
40 error_report("Failed to create D-Bus connection: %s", err->message);
41 return NULL;
42 }
43
44 return conn;
45 }
46
47 static gpointer
48 p2p_server_setup_thread(gpointer data)
49 {
50 return dbus_p2p_from_fd(GPOINTER_TO_INT(data));
51 }
52
53 GThread *
54 p2p_dbus_thread_new(int fd)
55 {
56 return g_thread_new("p2p-server-setup",
57 p2p_server_setup_thread,
58 GINT_TO_POINTER(fd));
59 }