* [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion
@ 2023-10-02 9:54 Paolo Bonzini
2023-10-02 9:58 ` Marc-André Lureau
2023-10-02 10:17 ` Michael Tokarev
0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2023-10-02 9:54 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau
VGA does not support getting the physical video size or refresh rate.
This is causing an assertion failure when the GTK+ user interface
calls dpy_get_ui_info(). Return NULL from dpy_get_ui_info() if the
information is not supported, and just ignore the request to set
refresh rate or size in that case.
While the assertion failure was introduced by commit a92e7bb4cad
("ui: add precondition for dpy_get_ui_info()", 2023-09-12), QEMU had
been using con->ui_info incorrectly since before.
Fixes: a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-12)
Fixes: aeffd071ed8 ("ui: Deliver refresh rate via QemuUIInfo", 2022-06-14)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
ui/console.c | 4 +++-
ui/gtk.c | 18 ++++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 4a4f19ed33e..24438b187c8 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -815,7 +815,9 @@ bool dpy_ui_info_supported(const QemuConsole *con)
const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
{
- assert(dpy_ui_info_supported(con));
+ if (!dpy_ui_info_supported(con)) {
+ return NULL;
+ }
if (con == NULL) {
con = active_console;
diff --git a/ui/gtk.c b/ui/gtk.c
index e09f97a86b7..0b5e314cf0d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -724,18 +724,32 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
{
+ const QemuUIInfo *p_info;
QemuUIInfo info;
- info = *dpy_get_ui_info(vc->gfx.dcl.con);
+ p_info = dpy_get_ui_info(vc->gfx.dcl.con);
+ if (!p_info) {
+ /* not supported by guest */
+ return;
+ }
+
+ info = *p_info;
info.refresh_rate = refresh_rate;
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
}
static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height)
{
+ const QemuUIInfo *p_info;
QemuUIInfo info;
- info = *dpy_get_ui_info(vc->gfx.dcl.con);
+ p_info = dpy_get_ui_info(vc->gfx.dcl.con);
+ if (!p_info) {
+ /* not supported by guest */
+ return;
+ }
+
+ info = *p_info;
info.width = width;
info.height = height;
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion
2023-10-02 9:54 [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion Paolo Bonzini
@ 2023-10-02 9:58 ` Marc-André Lureau
2023-10-02 10:18 ` Paolo Bonzini
2023-10-02 10:17 ` Michael Tokarev
1 sibling, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2023-10-02 9:58 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
Hi
On Mon, Oct 2, 2023 at 1:54 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> VGA does not support getting the physical video size or refresh rate.
> This is causing an assertion failure when the GTK+ user interface
> calls dpy_get_ui_info(). Return NULL from dpy_get_ui_info() if the
> information is not supported, and just ignore the request to set
> refresh rate or size in that case.
>
> While the assertion failure was introduced by commit a92e7bb4cad
> ("ui: add precondition for dpy_get_ui_info()", 2023-09-12), QEMU had
> been using con->ui_info incorrectly since before.
>
> Fixes: a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-12)
> Fixes: aeffd071ed8 ("ui: Deliver refresh rate via QemuUIInfo", 2022-06-14)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Did you see my patch ?
https://lore.kernel.org/qemu-devel/20230915113637.2127644-1-marcandre.lureau@redhat.com/
I think I prefer mine :)
> ---
> ui/console.c | 4 +++-
> ui/gtk.c | 18 ++++++++++++++++--
> 2 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/ui/console.c b/ui/console.c
> index 4a4f19ed33e..24438b187c8 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -815,7 +815,9 @@ bool dpy_ui_info_supported(const QemuConsole *con)
>
> const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
> {
> - assert(dpy_ui_info_supported(con));
> + if (!dpy_ui_info_supported(con)) {
> + return NULL;
> + }
>
> if (con == NULL) {
> con = active_console;
> diff --git a/ui/gtk.c b/ui/gtk.c
> index e09f97a86b7..0b5e314cf0d 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -724,18 +724,32 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
>
> static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
> {
> + const QemuUIInfo *p_info;
> QemuUIInfo info;
>
> - info = *dpy_get_ui_info(vc->gfx.dcl.con);
> + p_info = dpy_get_ui_info(vc->gfx.dcl.con);
> + if (!p_info) {
> + /* not supported by guest */
> + return;
> + }
> +
> + info = *p_info;
> info.refresh_rate = refresh_rate;
> dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
> }
>
> static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height)
> {
> + const QemuUIInfo *p_info;
> QemuUIInfo info;
>
> - info = *dpy_get_ui_info(vc->gfx.dcl.con);
> + p_info = dpy_get_ui_info(vc->gfx.dcl.con);
> + if (!p_info) {
> + /* not supported by guest */
> + return;
> + }
> +
> + info = *p_info;
> info.width = width;
> info.height = height;
> dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion
2023-10-02 9:58 ` Marc-André Lureau
@ 2023-10-02 10:18 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2023-10-02 10:18 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
On Mon, Oct 2, 2023 at 11:58 AM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> Hi
>
> On Mon, Oct 2, 2023 at 1:54 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > VGA does not support getting the physical video size or refresh rate.
> > This is causing an assertion failure when the GTK+ user interface
> > calls dpy_get_ui_info(). Return NULL from dpy_get_ui_info() if the
> > information is not supported, and just ignore the request to set
> > refresh rate or size in that case.
> >
> > While the assertion failure was introduced by commit a92e7bb4cad
> > ("ui: add precondition for dpy_get_ui_info()", 2023-09-12), QEMU had
> > been using con->ui_info incorrectly since before.
> >
> > Fixes: a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-12)
> > Fixes: aeffd071ed8 ("ui: Deliver refresh rate via QemuUIInfo", 2022-06-14)
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> Did you see my patch ?
> https://lore.kernel.org/qemu-devel/20230915113637.2127644-1-marcandre.lureau@redhat.com/
>
> I think I prefer mine :)
I hadn't seen it, either is okay with me.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion
2023-10-02 9:54 [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion Paolo Bonzini
2023-10-02 9:58 ` Marc-André Lureau
@ 2023-10-02 10:17 ` Michael Tokarev
1 sibling, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2023-10-02 10:17 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: marcandre.lureau
02.10.2023 12:54, Paolo Bonzini wrote:
> VGA does not support getting the physical video size or refresh rate.
> This is causing an assertion failure when the GTK+ user interface
> calls dpy_get_ui_info(). Return NULL from dpy_get_ui_info() if the
> information is not supported, and just ignore the request to set
> refresh rate or size in that case.
>
> While the assertion failure was introduced by commit a92e7bb4cad
> ("ui: add precondition for dpy_get_ui_info()", 2023-09-12), QEMU had
> been using con->ui_info incorrectly since before.
>
> Fixes: a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-12)
> Fixes: aeffd071ed8 ("ui: Deliver refresh rate via QemuUIInfo", 2022-06-14)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> ui/console.c | 4 +++-
> ui/gtk.c | 18 ++++++++++++++++--
> 2 files changed, 19 insertions(+), 3 deletions(-)
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
I think it is a step to the right direction.
It might need more work still, but at least it is asking properties of the
right pointer ;)
/mjt
> diff --git a/ui/console.c b/ui/console.c
> index 4a4f19ed33e..24438b187c8 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -815,7 +815,9 @@ bool dpy_ui_info_supported(const QemuConsole *con)
>
> const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
> {
> - assert(dpy_ui_info_supported(con));
> + if (!dpy_ui_info_supported(con)) {
> + return NULL;
> + }
>
> if (con == NULL) {
> con = active_console;
> diff --git a/ui/gtk.c b/ui/gtk.c
> index e09f97a86b7..0b5e314cf0d 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -724,18 +724,32 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
>
> static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
> {
> + const QemuUIInfo *p_info;
> QemuUIInfo info;
>
> - info = *dpy_get_ui_info(vc->gfx.dcl.con);
> + p_info = dpy_get_ui_info(vc->gfx.dcl.con);
> + if (!p_info) {
> + /* not supported by guest */
> + return;
> + }
> +
> + info = *p_info;
> info.refresh_rate = refresh_rate;
> dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
> }
>
> static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height)
> {
> + const QemuUIInfo *p_info;
> QemuUIInfo info;
>
> - info = *dpy_get_ui_info(vc->gfx.dcl.con);
> + p_info = dpy_get_ui_info(vc->gfx.dcl.con);
> + if (!p_info) {
> + /* not supported by guest */
> + return;
> + }
> +
> + info = *p_info;
> info.width = width;
> info.height = height;
> dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-02 10:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 9:54 [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion Paolo Bonzini
2023-10-02 9:58 ` Marc-André Lureau
2023-10-02 10:18 ` Paolo Bonzini
2023-10-02 10:17 ` Michael Tokarev
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).