qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates
@ 2016-09-30 15:16 Daniel P. Berrange
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels Daniel P. Berrange
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

This trivial series of patches gives names to all the
GSource instances that QEMU creates. These names are
useful when debugging QEMU main loop problems, as they
are emitted with GLib's built-in userspace probes for
event loop dispatch.

NB, all QEMU level AIO handlers and IO handlers get
hidden behind 2 global GSource objects, which means
data from those 2 GSource's is not particularly useful.
Mostly this series helps with anything backed by a
QIOChannel object, and a few other misc bits of the
chardev code.

Addressing AIO problems requires giving names to the
QEMU level objects associated with these, which I'm
not attempting - I just wanted to fix the GSource
stuff used with QIOChannel here. I'll leave it to
Prashanth to look at naming of the QEMU specific event
loop sources.

Daniel P. Berrange (6):
  io: add ability to set a name for IO channels
  nbd: set name for all I/O channels created
  char: set name for all I/O channels created
  migration: set name for all I/O channels created
  vnc: set name for all I/O channels created
  main: set names for main loop sources created

 block/nbd.c            |  1 +
 blockdev-nbd.c         |  3 ++
 include/io/channel.h   | 13 +++++++++
 io/channel.c           | 24 ++++++++++++----
 main-loop.c            |  2 ++
 migration/exec.c       |  2 ++
 migration/fd.c         |  2 ++
 migration/migration.c  |  1 +
 migration/savevm.c     |  3 ++
 migration/socket.c     |  5 ++++
 migration/tls.c        |  2 ++
 nbd/client.c           |  1 +
 nbd/server.c           |  1 +
 qemu-char.c            | 77 +++++++++++++++++++++++++++++++++++++++++++++-----
 ui/vnc-auth-vencrypt.c |  1 +
 ui/vnc-ws.c            |  3 ++
 ui/vnc.c               |  7 +++++
 17 files changed, 136 insertions(+), 12 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
@ 2016-09-30 15:16 ` Daniel P. Berrange
  2016-09-30 18:41   ` Eric Blake
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created Daniel P. Berrange
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

The GSource object has ability to have a name, which is useful
when debugging performance problems with the mainloop event
callbacks that take too long. By associating a name with an
QIOChannel object, we can then set the name on any GSource
associated with the channel.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 include/io/channel.h | 13 +++++++++++++
 io/channel.c         | 24 +++++++++++++++++++-----
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/include/io/channel.h b/include/io/channel.h
index cf1c622..32a9470 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -79,6 +79,7 @@ typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc,
 struct QIOChannel {
     Object parent;
     unsigned int features; /* bitmask of QIOChannelFeatures */
+    char *name;
 #ifdef _WIN32
     HANDLE event; /* For use with GSource on Win32 */
 #endif
@@ -159,6 +160,18 @@ 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:
  * @ioc: the channel object
  * @iov: the array of memory regions to read data into
diff --git a/io/channel.c b/io/channel.c
index d1f1ae5..80924c1 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -37,6 +37,14 @@ void qio_channel_set_feature(QIOChannel *ioc,
 }
 
 
+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,
                                const struct iovec *iov,
                                size_t niov,
@@ -136,7 +144,13 @@ GSource *qio_channel_create_watch(QIOChannel *ioc,
                                   GIOCondition condition)
 {
     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;
 }
 
 
@@ -282,24 +296,24 @@ void qio_channel_wait(QIOChannel *ioc,
 }
 
 
-#ifdef _WIN32
 static void qio_channel_finalize(Object *obj)
 {
     QIOChannel *ioc = QIO_CHANNEL(obj);
 
+    g_free(ioc->name);
+
+#ifdef _WIN32
     if (ioc->event) {
         CloseHandle(ioc->event);
     }
-}
 #endif
+}
 
 static const TypeInfo qio_channel_info = {
     .parent = TYPE_OBJECT,
     .name = TYPE_QIO_CHANNEL,
     .instance_size = sizeof(QIOChannel),
-#ifdef _WIN32
     .instance_finalize = qio_channel_finalize,
-#endif
     .abstract = true,
     .class_size = sizeof(QIOChannelClass),
 };
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels Daniel P. Berrange
@ 2016-09-30 15:16 ` Daniel P. Berrange
  2016-09-30 16:12   ` Paolo Bonzini
  2016-10-03 15:15   ` Stefan Hajnoczi
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 3/6] char: " Daniel P. Berrange
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

Ensure that all I/O channels created for NBD are given names
to distinguish their respective roles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 block/nbd.c    | 1 +
 blockdev-nbd.c | 3 +++
 nbd/client.c   | 1 +
 nbd/server.c   | 1 +
 4 files changed, 6 insertions(+)

diff --git a/block/nbd.c b/block/nbd.c
index 6bc06d6..1ec64ab 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -248,6 +248,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
     Error *local_err = NULL;
 
     sioc = qio_channel_socket_new();
+    qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
 
     qio_channel_socket_connect_sync(sioc,
                                     saddr,
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index ca41cc6..81bca17 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -44,6 +44,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
         return TRUE;
     }
 
+    qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
     nbd_client_new(NULL, cioc,
                    nbd_server->tlscreds, NULL,
                    nbd_client_put);
@@ -111,6 +112,8 @@ void qmp_nbd_server_start(SocketAddress *addr,
     nbd_server = g_new0(NBDServerData, 1);
     nbd_server->watch = -1;
     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(
             nbd_server->listen_ioc, addr, errp) < 0) {
         goto error;
diff --git a/nbd/client.c b/nbd/client.c
index a92f1e2..f6db836 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -387,6 +387,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
     if (!tioc) {
         return NULL;
     }
+    qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-client-tls");
     data.loop = g_main_loop_new(g_main_context_default(), FALSE);
     TRACE("Starting TLS handshake");
     qio_channel_tls_handshake(tioc,
diff --git a/nbd/server.c b/nbd/server.c
index 472f584..36bcafc 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -349,6 +349,7 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
         return NULL;
     }
 
+    qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-server-tls");
     TRACE("Starting TLS handshake");
     data.loop = g_main_loop_new(g_main_context_default(), FALSE);
     qio_channel_tls_handshake(tioc,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 3/6] char: set name for all I/O channels created
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels Daniel P. Berrange
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created Daniel P. Berrange
@ 2016-09-30 15:16 ` Daniel P. Berrange
  2016-09-30 16:12   ` Paolo Bonzini
  2016-10-03 15:18   ` Stefan Hajnoczi
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 4/6] migration: " Daniel P. Berrange
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

Ensure that all I/O channels created for character devices
are given names to distinguish their respective roles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 qemu-char.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 70 insertions(+), 7 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 48a45ef..5f3b2fc 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -934,7 +934,8 @@ static GSourceFuncs io_watch_poll_funcs = {
 };
 
 /* 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,
                                QIOChannelFunc fd_read,
                                gpointer user_data,
@@ -942,6 +943,7 @@ static guint io_add_watch_poll(QIOChannel *ioc,
 {
     IOWatchPoll *iwp;
     int tag;
+    char *name;
 
     iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs,
                                        sizeof(IOWatchPoll));
@@ -952,6 +954,10 @@ static guint io_add_watch_poll(QIOChannel *ioc,
     iwp->src = NULL;
     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);
     g_source_unref(&iwp->parent);
     return tag;
@@ -1091,7 +1097,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr,
 
     remove_fd_in_watch(chr);
     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, chr,
                                            context);
@@ -1120,6 +1126,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
 {
     CharDriverState *chr;
     FDCharDriver *s;
+    char *name;
 
     chr = qemu_chr_alloc(backend, errp);
     if (!chr) {
@@ -1127,7 +1134,13 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
     }
     s = g_new0(FDCharDriver, 1);
     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));
+    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);
     s->chr = chr;
     chr->opaque = s;
@@ -1305,6 +1318,7 @@ static gboolean pty_chr_timer(gpointer opaque)
 static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
 {
     PtyCharDriver *s = chr->opaque;
+    char *name;
 
     if (s->timer_tag) {
         g_source_remove(s->timer_tag);
@@ -1312,10 +1326,14 @@ static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
     }
 
     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);
     } else {
+        name = g_strdup_printf("pty-timer-ms-%s", chr->label);
         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.  */
@@ -1444,7 +1462,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)
             s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr);
         }
         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,
                                                chr, NULL);
@@ -1478,6 +1496,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
     int master_fd, slave_fd;
     char pty_name[PATH_MAX];
     ChardevCommon *common = backend->u.pty.data;
+    char *name;
 
     master_fd = qemu_openpty_raw(&slave_fd, pty_name);
     if (master_fd < 0) {
@@ -1510,6 +1529,9 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
     chr->explicit_be_open = true;
 
     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;
 
     return chr;
@@ -2596,7 +2618,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr,
 
     remove_fd_in_watch(chr);
     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, chr,
                                            context);
@@ -2673,9 +2695,13 @@ static gboolean socket_reconnect_timeout(gpointer opaque);
 static void qemu_chr_socket_restart_timer(CharDriverState *chr)
 {
     TCPCharDriver *s = chr->opaque;
+    char *name;
     assert(s->connected == 0);
     s->reconnect_timer = g_timeout_add_seconds(s->reconnect_time,
                                                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,
@@ -3000,7 +3026,7 @@ static void tcp_chr_connect(void *opaque)
 
     s->connected = 1;
     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,
                                            chr, NULL);
@@ -3019,7 +3045,7 @@ static void tcp_chr_update_read_handler(CharDriverState *chr,
 
     remove_fd_in_watch(chr);
     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, chr,
                                            context);
@@ -3117,6 +3143,7 @@ static void tcp_chr_tls_init(CharDriverState *chr)
     TCPCharDriver *s = chr->opaque;
     QIOChannelTLS *tioc;
     Error *err = NULL;
+    gchar *name;
 
     if (s->is_listen) {
         tioc = qio_channel_tls_new_server(
@@ -3134,6 +3161,11 @@ static void tcp_chr_tls_init(CharDriverState *chr)
         tcp_chr_disconnect(chr);
         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));
     s->ioc = QIO_CHANNEL(tioc);
 
@@ -3144,6 +3176,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)
 {
     TCPCharDriver *s = chr->opaque;
@@ -3189,6 +3234,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
     if (!sioc) {
         return -1;
     }
+    tcp_chr_set_client_ioc_name(chr, sioc);
     ret = tcp_chr_new_client(chr, sioc);
     object_unref(OBJECT(sioc));
     return ret;
@@ -3230,6 +3276,7 @@ static int tcp_chr_wait_connected(CharDriverState *chr, Error **errp)
             qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
         } else {
             sioc = qio_channel_socket_new();
+            tcp_chr_set_client_ioc_name(chr, sioc);
             if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
                 object_unref(OBJECT(sioc));
                 return -1;
@@ -4445,6 +4492,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
     }
 
     sioc = qio_channel_socket_new();
+    tcp_chr_set_client_ioc_name(chr, sioc);
     qio_channel_socket_connect_async(sioc, s->addr,
                                      qemu_chr_socket_connected,
                                      chr, NULL);
@@ -4541,12 +4589,19 @@ static CharDriverState *qmp_chardev_open_socket(const char *id,
 
     if (s->reconnect_time) {
         sioc = qio_channel_socket_new();
+        tcp_chr_set_client_ioc_name(chr, sioc);
         qio_channel_socket_connect_async(sioc, s->addr,
                                          qemu_chr_socket_connected,
                                          chr, NULL);
     } else {
         if (s->is_listen) {
+            char *name;
             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) {
                 goto error;
             }
@@ -4587,6 +4642,8 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
     ChardevUdp *udp = backend->u.udp.data;
     ChardevCommon *common = qapi_ChardevUdp_base(udp);
     QIOChannelSocket *sioc = qio_channel_socket_new();
+    char *name;
+    CharDriverState *chr;
 
     if (qio_channel_socket_dgram_sync(sioc,
                                       udp->local, udp->remote,
@@ -4594,7 +4651,13 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
         object_unref(OBJECT(sioc));
         return NULL;
     }
-    return qemu_chr_open_udp(sioc, common, errp);
+    chr = qemu_chr_open_udp(sioc, common, errp);
+
+    name = g_strdup_printf("chardev-udp-%s", chr->label);
+    qio_channel_set_name(QIO_CHANNEL(sioc), name);
+    g_free(name);
+
+    return chr;
 }
 
 ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 4/6] migration: set name for all I/O channels created
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
                   ` (2 preceding siblings ...)
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 3/6] char: " Daniel P. Berrange
@ 2016-09-30 15:16 ` Daniel P. Berrange
  2016-10-03 15:18   ` Stefan Hajnoczi
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 5/6] vnc: " Daniel P. Berrange
  2016-09-30 15:17 ` [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created Daniel P. Berrange
  5 siblings, 1 reply; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

Ensure that all I/O channels created for migration are given names
to distinguish their respective roles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 migration/exec.c      | 2 ++
 migration/fd.c        | 2 ++
 migration/migration.c | 1 +
 migration/savevm.c    | 3 +++
 migration/socket.c    | 5 +++++
 migration/tls.c       | 2 ++
 6 files changed, 15 insertions(+)

diff --git a/migration/exec.c b/migration/exec.c
index 2af63cc..9157721 100644
--- a/migration/exec.c
+++ b/migration/exec.c
@@ -38,6 +38,7 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error
         return;
     }
 
+    qio_channel_set_name(ioc, "migration-exec-outgoing");
     migration_channel_connect(s, ioc, NULL);
     object_unref(OBJECT(ioc));
 }
@@ -64,6 +65,7 @@ void exec_start_incoming_migration(const char *command, Error **errp)
         return;
     }
 
+    qio_channel_set_name(ioc, "migration-exec-incoming");
     qio_channel_add_watch(ioc,
                           G_IO_IN,
                           exec_accept_incoming_migration,
diff --git a/migration/fd.c b/migration/fd.c
index 84a10fd..58cb51a 100644
--- a/migration/fd.c
+++ b/migration/fd.c
@@ -38,6 +38,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **
         return;
     }
 
+    qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
     migration_channel_connect(s, ioc, NULL);
     object_unref(OBJECT(ioc));
 }
@@ -65,6 +66,7 @@ void fd_start_incoming_migration(const char *infd, Error **errp)
         return;
     }
 
+    qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
     qio_channel_add_watch(ioc,
                           G_IO_IN,
                           fd_accept_incoming_migration,
diff --git a/migration/migration.c b/migration/migration.c
index 955d5ee..e91c89b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1551,6 +1551,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.
      */
     bioc = qio_channel_buffer_new(4096);
+    qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
     fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
     object_unref(OBJECT(bioc));
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 33a2911..3f2c089 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1582,6 +1582,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis)
     }
 
     bioc = qio_channel_buffer_new(length);
+    qio_channel_set_name(QIO_CHANNEL(bioc), "migration-loadvm-buffer");
     ret = qemu_get_buffer(mis->from_src_file,
                           bioc->data,
                           length);
@@ -2068,6 +2069,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     if (!ioc) {
         goto the_end;
     }
+    qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
     f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
     ret = qemu_save_device_state(f);
     qemu_fclose(f);
@@ -2100,6 +2102,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
     if (!ioc) {
         return;
     }
+    qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state");
     f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
 
     migration_incoming_state_new(f);
diff --git a/migration/socket.c b/migration/socket.c
index 00de1fe..ad3172d 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -100,6 +100,7 @@ static void socket_start_outgoing_migration(MigrationState *s,
         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,
                                      saddr,
                                      socket_outgoing_migration,
@@ -142,6 +143,7 @@ static gboolean socket_accept_incoming_migration(QIOChannel *ioc,
 
     trace_migration_socket_incoming_accepted();
 
+    qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming");
     migration_channel_process_incoming(migrate_get_current(),
                                        QIO_CHANNEL(sioc));
     object_unref(OBJECT(sioc));
@@ -158,6 +160,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
 {
     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) {
         object_unref(OBJECT(listen_ioc));
         qapi_free_SocketAddress(saddr);
diff --git a/migration/tls.c b/migration/tls.c
index 12c053d..49ca9a8 100644
--- a/migration/tls.c
+++ b/migration/tls.c
@@ -99,6 +99,7 @@ void migration_tls_channel_process_incoming(MigrationState *s,
     }
 
     trace_migration_tls_incoming_handshake_start();
+    qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-incoming");
     qio_channel_tls_handshake(tioc,
                               migration_tls_incoming_handshake,
                               NULL,
@@ -154,6 +155,7 @@ void migration_tls_channel_connect(MigrationState *s,
     }
 
     trace_migration_tls_outgoing_handshake_start(hostname);
+    qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing");
     qio_channel_tls_handshake(tioc,
                               migration_tls_outgoing_handshake,
                               s,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 5/6] vnc: set name for all I/O channels created
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
                   ` (3 preceding siblings ...)
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 4/6] migration: " Daniel P. Berrange
@ 2016-09-30 15:16 ` Daniel P. Berrange
  2016-10-03 15:19   ` Stefan Hajnoczi
  2016-09-30 15:17 ` [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created Daniel P. Berrange
  5 siblings, 1 reply; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

Ensure that all I/O channels created for VNC are given names
to distinguish their respective roles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 ui/vnc-auth-vencrypt.c | 1 +
 ui/vnc-ws.c            | 3 +++
 ui/vnc.c               | 7 +++++++
 3 files changed, 11 insertions(+)

diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
index 11c8c9a..c0c29a5 100644
--- a/ui/vnc-auth-vencrypt.c
+++ b/ui/vnc-auth-vencrypt.c
@@ -116,6 +116,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len
             return 0;
         }
 
+        qio_channel_set_name(QIO_CHANNEL(tls), "vnc-server-tls");
         VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
         object_unref(OBJECT(vs->ioc));
         vs->ioc = QIO_CHANNEL(tls);
diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c
index 3bac46e..05628a6 100644
--- a/ui/vnc-ws.c
+++ b/ui/vnc-ws.c
@@ -67,6 +67,8 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,
         return TRUE;
     }
 
+    qio_channel_set_name(QIO_CHANNEL(tls), "vnc-ws-server-tls");
+
     VNC_DEBUG("Start TLS WS handshake process\n");
     object_unref(OBJECT(vs->ioc));
     vs->ioc = QIO_CHANNEL(tls);
@@ -113,6 +115,7 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,
     }
 
     wioc = qio_channel_websock_new_server(vs->ioc);
+    qio_channel_set_name(QIO_CHANNEL(wioc), "vnc-ws-server-websock");
 
     object_unref(OBJECT(vs->ioc));
     vs->ioc = QIO_CHANNEL(wioc);
diff --git a/ui/vnc.c b/ui/vnc.c
index 76a3273..ab68db3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3108,6 +3108,9 @@ static gboolean vnc_listen_io(QIOChannel *ioc,
     graphic_hw_update(vs->dcl.con);
     sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
     if (sioc != NULL) {
+        qio_channel_set_name(QIO_CHANNEL(sioc),
+                             ioc != QIO_CHANNEL(vs->lsock) ?
+                             "vnc-ws-server" : "vnc-server");
         qio_channel_set_delay(QIO_CHANNEL(sioc), false);
         vnc_connect(vs, sioc, false,
                     ioc != QIO_CHANNEL(vs->lsock));
@@ -3824,6 +3827,7 @@ void vnc_display_open(const char *id, Error **errp)
         }
         vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
         sioc = qio_channel_socket_new();
+        qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");
         if (qio_channel_socket_connect_sync(sioc, saddr, errp) < 0) {
             goto fail;
         }
@@ -3831,6 +3835,7 @@ void vnc_display_open(const char *id, Error **errp)
         object_unref(OBJECT(sioc));
     } else {
         vs->lsock = qio_channel_socket_new();
+        qio_channel_set_name(QIO_CHANNEL(vs->lsock), "vnc-listen");
         if (qio_channel_socket_listen_sync(vs->lsock, saddr, errp) < 0) {
             goto fail;
         }
@@ -3839,6 +3844,7 @@ void vnc_display_open(const char *id, Error **errp)
 
         if (vs->ws_enabled) {
             vs->lwebsock = qio_channel_socket_new();
+            qio_channel_set_name(QIO_CHANNEL(vs->lwebsock), "vnc-ws-listen");
             if (qio_channel_socket_listen_sync(vs->lwebsock,
                                                wsaddr, errp) < 0) {
                 object_unref(OBJECT(vs->lsock));
@@ -3883,6 +3889,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth)
 
     sioc = qio_channel_socket_new_fd(csock, NULL);
     if (sioc) {
+        qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-server");
         vnc_connect(vs, sioc, skipauth, false);
         object_unref(OBJECT(sioc));
     }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created
  2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
                   ` (4 preceding siblings ...)
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 5/6] vnc: " Daniel P. Berrange
@ 2016-09-30 15:17 ` Daniel P. Berrange
  2016-09-30 16:13   ` Paolo Bonzini
  2016-10-03 15:19   ` Stefan Hajnoczi
  5 siblings, 2 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2016-09-30 15:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, prashanth sunder, Daniel P. Berrange

The main loop creates two generic sources for the AIO
and IO handler systems.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 main-loop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/main-loop.c b/main-loop.c
index 6a7f8d3..66c4eb6 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -161,9 +161,11 @@ int qemu_init_main_loop(Error **errp)
     qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
     gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
     src = aio_get_g_source(qemu_aio_context);
+    g_source_set_name(src, "aio-context");
     g_source_attach(src, NULL);
     g_source_unref(src);
     src = iohandler_get_g_source();
+    g_source_set_name(src, "io-handler");
     g_source_attach(src, NULL);
     g_source_unref(src);
     return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 3/6] char: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 3/6] char: " Daniel P. Berrange
@ 2016-09-30 16:12   ` Paolo Bonzini
  2016-10-03 15:18   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2016-09-30 16:12 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: prashanth sunder, Stefan Hajnoczi



On 30/09/2016 17:16, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for character devices
> are given names to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qemu-char.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 70 insertions(+), 7 deletions(-)

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

> diff --git a/qemu-char.c b/qemu-char.c
> index 48a45ef..5f3b2fc 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -934,7 +934,8 @@ static GSourceFuncs io_watch_poll_funcs = {
>  };
>  
>  /* 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,
>                                 QIOChannelFunc fd_read,
>                                 gpointer user_data,
> @@ -942,6 +943,7 @@ static guint io_add_watch_poll(QIOChannel *ioc,
>  {
>      IOWatchPoll *iwp;
>      int tag;
> +    char *name;
>  
>      iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs,
>                                         sizeof(IOWatchPoll));
> @@ -952,6 +954,10 @@ static guint io_add_watch_poll(QIOChannel *ioc,
>      iwp->src = NULL;
>      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);
>      g_source_unref(&iwp->parent);
>      return tag;
> @@ -1091,7 +1097,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr,
>  
>      remove_fd_in_watch(chr);
>      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, chr,
>                                             context);
> @@ -1120,6 +1126,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
>  {
>      CharDriverState *chr;
>      FDCharDriver *s;
> +    char *name;
>  
>      chr = qemu_chr_alloc(backend, errp);
>      if (!chr) {
> @@ -1127,7 +1134,13 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out,
>      }
>      s = g_new0(FDCharDriver, 1);
>      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));
> +    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);
>      s->chr = chr;
>      chr->opaque = s;
> @@ -1305,6 +1318,7 @@ static gboolean pty_chr_timer(gpointer opaque)
>  static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
>  {
>      PtyCharDriver *s = chr->opaque;
> +    char *name;
>  
>      if (s->timer_tag) {
>          g_source_remove(s->timer_tag);
> @@ -1312,10 +1326,14 @@ static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
>      }
>  
>      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);
>      } else {
> +        name = g_strdup_printf("pty-timer-ms-%s", chr->label);
>          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.  */
> @@ -1444,7 +1462,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)
>              s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr);
>          }
>          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,
>                                                 chr, NULL);
> @@ -1478,6 +1496,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>      int master_fd, slave_fd;
>      char pty_name[PATH_MAX];
>      ChardevCommon *common = backend->u.pty.data;
> +    char *name;
>  
>      master_fd = qemu_openpty_raw(&slave_fd, pty_name);
>      if (master_fd < 0) {
> @@ -1510,6 +1529,9 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>      chr->explicit_be_open = true;
>  
>      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;
>  
>      return chr;
> @@ -2596,7 +2618,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr,
>  
>      remove_fd_in_watch(chr);
>      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, chr,
>                                             context);
> @@ -2673,9 +2695,13 @@ static gboolean socket_reconnect_timeout(gpointer opaque);
>  static void qemu_chr_socket_restart_timer(CharDriverState *chr)
>  {
>      TCPCharDriver *s = chr->opaque;
> +    char *name;
>      assert(s->connected == 0);
>      s->reconnect_timer = g_timeout_add_seconds(s->reconnect_time,
>                                                 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,
> @@ -3000,7 +3026,7 @@ static void tcp_chr_connect(void *opaque)
>  
>      s->connected = 1;
>      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,
>                                             chr, NULL);
> @@ -3019,7 +3045,7 @@ static void tcp_chr_update_read_handler(CharDriverState *chr,
>  
>      remove_fd_in_watch(chr);
>      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, chr,
>                                             context);
> @@ -3117,6 +3143,7 @@ static void tcp_chr_tls_init(CharDriverState *chr)
>      TCPCharDriver *s = chr->opaque;
>      QIOChannelTLS *tioc;
>      Error *err = NULL;
> +    gchar *name;
>  
>      if (s->is_listen) {
>          tioc = qio_channel_tls_new_server(
> @@ -3134,6 +3161,11 @@ static void tcp_chr_tls_init(CharDriverState *chr)
>          tcp_chr_disconnect(chr);
>          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));
>      s->ioc = QIO_CHANNEL(tioc);
>  
> @@ -3144,6 +3176,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)
>  {
>      TCPCharDriver *s = chr->opaque;
> @@ -3189,6 +3234,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
>      if (!sioc) {
>          return -1;
>      }
> +    tcp_chr_set_client_ioc_name(chr, sioc);
>      ret = tcp_chr_new_client(chr, sioc);
>      object_unref(OBJECT(sioc));
>      return ret;
> @@ -3230,6 +3276,7 @@ static int tcp_chr_wait_connected(CharDriverState *chr, Error **errp)
>              qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
>          } else {
>              sioc = qio_channel_socket_new();
> +            tcp_chr_set_client_ioc_name(chr, sioc);
>              if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
>                  object_unref(OBJECT(sioc));
>                  return -1;
> @@ -4445,6 +4492,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
>      }
>  
>      sioc = qio_channel_socket_new();
> +    tcp_chr_set_client_ioc_name(chr, sioc);
>      qio_channel_socket_connect_async(sioc, s->addr,
>                                       qemu_chr_socket_connected,
>                                       chr, NULL);
> @@ -4541,12 +4589,19 @@ static CharDriverState *qmp_chardev_open_socket(const char *id,
>  
>      if (s->reconnect_time) {
>          sioc = qio_channel_socket_new();
> +        tcp_chr_set_client_ioc_name(chr, sioc);
>          qio_channel_socket_connect_async(sioc, s->addr,
>                                           qemu_chr_socket_connected,
>                                           chr, NULL);
>      } else {
>          if (s->is_listen) {
> +            char *name;
>              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) {
>                  goto error;
>              }
> @@ -4587,6 +4642,8 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
>      ChardevUdp *udp = backend->u.udp.data;
>      ChardevCommon *common = qapi_ChardevUdp_base(udp);
>      QIOChannelSocket *sioc = qio_channel_socket_new();
> +    char *name;
> +    CharDriverState *chr;
>  
>      if (qio_channel_socket_dgram_sync(sioc,
>                                        udp->local, udp->remote,
> @@ -4594,7 +4651,13 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,
>          object_unref(OBJECT(sioc));
>          return NULL;
>      }
> -    return qemu_chr_open_udp(sioc, common, errp);
> +    chr = qemu_chr_open_udp(sioc, common, errp);
> +
> +    name = g_strdup_printf("chardev-udp-%s", chr->label);
> +    qio_channel_set_name(QIO_CHANNEL(sioc), name);
> +    g_free(name);
> +
> +    return chr;
>  }
>  
>  ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created Daniel P. Berrange
@ 2016-09-30 16:12   ` Paolo Bonzini
  2016-10-03 15:15   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2016-09-30 16:12 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: prashanth sunder, Stefan Hajnoczi



On 30/09/2016 17:16, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for NBD are given names
> to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  block/nbd.c    | 1 +
>  blockdev-nbd.c | 3 +++
>  nbd/client.c   | 1 +
>  nbd/server.c   | 1 +
>  4 files changed, 6 insertions(+)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index 6bc06d6..1ec64ab 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -248,6 +248,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
>      Error *local_err = NULL;
>  
>      sioc = qio_channel_socket_new();
> +    qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
>  
>      qio_channel_socket_connect_sync(sioc,
>                                      saddr,
> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
> index ca41cc6..81bca17 100644
> --- a/blockdev-nbd.c
> +++ b/blockdev-nbd.c
> @@ -44,6 +44,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
>          return TRUE;
>      }
>  
> +    qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
>      nbd_client_new(NULL, cioc,
>                     nbd_server->tlscreds, NULL,
>                     nbd_client_put);
> @@ -111,6 +112,8 @@ void qmp_nbd_server_start(SocketAddress *addr,
>      nbd_server = g_new0(NBDServerData, 1);
>      nbd_server->watch = -1;
>      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(
>              nbd_server->listen_ioc, addr, errp) < 0) {
>          goto error;
> diff --git a/nbd/client.c b/nbd/client.c
> index a92f1e2..f6db836 100644
> --- a/nbd/client.c
> +++ b/nbd/client.c
> @@ -387,6 +387,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
>      if (!tioc) {
>          return NULL;
>      }
> +    qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-client-tls");
>      data.loop = g_main_loop_new(g_main_context_default(), FALSE);
>      TRACE("Starting TLS handshake");
>      qio_channel_tls_handshake(tioc,
> diff --git a/nbd/server.c b/nbd/server.c
> index 472f584..36bcafc 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -349,6 +349,7 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
>          return NULL;
>      }
>  
> +    qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-server-tls");
>      TRACE("Starting TLS handshake");
>      data.loop = g_main_loop_new(g_main_context_default(), FALSE);
>      qio_channel_tls_handshake(tioc,
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created
  2016-09-30 15:17 ` [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created Daniel P. Berrange
@ 2016-09-30 16:13   ` Paolo Bonzini
  2016-10-03 15:19   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2016-09-30 16:13 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: prashanth sunder, Stefan Hajnoczi



On 30/09/2016 17:17, Daniel P. Berrange wrote:
> The main loop creates two generic sources for the AIO
> and IO handler systems.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  main-loop.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/main-loop.c b/main-loop.c
> index 6a7f8d3..66c4eb6 100644
> --- a/main-loop.c
> +++ b/main-loop.c
> @@ -161,9 +161,11 @@ int qemu_init_main_loop(Error **errp)
>      qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
>      gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
>      src = aio_get_g_source(qemu_aio_context);
> +    g_source_set_name(src, "aio-context");
>      g_source_attach(src, NULL);
>      g_source_unref(src);
>      src = iohandler_get_g_source();
> +    g_source_set_name(src, "io-handler");
>      g_source_attach(src, NULL);
>      g_source_unref(src);
>      return 0;
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels Daniel P. Berrange
@ 2016-09-30 18:41   ` Eric Blake
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Blake @ 2016-09-30 18:41 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: prashanth sunder, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

On 09/30/2016 10:16 AM, Daniel P. Berrange wrote:
> The GSource object has ability to have a name, which is useful
> when debugging performance problems with the mainloop event
> callbacks that take too long. By associating a name with an
> QIOChannel object, we can then set the name on any GSource

'an QIOChannel' sounds funny.

> associated with the channel.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  include/io/channel.h | 13 +++++++++++++
>  io/channel.c         | 24 +++++++++++++++++++-----
>  2 files changed, 32 insertions(+), 5 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created Daniel P. Berrange
  2016-09-30 16:12   ` Paolo Bonzini
@ 2016-10-03 15:15   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2016-10-03 15:15 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, prashanth sunder

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

On Fri, Sep 30, 2016 at 04:16:56PM +0100, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for NBD are given names
> to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  block/nbd.c    | 1 +
>  blockdev-nbd.c | 3 +++
>  nbd/client.c   | 1 +
>  nbd/server.c   | 1 +
>  4 files changed, 6 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 3/6] char: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 3/6] char: " Daniel P. Berrange
  2016-09-30 16:12   ` Paolo Bonzini
@ 2016-10-03 15:18   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2016-10-03 15:18 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, prashanth sunder

[-- Attachment #1: Type: text/plain, Size: 449 bytes --]

On Fri, Sep 30, 2016 at 04:16:57PM +0100, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for character devices
> are given names to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qemu-char.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 70 insertions(+), 7 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 4/6] migration: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 4/6] migration: " Daniel P. Berrange
@ 2016-10-03 15:18   ` Stefan Hajnoczi
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2016-10-03 15:18 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, prashanth sunder

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

On Fri, Sep 30, 2016 at 04:16:58PM +0100, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for migration are given names
> to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  migration/exec.c      | 2 ++
>  migration/fd.c        | 2 ++
>  migration/migration.c | 1 +
>  migration/savevm.c    | 3 +++
>  migration/socket.c    | 5 +++++
>  migration/tls.c       | 2 ++
>  6 files changed, 15 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 5/6] vnc: set name for all I/O channels created
  2016-09-30 15:16 ` [Qemu-devel] [PATCH 5/6] vnc: " Daniel P. Berrange
@ 2016-10-03 15:19   ` Stefan Hajnoczi
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2016-10-03 15:19 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, prashanth sunder

[-- Attachment #1: Type: text/plain, Size: 444 bytes --]

On Fri, Sep 30, 2016 at 04:16:59PM +0100, Daniel P. Berrange wrote:
> Ensure that all I/O channels created for VNC are given names
> to distinguish their respective roles.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  ui/vnc-auth-vencrypt.c | 1 +
>  ui/vnc-ws.c            | 3 +++
>  ui/vnc.c               | 7 +++++++
>  3 files changed, 11 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created
  2016-09-30 15:17 ` [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created Daniel P. Berrange
  2016-09-30 16:13   ` Paolo Bonzini
@ 2016-10-03 15:19   ` Stefan Hajnoczi
  1 sibling, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2016-10-03 15:19 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, prashanth sunder

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

On Fri, Sep 30, 2016 at 04:17:00PM +0100, Daniel P. Berrange wrote:
> The main loop creates two generic sources for the AIO
> and IO handler systems.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  main-loop.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-10-03 15:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-30 15:16 [Qemu-devel] [PATCH 0/6] Give names to all GSources QEMU creates Daniel P. Berrange
2016-09-30 15:16 ` [Qemu-devel] [PATCH 1/6] io: add ability to set a name for IO channels Daniel P. Berrange
2016-09-30 18:41   ` Eric Blake
2016-09-30 15:16 ` [Qemu-devel] [PATCH 2/6] nbd: set name for all I/O channels created Daniel P. Berrange
2016-09-30 16:12   ` Paolo Bonzini
2016-10-03 15:15   ` Stefan Hajnoczi
2016-09-30 15:16 ` [Qemu-devel] [PATCH 3/6] char: " Daniel P. Berrange
2016-09-30 16:12   ` Paolo Bonzini
2016-10-03 15:18   ` Stefan Hajnoczi
2016-09-30 15:16 ` [Qemu-devel] [PATCH 4/6] migration: " Daniel P. Berrange
2016-10-03 15:18   ` Stefan Hajnoczi
2016-09-30 15:16 ` [Qemu-devel] [PATCH 5/6] vnc: " Daniel P. Berrange
2016-10-03 15:19   ` Stefan Hajnoczi
2016-09-30 15:17 ` [Qemu-devel] [PATCH 6/6] main: set names for main loop sources created Daniel P. Berrange
2016-09-30 16:13   ` Paolo Bonzini
2016-10-03 15:19   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).