yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
169b9a
From 7d82cea3c5aa7abc7942eb63c9ce232e10084bd5 Mon Sep 17 00:00:00 2001
169b9a
From: Tarun Gupta <tgupta@redhat.com>
169b9a
Date: Wed, 20 Jun 2018 18:54:18 +0200
169b9a
Subject: [PATCH 10/17] console: nicer initial screen
169b9a
169b9a
RH-Author: Tarun Gupta <tgupta@redhat.com>
169b9a
Message-id: <1529520865-18127-5-git-send-email-tgupta@redhat.com>
169b9a
Patchwork-id: 80915
169b9a
O-Subject: [RHEL7.6 qemu-kvm PATCH v3 04/11] console: nicer initial screen
169b9a
Bugzilla: 1555246
169b9a
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
169b9a
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
169b9a
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
169b9a
169b9a
Now that we have a function to create a fancy DisplaySurface with a
169b9a
message for the user, to handle non-existing graphics hardware, we
169b9a
can make it more generic and use it for other things too.
169b9a
169b9a
This patch adds a text line to the in initial DisplaySurface,
169b9a
notifying the user that the display isn't initialized yet by the guest.
169b9a
169b9a
You can see this in action when starting qemu with '-S'.  Also when
169b9a
booting ovmf in qemu (which needs a few moments to initialize itself
169b9a
before it initializes the vga).
169b9a
169b9a
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
169b9a
169b9a
(cherry picked from 521a580d2352ad30086babcabb91e6338e47cf62)
169b9a
169b9a
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
169b9a
---
169b9a
 ui/console.c | 19 +++++++++++--------
169b9a
 1 file changed, 11 insertions(+), 8 deletions(-)
169b9a
169b9a
diff --git a/ui/console.c b/ui/console.c
169b9a
index fb08ec0..c14a0bc 100644
169b9a
--- a/ui/console.c
169b9a
+++ b/ui/console.c
169b9a
@@ -1323,19 +1323,18 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp,
169b9a
     return surface;
169b9a
 }
169b9a
 
169b9a
-static DisplaySurface *qemu_create_dummy_surface(void)
169b9a
+static DisplaySurface *qemu_create_message_surface(int w, int h,
169b9a
+                                                   const char *msg)
169b9a
 {
169b9a
-    static const char msg[] =
169b9a
-        "This VM has no graphic display device.";
169b9a
-    DisplaySurface *surface = qemu_create_displaysurface(640, 480);
169b9a
+    DisplaySurface *surface = qemu_create_displaysurface(w, h);
169b9a
     pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];
169b9a
     pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];
169b9a
     pixman_image_t *glyph;
169b9a
     int len, x, y, i;
169b9a
 
169b9a
     len = strlen(msg);
169b9a
-    x = (640/FONT_WIDTH  - len) / 2;
169b9a
-    y = (480/FONT_HEIGHT - 1)   / 2;
169b9a
+    x = (w/FONT_WIDTH  - len) / 2;
169b9a
+    y = (h/FONT_HEIGHT - 1)   / 2;
169b9a
     for (i = 0; i < len; i++) {
169b9a
         glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]);
169b9a
         qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg,
169b9a
@@ -1357,6 +1356,8 @@ void qemu_free_displaysurface(DisplaySurface *surface)
169b9a
 
169b9a
 void register_displaychangelistener(DisplayChangeListener *dcl)
169b9a
 {
169b9a
+    static const char nodev[] =
169b9a
+        "This VM has no graphic display device.";
169b9a
     static DisplaySurface *dummy;
169b9a
     QemuConsole *con;
169b9a
 
169b9a
@@ -1375,7 +1376,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
169b9a
             dcl->ops->dpy_gfx_switch(dcl, con->surface);
169b9a
         } else {
169b9a
             if (!dummy) {
169b9a
-                dummy = qemu_create_dummy_surface();
169b9a
+                dummy = qemu_create_message_surface(640, 480, nodev);
169b9a
             }
169b9a
             dcl->ops->dpy_gfx_switch(dcl, dummy);
169b9a
         }
169b9a
@@ -1602,6 +1603,8 @@ QemuConsole *graphic_console_init(DeviceState *dev,
169b9a
                                   const GraphicHwOps *hw_ops,
169b9a
                                   void *opaque)
169b9a
 {
169b9a
+    static const char noinit[] =
169b9a
+        "Guest has not initialized the display (yet).";
169b9a
     Error *local_err = NULL;
169b9a
     int width = 640;
169b9a
     int height = 480;
169b9a
@@ -1618,7 +1621,7 @@ QemuConsole *graphic_console_init(DeviceState *dev,
169b9a
                                  "device", &local_err);
169b9a
     }
169b9a
 
169b9a
-    s->surface = qemu_create_displaysurface(width, height);
169b9a
+    s->surface = qemu_create_message_surface(width, height, noinit);
169b9a
     return s;
169b9a
 }
169b9a
 
169b9a
-- 
169b9a
1.8.3.1
169b9a