Revision e0c64d08 ui/spice-display.c

b/ui/spice-display.c
62 62
    dest->right = MAX(dest->right, r->right);
63 63
}
64 64

  
65
/*
66
 * Called from spice server thread context (via interface_get_command).
67
 *
68
 * We must aquire the global qemu mutex here to make sure the
69
 * DisplayState (+DisplaySurface) we are accessing doesn't change
70
 * underneath us.
71
 */
72
SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
65
static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
73 66
{
74 67
    SimpleSpiceUpdate *update;
75 68
    QXLDrawable *drawable;
......
78 71
    uint8_t *src, *dst;
79 72
    int by, bw, bh;
80 73

  
81
    qemu_mutex_lock_iothread();
82 74
    if (qemu_spice_rect_is_empty(&ssd->dirty)) {
83
        qemu_mutex_unlock_iothread();
84 75
        return NULL;
85 76
    };
86 77

  
......
141 132
    cmd->data = (intptr_t)drawable;
142 133

  
143 134
    memset(&ssd->dirty, 0, sizeof(ssd->dirty));
144
    qemu_mutex_unlock_iothread();
145 135
    return update;
146 136
}
147 137

  
......
241 231
    qemu_pf_conv_put(ssd->conv);
242 232
    ssd->conv = NULL;
243 233

  
234
    qemu_mutex_lock(&ssd->lock);
235
    if (ssd->update != NULL) {
236
        qemu_spice_destroy_update(ssd, ssd->update);
237
        ssd->update = NULL;
238
    }
239
    qemu_mutex_unlock(&ssd->lock);
244 240
    qemu_spice_destroy_host_primary(ssd);
245 241
    qemu_spice_create_host_primary(ssd);
246 242

  
......
252 248
{
253 249
    dprint(3, "%s:\n", __FUNCTION__);
254 250
    vga_hw_update();
251

  
252
    qemu_mutex_lock(&ssd->lock);
253
    if (ssd->update == NULL) {
254
        ssd->update = qemu_spice_create_update(ssd);
255
        ssd->notify++;
256
    }
257
    qemu_mutex_unlock(&ssd->lock);
258

  
255 259
    if (ssd->notify) {
256 260
        ssd->notify = 0;
257 261
        ssd->worker->wakeup(ssd->worker);
......
298 302
{
299 303
    SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
300 304
    SimpleSpiceUpdate *update;
305
    int ret = false;
301 306

  
302 307
    dprint(3, "%s:\n", __FUNCTION__);
303
    update = qemu_spice_create_update(ssd);
304
    if (update == NULL) {
305
        return false;
308

  
309
    qemu_mutex_lock(&ssd->lock);
310
    if (ssd->update != NULL) {
311
        update = ssd->update;
312
        ssd->update = NULL;
313
        *ext = update->ext;
314
        ret = true;
306 315
    }
307
    *ext = update->ext;
308
    return true;
316
    qemu_mutex_unlock(&ssd->lock);
317

  
318
    return ret;
309 319
}
310 320

  
311 321
static int interface_req_cmd_notification(QXLInstance *sin)
......
398 408
{
399 409
    assert(sdpy.ds == NULL);
400 410
    sdpy.ds = ds;
411
    qemu_mutex_init(&sdpy.lock);
401 412
    sdpy.bufsize = (16 * 1024 * 1024);
402 413
    sdpy.buf = qemu_malloc(sdpy.bufsize);
403 414
    register_displaychangelistener(ds, &display_listener);

Also available in: Unified diff