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