From 2ce7ceac45d27a3d9fc4ede839f8ed17a7a57c6c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 17 Feb 2012 08:52:50 +0100
Subject: [PATCH 01/12] qxl: don't render stuff when the vm is stopped.

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1329468770-28600-1-git-send-email-kraxel@redhat.com>
Patchwork-id: 37399
O-Subject: [RHEL-6.3 qemu-kvm PATCH] qxl: don't render stuff when the vm is stopped.
Bugzilla: 748810
RH-Acked-by: Alon Levy <alevy@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>

This patch fixes the local qxl renderer to not kick spice-server
in case the vm is stopped.  First it is largely pointless because
we ask spice-server to process all not-yet processed commands when
the vm is stopped, so there isn't much do do anyway.  Second we
avoid triggering an assert in spice-server.

The patch makes sure we still honor redraw requests, even if we don't
ask spice-server for updates.  This is needed to handle displaysurface
changes with a stopped vm correctly.

With this patch applied it is possible to take screen shots (via
screendump monitor command) from a qxl gpu even in case the guest
is stopped.

bugzilla: #748810
upstream: http://patchwork.ozlabs.org/patch/141398/
upstream commit: 7844e448

brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4053146

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qxl-render.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/qxl-render.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index 69e81fd..ba93e4c 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -120,19 +120,17 @@ void qxl_render_update(PCIQXLDevice *qxl)
         dpy_resize(vga->ds);
     }
 
-    if (!qxl->guest_primary.commands) {
-        return;
-    }
-    qxl->guest_primary.commands = 0;
-
     update.left   = 0;
     update.right  = qxl->guest_primary.surface.width;
     update.top    = 0;
     update.bottom = qxl->guest_primary.surface.height;
 
     memset(dirty, 0, sizeof(dirty));
-    qxl_spice_update_area(qxl, 0, &update,
-                          dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC);
+    if (runstate_is_running() && qxl->guest_primary.commands) {
+        qxl->guest_primary.commands = 0;
+        qxl_spice_update_area(qxl, 0, &update,
+                              dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC);
+    }
     if (redraw) {
         memset(dirty, 0, sizeof(dirty));
         dirty[0] = update;
-- 
1.7.7.6