From 8fbf66121253969e59fe40de66e55bb2f27c5090 Mon Sep 17 00:00:00 2001 From: Felipe Franciosi Date: Thu, 29 Sep 2016 08:52:35 -0700 Subject: io: Fix double shift usages on QIOChannel features 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. Signed-off-by: Felipe Franciosi Signed-off-by: Daniel P. Berrange --- include/io/channel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/io/channel.h b/include/io/channel.h index 752e89f..5368604 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -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, }; -- cgit v1.1 From d8d3c7cc672d89b26180a404d6f0b03494160cf5 Mon Sep 17 00:00:00 2001 From: Felipe Franciosi Date: Thu, 29 Sep 2016 08:52:37 -0700 Subject: io: Introduce a qio_channel_set_feature() helper 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. Signed-off-by: Felipe Franciosi Signed-off-by: Daniel P. Berrange --- include/io/channel.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/io/channel.h b/include/io/channel.h index 5368604..cf1c622 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -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 -- cgit v1.1 From 20f4aa265ec8442be66f00ee3986a92018b44b7b Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 30 Sep 2016 11:50:18 +0100 Subject: io: add ability to set a name for IO channels 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. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- include/glib-compat.h | 7 +++++++ include/io/channel.h | 13 +++++++++++++ 2 files changed, 20 insertions(+) (limited to 'include') diff --git a/include/glib-compat.h b/include/glib-compat.h index 8093163..9dfe952 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -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 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 -- cgit v1.1 From e93a68e102ffc8f8316ce24a57f094734dc4d8f7 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 30 Sep 2016 11:57:14 +0100 Subject: char: set name for all I/O channels created Ensure that all I/O channels created for character devices are given names to distinguish their respective roles. Acked-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Signed-off-by: Daniel P. Berrange --- include/glib-compat.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/glib-compat.h b/include/glib-compat.h index 9dfe952..3f8370b 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -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 -- cgit v1.1