ui: fix dpy_ui_info_supported(con) assertion
PATCH v2 1/1 ui: fix dpy_ui_info_supported(con) assertion
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.
--- ui/console.c | 4 +++- ui/gtk.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
ui/console.c +3 -1
@@ -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;
ui/gtk.c +16 -2
@@ -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);
Signature · 1 line
2.41.0
Hi
Quoted 7 lines · Paolo Bonzini
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 fromdpy_get_ui_info()if the information is not supported, and just ignore the request to set refresh rate or size in that case.
Quoted 7 lines
While the assertion failure was introduced by commit
a92e7bb4cad("ui: add precondition fordpy_get_ui_info()", 2023-09-12), QEMU had been usingcon->ui_infoincorrectly 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 <[email protected]>
Did you see my patch ?
https://lore.kernel.org/qemu-devel/[email protected]/
I think I prefer mine :)
Quoted 62 lines
--- ui/console.c | 4 +++- ui/gtk.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)ui/console.c +3
-1@@ -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;ui/gtk.c +16
-3@@ -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
Quoted 15 lines · Marc-André Lureau
Hi
Quoted 11 lines · Paolo Bonzini
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 fromdpy_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 fordpy_get_ui_info()", 2023-09-12), QEMU had been usingcon->ui_infoincorrectly since before.
Quoted 8 lines
Quoted 3 lines
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 <[email protected]>Did you see my patch ?
https://lore.kernel.org/qemu-devel/[email protected]/I think I prefer mine :)
I hadn't seen it, either is okay with me.
Paolo
Quoted 10 lines · Paolo Bonzini
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 fromdpy_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 fordpy_get_ui_info()", 2023-09-12), QEMU had been usingcon->ui_infoincorrectly since before.
Quoted 7 lines
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 <[email protected]>--- ui/console.c | 4 +++- ui/gtk.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
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
Quoted 54 lines
ui/console.c +3
-1@@ -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;ui/gtk.c +16
-2@@ -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);