All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Dietmar Maurer <dietmar@proxmox.com>
Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v5 7/7] h264: stop gstreamer pipeline before destroying, cleanup on exit
Date: Tue, 13 May 2025 15:34:47 +0100	[thread overview]
Message-ID: <aCNYhxD4tn0f5_i5@redhat.com> (raw)
In-Reply-To: <20250430072524.3650582-8-dietmar@proxmox.com>

On Wed, Apr 30, 2025 at 09:25:24AM +0200, Dietmar Maurer wrote:
> Some encoders can hang indefinitely (i.e. nvh264enc) if
> the pipeline is not stopped before it is destroyed
> (Observed on Debian bookworm).
> 
> Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
> ---
>  include/system/system.h |  1 +
>  include/ui/console.h    |  1 +
>  system/runstate.c       |  2 ++
>  system/vl.c             |  7 +++++++
>  ui/vnc-enc-h264.c       | 18 ++++++++++++++++++
>  ui/vnc.c                | 15 +++++++++++++++
>  6 files changed, 44 insertions(+)
> 

> diff --git a/ui/vnc.c b/ui/vnc.c
> index c707b9da37..578d9eea32 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -4368,6 +4368,21 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      return 0;
>  }
>  
> +void vnc_cleanup(void)
> +{
> +    VncDisplay *vd;
> +    VncState *vs;
> +
> +    QTAILQ_FOREACH(vd, &vnc_displays, next) {
> +        QTAILQ_FOREACH(vs, &vd->clients, next) {
> +#ifdef CONFIG_GSTREAMER
> +            /* correctly close all h264 encoder pipelines */
> +            vnc_h264_clear(vs);
> +#endif

How is this safe to do ?

If we have an active client, we have to assume that the jobs
thread may be in the middle of processing an update, and thus
the jobs thread wil be using the h264 encoder. If we blindly
tear down the encoder I think we're liable to trigger
non-deterministic crashes in QEMU in the vnc jobs thread
accessing free'd memory.

> +        }
> +    }
> +}
> +
>  static void vnc_register_config(void)
>  {
>      qemu_add_opts(&qemu_vnc_opts);
> -- 
> 2.39.5
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2025-05-13 14:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  7:25 [PATCH v5 0/7] Add VNC Open H.264 Encoding Dietmar Maurer
2025-04-30  7:25 ` [PATCH v5 1/7] new configure option to enable gstreamer Dietmar Maurer
2025-04-30  7:38   ` Thomas Huth
2025-05-13 14:27   ` Daniel P. Berrangé
2025-04-30  7:25 ` [PATCH v5 2/7] add vnc h264 encoder Dietmar Maurer
2025-05-13 14:31   ` Daniel P. Berrangé
2025-04-30  7:25 ` [PATCH v5 3/7] vnc: h264: send additional frames after the display is clean Dietmar Maurer
2025-04-30  7:25 ` [PATCH v5 4/7] h264: search for available h264 encoder Dietmar Maurer
2025-04-30  7:25 ` [PATCH v5 5/7] h264: new vnc options to configure h264 at server side Dietmar Maurer
2025-04-30  7:25 ` [PATCH v5 6/7] h264: add hardware encoders Dietmar Maurer
2025-04-30  7:25 ` [PATCH v5 7/7] h264: stop gstreamer pipeline before destroying, cleanup on exit Dietmar Maurer
2025-05-13 14:34   ` Daniel P. Berrangé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aCNYhxD4tn0f5_i5@redhat.com \
    --to=berrange@redhat.com \
    --cc=dietmar@proxmox.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.