Skip to contentSkip to conversation

Merge qio 2016/10/20

GIT PULL Daniel P. Berrange 3 participants 19 messages Oct 20, 2016 – Oct 21, 2016 Block layer

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL v1 01/10] io: Fix double shift usages on QIOChannel features

In reply to Daniel P. Berrange

From: Felipe Franciosi <[email protected]>

When QIOChannels were introduced in 666a3af9, the feature bits were already defined shifted. However, when using them, the code was shifting them again. The incorrect use was consistent until 74b6ce43, where QIO_CHANNEL_FEATURE_LISTEN was defined shifted but tested unshifted.

This patch changes the definition to be unshifted and fixes the incorrect usage introduced on 74b6ce43.

---
 include/io/channel.h | 6 +++---
 io/channel-socket.c  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
include/io/channel.h +3 -3
index 752e89f..5368604 100644
@@ -40,9 +40,9 @@ typedef struct QIOChannelClass QIOChannelClass;
 typedef enum QIOChannelFeature QIOChannelFeature;
 
 enum QIOChannelFeature {
-    QIO_CHANNEL_FEATURE_FD_PASS  = (1 << 0),
-    QIO_CHANNEL_FEATURE_SHUTDOWN = (1 << 1),
-    QIO_CHANNEL_FEATURE_LISTEN   = (1 << 2),
+    QIO_CHANNEL_FEATURE_FD_PASS,
+    QIO_CHANNEL_FEATURE_SHUTDOWN,
+    QIO_CHANNEL_FEATURE_LISTEN,
 };
 
 
io/channel-socket.c +1 -1
index 196a4f1..6710b2e 100644
@@ -403,7 +403,7 @@ static void qio_channel_socket_finalize(Object *obj)
     QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj);
 
     if (ioc->fd != -1) {
-        if (QIO_CHANNEL(ioc)->features & QIO_CHANNEL_FEATURE_LISTEN) {
+        if (QIO_CHANNEL(ioc)->features & (1 << QIO_CHANNEL_FEATURE_LISTEN)) {
             Error *err = NULL;
 
             socket_listen_cleanup(ioc->fd, &err);
Signature · 1 line
2.7.4
#2 lore raw

[Qemu-devel] [PULL v1 02/10] io: Use qio_channel_has_feature() where applicable

In reply to Daniel P. Berrange

From: Felipe Franciosi <[email protected]>

Parts of the code have been testing QIOChannel features directly with a logical AND. This patch makes it all consistent by using the qio_channel_has_feature() function to test if a feature is present.

---
 io/channel-socket.c  | 3 ++-
 io/channel-tls.c     | 2 +-
 io/channel-websock.c | 2 +-
 io/channel.c         | 4 ++--
 4 files changed, 6 insertions(+), 5 deletions(-)
io/channel-socket.c +2 -1
index 6710b2e..8fc6e5a 100644
@@ -403,7 +403,8 @@ static void qio_channel_socket_finalize(Object *obj)
     QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj);
 
     if (ioc->fd != -1) {
-        if (QIO_CHANNEL(ioc)->features & (1 << QIO_CHANNEL_FEATURE_LISTEN)) {
+        QIOChannel *ioc_local = QIO_CHANNEL(ioc);
+        if (qio_channel_has_feature(ioc_local, QIO_CHANNEL_FEATURE_LISTEN)) {
             Error *err = NULL;
 
             socket_listen_cleanup(ioc->fd, &err);
io/channel-tls.c +1 -1
index 9a8525c..f7bb0e3 100644
@@ -111,7 +111,7 @@ qio_channel_tls_new_client(QIOChannel *master,
     ioc = QIO_CHANNEL(tioc);
 
     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);
     }
     object_ref(OBJECT(master));
io/channel-websock.c +1 -1
index 533bd4b..75df03e 100644
@@ -497,7 +497,7 @@ qio_channel_websock_new_server(QIOChannel *master)
     ioc = QIO_CHANNEL(wioc);
 
     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);
     }
     object_ref(OBJECT(master));
io/channel.c +2 -2
index 923c465..e50325c 100644
@@ -40,7 +40,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
     QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
 
     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,
                          "Channel does not support file descriptor passing");
         return -1;
@@ -60,7 +60,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
     QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
 
     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,
                          "Channel does not support file descriptor passing");
         return -1;
Signature · 1 line
2.7.4
#0 lore raw

The following changes since commit e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-10-18 09:29:44 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-2016-10-20-1

for you to fetch changes up to 8ef215b830231eb6bf2022d9ec261ca0de2b8014:

main: set names for main loop sources created (2016-10-20 13:06:39 +0100)

----------------------------------------------------------------
Merge qio 2016/10/20 v1

----------------------------------------------------------------

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

Felipe Franciosi (4):
io: Fix double shift usages on QIOChannel features
io: Use qio_channel_has_feature() where applicable
io: Introduce a qio_channel_set_feature() helper
io: Add a QIOChannelSocket cleanup test

 block/nbd.c                    |  1 +
 blockdev-nbd.c                 |  3 ++
 include/glib-compat.h          | 11 ++++++
 include/io/channel.h           | 29 ++++++++++++++--
 io/channel-socket.c            | 12 ++++---
 io/channel-tls.c               |  4 +--
 io/channel-websock.c           |  4 +--
 io/channel.c                   | 35 +++++++++++++++----
 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 ++++++++++++++++++++++++++++++++++++++----
 tests/test-io-channel-socket.c | 33 ++++++++++++++++++
 ui/vnc-auth-vencrypt.c         |  1 +
 ui/vnc-ws.c                    |  3 ++
 ui/vnc.c                       |  7 ++++
 22 files changed, 213 insertions(+), 26 deletions(-)
Signature · 1 line
2.7.4
#3 lore raw

[Qemu-devel] [PULL v1 03/10] io: Introduce a qio_channel_set_feature() helper

From: Felipe Franciosi <[email protected]>

Testing QIOChannel feature support can be done with a helper called qio_channel_has_feature(). Setting feature support, however, was done manually with a logical OR. This patch introduces a new helper called qio_channel_set_feature() and makes use of it where applicable.

---
 include/io/channel.h | 10 ++++++++++
 io/channel-socket.c  |  9 +++++----
 io/channel-tls.c     |  2 +-
 io/channel-websock.c |  2 +-
 io/channel.c         |  7 +++++++
 5 files changed, 24 insertions(+), 6 deletions(-)
include/io/channel.h +10 -0
index 5368604..cf1c622 100644
@@ -149,6 +149,16 @@ bool qio_channel_has_feature(QIOChannel *ioc,
                              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_readv_full:
  * @ioc: the channel object
  * @iov: the array of memory regions to read data into
io/channel-socket.c +5 -4
index 8fc6e5a..75cbca3 100644
@@ -55,7 +55,7 @@ qio_channel_socket_new(void)
     sioc->fd = -1;
 
     ioc = QIO_CHANNEL(sioc);
-    ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN);
+    qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
 
 #ifdef WIN32
     ioc->event = CreateEvent(NULL, FALSE, FALSE, NULL);
@@ -107,12 +107,12 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
 #ifndef WIN32
     if (sioc->localAddr.ss_family == AF_UNIX) {
         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 */
     if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &val, &len) == 0 && val) {
         QIOChannel *ioc = QIO_CHANNEL(sioc);
-        ioc->features |= (1 << QIO_CHANNEL_FEATURE_LISTEN);
+        qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN);
     }
 
     return 0;
@@ -380,7 +380,8 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
 
 #ifndef WIN32
     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 */
 
io/channel-tls.c +1 -1
index f7bb0e3..d24dc8c 100644
@@ -112,7 +112,7 @@ qio_channel_tls_new_client(QIOChannel *master,
 
     tioc->master = master;
     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));
 
io/channel-websock.c +1 -1
index 75df03e..f45bced 100644
@@ -498,7 +498,7 @@ qio_channel_websock_new_server(QIOChannel *master)
 
     wioc->master = master;
     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));
 
io/channel.c +7 -0
index e50325c..d1f1ae5 100644
@@ -30,6 +30,13 @@ bool qio_channel_has_feature(QIOChannel *ioc,
 }
 
 
+void qio_channel_set_feature(QIOChannel *ioc,
+                             QIOChannelFeature feature)
+{
+    ioc->features |= (1 << feature);
+}
+
+
 ssize_t qio_channel_readv_full(QIOChannel *ioc,
                                const struct iovec *iov,
                                size_t niov,
Signature · 1 line
2.7.4
#4 lore raw

[Qemu-devel] [PULL v1 04/10] io: Add a QIOChannelSocket cleanup test

In reply to Daniel P. Berrange

From: Felipe Franciosi <[email protected]>

This patch adds a test to verify that the QIOChannel framework will not unlink a filesystem unix socket unless the _FEATURE_LISTEN bit is set.

Due to a bug introduced in 74b6ce43, the framework would unlink the entry if the _FEATURE_SHUTDOWN bit was set, regardless of the presence of _FEATURE_LISTEN.

---
 tests/test-io-channel-socket.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
tests/test-io-channel-socket.c +33 -0
index f73e063..aa88c3c 100644
@@ -491,6 +491,37 @@ static void test_io_channel_unix_fd_pass(void)
     }
     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 */
 
 
@@ -562,6 +593,8 @@ int main(int argc, char **argv)
                     test_io_channel_unix_async);
     g_test_add_func("/io/channel/socket/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 */
 
     return g_test_run();
Signature · 1 line
2.7.4
#5 lore raw

[Qemu-devel] [PULL v1 05/10] io: add ability to set a name for IO channels

In reply to 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 a QIOChannel object, we can then set the name on any GSource associated with the channel.

---
 include/glib-compat.h |  7 +++++++
 include/io/channel.h  | 13 +++++++++++++
 io/channel.c          | 24 +++++++++++++++++++-----
 3 files changed, 39 insertions(+), 5 deletions(-)
include/glib-compat.h +7 -0
index 8093163..9dfe952 100644
@@ -304,4 +304,11 @@ static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func)
 }
 #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 */
+}
+#endif
+
 #endif
include/io/channel.h +13 -0
index cf1c622..32a9470 100644
@@ -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
io/channel.c +19 -5
index d1f1ae5..80924c1 100644
@@ -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),
 };
Signature · 1 line
2.7.4
#6 lore raw

[Qemu-devel] [PULL v1 06/10] nbd: set name for all I/O channels created

In reply to Daniel P. Berrange

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

---
 block/nbd.c    | 1 +
 blockdev-nbd.c | 3 +++
 nbd/client.c   | 1 +
 nbd/server.c   | 1 +
 4 files changed, 6 insertions(+)
block/nbd.c +1 -0
index 6bc06d6..1ec64ab 100644
@@ -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,
blockdev-nbd.c +3 -0
index ca41cc6..81bca17 100644
@@ -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;
nbd/client.c +1 -0
index a92f1e2..f6db836 100644
@@ -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,
nbd/server.c +1 -0
index 472f584..36bcafc 100644
@@ -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,
Signature · 1 line
2.7.4
#7 lore raw

[Qemu-devel] [PULL v1 09/10] vnc: set name for all I/O channels created

In reply to Daniel P. Berrange

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

---
 ui/vnc-auth-vencrypt.c | 1 +
 ui/vnc-ws.c            | 3 +++
 ui/vnc.c               | 7 +++++++
 3 files changed, 11 insertions(+)
ui/vnc-auth-vencrypt.c +1 -0
index 11c8c9a..c0c29a5 100644
@@ -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);
ui/vnc-ws.c +3 -0
index 42a8e7b..bffb484 100644
@@ -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);
ui/vnc.c +7 -0
index c1e98fb..f863b64 100644
@@ -3100,6 +3100,9 @@ static gboolean vnc_listen_io(QIOChannel *ioc,
 
     sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
     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);
         vnc_connect(vd, sioc, false,
                     ioc != QIO_CHANNEL(vd->lsock));
@@ -3788,6 +3791,7 @@ void vnc_display_open(const char *id, Error **errp)
         }
         vd->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;
         }
@@ -3795,6 +3799,7 @@ void vnc_display_open(const char *id, Error **errp)
         object_unref(OBJECT(sioc));
     } else {
         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) {
             goto fail;
         }
@@ -3802,6 +3807,7 @@ void vnc_display_open(const char *id, Error **errp)
 
         if (ws_enabled) {
             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,
                                                wsaddr, errp) < 0) {
                 object_unref(OBJECT(vd->lsock));
@@ -3845,6 +3851,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(vd, sioc, skipauth, false);
         object_unref(OBJECT(sioc));
     }
Signature · 1 line
2.7.4
#8 lore raw

[Qemu-devel] [PULL v1 08/10] migration: set name for all I/O channels created

In reply to Daniel P. Berrange

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

---
 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(+)
migration/exec.c +2 -0
index 2af63cc..9157721 100644
@@ -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,
migration/fd.c +2 -0
index 84a10fd..58cb51a 100644
@@ -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,
migration/migration.c +1 -0
index 4d417b7..156e707 100644
@@ -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.
      */
     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));
 
migration/savevm.c +3 -0
index a831ec2..0dede9d 100644
@@ -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);
@@ -2073,6 +2074,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);
@@ -2105,6 +2107,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);
migration/socket.c +5 -0
index a21c0c5..11f80b1 100644
@@ -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,
@@ -146,6 +147,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));
@@ -162,6 +164,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);
migration/tls.c +2 -0
index 12c053d..49ca9a8 100644
@@ -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,
Signature · 1 line
2.7.4
#9 lore raw

[Qemu-devel] [PULL v1 10/10] main: set names for main loop sources created

In reply to Daniel P. Berrange

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

---
 main-loop.c | 2 ++
 1 file changed, 2 insertions(+)
main-loop.c +2 -0
index 6a7f8d3..66c4eb6 100644
@@ -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;
Signature · 1 line
2.7.4
#10 lore raw

[Qemu-devel] [PULL v1 07/10] char: set name for all I/O channels created

In reply to Daniel P. Berrange

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

---
 include/glib-compat.h |  4 +++
 qemu-char.c           | 77 ++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 74 insertions(+), 7 deletions(-)
include/glib-compat.h +4 -0
index 9dfe952..3f8370b 100644
@@ -309,6 +309,10 @@ 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
qemu-char.c +70 -7

235 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw
In reply to Daniel P. Berrange
Quoted 6 lines · Daniel P. Berrange

The following changes since commit e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-10-18 09:29:44 +0100)

are available in the git repository at:

Quoted 8 lines

git://github.com/berrange/qemu tags/pull-qio-2016-10-20-1

for you to fetch changes up to 8ef215b830231eb6bf2022d9ec261ca0de2b8014:

main: set names for main loop sources created (2016-10-20 13:06:39 +0100)

----------------------------------------------------------------
Merge qio 2016/10/20 v1

Isn't this v2 of the pull request?

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#12 lore raw
Quoted 9 lines · Eric Blake
Quoted 8 lines · Daniel P. Berrange

The following changes since commit e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-10-18 09:29:44 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-2016-10-20-1

Quoted 8 lines
Quoted 6 lines

for you to fetch changes up to 8ef215b830231eb6bf2022d9ec261ca0de2b8014:

main: set names for main loop sources created (2016-10-20 13:06:39 +0100)

----------------------------------------------------------------
Merge qio 2016/10/20 v1

Isn't this v2 of the pull request?

I guess so. My pull request script just starts numbering from 1 on each new day and the previous pull was sent yesterday.

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#13 lore raw
Quoted 6 lines · Daniel P. Berrange
Quoted 3 lines
Quoted 1 line

Merge qio 2016/10/20 v1

Isn't this v2 of the pull request?

I guess so. My pull request script just starts numbering from 1 on each new day and the previous pull was sent yesterday.

Ah, I see; yesterday's was 'merge qio 2016/10/19', where the difference in date is sufficient. Not worth worrying about, then, so sorry for my noise :)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#14 lore raw
In reply to Daniel P. Berrange
Quoted 8 lines · Daniel P. Berrange

The following changes since commit e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-10-18 09:29:44 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-2016-10-20-1

Quoted 9 lines

for you to fetch changes up to 8ef215b830231eb6bf2022d9ec261ca0de2b8014:

main: set names for main loop sources created (2016-10-20 13:06:39 +0100)

----------------------------------------------------------------
Merge qio 2016/10/20 v1

----------------------------------------------------------------

Unfortunately the new test seems to fail on OSX:

GTESTER tests/test-io-channel-socket
** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S300c198252e54fe12ff5d64603150e68 ** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S7ade3405366ffc33ad5cf50619671f53

thanks
-- PMM

#15 lore raw
Quoted 21 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrange

The following changes since commit e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-10-18 09:29:44 +0100)

are available in the git repository at:

git://github.com/berrange/qemu tags/pull-qio-2016-10-20-1

Quoted 9 lines

for you to fetch changes up to 8ef215b830231eb6bf2022d9ec261ca0de2b8014:

main: set names for main loop sources created (2016-10-20 13:06:39 +0100)

----------------------------------------------------------------
Merge qio 2016/10/20 v1

----------------------------------------------------------------

Unfortunately the new test seems to fail on OSX:

Quoted 11 lines

GTESTER tests/test-io-channel-socket
** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S300c198252e54fe12ff5d64603150e68 ** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S7ade3405366ffc33ad5cf50619671f53

Oh interesting - I've just seen my Travis CI build check also failed over night on OS-X.

I wonder if OS-X automatically deletes UNIX non-abstract sockets paths on the filesystem when the socket FD is closed ?!?!

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#16 lore raw
Quoted 15 lines · Daniel P. Berrange
Quoted 13 lines · Peter Maydell

Unfortunately the new test seems to fail on OSX:

GTESTER tests/test-io-channel-socket
** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S300c198252e54fe12ff5d64603150e68 ** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S7ade3405366ffc33ad5cf50619671f53

Quoted 5 lines

Oh interesting - I've just seen my Travis CI build check also failed over night on OS-X.

I wonder if OS-X automatically deletes UNIX non-abstract sockets paths on the filesystem when the socket FD is closed ?!?!

The assertion is the other way round, isn't it? It's trying to assert that the path doesn't exist, but in fact it does (and it's still lying around in my working tree after the test failure).

thanks
-- PMM

#17 lore raw
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Daniel P. Berrange
Quoted 13 lines · Peter Maydell

Unfortunately the new test seems to fail on OSX:

GTESTER tests/test-io-channel-socket
** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S300c198252e54fe12ff5d64603150e68 ** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S7ade3405366ffc33ad5cf50619671f53

Oh interesting - I've just seen my Travis CI build check also failed over night on OS-X.

Quoted 7 lines
Quoted 2 lines

I wonder if OS-X automatically deletes UNIX non-abstract sockets paths on the filesystem when the socket FD is closed ?!?!

The assertion is the other way round, isn't it? It's trying to assert that the path doesn't exist, but in fact it does (and it's still lying around in my working tree after the test failure).

Oooooh, I'm looking at the wrong test case. I was assuming it was the newly added test case that failed, whereas it is the original test case we've regressd on.

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#18 lore raw
Quoted 23 lines · Daniel P. Berrange
Quoted 22 lines · Peter Maydell
Quoted 20 lines · Daniel P. Berrange
Quoted 13 lines · Peter Maydell

Unfortunately the new test seems to fail on OSX:

GTESTER tests/test-io-channel-socket
** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S300c198252e54fe12ff5d64603150e68 ** ERROR:/Users/pm215/src/qemu-for-merges/tests/test-io-channel-socket.c:386:void test_io_channel_unix(_Bool): assertion failed:
(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE)
GTester: last random seed: R02S7ade3405366ffc33ad5cf50619671f53

Oh interesting - I've just seen my Travis CI build check also failed over night on OS-X.

I wonder if OS-X automatically deletes UNIX non-abstract sockets paths on the filesystem when the socket FD is closed ?!?!

Quoted 8 lines
Quoted 4 lines

The assertion is the other way round, isn't it? It's trying to assert that the path doesn't exist, but in fact it does (and it's still lying around in my working tree after the test failure).

Oooooh, I'm looking at the wrong test case. I was assuming it was the newly added test case that failed, whereas it is the original test case we've regressd on.

Ok, the problem is that SO_ACCEPTCONN is not working on OS-X. Googling it seems this is likely broken on some versions of BSD too, so I'll rework the patch to avoid that function.

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|