dftxbs3e / rpms / qemu

Forked from rpms/qemu 3 years ago
Clone
5544c1b
From c50f358fbd549b5ec3b5dd82e29ed06ce969e50a Mon Sep 17 00:00:00 2001
c8dfc65
From: Yonit Halperin <yhalperi@redhat.com>
c8dfc65
Date: Tue, 21 Aug 2012 11:51:56 +0300
5544c1b
Subject: [PATCH] spice: notify on vm state change only via
c8dfc65
 spice_server_vm_start/stop
c8dfc65
c8dfc65
QXLWorker->start/stop are deprecated since spice-server 0.11.2
c8dfc65
c8dfc65
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
c8dfc65
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5544c1b
(cherry picked from commit 71d388d420e68ac77cd42f15f7e68cf5a6fb01b2)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
c8dfc65
---
c8dfc65
 hw/qxl.c           |  7 ++++---
c8dfc65
 ui/spice-core.c    |  4 ++++
c8dfc65
 ui/spice-display.c | 32 ++++++++++++++++++++++++++++++--
c8dfc65
 ui/spice-display.h |  9 +++++++--
c8dfc65
 4 files changed, 45 insertions(+), 7 deletions(-)
c8dfc65
c8dfc65
diff --git a/hw/qxl.c b/hw/qxl.c
c8dfc65
index c2dd3b4..95bbc03 100644
c8dfc65
--- a/hw/qxl.c
c8dfc65
+++ b/hw/qxl.c
c8dfc65
@@ -958,9 +958,10 @@ static void qxl_update_irq(PCIQXLDevice *d)
c8dfc65
 static void qxl_check_state(PCIQXLDevice *d)
c8dfc65
 {
c8dfc65
     QXLRam *ram = d->ram;
c8dfc65
+    int spice_display_running = qemu_spice_display_is_running(&d->ssd);
c8dfc65
 
c8dfc65
-    assert(!d->ssd.running || SPICE_RING_IS_EMPTY(&ram->cmd_ring));
c8dfc65
-    assert(!d->ssd.running || SPICE_RING_IS_EMPTY(&ram->cursor_ring));
c8dfc65
+    assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cmd_ring));
c8dfc65
+    assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cursor_ring));
c8dfc65
 }
c8dfc65
 
c8dfc65
 static void qxl_reset_state(PCIQXLDevice *d)
c8dfc65
@@ -1538,7 +1539,7 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
c8dfc65
     uint32_t old_pending;
c8dfc65
     uint32_t le_events = cpu_to_le32(events);
c8dfc65
 
c8dfc65
-    assert(d->ssd.running);
c8dfc65
+    assert(qemu_spice_display_is_running(&d->ssd));
c8dfc65
     old_pending = __sync_fetch_and_or(&d->ram->int_pending, le_events);
c8dfc65
     if ((old_pending & le_events) == le_events) {
c8dfc65
         return;
c8dfc65
diff --git a/ui/spice-core.c b/ui/spice-core.c
c8dfc65
index a515c94..1a7a773 100644
c8dfc65
--- a/ui/spice-core.c
c8dfc65
+++ b/ui/spice-core.c
c8dfc65
@@ -37,6 +37,7 @@
c8dfc65
 #include "migration.h"
c8dfc65
 #include "monitor.h"
c8dfc65
 #include "hw/hw.h"
c8dfc65
+#include "spice-display.h"
c8dfc65
 
c8dfc65
 /* core bits */
c8dfc65
 
c8dfc65
@@ -551,9 +552,11 @@ static void vm_change_state_handler(void *opaque, int running,
c8dfc65
 {
c8dfc65
 #if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
c8dfc65
     if (running) {
c8dfc65
+        qemu_spice_display_start();
c8dfc65
         spice_server_vm_start(spice_server);
c8dfc65
     } else {
c8dfc65
         spice_server_vm_stop(spice_server);
c8dfc65
+        qemu_spice_display_stop();
c8dfc65
     }
c8dfc65
 #endif
c8dfc65
 }
c8dfc65
@@ -755,6 +758,7 @@ int qemu_spice_add_interface(SpiceBaseInstance *sin)
c8dfc65
         spice_server = spice_server_new();
c8dfc65
         spice_server_init(spice_server, &core_interface);
c8dfc65
     }
c8dfc65
+
c8dfc65
     return spice_server_add_interface(spice_server, sin);
c8dfc65
 }
c8dfc65
 
c8dfc65
diff --git a/ui/spice-display.c b/ui/spice-display.c
c8dfc65
index 3e8f0b3..1c31418 100644
c8dfc65
--- a/ui/spice-display.c
c8dfc65
+++ b/ui/spice-display.c
c8dfc65
@@ -126,18 +126,44 @@ void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
c8dfc65
     ssd->worker->wakeup(ssd->worker);
c8dfc65
 }
c8dfc65
 
c8dfc65
-void qemu_spice_start(SimpleSpiceDisplay *ssd)
c8dfc65
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
c8dfc65
+static void qemu_spice_start(SimpleSpiceDisplay *ssd)
c8dfc65
 {
c8dfc65
     trace_qemu_spice_start(ssd->qxl.id);
c8dfc65
     ssd->worker->start(ssd->worker);
c8dfc65
 }
c8dfc65
 
c8dfc65
-void qemu_spice_stop(SimpleSpiceDisplay *ssd)
c8dfc65
+static void qemu_spice_stop(SimpleSpiceDisplay *ssd)
c8dfc65
 {
c8dfc65
     trace_qemu_spice_stop(ssd->qxl.id);
c8dfc65
     ssd->worker->stop(ssd->worker);
c8dfc65
 }
c8dfc65
 
c8dfc65
+#else
c8dfc65
+
c8dfc65
+static int spice_display_is_running;
c8dfc65
+
c8dfc65
+void qemu_spice_display_start(void)
c8dfc65
+{
c8dfc65
+    spice_display_is_running = true;
c8dfc65
+}
c8dfc65
+
c8dfc65
+void qemu_spice_display_stop(void)
c8dfc65
+{
c8dfc65
+    spice_display_is_running = false;
c8dfc65
+}
c8dfc65
+
c8dfc65
+#endif
c8dfc65
+
c8dfc65
+int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
c8dfc65
+{
c8dfc65
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
c8dfc65
+    return ssd->running;
c8dfc65
+#else
c8dfc65
+    return spice_display_is_running;
c8dfc65
+#endif
c8dfc65
+}
c8dfc65
+
c8dfc65
 static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
c8dfc65
 {
c8dfc65
     SimpleSpiceUpdate *update;
c8dfc65
@@ -272,6 +298,7 @@ void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)
c8dfc65
 void qemu_spice_vm_change_state_handler(void *opaque, int running,
c8dfc65
                                         RunState state)
c8dfc65
 {
c8dfc65
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
c8dfc65
     SimpleSpiceDisplay *ssd = opaque;
c8dfc65
 
c8dfc65
     if (running) {
c8dfc65
@@ -281,6 +308,7 @@ void qemu_spice_vm_change_state_handler(void *opaque, int running,
c8dfc65
         qemu_spice_stop(ssd);
c8dfc65
         ssd->running = false;
c8dfc65
     }
c8dfc65
+#endif
c8dfc65
 }
c8dfc65
 
c8dfc65
 void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
c8dfc65
diff --git a/ui/spice-display.h b/ui/spice-display.h
c8dfc65
index 12e50b6..672d65e 100644
c8dfc65
--- a/ui/spice-display.h
c8dfc65
+++ b/ui/spice-display.h
c8dfc65
@@ -82,7 +82,9 @@ struct SimpleSpiceDisplay {
c8dfc65
 
c8dfc65
     QXLRect dirty;
c8dfc65
     int notify;
c8dfc65
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
c8dfc65
     int running;
c8dfc65
+#endif
c8dfc65
 
c8dfc65
     /*
c8dfc65
      * All struct members below this comment can be accessed from
c8dfc65
@@ -129,5 +131,8 @@ void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
c8dfc65
 void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
c8dfc65
                                         uint32_t id, qxl_async_io async);
c8dfc65
 void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
c8dfc65
-void qemu_spice_start(SimpleSpiceDisplay *ssd);
c8dfc65
-void qemu_spice_stop(SimpleSpiceDisplay *ssd);
c8dfc65
+#if SPICE_SERVER_VERSION >= 0x000b02 /* before 0.11.2 */
c8dfc65
+void qemu_spice_display_start(void);
c8dfc65
+void qemu_spice_display_stop(void);
c8dfc65
+#endif
c8dfc65
+int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd);
c8dfc65
-- 
5544c1b
1.7.12.1
c8dfc65