Skip to content

Commit

Permalink
spice: notify on vm state change only via spice_server_vm_start/stop
Browse files Browse the repository at this point in the history
QXLWorker->start/stop are deprecated since spice-server 0.11.2

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
Yonit Halperin authored and kraxel committed Sep 5, 2012
1 parent f5bb039 commit 71d388d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
7 changes: 4 additions & 3 deletions hw/qxl.c
Expand Up @@ -958,9 +958,10 @@ static void qxl_update_irq(PCIQXLDevice *d)
static void qxl_check_state(PCIQXLDevice *d)
{
QXLRam *ram = d->ram;
int spice_display_running = qemu_spice_display_is_running(&d->ssd);

assert(!d->ssd.running || SPICE_RING_IS_EMPTY(&ram->cmd_ring));
assert(!d->ssd.running || SPICE_RING_IS_EMPTY(&ram->cursor_ring));
assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cmd_ring));
assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cursor_ring));
}

static void qxl_reset_state(PCIQXLDevice *d)
Expand Down Expand Up @@ -1538,7 +1539,7 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
uint32_t old_pending;
uint32_t le_events = cpu_to_le32(events);

assert(d->ssd.running);
assert(qemu_spice_display_is_running(&d->ssd));
old_pending = __sync_fetch_and_or(&d->ram->int_pending, le_events);
if ((old_pending & le_events) == le_events) {
return;
Expand Down
4 changes: 4 additions & 0 deletions ui/spice-core.c
Expand Up @@ -37,6 +37,7 @@
#include "migration.h"
#include "monitor.h"
#include "hw/hw.h"
#include "spice-display.h"

/* core bits */

Expand Down Expand Up @@ -551,9 +552,11 @@ static void vm_change_state_handler(void *opaque, int running,
{
#if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
if (running) {
qemu_spice_display_start();
spice_server_vm_start(spice_server);
} else {
spice_server_vm_stop(spice_server);
qemu_spice_display_stop();
}
#endif
}
Expand Down Expand Up @@ -755,6 +758,7 @@ int qemu_spice_add_interface(SpiceBaseInstance *sin)
spice_server = spice_server_new();
spice_server_init(spice_server, &core_interface);
}

return spice_server_add_interface(spice_server, sin);
}

Expand Down
32 changes: 30 additions & 2 deletions ui/spice-display.c
Expand Up @@ -126,18 +126,44 @@ void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
ssd->worker->wakeup(ssd->worker);
}

void qemu_spice_start(SimpleSpiceDisplay *ssd)
#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
static void qemu_spice_start(SimpleSpiceDisplay *ssd)
{
trace_qemu_spice_start(ssd->qxl.id);
ssd->worker->start(ssd->worker);
}

void qemu_spice_stop(SimpleSpiceDisplay *ssd)
static void qemu_spice_stop(SimpleSpiceDisplay *ssd)
{
trace_qemu_spice_stop(ssd->qxl.id);
ssd->worker->stop(ssd->worker);
}

#else

static int spice_display_is_running;

void qemu_spice_display_start(void)
{
spice_display_is_running = true;
}

void qemu_spice_display_stop(void)
{
spice_display_is_running = false;
}

#endif

int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
{
#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
return ssd->running;
#else
return spice_display_is_running;
#endif
}

static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{
SimpleSpiceUpdate *update;
Expand Down Expand Up @@ -272,6 +298,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) {
Expand All @@ -281,6 +308,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)
Expand Down
9 changes: 7 additions & 2 deletions ui/spice-display.h
Expand Up @@ -82,7 +82,9 @@ struct SimpleSpiceDisplay {

QXLRect dirty;
int notify;
#if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
int running;
#endif

/*
* All struct members below this comment can be accessed from
Expand Down Expand Up @@ -129,5 +131,8 @@ 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);
void qemu_spice_start(SimpleSpiceDisplay *ssd);
void qemu_spice_stop(SimpleSpiceDisplay *ssd);
#if SPICE_SERVER_VERSION >= 0x000b02 /* before 0.11.2 */
void qemu_spice_display_start(void);
void qemu_spice_display_stop(void);
#endif
int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd);

0 comments on commit 71d388d

Please sign in to comment.