On Tue, May 31, 2022 at 01:23:26PM -0700, Dongwon Kim wrote:
> Detaching any addtional guest displays in case there are multiple
> displays assigned to the guest OS (e.g. max_outputs=n) so that
> all of them are visible upon lauching.
> 
> Cc: Daniel P. Berrangé <berra...@redhat.com>
> Cc: Markus Armbruster <arm...@redhat.com>
> Cc: Philippe Mathieu-Daudé <phi...@redhat.com>
> Cc: Paolo Bonzini <pbonz...@redhat.com>
> Cc: Gerd Hoffmann <kra...@redhat.com>
> Cc: Vivek Kasireddy <vivek.kasire...@intel.com>
> Signed-off-by: Dongwon Kim <dongwon....@intel.com>
> ---
>  ui/gtk.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/gtk.c b/ui/gtk.c
> index c57c36749e..abfcf48547 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2304,6 +2304,8 @@ static void gtk_display_init(DisplayState *ds, 
> DisplayOptions *opts)
>      GtkDisplayState *s = g_malloc0(sizeof(*s));
>      GdkDisplay *window_display;
>      GtkIconTheme *theme;
> +    int n_gfx_vcs = 0;
> +    int i;
>      char *dir;
>  
>      if (!gtkinit) {
> @@ -2374,7 +2376,14 @@ static void gtk_display_init(DisplayState *ds, 
> DisplayOptions *opts)
>      gtk_widget_set_sensitive(s->copy_item,
>                               vc && vc->type == GD_VC_VTE);
>  #endif
> -
> +    for (i = 0; i < s->nb_vcs; i++) {
> +        if (qemu_console_is_graphic(s->vc[i].gfx.dcl.con)) {

Accessing vc[i].gfx without checking vc[i].type beforehand is wrong.

Also note that graphical consoles are sorted to the head of the list.
n_gfx_vcs should not be needed because the primary gfx display has
index 0 no matter what.

take care,
  Gerd


Reply via email to