提交 01b601f0 编写于 作者: P Peter Maydell

Merge remote-tracking branch 'remotes/berrange/tags/pull-qio-2016-10-27-1' into staging

Merge qio 2016/10/27 v1

# gpg: Signature made Thu 27 Oct 2016 13:54:03 BST
# gpg:                using RSA key 0xBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/pull-qio-2016-10-27-1:
  main: set names for main loop sources created
  vnc: set name for all I/O channels created
  migration: set name for all I/O channels created
  char: set name for all I/O channels created
  nbd: set name for all I/O channels created
  io: add ability to set a name for IO channels
  io: Add a QIOChannelSocket cleanup test
  io: set LISTEN flag explicitly for listen sockets
  io: Introduce a qio_channel_set_feature() helper
  io: Use qio_channel_has_feature() where applicable
  io: Fix double shift usages on QIOChannel features

Conflicts:
	qemu-char.c
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
...@@ -307,6 +307,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, ...@@ -307,6 +307,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
Error *local_err = NULL; Error *local_err = NULL;
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
qio_channel_socket_connect_sync(sioc, qio_channel_socket_connect_sync(sioc,
saddr, saddr,
......
...@@ -44,6 +44,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition, ...@@ -44,6 +44,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
return TRUE; return TRUE;
} }
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
nbd_client_new(NULL, cioc, nbd_client_new(NULL, cioc,
nbd_server->tlscreds, NULL, nbd_server->tlscreds, NULL,
nbd_client_put); nbd_client_put);
...@@ -111,6 +112,8 @@ void qmp_nbd_server_start(SocketAddress *addr, ...@@ -111,6 +112,8 @@ void qmp_nbd_server_start(SocketAddress *addr,
nbd_server = g_new0(NBDServerData, 1); nbd_server = g_new0(NBDServerData, 1);
nbd_server->watch = -1; nbd_server->watch = -1;
nbd_server->listen_ioc = qio_channel_socket_new(); nbd_server->listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(nbd_server->listen_ioc),
"nbd-listener");
if (qio_channel_socket_listen_sync( if (qio_channel_socket_listen_sync(
nbd_server->listen_ioc, addr, errp) < 0) { nbd_server->listen_ioc, addr, errp) < 0) {
goto error; goto error;
......
...@@ -304,4 +304,15 @@ static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func) ...@@ -304,4 +304,15 @@ static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func)
} }
#endif #endif
#if !GLIB_CHECK_VERSION(2, 26, 0)
static inline void g_source_set_name(GSource *source, const char *name)
{
/* This is just a debugging aid, so leaving it a no-op */
}
static inline void g_source_set_name_by_id(guint tag, const char *name)
{
/* This is just a debugging aid, so leaving it a no-op */
}
#endif
#endif #endif
...@@ -40,9 +40,9 @@ typedef struct QIOChannelClass QIOChannelClass; ...@@ -40,9 +40,9 @@ typedef struct QIOChannelClass QIOChannelClass;
typedef enum QIOChannelFeature QIOChannelFeature; typedef enum QIOChannelFeature QIOChannelFeature;
enum QIOChannelFeature { enum QIOChannelFeature {
QIO_CHANNEL_FEATURE_FD_PASS = (1 << 0), QIO_CHANNEL_FEATURE_FD_PASS,
QIO_CHANNEL_FEATURE_SHUTDOWN = (1 << 1), QIO_CHANNEL_FEATURE_SHUTDOWN,
QIO_CHANNEL_FEATURE_LISTEN = (1 << 2), QIO_CHANNEL_FEATURE_LISTEN,
}; };
...@@ -79,6 +79,7 @@ typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc, ...@@ -79,6 +79,7 @@ typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc,
struct QIOChannel { struct QIOChannel {
Object parent; Object parent;
unsigned int features; /* bitmask of QIOChannelFeatures */ unsigned int features; /* bitmask of QIOChannelFeatures */
char *name;
#ifdef _WIN32 #ifdef _WIN32
HANDLE event; /* For use with GSource on Win32 */ HANDLE event; /* For use with GSource on Win32 */
#endif #endif
...@@ -148,6 +149,28 @@ struct QIOChannelClass { ...@@ -148,6 +149,28 @@ struct QIOChannelClass {
bool qio_channel_has_feature(QIOChannel *ioc, bool qio_channel_has_feature(QIOChannel *ioc,
QIOChannelFeature feature); QIOChannelFeature feature);
/**
* qio_channel_set_feature:
* @ioc: the channel object
* @feature: the feature to set support for
*
* Add channel support for the feature named in @feature.
*/
void qio_channel_set_feature(QIOChannel *ioc,
QIOChannelFeature feature);
/**
* qio_channel_set_name:
* @ioc: the channel object
* @name: the name of the channel
*
* Sets the name of the channel, which serves as an aid
* to debugging. The name is used when creating GSource
* watches for this channel.
*/
void qio_channel_set_name(QIOChannel *ioc,
const char *name);
/** /**
* qio_channel_readv_full: * qio_channel_readv_full:
* @ioc: the channel object * @ioc: the channel object
......
...@@ -55,7 +55,7 @@ qio_channel_socket_new(void) ...@@ -55,7 +55,7 @@ qio_channel_socket_new(void)
sioc->fd = -1; sioc->fd = -1;
ioc = QIO_CHANNEL(sioc); ioc = QIO_CHANNEL(sioc);
ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
#ifdef WIN32 #ifdef WIN32
ioc->event = CreateEvent(NULL, FALSE, FALSE, NULL); ioc->event = CreateEvent(NULL, FALSE, FALSE, NULL);
...@@ -72,9 +72,6 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc, ...@@ -72,9 +72,6 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
int fd, int fd,
Error **errp) Error **errp)
{ {
int val;
socklen_t len = sizeof(val);
if (sioc->fd != -1) { if (sioc->fd != -1) {
error_setg(errp, "Socket is already open"); error_setg(errp, "Socket is already open");
return -1; return -1;
...@@ -107,13 +104,9 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc, ...@@ -107,13 +104,9 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
#ifndef WIN32 #ifndef WIN32
if (sioc->localAddr.ss_family == AF_UNIX) { if (sioc->localAddr.ss_family == AF_UNIX) {
QIOChannel *ioc = QIO_CHANNEL(sioc); QIOChannel *ioc = QIO_CHANNEL(sioc);
ioc->features |= (1 << QIO_CHANNEL_FEATURE_FD_PASS); qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS);
} }
#endif /* WIN32 */ #endif /* WIN32 */
if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &val, &len) == 0 && val) {
QIOChannel *ioc = QIO_CHANNEL(sioc);
ioc->features |= (1 << QIO_CHANNEL_FEATURE_LISTEN);
}
return 0; return 0;
...@@ -220,6 +213,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc, ...@@ -220,6 +213,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
close(fd); close(fd);
return -1; return -1;
} }
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN);
return 0; return 0;
} }
...@@ -380,7 +374,8 @@ qio_channel_socket_accept(QIOChannelSocket *ioc, ...@@ -380,7 +374,8 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
#ifndef WIN32 #ifndef WIN32
if (cioc->localAddr.ss_family == AF_UNIX) { if (cioc->localAddr.ss_family == AF_UNIX) {
QIO_CHANNEL(cioc)->features |= (1 << QIO_CHANNEL_FEATURE_FD_PASS); QIOChannel *ioc_local = QIO_CHANNEL(cioc);
qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);
} }
#endif /* WIN32 */ #endif /* WIN32 */
...@@ -403,7 +398,8 @@ static void qio_channel_socket_finalize(Object *obj) ...@@ -403,7 +398,8 @@ static void qio_channel_socket_finalize(Object *obj)
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj); QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj);
if (ioc->fd != -1) { if (ioc->fd != -1) {
if (QIO_CHANNEL(ioc)->features & QIO_CHANNEL_FEATURE_LISTEN) { QIOChannel *ioc_local = QIO_CHANNEL(ioc);
if (qio_channel_has_feature(ioc_local, QIO_CHANNEL_FEATURE_LISTEN)) {
Error *err = NULL; Error *err = NULL;
socket_listen_cleanup(ioc->fd, &err); socket_listen_cleanup(ioc->fd, &err);
......
...@@ -111,8 +111,8 @@ qio_channel_tls_new_client(QIOChannel *master, ...@@ -111,8 +111,8 @@ qio_channel_tls_new_client(QIOChannel *master,
ioc = QIO_CHANNEL(tioc); ioc = QIO_CHANNEL(tioc);
tioc->master = master; tioc->master = master;
if (master->features & (1 << QIO_CHANNEL_FEATURE_SHUTDOWN)) { if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
} }
object_ref(OBJECT(master)); object_ref(OBJECT(master));
......
...@@ -497,8 +497,8 @@ qio_channel_websock_new_server(QIOChannel *master) ...@@ -497,8 +497,8 @@ qio_channel_websock_new_server(QIOChannel *master)
ioc = QIO_CHANNEL(wioc); ioc = QIO_CHANNEL(wioc);
wioc->master = master; wioc->master = master;
if (master->features & (1 << QIO_CHANNEL_FEATURE_SHUTDOWN)) { if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
} }
object_ref(OBJECT(master)); object_ref(OBJECT(master));
......
...@@ -30,6 +30,21 @@ bool qio_channel_has_feature(QIOChannel *ioc, ...@@ -30,6 +30,21 @@ bool qio_channel_has_feature(QIOChannel *ioc,
} }
void qio_channel_set_feature(QIOChannel *ioc,
QIOChannelFeature feature)
{
ioc->features |= (1 << feature);
}
void qio_channel_set_name(QIOChannel *ioc,
const char *name)
{
g_free(ioc->name);
ioc->name = g_strdup(name);
}
ssize_t qio_channel_readv_full(QIOChannel *ioc, ssize_t qio_channel_readv_full(QIOChannel *ioc,
const struct iovec *iov, const struct iovec *iov,
size_t niov, size_t niov,
...@@ -40,7 +55,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc, ...@@ -40,7 +55,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc); QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
if ((fds || nfds) && if ((fds || nfds) &&
!(ioc->features & (1 << QIO_CHANNEL_FEATURE_FD_PASS))) { !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
error_setg_errno(errp, EINVAL, error_setg_errno(errp, EINVAL,
"Channel does not support file descriptor passing"); "Channel does not support file descriptor passing");
return -1; return -1;
...@@ -60,7 +75,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc, ...@@ -60,7 +75,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc); QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
if ((fds || nfds) && if ((fds || nfds) &&
!(ioc->features & (1 << QIO_CHANNEL_FEATURE_FD_PASS))) { !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
error_setg_errno(errp, EINVAL, error_setg_errno(errp, EINVAL,
"Channel does not support file descriptor passing"); "Channel does not support file descriptor passing");
return -1; return -1;
...@@ -129,7 +144,13 @@ GSource *qio_channel_create_watch(QIOChannel *ioc, ...@@ -129,7 +144,13 @@ GSource *qio_channel_create_watch(QIOChannel *ioc,
GIOCondition condition) GIOCondition condition)
{ {
QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc); QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
return klass->io_create_watch(ioc, condition); GSource *ret = klass->io_create_watch(ioc, condition);
if (ioc->name) {
g_source_set_name(ret, ioc->name);
}
return ret;
} }
...@@ -275,24 +296,24 @@ void qio_channel_wait(QIOChannel *ioc, ...@@ -275,24 +296,24 @@ void qio_channel_wait(QIOChannel *ioc,
} }
#ifdef _WIN32
static void qio_channel_finalize(Object *obj) static void qio_channel_finalize(Object *obj)
{ {
QIOChannel *ioc = QIO_CHANNEL(obj); QIOChannel *ioc = QIO_CHANNEL(obj);
g_free(ioc->name);
#ifdef _WIN32
if (ioc->event) { if (ioc->event) {
CloseHandle(ioc->event); CloseHandle(ioc->event);
} }
}
#endif #endif
}
static const TypeInfo qio_channel_info = { static const TypeInfo qio_channel_info = {
.parent = TYPE_OBJECT, .parent = TYPE_OBJECT,
.name = TYPE_QIO_CHANNEL, .name = TYPE_QIO_CHANNEL,
.instance_size = sizeof(QIOChannel), .instance_size = sizeof(QIOChannel),
#ifdef _WIN32
.instance_finalize = qio_channel_finalize, .instance_finalize = qio_channel_finalize,
#endif
.abstract = true, .abstract = true,
.class_size = sizeof(QIOChannelClass), .class_size = sizeof(QIOChannelClass),
}; };
......
...@@ -161,9 +161,11 @@ int qemu_init_main_loop(Error **errp) ...@@ -161,9 +161,11 @@ int qemu_init_main_loop(Error **errp)
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL); qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD)); gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
src = aio_get_g_source(qemu_aio_context); src = aio_get_g_source(qemu_aio_context);
g_source_set_name(src, "aio-context");
g_source_attach(src, NULL); g_source_attach(src, NULL);
g_source_unref(src); g_source_unref(src);
src = iohandler_get_g_source(); src = iohandler_get_g_source();
g_source_set_name(src, "io-handler");
g_source_attach(src, NULL); g_source_attach(src, NULL);
g_source_unref(src); g_source_unref(src);
return 0; return 0;
......
...@@ -38,6 +38,7 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error ...@@ -38,6 +38,7 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error
return; return;
} }
qio_channel_set_name(ioc, "migration-exec-outgoing");
migration_channel_connect(s, ioc, NULL); migration_channel_connect(s, ioc, NULL);
object_unref(OBJECT(ioc)); object_unref(OBJECT(ioc));
} }
...@@ -64,6 +65,7 @@ void exec_start_incoming_migration(const char *command, Error **errp) ...@@ -64,6 +65,7 @@ void exec_start_incoming_migration(const char *command, Error **errp)
return; return;
} }
qio_channel_set_name(ioc, "migration-exec-incoming");
qio_channel_add_watch(ioc, qio_channel_add_watch(ioc,
G_IO_IN, G_IO_IN,
exec_accept_incoming_migration, exec_accept_incoming_migration,
......
...@@ -38,6 +38,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** ...@@ -38,6 +38,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **
return; return;
} }
qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
migration_channel_connect(s, ioc, NULL); migration_channel_connect(s, ioc, NULL);
object_unref(OBJECT(ioc)); object_unref(OBJECT(ioc));
} }
...@@ -65,6 +66,7 @@ void fd_start_incoming_migration(const char *infd, Error **errp) ...@@ -65,6 +66,7 @@ void fd_start_incoming_migration(const char *infd, Error **errp)
return; return;
} }
qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
qio_channel_add_watch(ioc, qio_channel_add_watch(ioc,
G_IO_IN, G_IO_IN,
fd_accept_incoming_migration, fd_accept_incoming_migration,
......
...@@ -1567,6 +1567,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) ...@@ -1567,6 +1567,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running)
* to do this we use a qemu_buf to hold the whole of the device state. * to do this we use a qemu_buf to hold the whole of the device state.
*/ */
bioc = qio_channel_buffer_new(4096); bioc = qio_channel_buffer_new(4096);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc)); fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc)); object_unref(OBJECT(bioc));
......
...@@ -1631,6 +1631,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis) ...@@ -1631,6 +1631,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis)
} }
bioc = qio_channel_buffer_new(length); bioc = qio_channel_buffer_new(length);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-loadvm-buffer");
ret = qemu_get_buffer(mis->from_src_file, ret = qemu_get_buffer(mis->from_src_file,
bioc->data, bioc->data,
length); length);
...@@ -2122,6 +2123,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) ...@@ -2122,6 +2123,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
if (!ioc) { if (!ioc) {
goto the_end; goto the_end;
} }
qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
f = qemu_fopen_channel_output(QIO_CHANNEL(ioc)); f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
ret = qemu_save_device_state(f); ret = qemu_save_device_state(f);
qemu_fclose(f); qemu_fclose(f);
...@@ -2154,6 +2156,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp) ...@@ -2154,6 +2156,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
if (!ioc) { if (!ioc) {
return; return;
} }
qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state");
f = qemu_fopen_channel_input(QIO_CHANNEL(ioc)); f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
migration_incoming_state_new(f); migration_incoming_state_new(f);
......
...@@ -100,6 +100,7 @@ static void socket_start_outgoing_migration(MigrationState *s, ...@@ -100,6 +100,7 @@ static void socket_start_outgoing_migration(MigrationState *s,
data->hostname = g_strdup(saddr->u.inet.data->host); data->hostname = g_strdup(saddr->u.inet.data->host);
} }
qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing");
qio_channel_socket_connect_async(sioc, qio_channel_socket_connect_async(sioc,
saddr, saddr,
socket_outgoing_migration, socket_outgoing_migration,
...@@ -146,6 +147,7 @@ static gboolean socket_accept_incoming_migration(QIOChannel *ioc, ...@@ -146,6 +147,7 @@ static gboolean socket_accept_incoming_migration(QIOChannel *ioc,
trace_migration_socket_incoming_accepted(); trace_migration_socket_incoming_accepted();
qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming");
migration_channel_process_incoming(migrate_get_current(), migration_channel_process_incoming(migrate_get_current(),
QIO_CHANNEL(sioc)); QIO_CHANNEL(sioc));
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
...@@ -162,6 +164,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr, ...@@ -162,6 +164,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
{ {
QIOChannelSocket *listen_ioc = qio_channel_socket_new(); QIOChannelSocket *listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(listen_ioc),
"migration-socket-listener");
if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
object_unref(OBJECT(listen_ioc)); object_unref(OBJECT(listen_ioc));
qapi_free_SocketAddress(saddr); qapi_free_SocketAddress(saddr);
......
...@@ -99,6 +99,7 @@ void migration_tls_channel_process_incoming(MigrationState *s, ...@@ -99,6 +99,7 @@ void migration_tls_channel_process_incoming(MigrationState *s,
} }
trace_migration_tls_incoming_handshake_start(); trace_migration_tls_incoming_handshake_start();
qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-incoming");
qio_channel_tls_handshake(tioc, qio_channel_tls_handshake(tioc,
migration_tls_incoming_handshake, migration_tls_incoming_handshake,
NULL, NULL,
...@@ -154,6 +155,7 @@ void migration_tls_channel_connect(MigrationState *s, ...@@ -154,6 +155,7 @@ void migration_tls_channel_connect(MigrationState *s,
} }
trace_migration_tls_outgoing_handshake_start(hostname); trace_migration_tls_outgoing_handshake_start(hostname);
qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing");
qio_channel_tls_handshake(tioc, qio_channel_tls_handshake(tioc,
migration_tls_outgoing_handshake, migration_tls_outgoing_handshake,
s, s,
......
...@@ -387,6 +387,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc, ...@@ -387,6 +387,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
if (!tioc) { if (!tioc) {
return NULL; return NULL;
} }
qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-client-tls");
data.loop = g_main_loop_new(g_main_context_default(), FALSE); data.loop = g_main_loop_new(g_main_context_default(), FALSE);
TRACE("Starting TLS handshake"); TRACE("Starting TLS handshake");
qio_channel_tls_handshake(tioc, qio_channel_tls_handshake(tioc,
......
...@@ -349,6 +349,7 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client, ...@@ -349,6 +349,7 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
return NULL; return NULL;
} }
qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-server-tls");
TRACE("Starting TLS handshake"); TRACE("Starting TLS handshake");
data.loop = g_main_loop_new(g_main_context_default(), FALSE); data.loop = g_main_loop_new(g_main_context_default(), FALSE);
qio_channel_tls_handshake(tioc, qio_channel_tls_handshake(tioc,
......
...@@ -1075,7 +1075,8 @@ static GSourceFuncs io_watch_poll_funcs = { ...@@ -1075,7 +1075,8 @@ static GSourceFuncs io_watch_poll_funcs = {
}; };
/* Can only be used for read */ /* Can only be used for read */
static guint io_add_watch_poll(QIOChannel *ioc, static guint io_add_watch_poll(CharDriverState *chr,
QIOChannel *ioc,
IOCanReadHandler *fd_can_read, IOCanReadHandler *fd_can_read,
QIOChannelFunc fd_read, QIOChannelFunc fd_read,
gpointer user_data, gpointer user_data,
...@@ -1083,6 +1084,7 @@ static guint io_add_watch_poll(QIOChannel *ioc, ...@@ -1083,6 +1084,7 @@ static guint io_add_watch_poll(QIOChannel *ioc,
{ {
IOWatchPoll *iwp; IOWatchPoll *iwp;
int tag; int tag;
char *name;
iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs,
sizeof(IOWatchPoll)); sizeof(IOWatchPoll));
...@@ -1093,6 +1095,10 @@ static guint io_add_watch_poll(QIOChannel *ioc, ...@@ -1093,6 +1095,10 @@ static guint io_add_watch_poll(QIOChannel *ioc,
iwp->src = NULL; iwp->src = NULL;
iwp->context = context; iwp->context = context;
name = g_strdup_printf("chardev-iowatch-%s", chr->label);
g_source_set_name((GSource *)iwp, name);
g_free(name);
tag = g_source_attach(&iwp->parent, context); tag = g_source_attach(&iwp->parent, context);
g_source_unref(&iwp->parent); g_source_unref(&iwp->parent);
return tag; return tag;
...@@ -1232,7 +1238,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr, ...@@ -1232,7 +1238,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr,
remove_fd_in_watch(chr); remove_fd_in_watch(chr);
if (s->ioc_in) { if (s->ioc_in) {
chr->fd_in_tag = io_add_watch_poll(s->ioc_in, chr->fd_in_tag = io_add_watch_poll(chr, s->ioc_in,
fd_chr_read_poll, fd_chr_read_poll,
fd_chr_read, chr, fd_chr_read, chr,
context); context);
...@@ -1261,6 +1267,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out, ...@@ -1261,6 +1267,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
{ {
CharDriverState *chr; CharDriverState *chr;
FDCharDriver *s; FDCharDriver *s;
char *name;
chr = qemu_chr_alloc(backend, errp); chr = qemu_chr_alloc(backend, errp);
if (!chr) { if (!chr) {
...@@ -1268,7 +1275,13 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out, ...@@ -1268,7 +1275,13 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
} }
s = g_new0(FDCharDriver, 1); s = g_new0(FDCharDriver, 1);
s->ioc_in = QIO_CHANNEL(qio_channel_file_new_fd(fd_in)); s->ioc_in = QIO_CHANNEL(qio_channel_file_new_fd(fd_in));
name = g_strdup_printf("chardev-file-in-%s", chr->label);
qio_channel_set_name(QIO_CHANNEL(s->ioc_in), name);
g_free(name);
s->ioc_out = QIO_CHANNEL(qio_channel_file_new_fd(fd_out)); s->ioc_out = QIO_CHANNEL(qio_channel_file_new_fd(fd_out));
name = g_strdup_printf("chardev-file-out-%s", chr->label);
qio_channel_set_name(QIO_CHANNEL(s->ioc_out), name);
g_free(name);
qemu_set_nonblock(fd_out); qemu_set_nonblock(fd_out);
s->chr = chr; s->chr = chr;
chr->opaque = s; chr->opaque = s;
...@@ -1448,6 +1461,7 @@ static gboolean pty_chr_timer(gpointer opaque) ...@@ -1448,6 +1461,7 @@ static gboolean pty_chr_timer(gpointer opaque)
static void pty_chr_rearm_timer(CharDriverState *chr, int ms) static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
{ {
PtyCharDriver *s = chr->opaque; PtyCharDriver *s = chr->opaque;
char *name;
if (s->timer_tag) { if (s->timer_tag) {
g_source_remove(s->timer_tag); g_source_remove(s->timer_tag);
...@@ -1455,10 +1469,14 @@ static void pty_chr_rearm_timer(CharDriverState *chr, int ms) ...@@ -1455,10 +1469,14 @@ static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
} }
if (ms == 1000) { if (ms == 1000) {
name = g_strdup_printf("pty-timer-secs-%s", chr->label);
s->timer_tag = g_timeout_add_seconds(1, pty_chr_timer, chr); s->timer_tag = g_timeout_add_seconds(1, pty_chr_timer, chr);
} else { } else {
name = g_strdup_printf("pty-timer-ms-%s", chr->label);
s->timer_tag = g_timeout_add(ms, pty_chr_timer, chr); s->timer_tag = g_timeout_add(ms, pty_chr_timer, chr);
} }
g_source_set_name_by_id(s->timer_tag, name);
g_free(name);
} }
/* Called with chr_write_lock held. */ /* Called with chr_write_lock held. */
...@@ -1587,7 +1605,7 @@ static void pty_chr_state(CharDriverState *chr, int connected) ...@@ -1587,7 +1605,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)
s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr); s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr);
} }
if (!chr->fd_in_tag) { if (!chr->fd_in_tag) {
chr->fd_in_tag = io_add_watch_poll(s->ioc, chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
pty_chr_read_poll, pty_chr_read_poll,
pty_chr_read, pty_chr_read,
chr, NULL); chr, NULL);
...@@ -1622,6 +1640,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id, ...@@ -1622,6 +1640,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
int master_fd, slave_fd; int master_fd, slave_fd;
char pty_name[PATH_MAX]; char pty_name[PATH_MAX];
ChardevCommon *common = backend->u.pty.data; ChardevCommon *common = backend->u.pty.data;
char *name;
master_fd = qemu_openpty_raw(&slave_fd, pty_name); master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) { if (master_fd < 0) {
...@@ -1654,6 +1673,9 @@ static CharDriverState *qemu_chr_open_pty(const char *id, ...@@ -1654,6 +1673,9 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
*be_opened = false; *be_opened = false;
s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd));
name = g_strdup_printf("chardev-pty-%s", chr->label);
qio_channel_set_name(QIO_CHANNEL(s->ioc), name);
g_free(name);
s->timer_tag = 0; s->timer_tag = 0;
return chr; return chr;
...@@ -2744,7 +2766,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr, ...@@ -2744,7 +2766,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr,
remove_fd_in_watch(chr); remove_fd_in_watch(chr);
if (s->ioc) { if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc, chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
udp_chr_read_poll, udp_chr_read_poll,
udp_chr_read, chr, udp_chr_read, chr,
context); context);
...@@ -2822,9 +2844,13 @@ static gboolean socket_reconnect_timeout(gpointer opaque); ...@@ -2822,9 +2844,13 @@ static gboolean socket_reconnect_timeout(gpointer opaque);
static void qemu_chr_socket_restart_timer(CharDriverState *chr) static void qemu_chr_socket_restart_timer(CharDriverState *chr)
{ {
TCPCharDriver *s = chr->opaque; TCPCharDriver *s = chr->opaque;
char *name;
assert(s->connected == 0); assert(s->connected == 0);
s->reconnect_timer = g_timeout_add_seconds(s->reconnect_time, s->reconnect_timer = g_timeout_add_seconds(s->reconnect_time,
socket_reconnect_timeout, chr); socket_reconnect_timeout, chr);
name = g_strdup_printf("chardev-socket-reconnect-%s", chr->label);
g_source_set_name_by_id(s->reconnect_timer, name);
g_free(name);
} }
static void check_report_connect_error(CharDriverState *chr, static void check_report_connect_error(CharDriverState *chr,
...@@ -3149,7 +3175,7 @@ static void tcp_chr_connect(void *opaque) ...@@ -3149,7 +3175,7 @@ static void tcp_chr_connect(void *opaque)
s->connected = 1; s->connected = 1;
if (s->ioc) { if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc, chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
tcp_chr_read_poll, tcp_chr_read_poll,
tcp_chr_read, tcp_chr_read,
chr, NULL); chr, NULL);
...@@ -3168,7 +3194,7 @@ static void tcp_chr_update_read_handler(CharDriverState *chr, ...@@ -3168,7 +3194,7 @@ static void tcp_chr_update_read_handler(CharDriverState *chr,
remove_fd_in_watch(chr); remove_fd_in_watch(chr);
if (s->ioc) { if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc, chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
tcp_chr_read_poll, tcp_chr_read_poll,
tcp_chr_read, chr, tcp_chr_read, chr,
context); context);
...@@ -3266,6 +3292,7 @@ static void tcp_chr_tls_init(CharDriverState *chr) ...@@ -3266,6 +3292,7 @@ static void tcp_chr_tls_init(CharDriverState *chr)
TCPCharDriver *s = chr->opaque; TCPCharDriver *s = chr->opaque;
QIOChannelTLS *tioc; QIOChannelTLS *tioc;
Error *err = NULL; Error *err = NULL;
gchar *name;
if (s->is_listen) { if (s->is_listen) {
tioc = qio_channel_tls_new_server( tioc = qio_channel_tls_new_server(
...@@ -3283,6 +3310,11 @@ static void tcp_chr_tls_init(CharDriverState *chr) ...@@ -3283,6 +3310,11 @@ static void tcp_chr_tls_init(CharDriverState *chr)
tcp_chr_disconnect(chr); tcp_chr_disconnect(chr);
return; return;
} }
name = g_strdup_printf("chardev-tls-%s-%s",
s->is_listen ? "server" : "client",
chr->label);
qio_channel_set_name(QIO_CHANNEL(tioc), name);
g_free(name);
object_unref(OBJECT(s->ioc)); object_unref(OBJECT(s->ioc));
s->ioc = QIO_CHANNEL(tioc); s->ioc = QIO_CHANNEL(tioc);
...@@ -3293,6 +3325,19 @@ static void tcp_chr_tls_init(CharDriverState *chr) ...@@ -3293,6 +3325,19 @@ static void tcp_chr_tls_init(CharDriverState *chr)
} }
static void tcp_chr_set_client_ioc_name(CharDriverState *chr,
QIOChannelSocket *sioc)
{
TCPCharDriver *s = chr->opaque;
char *name;
name = g_strdup_printf("chardev-tcp-%s-%s",
s->is_listen ? "server" : "client",
chr->label);
qio_channel_set_name(QIO_CHANNEL(sioc), name);
g_free(name);
}
static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc) static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc)
{ {
TCPCharDriver *s = chr->opaque; TCPCharDriver *s = chr->opaque;
...@@ -3338,6 +3383,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd) ...@@ -3338,6 +3383,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
if (!sioc) { if (!sioc) {
return -1; return -1;
} }
tcp_chr_set_client_ioc_name(chr, sioc);
ret = tcp_chr_new_client(chr, sioc); ret = tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
return ret; return ret;
...@@ -3379,6 +3425,7 @@ static int tcp_chr_wait_connected(CharDriverState *chr, Error **errp) ...@@ -3379,6 +3425,7 @@ static int tcp_chr_wait_connected(CharDriverState *chr, Error **errp)
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL); qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
} else { } else {
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
tcp_chr_set_client_ioc_name(chr, sioc);
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) { if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
return -1; return -1;
...@@ -4586,6 +4633,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque) ...@@ -4586,6 +4633,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
} }
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
tcp_chr_set_client_ioc_name(chr, sioc);
qio_channel_socket_connect_async(sioc, s->addr, qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected, qemu_chr_socket_connected,
chr, NULL); chr, NULL);
...@@ -4688,12 +4736,19 @@ static CharDriverState *qmp_chardev_open_socket(const char *id, ...@@ -4688,12 +4736,19 @@ static CharDriverState *qmp_chardev_open_socket(const char *id,
if (s->reconnect_time) { if (s->reconnect_time) {
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
tcp_chr_set_client_ioc_name(chr, sioc);
qio_channel_socket_connect_async(sioc, s->addr, qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected, qemu_chr_socket_connected,
chr, NULL); chr, NULL);
} else { } else {
if (s->is_listen) { if (s->is_listen) {
char *name;
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
name = g_strdup_printf("chardev-tcp-listener-%s", chr->label);
qio_channel_set_name(QIO_CHANNEL(sioc), name);
g_free(name);
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) { if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto error; goto error;
} }
...@@ -4735,6 +4790,8 @@ static CharDriverState *qmp_chardev_open_udp(const char *id, ...@@ -4735,6 +4790,8 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
ChardevUdp *udp = backend->u.udp.data; ChardevUdp *udp = backend->u.udp.data;
ChardevCommon *common = qapi_ChardevUdp_base(udp); ChardevCommon *common = qapi_ChardevUdp_base(udp);
QIOChannelSocket *sioc = qio_channel_socket_new(); QIOChannelSocket *sioc = qio_channel_socket_new();
char *name;
CharDriverState *chr;
if (qio_channel_socket_dgram_sync(sioc, if (qio_channel_socket_dgram_sync(sioc,
udp->local, udp->remote, udp->local, udp->remote,
...@@ -4742,7 +4799,13 @@ static CharDriverState *qmp_chardev_open_udp(const char *id, ...@@ -4742,7 +4799,13 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
return NULL; return NULL;
} }
return qemu_chr_open_udp(sioc, common, be_opened, errp); chr = qemu_chr_open_udp(sioc, common, be_opened, errp);
name = g_strdup_printf("chardev-udp-%s", chr->label);
qio_channel_set_name(QIO_CHANNEL(sioc), name);
g_free(name);
return chr;
} }
......
...@@ -491,6 +491,37 @@ static void test_io_channel_unix_fd_pass(void) ...@@ -491,6 +491,37 @@ static void test_io_channel_unix_fd_pass(void)
} }
g_free(fdrecv); g_free(fdrecv);
} }
static void test_io_channel_unix_listen_cleanup(void)
{
QIOChannelSocket *ioc;
struct sockaddr_un un;
int sock;
#define TEST_SOCKET "test-io-channel-socket.sock"
ioc = qio_channel_socket_new();
/* Manually bind ioc without calling the qio api to avoid setting
* the LISTEN feature */
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
snprintf(un.sun_path, sizeof(un.sun_path), "%s", TEST_SOCKET);
unlink(TEST_SOCKET);
bind(sock, (struct sockaddr *)&un, sizeof(un));
ioc->fd = sock;
ioc->localAddrLen = sizeof(ioc->localAddr);
getsockname(sock, (struct sockaddr *)&ioc->localAddr,
&ioc->localAddrLen);
g_assert(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS));
object_unref(OBJECT(ioc));
g_assert(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS));
unlink(TEST_SOCKET);
}
#endif /* _WIN32 */ #endif /* _WIN32 */
...@@ -562,6 +593,8 @@ int main(int argc, char **argv) ...@@ -562,6 +593,8 @@ int main(int argc, char **argv)
test_io_channel_unix_async); test_io_channel_unix_async);
g_test_add_func("/io/channel/socket/unix-fd-pass", g_test_add_func("/io/channel/socket/unix-fd-pass",
test_io_channel_unix_fd_pass); test_io_channel_unix_fd_pass);
g_test_add_func("/io/channel/socket/unix-listen-cleanup",
test_io_channel_unix_listen_cleanup);
#endif /* _WIN32 */ #endif /* _WIN32 */
return g_test_run(); return g_test_run();
......
...@@ -116,6 +116,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len ...@@ -116,6 +116,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len
return 0; return 0;
} }
qio_channel_set_name(QIO_CHANNEL(tls), "vnc-server-tls");
VNC_DEBUG("Start TLS VeNCrypt handshake process\n"); VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
object_unref(OBJECT(vs->ioc)); object_unref(OBJECT(vs->ioc));
vs->ioc = QIO_CHANNEL(tls); vs->ioc = QIO_CHANNEL(tls);
......
...@@ -67,6 +67,8 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UNUSED, ...@@ -67,6 +67,8 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,
return TRUE; return TRUE;
} }
qio_channel_set_name(QIO_CHANNEL(tls), "vnc-ws-server-tls");
VNC_DEBUG("Start TLS WS handshake process\n"); VNC_DEBUG("Start TLS WS handshake process\n");
object_unref(OBJECT(vs->ioc)); object_unref(OBJECT(vs->ioc));
vs->ioc = QIO_CHANNEL(tls); vs->ioc = QIO_CHANNEL(tls);
...@@ -113,6 +115,7 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUSED, ...@@ -113,6 +115,7 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,
} }
wioc = qio_channel_websock_new_server(vs->ioc); wioc = qio_channel_websock_new_server(vs->ioc);
qio_channel_set_name(QIO_CHANNEL(wioc), "vnc-ws-server-websock");
object_unref(OBJECT(vs->ioc)); object_unref(OBJECT(vs->ioc));
vs->ioc = QIO_CHANNEL(wioc); vs->ioc = QIO_CHANNEL(wioc);
......
...@@ -3100,6 +3100,9 @@ static gboolean vnc_listen_io(QIOChannel *ioc, ...@@ -3100,6 +3100,9 @@ static gboolean vnc_listen_io(QIOChannel *ioc,
sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err); sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
if (sioc != NULL) { if (sioc != NULL) {
qio_channel_set_name(QIO_CHANNEL(sioc),
ioc != QIO_CHANNEL(vd->lsock) ?
"vnc-ws-server" : "vnc-server");
qio_channel_set_delay(QIO_CHANNEL(sioc), false); qio_channel_set_delay(QIO_CHANNEL(sioc), false);
vnc_connect(vd, sioc, false, vnc_connect(vd, sioc, false,
ioc != QIO_CHANNEL(vd->lsock)); ioc != QIO_CHANNEL(vd->lsock));
...@@ -3788,6 +3791,7 @@ void vnc_display_open(const char *id, Error **errp) ...@@ -3788,6 +3791,7 @@ void vnc_display_open(const char *id, Error **errp)
} }
vd->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX; vd->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
sioc = qio_channel_socket_new(); sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");
if (qio_channel_socket_connect_sync(sioc, saddr, errp) < 0) { if (qio_channel_socket_connect_sync(sioc, saddr, errp) < 0) {
goto fail; goto fail;
} }
...@@ -3795,6 +3799,7 @@ void vnc_display_open(const char *id, Error **errp) ...@@ -3795,6 +3799,7 @@ void vnc_display_open(const char *id, Error **errp)
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
} else { } else {
vd->lsock = qio_channel_socket_new(); vd->lsock = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(vd->lsock), "vnc-listen");
if (qio_channel_socket_listen_sync(vd->lsock, saddr, errp) < 0) { if (qio_channel_socket_listen_sync(vd->lsock, saddr, errp) < 0) {
goto fail; goto fail;
} }
...@@ -3802,6 +3807,7 @@ void vnc_display_open(const char *id, Error **errp) ...@@ -3802,6 +3807,7 @@ void vnc_display_open(const char *id, Error **errp)
if (ws_enabled) { if (ws_enabled) {
vd->lwebsock = qio_channel_socket_new(); vd->lwebsock = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(vd->lwebsock), "vnc-ws-listen");
if (qio_channel_socket_listen_sync(vd->lwebsock, if (qio_channel_socket_listen_sync(vd->lwebsock,
wsaddr, errp) < 0) { wsaddr, errp) < 0) {
object_unref(OBJECT(vd->lsock)); object_unref(OBJECT(vd->lsock));
...@@ -3845,6 +3851,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth) ...@@ -3845,6 +3851,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth)
sioc = qio_channel_socket_new_fd(csock, NULL); sioc = qio_channel_socket_new_fd(csock, NULL);
if (sioc) { if (sioc) {
qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-server");
vnc_connect(vd, sioc, skipauth, false); vnc_connect(vd, sioc, skipauth, false);
object_unref(OBJECT(sioc)); object_unref(OBJECT(sioc));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册