thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qxl-use-guest_monitor_config-for-local-renderer.patch

26ba25
From 53f7b5bea75509998a5280e714029d639d255e9e Mon Sep 17 00:00:00 2001
26ba25
From: Gerd Hoffmann <kraxel@redhat.com>
26ba25
Date: Thu, 22 Nov 2018 11:33:36 +0000
26ba25
Subject: [PATCH 06/16] qxl: use guest_monitor_config for local renderer.
26ba25
MIME-Version: 1.0
26ba25
Content-Type: text/plain; charset=UTF-8
26ba25
Content-Transfer-Encoding: 8bit
26ba25
26ba25
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
26ba25
Message-id: <20181122113336.2925-2-kraxel@redhat.com>
26ba25
Patchwork-id: 83094
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 1/1] qxl: use guest_monitor_config for local renderer.
26ba25
Bugzilla: 1610163
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
26ba25
When processing monitor config from guest store head0 width and height
26ba25
for single-head configurations.  Use these when creating the
26ba25
DisplaySurface in the local renderer.
26ba25
26ba25
This fixes a rendering issue with wayland.  Wayland rounds up the
26ba25
framebuffer width and height to a multiple of 64, so with odd
26ba25
resolutions (800x600 for example) the framebuffer is larger than the
26ba25
actual screen.  The monitor config has the actual screen size though.
26ba25
26ba25
This fixes guest display for anything using the local renderer
26ba25
(non-spice UI, screendump monitor command).
26ba25
26ba25
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
26ba25
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
26ba25
Message-id: 20180919103057.9666-1-kraxel@redhat.com
26ba25
(cherry picked from commit 979f7ef8966bc4495a710ed9e4af42098f92ee79)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 hw/display/qxl-render.c | 18 ++++++++++--------
26ba25
 hw/display/qxl.c        | 12 ++++++++++++
26ba25
 hw/display/qxl.h        |  2 ++
26ba25
 3 files changed, 24 insertions(+), 8 deletions(-)
26ba25
26ba25
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
26ba25
index c62b9a5..6debe8f 100644
26ba25
--- a/hw/display/qxl-render.c
26ba25
+++ b/hw/display/qxl-render.c
26ba25
@@ -98,6 +98,8 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
26ba25
 {
26ba25
     VGACommonState *vga = &qxl->vga;
26ba25
     DisplaySurface *surface;
26ba25
+    int width = qxl->guest_head0_width ?: qxl->guest_primary.surface.width;
26ba25
+    int height = qxl->guest_head0_height ?: qxl->guest_primary.surface.height;
26ba25
     int i;
26ba25
 
26ba25
     if (qxl->guest_primary.resized) {
26ba25
@@ -111,8 +113,8 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
26ba25
         qxl_set_rect_to_surface(qxl, &qxl->dirty[0]);
26ba25
         qxl->num_dirty_rects = 1;
26ba25
         trace_qxl_render_guest_primary_resized(
26ba25
-               qxl->guest_primary.surface.width,
26ba25
-               qxl->guest_primary.surface.height,
26ba25
+               width,
26ba25
+               height,
26ba25
                qxl->guest_primary.qxl_stride,
26ba25
                qxl->guest_primary.bytes_pp,
26ba25
                qxl->guest_primary.bits_pp);
26ba25
@@ -120,15 +122,15 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
26ba25
             pixman_format_code_t format =
26ba25
                 qemu_default_pixman_format(qxl->guest_primary.bits_pp, true);
26ba25
             surface = qemu_create_displaysurface_from
26ba25
-                (qxl->guest_primary.surface.width,
26ba25
-                 qxl->guest_primary.surface.height,
26ba25
+                (width,
26ba25
+                 height,
26ba25
                  format,
26ba25
                  qxl->guest_primary.abs_stride,
26ba25
                  qxl->guest_primary.data);
26ba25
         } else {
26ba25
             surface = qemu_create_displaysurface
26ba25
-                (qxl->guest_primary.surface.width,
26ba25
-                 qxl->guest_primary.surface.height);
26ba25
+                (width,
26ba25
+                 height);
26ba25
         }
26ba25
         dpy_gfx_replace_surface(vga->con, surface);
26ba25
     }
26ba25
@@ -144,8 +146,8 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
26ba25
             qxl->dirty[i].top < 0 ||
26ba25
             qxl->dirty[i].left > qxl->dirty[i].right ||
26ba25
             qxl->dirty[i].top > qxl->dirty[i].bottom ||
26ba25
-            qxl->dirty[i].right > qxl->guest_primary.surface.width ||
26ba25
-            qxl->dirty[i].bottom > qxl->guest_primary.surface.height) {
26ba25
+            qxl->dirty[i].right > width ||
26ba25
+            qxl->dirty[i].bottom > height) {
26ba25
             continue;
26ba25
         }
26ba25
         qxl_blit(qxl, qxl->dirty+i);
26ba25
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
26ba25
index a71714c..e36ef32 100644
26ba25
--- a/hw/display/qxl.c
26ba25
+++ b/hw/display/qxl.c
26ba25
@@ -258,6 +258,8 @@ static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl, qxl_async_io async)
26ba25
 
26ba25
 static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
26ba25
 {
26ba25
+    QXLMonitorsConfig *cfg;
26ba25
+
26ba25
     trace_qxl_spice_monitors_config(qxl->id);
26ba25
     if (replay) {
26ba25
         /*
26ba25
@@ -285,6 +287,16 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
26ba25
                 (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
26ba25
                                           QXL_IO_MONITORS_CONFIG_ASYNC));
26ba25
     }
26ba25
+
26ba25
+    cfg = qxl_phys2virt(qxl, qxl->guest_monitors_config, MEMSLOT_GROUP_GUEST);
26ba25
+    if (cfg->count == 1) {
26ba25
+        qxl->guest_primary.resized = 1;
26ba25
+        qxl->guest_head0_width  = cfg->heads[0].width;
26ba25
+        qxl->guest_head0_height = cfg->heads[0].height;
26ba25
+    } else {
26ba25
+        qxl->guest_head0_width  = 0;
26ba25
+        qxl->guest_head0_height = 0;
26ba25
+    }
26ba25
 }
26ba25
 
26ba25
 void qxl_spice_reset_image_cache(PCIQXLDevice *qxl)
26ba25
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
26ba25
index 089696e..ffa6260 100644
26ba25
--- a/hw/display/qxl.h
26ba25
+++ b/hw/display/qxl.h
26ba25
@@ -79,6 +79,8 @@ typedef struct PCIQXLDevice {
26ba25
     QXLPHYSICAL        guest_cursor;
26ba25
 
26ba25
     QXLPHYSICAL        guest_monitors_config;
26ba25
+    uint32_t           guest_head0_width;
26ba25
+    uint32_t           guest_head0_height;
26ba25
 
26ba25
     QemuMutex          track_lock;
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25