[PATCH] hw/char: clear dangling GLib event source tag

Matthew Penney posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260305003012.108262-1-matt@matthewpenney.net
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Amit Shah <amit@kernel.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
hw/char/virtio-console.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] hw/char: clear dangling GLib event source tag
Posted by Matthew Penney 1 month, 1 week ago
Clear dangling GLib event source tag when virtio-console is
unrealized. This prevents a stale tag from being used, and
maintains consistency with the rest of virtio-console.

Signed-off-by: Matthew Penney <matt@matthewpenney.net>
---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index 25db0f019b..11bf51e3ea 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;
     }
 }
 
-- 
2.53.0
Re: [PATCH] hw/char: clear dangling GLib event source tag
Posted by Marc-André Lureau 1 month, 1 week ago
Hi

On Thu, Mar 5, 2026 at 1:40 AM Matthew Penney <matt@matthewpenney.net> wrote:
>
> Clear dangling GLib event source tag when virtio-console is
> unrealized. This prevents a stale tag from being used, and
> maintains consistency with the rest of virtio-console.
>
> Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> ---
>  hw/char/virtio-console.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
> index 25db0f019b..11bf51e3ea 100644
> --- a/hw/char/virtio-console.c
> +++ b/hw/char/virtio-console.c
> @@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
>
>      if (vcon->watch) {
>          g_source_remove(vcon->watch);
> +        vcon->watch = 0;

The glib >= 2.56 way is:
g_clear_handle_id(&vcon->watch, g_source_remove);

We could do a bulk change for the whole code base imho

anyway
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

>      }
>  }
>
> --
> 2.53.0
>
>
Re: [PATCH] hw/char: clear dangling GLib event source tag
Posted by Matthew Penney 1 month, 1 week ago
Hi Marc-André,

Thanks for the swift reply!

Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?

Best,
Matthew



Sent with Proton Mail secure email.

On Thursday, 5 March 2026 at 10:23, Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Hi
> 
> On Thu, Mar 5, 2026 at 1:40 AM Matthew Penney <matt@matthewpenney.net> wrote:
> >
> > Clear dangling GLib event source tag when virtio-console is
> > unrealized. This prevents a stale tag from being used, and
> > maintains consistency with the rest of virtio-console.
> >
> > Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> > ---
> >  hw/char/virtio-console.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
> > index 25db0f019b..11bf51e3ea 100644
> > --- a/hw/char/virtio-console.c
> > +++ b/hw/char/virtio-console.c
> > @@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
> >
> >      if (vcon->watch) {
> >          g_source_remove(vcon->watch);
> > +        vcon->watch = 0;
> 
> The glib >= 2.56 way is:
> g_clear_handle_id(&vcon->watch, g_source_remove);
> 
> We could do a bulk change for the whole code base imho
> 
> anyway
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> >      }
> >  }
> >
> > --
> > 2.53.0
> >
> >
> 
>
Re: [PATCH] hw/char: clear dangling GLib event source tag
Posted by Marc-André Lureau 1 month, 1 week ago
Hi

On Thu, Mar 5, 2026 at 2:22 PM Matthew Penney <matt@matthewpenney.net> wrote:
>
> Hi Marc-André,
>
> Thanks for the swift reply!
>
> Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?

If you can clean the codebase in one patch, hopefully this is
agreeable with all the subsystem maintainers.

Though if your patch is actually a fix, it's worth it to make it a
different patch.

>
> Best,
> Matthew
>
>
>
> Sent with Proton Mail secure email.
>
> On Thursday, 5 March 2026 at 10:23, Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
>
> > Hi
> >
> > On Thu, Mar 5, 2026 at 1:40 AM Matthew Penney <matt@matthewpenney.net> wrote:
> > >
> > > Clear dangling GLib event source tag when virtio-console is
> > > unrealized. This prevents a stale tag from being used, and
> > > maintains consistency with the rest of virtio-console.
> > >
> > > Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> > > ---
> > >  hw/char/virtio-console.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
> > > index 25db0f019b..11bf51e3ea 100644
> > > --- a/hw/char/virtio-console.c
> > > +++ b/hw/char/virtio-console.c
> > > @@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
> > >
> > >      if (vcon->watch) {
> > >          g_source_remove(vcon->watch);
> > > +        vcon->watch = 0;
> >
> > The glib >= 2.56 way is:
> > g_clear_handle_id(&vcon->watch, g_source_remove);
> >
> > We could do a bulk change for the whole code base imho
> >
> > anyway
> > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > >      }
> > >  }
> > >
> > > --
> > > 2.53.0
> > >
> > >
> >
> >
>


-- 
Marc-André Lureau
Re: [PATCH] hw/char: clear dangling GLib event source tag
Posted by Matthew Penney 1 month, 1 week ago
Hi Marc-André,

Thanks for the suggestion.

I will send a v2 of this patch updating it to use g_clear_handle_id(),
keeping the scope limited to the virtio-console fix.

I may submit a separate patch later for a broader conversion if the
maintainers are in agreement.

Best,
Matthew



Sent with Proton Mail secure email.

On Thursday, 5 March 2026 at 13:25, Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> 
> On Thu, Mar 5, 2026 at 2:22 PM Matthew Penney <matt@matthewpenney.net> wrote:
> >
> > Hi Marc-André,
> >
> > Thanks for the swift reply!
> >
> > Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?
> 
> If you can clean the codebase in one patch, hopefully this is
> agreeable with all the subsystem maintainers.
> 
> Though if your patch is actually a fix, it's worth it to make it a
> different patch.
> 
> >
> > Best,
> > Matthew
> >
> >
> >
> > Sent with Proton Mail secure email.
> >
> > On Thursday, 5 March 2026 at 10:23, Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >
> > > Hi
> > >
> > > On Thu, Mar 5, 2026 at 1:40 AM Matthew Penney <matt@matthewpenney.net> wrote:
> > > >
> > > > Clear dangling GLib event source tag when virtio-console is
> > > > unrealized. This prevents a stale tag from being used, and
> > > > maintains consistency with the rest of virtio-console.
> > > >
> > > > Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> > > > ---
> > > >  hw/char/virtio-console.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
> > > > index 25db0f019b..11bf51e3ea 100644
> > > > --- a/hw/char/virtio-console.c
> > > > +++ b/hw/char/virtio-console.c
> > > > @@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
> > > >
> > > >      if (vcon->watch) {
> > > >          g_source_remove(vcon->watch);
> > > > +        vcon->watch = 0;
> > >
> > > The glib >= 2.56 way is:
> > > g_clear_handle_id(&vcon->watch, g_source_remove);
> > >
> > > We could do a bulk change for the whole code base imho
> > >
> > > anyway
> > > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > >      }
> > > >  }
> > > >
> > > > --
> > > > 2.53.0
> > > >
> > > >
> > >
> > >
> >
> 
> 
> --
> Marc-André Lureau
>