thebeanogamer / rpms / qemu-kvm

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