qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: berrange@redhat.com, kraxel@redhat.com
Subject: Re: [PATCH] ui/gtk: fix UI info precondition
Date: Fri, 15 Sep 2023 15:45:19 +0300	[thread overview]
Message-ID: <0cae6d58-1476-9b92-0b48-f593b8e92ef2@tls.msk.ru> (raw)
In-Reply-To: <20230915113637.2127644-1-marcandre.lureau@redhat.com>

15.09.2023 14:36, marcandre.lureau@redhat.com:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> dpy_get_ui_info() shouldn't be called if the underlying GPU doesn't
> support it.
> 
> Before the assert() was added and the regression introduced, GTK code
> used to get "zero" UI info, for ex with a simple VGA device. The assert
> was added to prevent from calling when there are no console too. The
> other display backend that calls dpy_get_ui_info() correctly checks that
> pre-condition.
> 
> Calling dpy_set_ui_info() is "safe" in this case, it will simply return
> an error that can be generally ignored.
> 
> Fixes: commit a92e7bb4c ("ui: add precondition for dpy_get_ui_info()")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   ui/gtk.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/ui/gtk.c b/ui/gtk.c
> index e09f97a86b..7b542da0c0 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -726,6 +726,10 @@ static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
>   {
>       QemuUIInfo info;
>   
> +    if (!dpy_ui_info_supported(vc->gfx.dcl.con)) {
> +        return;
> +    }
> +
>       info = *dpy_get_ui_info(vc->gfx.dcl.con);

Current dpy_ui_info_supported():

bool dpy_ui_info_supported(QemuConsole *con)
{
     if (con == NULL) {
         con = active_console;
     }
     if (con == NULL) {
         return false;
     }

     return con->hw_ops->ui_info != NULL;
}

This whole thing smells a bit wrong.  I'm not saying it *is* wrong, but
the feeling is here.

Where dpy_ui_info_supported() is called with a NULL con, so that an "active"
console needs to be used instead?

Maybe we should instead use something like

    if (!vc->gfx.dcl.con)

here in gd_set_ui_refresh_rate() ?

At the very least, the code is a bit, well, confusing.

/mjt


  reply	other threads:[~2023-09-15 12:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 11:36 [PATCH] ui/gtk: fix UI info precondition marcandre.lureau
2023-09-15 12:45 ` Michael Tokarev [this message]
2023-09-18 11:06   ` Marc-André Lureau

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=0cae6d58-1476-9b92-0b48-f593b8e92ef2@tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).