Blob Blame History Raw
From 7d82cea3c5aa7abc7942eb63c9ce232e10084bd5 Mon Sep 17 00:00:00 2001
From: Tarun Gupta <tgupta@redhat.com>
Date: Wed, 20 Jun 2018 18:54:18 +0200
Subject: [PATCH 10/17] console: nicer initial screen

RH-Author: Tarun Gupta <tgupta@redhat.com>
Message-id: <1529520865-18127-5-git-send-email-tgupta@redhat.com>
Patchwork-id: 80915
O-Subject: [RHEL7.6 qemu-kvm PATCH v3 04/11] console: nicer initial screen
Bugzilla: 1555246
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Now that we have a function to create a fancy DisplaySurface with a
message for the user, to handle non-existing graphics hardware, we
can make it more generic and use it for other things too.

This patch adds a text line to the in initial DisplaySurface,
notifying the user that the display isn't initialized yet by the guest.

You can see this in action when starting qemu with '-S'.  Also when
booting ovmf in qemu (which needs a few moments to initialize itself
before it initializes the vga).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

(cherry picked from 521a580d2352ad30086babcabb91e6338e47cf62)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 ui/console.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index fb08ec0..c14a0bc 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1323,19 +1323,18 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp,
     return surface;
 }
 
-static DisplaySurface *qemu_create_dummy_surface(void)
+static DisplaySurface *qemu_create_message_surface(int w, int h,
+                                                   const char *msg)
 {
-    static const char msg[] =
-        "This VM has no graphic display device.";
-    DisplaySurface *surface = qemu_create_displaysurface(640, 480);
+    DisplaySurface *surface = qemu_create_displaysurface(w, h);
     pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];
     pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];
     pixman_image_t *glyph;
     int len, x, y, i;
 
     len = strlen(msg);
-    x = (640/FONT_WIDTH  - len) / 2;
-    y = (480/FONT_HEIGHT - 1)   / 2;
+    x = (w/FONT_WIDTH  - len) / 2;
+    y = (h/FONT_HEIGHT - 1)   / 2;
     for (i = 0; i < len; i++) {
         glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]);
         qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg,
@@ -1357,6 +1356,8 @@ void qemu_free_displaysurface(DisplaySurface *surface)
 
 void register_displaychangelistener(DisplayChangeListener *dcl)
 {
+    static const char nodev[] =
+        "This VM has no graphic display device.";
     static DisplaySurface *dummy;
     QemuConsole *con;
 
@@ -1375,7 +1376,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
             dcl->ops->dpy_gfx_switch(dcl, con->surface);
         } else {
             if (!dummy) {
-                dummy = qemu_create_dummy_surface();
+                dummy = qemu_create_message_surface(640, 480, nodev);
             }
             dcl->ops->dpy_gfx_switch(dcl, dummy);
         }
@@ -1602,6 +1603,8 @@ QemuConsole *graphic_console_init(DeviceState *dev,
                                   const GraphicHwOps *hw_ops,
                                   void *opaque)
 {
+    static const char noinit[] =
+        "Guest has not initialized the display (yet).";
     Error *local_err = NULL;
     int width = 640;
     int height = 480;
@@ -1618,7 +1621,7 @@ QemuConsole *graphic_console_init(DeviceState *dev,
                                  "device", &local_err);
     }
 
-    s->surface = qemu_create_displaysurface(width, height);
+    s->surface = qemu_create_message_surface(width, height, noinit);
     return s;
 }
 
-- 
1.8.3.1