[PATCH] ui/console: fix default VC when there are no display

marcandre.lureau@redhat.com posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231108133719.113217-1-marcandre.lureau@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
system/vl.c  |  4 +++-
ui/console.c | 14 ++++++++------
2 files changed, 11 insertions(+), 7 deletions(-)
[PATCH] ui/console: fix default VC when there are no display
Posted by marcandre.lureau@redhat.com 1 year ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

When display is "none", we may still have remote displays (I think it
would be simpler if VNC/Spice were regular display btw). Return the
default VC then, and set them up to fix a regression when using remote
display and it used the TTY instead.

Fixes: commit 1bec1cc0d ("ui/console: allow to override the default VC")
Reported-by: German Maglione <gmaglione@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 system/vl.c  |  4 +++-
 ui/console.c | 14 ++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index bd7fad770b..8c522a07da 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1359,6 +1359,7 @@ static void qemu_setup_display(void)
             dpy.type = DISPLAY_TYPE_NONE;
 #if defined(CONFIG_VNC)
             vnc_parse("localhost:0,to=99,id=default");
+            display_remote++;
 #endif
         }
     }
@@ -1391,7 +1392,8 @@ static void qemu_create_default_devices(void)
         }
     }
 
-    if (nographic || (!vc && !is_daemonized() && isatty(STDOUT_FILENO))) {
+    if (nographic ||
+        ((!display_remote || !vc) && !is_daemonized() && isatty(STDOUT_FILENO))) {
         if (default_parallel) {
             add_device_config(DEV_PARALLEL, "null");
         }
diff --git a/ui/console.c b/ui/console.c
index 8e688d3569..f08c8365b0 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1679,19 +1679,21 @@ void qemu_display_init(DisplayState *ds, DisplayOptions *opts)
 
 const char *qemu_display_get_vc(DisplayOptions *opts)
 {
+#ifdef CONFIG_PIXMAN
+    const char *vc = "vc:80Cx24C";
+#else
+    const char *vc = NULL;
+#endif
+
     assert(opts->type < DISPLAY_TYPE__MAX);
     if (opts->type == DISPLAY_TYPE_NONE) {
-        return NULL;
+        return vc;
     }
     assert(dpys[opts->type] != NULL);
     if (dpys[opts->type]->vc) {
         return dpys[opts->type]->vc;
-    } else {
-#ifdef CONFIG_PIXMAN
-        return "vc:80Cx24C";
-#endif
     }
-    return NULL;
+    return vc;
 }
 
 void qemu_display_help(void)
-- 
2.41.0


Re: [PATCH] ui/console: fix default VC when there are no display
Posted by Marc-André Lureau 1 year ago
Hi

On Wed, Nov 8, 2023 at 5:37 PM <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> When display is "none", we may still have remote displays (I think it
> would be simpler if VNC/Spice were regular display btw). Return the
> default VC then, and set them up to fix a regression when using remote
> display and it used the TTY instead.
>
> Fixes: commit 1bec1cc0d ("ui/console: allow to override the default VC")
> Reported-by: German Maglione <gmaglione@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

German, did you file an issue on gitlab? Could you check/test this patch?

thanks

> ---
>  system/vl.c  |  4 +++-
>  ui/console.c | 14 ++++++++------
>  2 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/system/vl.c b/system/vl.c
> index bd7fad770b..8c522a07da 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -1359,6 +1359,7 @@ static void qemu_setup_display(void)
>              dpy.type = DISPLAY_TYPE_NONE;
>  #if defined(CONFIG_VNC)
>              vnc_parse("localhost:0,to=99,id=default");
> +            display_remote++;
>  #endif
>          }
>      }
> @@ -1391,7 +1392,8 @@ static void qemu_create_default_devices(void)
>          }
>      }
>
> -    if (nographic || (!vc && !is_daemonized() && isatty(STDOUT_FILENO))) {
> +    if (nographic ||
> +        ((!display_remote || !vc) && !is_daemonized() && isatty(STDOUT_FILENO))) {
>          if (default_parallel) {
>              add_device_config(DEV_PARALLEL, "null");
>          }
> diff --git a/ui/console.c b/ui/console.c
> index 8e688d3569..f08c8365b0 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -1679,19 +1679,21 @@ void qemu_display_init(DisplayState *ds, DisplayOptions *opts)
>
>  const char *qemu_display_get_vc(DisplayOptions *opts)
>  {
> +#ifdef CONFIG_PIXMAN
> +    const char *vc = "vc:80Cx24C";
> +#else
> +    const char *vc = NULL;
> +#endif
> +
>      assert(opts->type < DISPLAY_TYPE__MAX);
>      if (opts->type == DISPLAY_TYPE_NONE) {
> -        return NULL;
> +        return vc;
>      }
>      assert(dpys[opts->type] != NULL);
>      if (dpys[opts->type]->vc) {
>          return dpys[opts->type]->vc;
> -    } else {
> -#ifdef CONFIG_PIXMAN
> -        return "vc:80Cx24C";
> -#endif
>      }
> -    return NULL;
> +    return vc;
>  }
>
>  void qemu_display_help(void)
> --
> 2.41.0
>