Skip to contentSkip to conversation

spice fixes.

PATCH New Gerd Hoffmann 1 participant 3 messages Oct 15, 2010

lore
Share & tools
lore
#0 lore raw

cover spice fixes.

Hi,

This patch series brings two bug fixes for spice.

The patches are also available in the git repository at:
git://anongit.freedesktop.org/spice/qemu bugfix.1

please pull,
Gerd

Gerd Hoffmann (1):
spice display: replace private lock with qemu mutex.

Hans de Goede (1):
spice-core: fix watching for write events

 ui/spice-core.c    |    2 +-
 ui/spice-display.c |   22 +++++++++-------------
 ui/spice-display.h |    1 -
 3 files changed, 10 insertions(+), 15 deletions(-)
#1 lore raw

PATCH 1/2 spice-core: fix watching for write events

From: Hans de Goede <[email protected]>

---
 ui/spice-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ui/spice-core.c +1 -1
index 8b5e4a8..3fcbeca 100644
@@ -94,7 +94,7 @@ static void watch_update_mask(SpiceWatch *watch, int event_mask)
         on_read = watch_read;
     }
     if (watch->event_mask & SPICE_WATCH_EVENT_WRITE) {
-        on_read = watch_write;
+        on_write = watch_write;
     }
     qemu_set_fd_handler(watch->fd, on_read, on_write, watch);
 }
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 spice display: replace private lock with qemu mutex.

In reply to Gerd Hoffmann

qemu_spice_create_update() must aquire the global qemu mutex to make sure DisplayState doesn't change while we are accessing it.

Once this is in place the private lock is pretty pointless as everything it protects is covered by the global qemu mutex now. Drop it.

---
 ui/spice-display.c |   22 +++++++++-------------
 ui/spice-display.h |    1 -
 2 files changed, 9 insertions(+), 14 deletions(-)
ui/spice-display.c +9 -13
index 6702dfd..febf411 100644
@@ -65,10 +65,10 @@ void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r)
 
 /*
  * Called from spice server thread context (via interface_get_command).
- * We do *not* hold the global qemu mutex here, so extra care is needed
- * when calling qemu functions.  Qemu interfaces used:
- *    - pflib (is re-entrant).
- *    - qemu_malloc (underlying glibc malloc is re-entrant).
+ *
+ * We must aquire the global qemu mutex here to make sure the
+ * DisplayState (+DisplaySurface) we are accessing doesn't change
+ * underneath us.
  */
 SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
 {
@@ -79,11 +79,12 @@ SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
     uint8_t *src, *dst;
     int by, bw, bh;
 
+    qemu_mutex_lock_iothread();
     if (qemu_spice_rect_is_empty(&ssd->dirty)) {
+        qemu_mutex_unlock_iothread();
         return NULL;
     };
 
-    pthread_mutex_lock(&ssd->lock);
     dprint(2, "%s: lr %d -> %d,  tb -> %d -> %d\n", __FUNCTION__,
            ssd->dirty.left, ssd->dirty.right,
            ssd->dirty.top, ssd->dirty.bottom);
@@ -141,7 +142,7 @@ SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
     cmd->data = (intptr_t)drawable;
 
     memset(&ssd->dirty, 0, sizeof(ssd->dirty));
-    pthread_mutex_unlock(&ssd->lock);
+    qemu_mutex_unlock_iothread();
     return update;
 }
 
@@ -220,31 +221,27 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
     update_area.top = y;
     update_area.bottom = y + h;
 
-    pthread_mutex_lock(&ssd->lock);
     if (qemu_spice_rect_is_empty(&ssd->dirty)) {
         ssd->notify++;
     }
     qemu_spice_rect_union(&ssd->dirty, &update_area);
-    pthread_mutex_unlock(&ssd->lock);
 }
 
 void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
 {
     dprint(1, "%s:\n", __FUNCTION__);
 
-    pthread_mutex_lock(&ssd->lock);
     memset(&ssd->dirty, 0, sizeof(ssd->dirty));
     qemu_pf_conv_put(ssd->conv);
     ssd->conv = NULL;
-    pthread_mutex_unlock(&ssd->lock);
 
+    qemu_mutex_unlock_iothread();
     qemu_spice_destroy_host_primary(ssd);
     qemu_spice_create_host_primary(ssd);
+    qemu_mutex_lock_iothread();
 
-    pthread_mutex_lock(&ssd->lock);
     memset(&ssd->dirty, 0, sizeof(ssd->dirty));
     ssd->notify++;
-    pthread_mutex_unlock(&ssd->lock);
 }
 
 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
@@ -399,7 +396,6 @@ void qemu_spice_display_init(DisplayState *ds)
     sdpy.ds = ds;
     sdpy.bufsize = (16 * 1024 * 1024);
     sdpy.buf = qemu_malloc(sdpy.bufsize);
-    pthread_mutex_init(&sdpy.lock, NULL);
     register_displaychangelistener(ds, &display_listener);
 
     sdpy.qxl.base.sif = &dpy_interface.base;
ui/spice-display.h +0 -1
index e17671c..aef0464 100644
@@ -40,7 +40,6 @@ typedef struct SimpleSpiceDisplay {
     uint32_t unique;
     QemuPfConv *conv;
 
-    pthread_mutex_t lock;
     QXLRect dirty;
     int notify;
     int running;
Signature · 1 line
1.7.1