26ba25
From e41c578615d2b52db633214891631ca61973f34b Mon Sep 17 00:00:00 2001
26ba25
From: Gerd Hoffmann <kraxel@redhat.com>
26ba25
Date: Wed, 4 Jul 2018 09:54:07 +0200
26ba25
Subject: [PATCH 187/268] virtio-gpu: tweak scanout disable.
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: <20180704095409.14514-2-kraxel@redhat.com>
26ba25
Patchwork-id: 81226
26ba25
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/3] virtio-gpu: tweak scanout disable.
26ba25
Bugzilla: 1589634
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
26ba25
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
26ba25
26ba25
- Factor out the code to virtio_gpu_disable_scanout().
26ba25
- Allow disable scanout 0, show a message then.
26ba25
- Clear scanout->resource_id.
26ba25
26ba25
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
26ba25
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
26ba25
Message-id: 20180702162443.16796-2-kraxel@redhat.com
26ba25
(cherry picked from commit da566a18a7799e5a655cd9f87e222b672cc93e7b)
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 hw/display/virtio-gpu.c | 47 +++++++++++++++++++++++++++++------------------
26ba25
 1 file changed, 29 insertions(+), 18 deletions(-)
26ba25
26ba25
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
26ba25
index 2dd3c34..054ec73 100644
26ba25
--- a/hw/display/virtio-gpu.c
26ba25
+++ b/hw/display/virtio-gpu.c
26ba25
@@ -399,6 +399,34 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g,
26ba25
     g->hostmem += res->hostmem;
26ba25
 }
26ba25
 
26ba25
+static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id)
26ba25
+{
26ba25
+    struct virtio_gpu_scanout *scanout = &g->scanout[scanout_id];
26ba25
+    struct virtio_gpu_simple_resource *res;
26ba25
+    DisplaySurface *ds = NULL;
26ba25
+
26ba25
+    if (scanout->resource_id == 0) {
26ba25
+        return;
26ba25
+    }
26ba25
+
26ba25
+    res = virtio_gpu_find_resource(g, scanout->resource_id);
26ba25
+    if (res) {
26ba25
+        res->scanout_bitmask &= ~(1 << scanout_id);
26ba25
+    }
26ba25
+
26ba25
+    if (scanout_id == 0) {
26ba25
+        /* primary head */
26ba25
+        ds = qemu_create_message_surface(scanout->width  ?: 640,
26ba25
+                                         scanout->height ?: 480,
26ba25
+                                         "Guest disabled display.");
26ba25
+    }
26ba25
+    dpy_gfx_replace_surface(scanout->con, ds);
26ba25
+    scanout->resource_id = 0;
26ba25
+    scanout->ds = NULL;
26ba25
+    scanout->width = 0;
26ba25
+    scanout->height = 0;
26ba25
+}
26ba25
+
26ba25
 static void virtio_gpu_resource_destroy(VirtIOGPU *g,
26ba25
                                         struct virtio_gpu_simple_resource *res)
26ba25
 {
26ba25
@@ -583,24 +611,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
26ba25
 
26ba25
     g->enable = 1;
26ba25
     if (ss.resource_id == 0) {
26ba25
-        scanout = &g->scanout[ss.scanout_id];
26ba25
-        if (scanout->resource_id) {
26ba25
-            res = virtio_gpu_find_resource(g, scanout->resource_id);
26ba25
-            if (res) {
26ba25
-                res->scanout_bitmask &= ~(1 << ss.scanout_id);
26ba25
-            }
26ba25
-        }
26ba25
-        if (ss.scanout_id == 0) {
26ba25
-            qemu_log_mask(LOG_GUEST_ERROR,
26ba25
-                          "%s: illegal scanout id specified %d",
26ba25
-                          __func__, ss.scanout_id);
26ba25
-            cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID;
26ba25
-            return;
26ba25
-        }
26ba25
-        dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL);
26ba25
-        scanout->ds = NULL;
26ba25
-        scanout->width = 0;
26ba25
-        scanout->height = 0;
26ba25
+        virtio_gpu_disable_scanout(g, ss.scanout_id);
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25