qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yonit Halperin <yhalperi@redhat.com>
To: qemu-devel@nongnu.org
Cc: Yonit Halperin <yhalperi@redhat.com>, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v2 2/5] spice: notify on vm state change only via spice_server_vm_start/stop
Date: Mon, 20 Aug 2012 16:26:13 +0300	[thread overview]
Message-ID: <1345469176-1675-3-git-send-email-yhalperi@redhat.com> (raw)
In-Reply-To: <1345469176-1675-1-git-send-email-yhalperi@redhat.com>

QXLWorker->start/stop are deprecated since spice-server 0.11.2

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 ui/spice-core.c    |   44 ++++++++++++++++++++++++++++++++++++++++++++
 ui/spice-display.c |    6 ++++++
 ui/spice-display.h |    2 ++
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 32de1f1..97b45f8 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -37,6 +37,7 @@
 #include "migration.h"
 #include "monitor.h"
 #include "hw/hw.h"
+#include "spice-display.h"
 
 /* core bits */
 
@@ -55,6 +56,16 @@ struct SpiceTimer {
 };
 static QTAILQ_HEAD(, SpiceTimer) timers = QTAILQ_HEAD_INITIALIZER(timers);
 
+typedef struct DisplayListItem DisplayListItem;
+
+struct DisplayListItem {
+    SimpleSpiceDisplay *display;
+    QLIST_ENTRY(DisplayListItem) link;
+};
+static QLIST_HEAD(, DisplayListItem) display_list =
+    QLIST_HEAD_INITIALIZER(display_list);
+
+
 static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
 {
     SpiceTimer *timer;
@@ -545,14 +556,36 @@ static int add_channel(const char *name, const char *value, void *opaque)
     return 0;
 }
 
+#if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
+static void display_start(void)
+{
+    DisplayListItem *item;
+
+    QLIST_FOREACH(item, &display_list, link) {
+        item->display->running = true;
+    }
+}
+
+static void display_stop(void)
+{
+    DisplayListItem *item;
+
+    QLIST_FOREACH(item, &display_list, link) {
+        item->display->running = false;
+    }
+}
+#endif
+
 static void vm_change_state_handler(void *opaque, int running,
                                     RunState state)
 {
 #if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
     if (running) {
+        display_start();
         spice_server_vm_start(spice_server);
     } else {
         spice_server_vm_stop(spice_server);
+        display_stop();
     }
 #endif
 }
@@ -754,6 +787,17 @@ int qemu_spice_add_interface(SpiceBaseInstance *sin)
         spice_server = spice_server_new();
         spice_server_init(spice_server, &core_interface);
     }
+
+    if (strcmp(sin->sif->type, SPICE_INTERFACE_QXL) == 0) {
+        QXLInstance *qxl;
+        DisplayListItem *item;
+
+        qxl = container_of(sin, QXLInstance, base);
+        item = g_malloc0(sizeof(*item));
+        item->display = container_of(qxl, SimpleSpiceDisplay, qxl);
+
+        QLIST_INSERT_HEAD(&display_list, item, link);
+    }
     return spice_server_add_interface(spice_server, sin);
 }
 
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 3e8f0b3..073a354 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -126,6 +126,7 @@ void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
     ssd->worker->wakeup(ssd->worker);
 }
 
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
 void qemu_spice_start(SimpleSpiceDisplay *ssd)
 {
     trace_qemu_spice_start(ssd->qxl.id);
@@ -137,6 +138,7 @@ void qemu_spice_stop(SimpleSpiceDisplay *ssd)
     trace_qemu_spice_stop(ssd->qxl.id);
     ssd->worker->stop(ssd->worker);
 }
+#endif
 
 static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
 {
@@ -272,6 +274,7 @@ void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)
 void qemu_spice_vm_change_state_handler(void *opaque, int running,
                                         RunState state)
 {
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
     SimpleSpiceDisplay *ssd = opaque;
 
     if (running) {
@@ -281,6 +284,7 @@ void qemu_spice_vm_change_state_handler(void *opaque, int running,
         qemu_spice_stop(ssd);
         ssd->running = false;
     }
+#endif
 }
 
 void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
@@ -518,7 +522,9 @@ void qemu_spice_display_init(DisplayState *ds)
     qemu_spice_add_interface(&sdpy.qxl.base);
     assert(sdpy.worker);
 
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
     qemu_add_vm_change_state_handler(qemu_spice_vm_change_state_handler, &sdpy);
+#endif
     qemu_spice_create_host_memslot(&sdpy);
     qemu_spice_create_host_primary(&sdpy);
 }
diff --git a/ui/spice-display.h b/ui/spice-display.h
index 12e50b6..cf7a8e7 100644
--- a/ui/spice-display.h
+++ b/ui/spice-display.h
@@ -129,5 +129,7 @@ void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
 void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
                                         uint32_t id, qxl_async_io async);
 void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
+#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
 void qemu_spice_start(SimpleSpiceDisplay *ssd);
 void qemu_spice_stop(SimpleSpiceDisplay *ssd);
+#endif
-- 
1.7.7.6

  parent reply	other threads:[~2012-08-20 13:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-20 13:26 [Qemu-devel] [PATCH v2 0/5] add support for spice migration v2 Yonit Halperin
2012-08-20 13:26 ` [Qemu-devel] [PATCH v2 1/5] spice: notify spice server on vm start/stop Yonit Halperin
2012-08-20 13:26 ` Yonit Halperin [this message]
2012-08-21  6:58   ` [Qemu-devel] [PATCH v2 2/5] spice: notify on vm state change only via spice_server_vm_start/stop Gerd Hoffmann
2012-08-21  7:09     ` Yonit Halperin
2012-08-21  7:17       ` Gerd Hoffmann
2012-08-20 13:26 ` [Qemu-devel] [PATCH v2 3/5] spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED Yonit Halperin
2012-08-20 13:26 ` [Qemu-devel] [PATCH v2 4/5] spice: add 'migrated' flag to spice info Yonit Halperin
2012-08-20 13:26 ` [Qemu-devel] [PATCH v2 5/5] spice: adding seamless-migration option to the command line Yonit Halperin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345469176-1675-3-git-send-email-yhalperi@redhat.com \
    --to=yhalperi@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).