[Spice-devel] [RfC PATCH 3/7] spice: lock spice worker calls
Alon Levy
alevy at redhat.com
Wed Jun 22 02:35:47 PDT 2011
On Wed, Jun 22, 2011 at 10:46:02AM +0200, Gerd Hoffmann wrote:
> ... so we can call them from a thread.
maybe better to rename the existing lock to something else in the same time?
>
> Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
> ui/spice-display.c | 31 +++++++++++++++++++++++++++++++
> ui/spice-display.h | 1 +
> 2 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index b524b82..bb1e4a7 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -67,80 +67,110 @@ void qemu_spice_update_area(SimpleSpiceDisplay *ssd, uint32_t surface_id,
> struct QXLRect *area, struct QXLRect *dirty_rects,
> uint32_t num_dirty_rects, uint32_t clear_dirty_region)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->update_area(ssd->worker, surface_id, area, dirty_rects,
> num_dirty_rects, clear_dirty_region);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->add_memslot(ssd->worker, memslot);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid, uint32_t sid)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->del_memslot(ssd->worker, gid, sid);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
> QXLDevSurfaceCreate *surface)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->create_primary_surface(ssd->worker, id, surface);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->destroy_primary_surface(ssd->worker, id);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_destroy_surface_wait(SimpleSpiceDisplay *ssd, uint32_t id)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->destroy_surface_wait(ssd->worker, id);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_loadvm_commands(SimpleSpiceDisplay *ssd, struct QXLCommandExt *ext,
> uint32_t count)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->loadvm_commands(ssd->worker, ext, count);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->wakeup(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_oom(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->oom(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_start(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->start(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_stop(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->stop(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_reset_memslots(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->reset_memslots(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_destroy_surfaces(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->destroy_surfaces(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_reset_image_cache(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->reset_image_cache(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
> void qemu_spice_reset_cursor(SimpleSpiceDisplay *ssd)
> {
> + qemu_mutex_lock(&ssd->wlock);
> ssd->worker->reset_cursor(ssd->worker);
> + qemu_mutex_unlock(&ssd->wlock);
> }
>
>
> @@ -284,6 +314,7 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
> {
> ssd->ds = ds;
> qemu_mutex_init(&ssd->lock);
> + qemu_mutex_init(&ssd->wlock);
> ssd->mouse_x = -1;
> ssd->mouse_y = -1;
> ssd->bufsize = (16 * 1024 * 1024);
> diff --git a/ui/spice-display.h b/ui/spice-display.h
> index a39b19d..3968d75 100644
> --- a/ui/spice-display.h
> +++ b/ui/spice-display.h
> @@ -41,6 +41,7 @@ struct SimpleSpiceDisplay {
> void *buf;
> int bufsize;
> QXLWorker *worker;
> + QemuMutex wlock;
> QXLInstance qxl;
> uint32_t unique;
> QemuPfConv *conv;
> --
> 1.7.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list