[virt-tools-list] [virt-viewer][PATCH 4/6] events: protect handles and timeouts agins concurrent access

2015-07-17 Thread Fabiano Fidêncio
Timeout and Handle operations are done from an idle callback. However, we cannot assume that all libvirt event calls (the callbacks passed to virEventRegisterImpl) will be done from the mainloop thread. It's thus possible that a libvirt event call will run a thread while one of the callbacks runs.

[virt-tools-list] [virt-viewer][PATCH 1/6] events: Register event using GOnce to avoid multiple initializations

2015-07-17 Thread Fabiano Fidêncio
Based on http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=8f8d9ce5238dbcbce40aa04ba55b8c55f97c79c0 Related to: rhbz#1243228 --- src/virt-viewer-events.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c

[virt-tools-list] [virt-viewer][PATCH 3/6] glib-compat: Add g_mutex_new()

2015-07-17 Thread Fabiano Fidêncio
Related to: rhbz#1243228 --- src/virt-glib-compat.h | 4 1 file changed, 4 insertions(+) diff --git a/src/virt-glib-compat.h b/src/virt-glib-compat.h index 2c887e9..17c33f0 100644 --- a/src/virt-glib-compat.h +++ b/src/virt-glib-compat.h @@ -76,6 +76,10 @@ GByteArray *g_byte_array_new_take

[virt-tools-list] [virt-viewer][PATCH 2/6] events: remove timeout and handle from arrays

2015-07-17 Thread Fabiano Fidêncio
Based on http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=cff5f1c46f4b9661e112b85159fb58ae473a9a89 Related to: rhbz#1243228 --- src/virt-viewer-events.c | 97 +++- 1 file changed, 63 insertions(+), 34 deletions(-) diff --git

[virt-tools-list] [virt-viewer][PATCH 6/6] events: Allow zero timeouts for timer

2015-07-17 Thread Fabiano Fidêncio
In libvirt, it's perfectly possible and widely used to have disabled timers (timeout=-1) and fire them up 'randomly' with timeout=0. However, with current mapping into glib mainloop it's not possible and causing troubles. Based on

[virt-tools-list] [virt-viewer][PATCH 5/6] events: Don't create glib IO watch for disabled handles

2015-07-17 Thread Fabiano Fidêncio
It's possible to create a handle to watch for file events which do not watch for any file event. Such a handle can be enabled later with gvir_event_handle_update() by setting some conditions to watch for. When a handle is disabled after it has been created, gvir_event_handle_update() makes sure

[virt-tools-list] [virt-viewer][PATCH 0/6] events: backport a few patches from libvirt-glib-events to virt-viewer

2015-07-17 Thread Fabiano Fidêncio
In order to fix rhbz#1243228, I am backporting a few fixes from libvirt-glib/libvirt-glib-events.c to virt-viewer, as the events file used for both seems to be pretty much the same (with the same issues as well, sometimes fixed in one, sometimes fixed in the other). All patches have a link for

Re: [virt-tools-list] [virt-viewer][PATCH 3/6] glib-compat: Add g_mutex_new()

2015-07-17 Thread Christophe Fergeau
On Fri, Jul 17, 2015 at 04:01:20PM +0200, Fabiano Fidêncio wrote: Related to: rhbz#1243228 --- src/virt-glib-compat.h | 4 1 file changed, 4 insertions(+) diff --git a/src/virt-glib-compat.h b/src/virt-glib-compat.h index 2c887e9..17c33f0 100644 --- a/src/virt-glib-compat.h +++

Re: [virt-tools-list] [virt-viewer][PATCH 1/6] events: Register event using GOnce to avoid multiple initializations

2015-07-17 Thread Christophe Fergeau
ACK On Fri, Jul 17, 2015 at 04:01:18PM +0200, Fabiano Fidêncio wrote: Based on http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=8f8d9ce5238dbcbce40aa04ba55b8c55f97c79c0 Related to: rhbz#1243228 --- src/virt-viewer-events.c | 12 ++-- 1 file changed, 10 insertions(+), 2

Re: [virt-tools-list] [virt-viewer][PATCH 2/6] events: remove timeout and handle from arrays

2015-07-17 Thread Christophe Fergeau
On Fri, Jul 17, 2015 at 06:15:19PM +0200, Christophe Fergeau wrote: @@ -115,7 +112,7 @@ int virt_viewer_events_add_handle(int fd, virt_viewer_events_dispatch_handle, data); -handles[nhandles++] = data; +

[virt-tools-list] [virt-viewer][PATCH] events: Don't leak GIOChannel when destroying IO handle

2015-07-17 Thread Fabiano Fidêncio
virt_viewer_events_add_handle() creates a GIOChannel in order to watch the fd it was given for changes. virt_viewer_events_remove_handle() is freeing all the resources allocated by virt_viewer_events_add_handle() expect for this GIOChannel. This commit adds the needed g_io_channel_unref() call to

Re: [virt-tools-list] [virt-viewer][PATCH 5/6] events: Don't create glib IO watch for disabled handles

2015-07-17 Thread Christophe Fergeau
ACK. On Fri, Jul 17, 2015 at 04:01:22PM +0200, Fabiano Fidêncio wrote: It's possible to create a handle to watch for file events which do not watch for any file event. Such a handle can be enabled later with gvir_event_handle_update() by setting some conditions to watch for. When a handle

Re: [virt-tools-list] [virt-viewer][PATCH 2/6] events: remove timeout and handle from arrays

2015-07-17 Thread Fabiano Fidêncio
On Fri, Jul 17, 2015 at 6:15 PM, Christophe Fergeau cferg...@redhat.com wrote: Hey, On Fri, Jul 17, 2015 at 04:01:19PM +0200, Fabiano Fidêncio wrote: Based on http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=cff5f1c46f4b9661e112b85159fb58ae473a9a89 I'd tend to cp the initial log too

Re: [virt-tools-list] [virt-viewer][PATCH 0/6] events: backport a few patches from libvirt-glib-events to virt-viewer

2015-07-17 Thread Christophe Fergeau
An alternative to this series is to revert https://git.fedorahosted.org/cgit/virt-viewer.git/commit/?id=296f91c (which would mean a new dependency not available in EL6). libvirt-glib mainloop implementation has matured a lot in the mean time as shown by this series ;) Christophe On Fri, Jul 17,

Re: [virt-tools-list] [virt-viewer][PATCH 4/6] events: protect handles and timeouts agins concurrent access

2015-07-17 Thread Victor Toso
Typo in the short commit message: against On Fri, Jul 17, 2015 at 04:01:21PM +0200, Fabiano Fidêncio wrote: Timeout and Handle operations are done from an idle callback. However, we cannot assume that all libvirt event calls (the callbacks passed to virEventRegisterImpl) will be done from the

Re: [virt-tools-list] [virt-viewer][PATCH 6/6] events: Allow zero timeouts for timer

2015-07-17 Thread Christophe Fergeau
ACK, though this one comes much sooner in libvirt-glib history. Christophe On Fri, Jul 17, 2015 at 04:01:23PM +0200, Fabiano Fidêncio wrote: In libvirt, it's perfectly possible and widely used to have disabled timers (timeout=-1) and fire them up 'randomly' with timeout=0. However, with

[virt-tools-list] [virt-viewer][PATCH] events: backport a few patches from libvirt-glib-events to virt-viewer -- missing patch

2015-07-17 Thread Fabiano Fidêncio
This patch should part of the previous series that I sent [0]. [0]: https://www.redhat.com/archives/virt-tools-list/2015-July/msg00063.html Fabiano Fidêncio (1): events: Don't leak GIOChannel when destroying IO handle src/virt-viewer-events.c | 4 1 file changed, 4 insertions(+) --

Re: [virt-tools-list] [virt-viewer][PATCH 4/6] events: protect handles and timeouts agins concurrent access

2015-07-17 Thread Christophe Fergeau
On Fri, Jul 17, 2015 at 04:01:21PM +0200, Fabiano Fidêncio wrote: Timeout and Handle operations are done from an idle callback. However, we cannot assume that all libvirt event calls (the callbacks passed to virEventRegisterImpl) will be done from the mainloop thread. It's thus possible that a

Re: [virt-tools-list] [virt-viewer][PATCH] events: Don't leak GIOChannel when destroying IO handle

2015-07-17 Thread Christophe Fergeau
ACK. On Fri, Jul 17, 2015 at 06:33:51PM +0200, Fabiano Fidêncio wrote: virt_viewer_events_add_handle() creates a GIOChannel in order to watch the fd it was given for changes. virt_viewer_events_remove_handle() is freeing all the resources allocated by virt_viewer_events_add_handle() expect

Re: [virt-tools-list] [virt-viewer][PATCH 0/6] events: backport a few patches from libvirt-glib-events to virt-viewer

2015-07-17 Thread Christophe Fergeau
On Fri, Jul 17, 2015 at 04:01:17PM +0200, Fabiano Fidêncio wrote: In order to fix rhbz#1243228, I am backporting a few fixes from libvirt-glib/libvirt-glib-events.c to virt-viewer, as the events file used for both seems to be pretty much the same (with the same issues as well, sometimes fixed