[Spice-commits] 5 commits - server/red_worker.c
Yonit Halperin
yhalperi at kemper.freedesktop.org
Tue Jul 5 07:32:10 PDT 2011
server/red_worker.c | 353 +++++++++++++++++++++++-----------------------------
1 file changed, 158 insertions(+), 195 deletions(-)
New commits:
commit 6d17dbeb0bf1b57b8290cbd7facccf5beff5ed8f
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Tue Jul 5 15:48:31 2011 +0300
server: cursor_channel: releasing pipe items resources when the pipe is cleared (on disconnect)
same as commit 74a9d10af96f4d7c8c1b1d7fca124a8df9180787 for cursor channel
diff --git a/server/red_worker.c b/server/red_worker.c
index 6c25711..9a61e86 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -936,6 +936,8 @@ static void red_disconnect_cursor(RedChannel *channel);
static void red_wait_pipe_item_sent(RedChannel *channel, PipeItem *item);
static void display_channel_release_item_before_push(DisplayChannel *display_channel, PipeItem *item);
static void display_channel_release_item_after_push(DisplayChannel *display_channel, PipeItem *item);
+static void cursor_channel_release_item_before_push(CursorChannel *cursor_channel, PipeItem *item);
+static void cursor_channel_release_item_after_push(CursorChannel *cursor_channel, PipeItem *item);
#ifdef DUMP_BITMAP
static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id);
@@ -8092,30 +8094,27 @@ static void cursor_channel_send_item(RedChannel *channel, PipeItem *pipe_item)
break;
case PIPE_ITEM_TYPE_INVAL_ONE:
red_cursor_marshall_inval(cursor_channel, m, (CacheItem *)pipe_item);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_VERB:
red_marshall_verb(channel, ((VerbItem*)pipe_item)->verb);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_MIGRATE:
red_printf("PIPE_ITEM_TYPE_MIGRATE");
cursor_channel_marshall_migrate(cursor_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_CURSOR_INIT:
red_reset_cursor_cache(cursor_channel);
red_marshall_cursor_init(cursor_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
red_reset_cursor_cache(cursor_channel);
red_marshall_verb(channel, SPICE_MSG_CURSOR_INVAL_ALL);
- free(pipe_item);
break;
default:
red_error("invalid pipe item type");
}
+
+ cursor_channel_release_item_before_push(cursor_channel, pipe_item);
red_channel_begin_send_message(channel);
red_unref_channel(channel);
}
@@ -9268,20 +9267,46 @@ static void cursor_channel_hold_pipe_item(RedChannel *channel, PipeItem *item)
((CursorItem *)item)->refs++;
}
-static void cursor_channel_release_item(RedChannel *channel, PipeItem *item, int item_pushed)
+static void cursor_channel_release_item_before_push(CursorChannel *cursor_channel, PipeItem *item)
{
- CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
+ switch (item->type) {
+ case PIPE_ITEM_TYPE_CURSOR:
+ break;
+ case PIPE_ITEM_TYPE_INVAL_ONE:
+ case PIPE_ITEM_TYPE_VERB:
+ case PIPE_ITEM_TYPE_MIGRATE:
+ case PIPE_ITEM_TYPE_CURSOR_INIT:
+ case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
+ free(item);
+ break;
+ default:
+ red_error("invalid pipe item type");
+ }
+}
- ASSERT(item);
+static void cursor_channel_release_item_after_push(CursorChannel *cursor_channel, PipeItem *item)
+{
switch (item->type) {
case PIPE_ITEM_TYPE_CURSOR:
- red_release_cursor(common->worker, SPICE_CONTAINEROF(item, CursorItem, pipe_data));
+ red_release_cursor(cursor_channel->common.worker, SPICE_CONTAINEROF(item, CursorItem, pipe_data));
break;
default:
PANIC("invalid item type");
}
}
+static void cursor_channel_release_item(RedChannel *channel, PipeItem *item, int item_pushed)
+{
+ ASSERT(item);
+
+ if (item_pushed) {
+ cursor_channel_release_item_after_push((CursorChannel *)channel, item);
+ } else {
+ red_printf("not pushed");
+ cursor_channel_release_item_before_push((CursorChannel *)channel, item);
+ }
+}
+
static void red_connect_cursor(RedWorker *worker, RedsStream *stream, int migrate)
{
CursorChannel *channel;
commit 6336f9413a23b2aed2513e1380168aa99be4efac
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Tue Jul 5 15:30:49 2011 +0300
server: display_channel: releasing pipe items resources when the pipe is cleared (on disconnect)
fixes "display_channel_release_item: panic: invalid item type"
Before changing the red_worker to use the red_channel interface, there
was a devoted red_pipe_clear routine for the display channel and cursor channel.
However, clearing the pipe in red_channel, uses the release_item callback
the worker provided. This callback has handled only resources that need to be released
after the pipe item was enqueued from the pipe, and only for pipe items that were set in
red_channel_init_send_data.
This fix changes the display channel release_item callback to handle all types of
pipe items, and also handles differently pushed and non-pushed pipe items.
diff --git a/server/red_worker.c b/server/red_worker.c
index 7632c60..6c25711 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -934,6 +934,8 @@ static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBi
static inline int _stride_is_extra(SpiceBitmap *bitmap);
static void red_disconnect_cursor(RedChannel *channel);
static void red_wait_pipe_item_sent(RedChannel *channel, PipeItem *item);
+static void display_channel_release_item_before_push(DisplayChannel *display_channel, PipeItem *item);
+static void display_channel_release_item_after_push(DisplayChannel *display_channel, PipeItem *item);
#ifdef DUMP_BITMAP
static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id);
@@ -8002,89 +8004,75 @@ static void display_channel_send_item(RedChannel *base, PipeItem *pipe_item)
{
SpiceMarshaller *m = red_channel_get_marshaller(base);
DisplayChannel *display_channel = (DisplayChannel *)red_ref_channel(base);
- RedWorker *worker = display_channel->common.worker;
red_display_reset_send_data(display_channel);
switch (pipe_item->type) {
case PIPE_ITEM_TYPE_DRAW: {
Drawable *drawable = SPICE_CONTAINEROF(pipe_item, Drawable, pipe_item);
marshall_qxl_drawable(display_channel, m, drawable);
- release_drawable(worker, drawable);
break;
}
case PIPE_ITEM_TYPE_INVAL_ONE:
red_display_marshall_inval(display_channel, m, (CacheItem *)pipe_item);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_STREAM_CREATE: {
StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, create_item);
red_display_marshall_stream_start(display_channel, m, agent);
- red_display_release_stream(display_channel, agent);
break;
}
case PIPE_ITEM_TYPE_STREAM_CLIP: {
- StreamClipItem* clip_item = (StreamClipItem *)pipe_item;
- red_display_marshall_stream_clip(display_channel, m, clip_item);
- red_display_release_stream_clip(display_channel, clip_item);
+ red_display_marshall_stream_clip(display_channel, m, (StreamClipItem *)pipe_item);
break;
}
case PIPE_ITEM_TYPE_STREAM_DESTROY: {
StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, destroy_item);
red_display_marshall_stream_end(display_channel, m, agent);
- red_display_release_stream(display_channel, agent);
break;
}
case PIPE_ITEM_TYPE_UPGRADE:
red_display_marshall_upgrade(display_channel, m, (UpgradeItem *)pipe_item);
- release_upgrade_item(worker, (UpgradeItem *)pipe_item);
break;
case PIPE_ITEM_TYPE_VERB:
display_marshall_verb(display_channel, ((VerbItem*)pipe_item)->verb);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_MIGRATE:
red_printf("PIPE_ITEM_TYPE_MIGRATE");
display_channel_marshall_migrate(display_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_MIGRATE_DATA:
display_channel_marshall_migrate_data(display_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_IMAGE:
red_marshall_image(display_channel, m, (ImageItem *)pipe_item);
- release_image_item((ImageItem *)pipe_item);
break;
case PIPE_ITEM_TYPE_PIXMAP_SYNC:
display_channel_marshall_pixmap_sync(display_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_PIXMAP_RESET:
display_channel_marshall_reset_cache(display_channel, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
red_reset_palette_cache(display_channel);
red_marshall_verb((RedChannel *)display_channel, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_CREATE_SURFACE: {
SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, SurfaceCreateItem,
pipe_item);
red_marshall_surface_create(display_channel, m, &surface_create->surface_create);
- free(surface_create);
break;
}
case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(pipe_item, SurfaceDestroyItem,
pipe_item);
red_marshall_surface_destroy(display_channel, m, surface_destroy->surface_destroy.surface_id);
- free(surface_destroy);
break;
}
default:
red_error("invalid pipe item type");
}
+
+ display_channel_release_item_before_push(display_channel, pipe_item);
+
// a message is pending
if (red_channel_send_message_pending(&display_channel->common.base)) {
display_begin_send_message(display_channel, m);
@@ -9071,21 +9059,20 @@ static void display_channel_hold_pipe_item(RedChannel *channel, PipeItem *item)
}
}
-static void display_channel_release_item(RedChannel *channel, PipeItem *item, int item_pushed /* ignored */)
+static void display_channel_release_item_after_push(DisplayChannel *display_channel, PipeItem *item)
{
- CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
+ RedWorker *worker = display_channel->common.worker;
- ASSERT(item);
switch (item->type) {
case PIPE_ITEM_TYPE_DRAW:
case PIPE_ITEM_TYPE_STREAM_CREATE:
- release_drawable(common->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
+ release_drawable(worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
break;
case PIPE_ITEM_TYPE_STREAM_CLIP:
- red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem *)item);
+ red_display_release_stream_clip(display_channel, (StreamClipItem *)item);
break;
case PIPE_ITEM_TYPE_UPGRADE:
- release_upgrade_item(common->worker, (UpgradeItem *)item);
+ release_upgrade_item(worker, (UpgradeItem *)item);
break;
case PIPE_ITEM_TYPE_IMAGE:
release_image_item((ImageItem *)item);
@@ -9095,6 +9082,70 @@ static void display_channel_release_item(RedChannel *channel, PipeItem *item, in
}
}
+static void display_channel_release_item_before_push(DisplayChannel *display_channel, PipeItem *item)
+{
+ RedWorker *worker = display_channel->common.worker;
+
+ switch (item->type) {
+ case PIPE_ITEM_TYPE_DRAW:
+ release_drawable(worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
+ break;
+ case PIPE_ITEM_TYPE_STREAM_CREATE: {
+ StreamAgent *agent = SPICE_CONTAINEROF(item, StreamAgent, create_item);
+ red_display_release_stream(display_channel, agent);
+ break;
+ }
+ case PIPE_ITEM_TYPE_STREAM_CLIP:
+ red_display_release_stream_clip(display_channel, (StreamClipItem *)item);
+ break;
+ case PIPE_ITEM_TYPE_STREAM_DESTROY: {
+ StreamAgent *agent = SPICE_CONTAINEROF(item, StreamAgent, destroy_item);
+ red_display_release_stream(display_channel, agent);
+ break;
+ }
+ case PIPE_ITEM_TYPE_UPGRADE:
+ release_upgrade_item(worker, (UpgradeItem *)item);
+ break;
+ case PIPE_ITEM_TYPE_IMAGE:
+ release_image_item((ImageItem *)item);
+ break;
+ case PIPE_ITEM_TYPE_CREATE_SURFACE: {
+ SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(item, SurfaceCreateItem,
+ pipe_item);
+ free(surface_create);
+ break;
+ }
+ case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
+ SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(item, SurfaceDestroyItem,
+ pipe_item);
+ free(surface_destroy);
+ break;
+ }
+ case PIPE_ITEM_TYPE_INVAL_ONE:
+ case PIPE_ITEM_TYPE_VERB:
+ case PIPE_ITEM_TYPE_MIGRATE:
+ case PIPE_ITEM_TYPE_MIGRATE_DATA:
+ case PIPE_ITEM_TYPE_PIXMAP_SYNC:
+ case PIPE_ITEM_TYPE_PIXMAP_RESET:
+ case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
+ free(item);
+ break;
+ default:
+ PANIC("invalid item type");
+ }
+}
+
+static void display_channel_release_item(RedChannel *channel, PipeItem *item, int item_pushed)
+{
+ ASSERT(item);
+ if (item_pushed) {
+ display_channel_release_item_after_push((DisplayChannel *)channel, item);
+ } else {
+ red_printf("not pushed");
+ display_channel_release_item_before_push((DisplayChannel *)channel, item);
+ }
+}
+
static void handle_new_display_channel(RedWorker *worker, RedsStream *stream, int migrate)
{
DisplayChannel *display_channel;
commit b881c4b5caa42544d449e3454a00250f7cd023c0
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jul 4 15:14:43 2011 +0300
server: not reading command rings before RED_WORKER_MESSAGE_START, RHBZ #718713
On migration, destroy_surfaces is called from qxl (qxl_hard_reset), before the device was loaded (on destination).
handle_dev_destroy_surfaces led to red_process_commands, which read the qxl command ring
(which appeared to be not empty), and then when processing the command
it accessed unmapped memory.
diff --git a/server/red_worker.c b/server/red_worker.c
index e00751c..7632c60 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4166,6 +4166,11 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
QXLCommandExt ext_cmd;
int n = 0;
+ if (!worker->running) {
+ *ring_is_empty = TRUE;
+ return n;
+ }
+
*ring_is_empty = FALSE;
while (!worker->cursor_channel || worker->cursor_channel->common.base.pipe_size <= max_pipe_size) {
if (!worker->qxl->st->qif->get_cursor_command(worker->qxl, &ext_cmd)) {
@@ -4205,7 +4210,12 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
QXLCommandExt ext_cmd;
int n = 0;
uint64_t start = red_now();
-
+
+ if (!worker->running) {
+ *ring_is_empty = TRUE;
+ return n;
+ }
+
*ring_is_empty = FALSE;
while (!worker->display_channel || worker->display_channel->common.base.pipe_size <= max_pipe_size) {
if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
commit 3d3066b175ee2dec8e73c8c56f418a6ae98b1c26
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jul 4 11:12:33 2011 +0300
server: replace redundant code with red_cursor_reset
In addition (1) make handle_dev_destroy_surfaces call red_release_cursor
(2) call red_wait_outgoing_item(cursor_channel) only after adding msgs to pipe
diff --git a/server/red_worker.c b/server/red_worker.c
index d4eff25..e00751c 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9429,6 +9429,27 @@ static inline void handle_dev_destroy_surface_wait(RedWorker *worker)
write_message(worker->channel, &message);
}
+static inline void red_cursor_reset(RedWorker *worker)
+{
+ if (worker->cursor) {
+ red_release_cursor(worker, worker->cursor);
+ worker->cursor = NULL;
+ }
+
+ worker->cursor_visible = TRUE;
+ worker->cursor_position.x = worker->cursor_position.y = 0;
+ worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+
+ if (worker->cursor_channel) {
+ red_channel_pipe_add_type(&worker->cursor_channel->common.base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
+ if (!worker->cursor_channel->common.base.migrate) {
+ red_pipe_add_verb(&worker->cursor_channel->common.base, SPICE_MSG_CURSOR_RESET);
+ }
+ red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
+ ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
+ }
+}
+
/* called upon device reset */
static inline void handle_dev_destroy_surfaces(RedWorker *worker)
{
@@ -9448,15 +9469,6 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
}
ASSERT(ring_is_empty(&worker->streams));
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_channel_pipe_add_type(&worker->cursor_channel->common.base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!worker->cursor_channel->common.base.migrate) {
- red_pipe_add_verb(&worker->cursor_channel->common.base, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
- }
-
if (worker->display_channel) {
red_channel_pipe_add_type(&worker->display_channel->common.base, PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
red_pipe_add_verb(&worker->display_channel->common.base, SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
@@ -9464,9 +9476,7 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
red_display_clear_glz_drawables(worker->display_channel);
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
@@ -9519,20 +9529,6 @@ static inline void handle_dev_destroy_primary_surface(RedWorker *worker)
PANIC_ON(surface_id != 0);
PANIC_ON(!worker->surfaces[surface_id].context.canvas);
- if (worker->cursor) {
- red_release_cursor(worker, worker->cursor);
- worker->cursor = NULL;
- }
-
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_channel_pipe_add_type(&worker->cursor_channel->common.base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!worker->cursor_channel->common.base.migrate) {
- red_pipe_add_verb(&worker->cursor_channel->common.base, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
- }
-
flush_all_qxl_commands(worker);
destroy_surface_wait(worker, 0);
red_destroy_surface(worker, 0);
@@ -9540,9 +9536,7 @@ static inline void handle_dev_destroy_primary_surface(RedWorker *worker)
ASSERT(!worker->surfaces[surface_id].context.canvas);
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
@@ -9581,24 +9575,7 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
clear_bit(RED_WORKER_PENDING_OOM, worker->pending);
break;
case RED_WORKER_MESSAGE_RESET_CURSOR:
- if (worker->cursor) {
- red_release_cursor(worker, worker->cursor);
- worker->cursor = NULL;
- }
-
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_channel_pipe_add_type(cursor_red_channel, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!cursor_red_channel->migrate) {
- red_pipe_add_verb(cursor_red_channel, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(red_channel_no_item_being_sent(cursor_red_channel));
-
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
- }
-
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
break;
commit 7b34d1994e03e0f86611079971f7a80280d07b5f
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jul 4 10:59:43 2011 +0300
server: removing local cursor, this solves RHBZ #714801
When the worker was stoped, the cursor was copied from guest ram to the host ram,
and its corresponding qxl command was released.
This is unecessary, since the qxl ram still exists (we keep references
to the surfaces in the same manner).
It also led to BSOD on guest upon migration: the device tracks cursor set commands and it stores
a reference to the last one. Then, it replays it to the destination server when migrating to it.
However, the command the qxl replayed has already been released from the pci by the original
worker, upon STOP.
diff --git a/server/red_worker.c b/server/red_worker.c
index 577dee2..d4eff25 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -239,7 +239,6 @@ enum {
PIPE_ITEM_TYPE_INVAL_ONE,
PIPE_ITEM_TYPE_CURSOR,
PIPE_ITEM_TYPE_MIGRATE,
- PIPE_ITEM_TYPE_LOCAL_CURSOR,
PIPE_ITEM_TYPE_CURSOR_INIT,
PIPE_ITEM_TYPE_IMAGE,
PIPE_ITEM_TYPE_STREAM_CREATE,
@@ -300,17 +299,10 @@ typedef struct SurfaceDestroyItem {
PipeItem pipe_item;
} SurfaceDestroyItem;
-enum {
- CURSOR_TYPE_INVALID,
- CURSOR_TYPE_DEV,
- CURSOR_TYPE_LOCAL,
-};
-
typedef struct CursorItem {
PipeItem pipe_data;
uint32_t group_id;
int refs;
- int type;
RedCursorCmd *red_cursor;
} CursorItem;
@@ -4065,11 +4057,6 @@ static void red_release_cursor(RedWorker *worker, CursorItem *cursor)
QXLReleaseInfoExt release_info_ext;
RedCursorCmd *cursor_cmd;
- if (cursor->type == CURSOR_TYPE_LOCAL) {
- free(cursor);
- return;
- }
-
cursor_cmd = cursor->red_cursor;
release_info_ext.group_id = cursor->group_id;
release_info_ext.info = cursor_cmd->release_info;
@@ -4125,7 +4112,6 @@ static CursorItem *get_cursor_item(RedWorker *worker, RedCursorCmd *cmd, uint32_
cursor_item->refs = 1;
red_channel_pipe_item_init(&worker->cursor_channel->common.base,
&cursor_item->pipe_data, PIPE_ITEM_TYPE_CURSOR);
- cursor_item->type = CURSOR_TYPE_INVALID;
cursor_item->group_id = group_id;
cursor_item->red_cursor = cmd;
@@ -4140,7 +4126,6 @@ static void qxl_process_cursor(RedWorker *worker, RedCursorCmd *cursor_cmd, uint
switch (cursor_cmd->type) {
case QXL_CURSOR_SET:
worker->cursor_visible = cursor_cmd->u.set.visible;
- item->type = CURSOR_TYPE_DEV;
red_set_cursor(worker, item);
break;
case QXL_CURSOR_MOVE:
@@ -5883,6 +5868,7 @@ static void fill_attr(DisplayChannel *display_channel, SpiceMarshaller *m, Spice
static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor, CursorItem *cursor, AddBufInfo *addbuf)
{
+ RedCursorCmd *cursor_cmd;
addbuf->data = NULL;
if (!cursor) {
@@ -5890,35 +5876,23 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
return;
}
- if (cursor->type == CURSOR_TYPE_DEV) {
- RedCursorCmd *cursor_cmd;
-
- cursor_cmd = cursor->red_cursor;
- *red_cursor = cursor_cmd->u.set.shape;
+ cursor_cmd = cursor->red_cursor;
+ *red_cursor = cursor_cmd->u.set.shape;
- if (red_cursor->header.unique) {
- if (red_cursor_cache_find(cursor_channel, red_cursor->header.unique)) {
- red_cursor->flags |= SPICE_CURSOR_FLAGS_FROM_CACHE;
- return;
- }
- if (red_cursor_cache_add(cursor_channel, red_cursor->header.unique, 1)) {
- red_cursor->flags |= SPICE_CURSOR_FLAGS_CACHE_ME;
- }
+ if (red_cursor->header.unique) {
+ if (red_cursor_cache_find(cursor_channel, red_cursor->header.unique)) {
+ red_cursor->flags |= SPICE_CURSOR_FLAGS_FROM_CACHE;
+ return;
}
-
- if (red_cursor->data_size) {
- addbuf->type = BUF_TYPE_RAW;
- addbuf->data = red_cursor->data;
- addbuf->size = red_cursor->data_size;
+ if (red_cursor_cache_add(cursor_channel, red_cursor->header.unique, 1)) {
+ red_cursor->flags |= SPICE_CURSOR_FLAGS_CACHE_ME;
}
- } else {
- LocalCursor *local_cursor;
- ASSERT(cursor->type == CURSOR_TYPE_LOCAL);
- local_cursor = (LocalCursor *)cursor;
- *red_cursor = local_cursor->red_cursor;
+ }
+
+ if (red_cursor->data_size) {
addbuf->type = BUF_TYPE_RAW;
- addbuf->data = local_cursor->red_cursor.data;
- addbuf->size = local_cursor->data_size;
+ addbuf->data = red_cursor->data;
+ addbuf->size = red_cursor->data_size;
}
}
@@ -7916,27 +7890,6 @@ static void red_marshall_cursor_init(CursorChannel *channel, SpiceMarshaller *ba
add_buf_from_info(base_marshaller, &info);
}
-static void red_marshall_local_cursor(CursorChannel *cursor_channel,
- SpiceMarshaller *base_marshaller, LocalCursor *cursor)
-{
- RedChannel *channel;
- SpiceMsgCursorSet cursor_set;
- AddBufInfo info;
- RedWorker *worker;
-
- ASSERT(cursor_channel);
- worker = cursor_channel->common.worker;
- channel = &cursor_channel->common.base;
- red_channel_init_send_data(channel, SPICE_MSG_CURSOR_SET, &cursor->base.pipe_data);
- cursor_set.position = cursor->position;
- cursor_set.visible = worker->cursor_visible;
-
- fill_cursor(cursor_channel, &cursor_set.cursor, &cursor->base, &info);
- spice_marshall_msg_cursor_set(base_marshaller, &cursor_set);
- add_buf_from_info(base_marshaller, &info);
- red_release_cursor(worker, (CursorItem *)cursor);
-}
-
static void cursor_channel_marshall_migrate(CursorChannel *cursor_channel,
SpiceMarshaller *base_marshaller)
{
@@ -8139,9 +8092,6 @@ static void cursor_channel_send_item(RedChannel *channel, PipeItem *pipe_item)
case PIPE_ITEM_TYPE_CURSOR:
red_marshall_cursor(cursor_channel, m, (CursorItem *)pipe_item);
break;
- case PIPE_ITEM_TYPE_LOCAL_CURSOR:
- red_marshall_local_cursor(cursor_channel, m, (LocalCursor *)pipe_item);
- break;
case PIPE_ITEM_TYPE_INVAL_ONE:
red_cursor_marshall_inval(cursor_channel, m, (CacheItem *)pipe_item);
free(pipe_item);
@@ -9309,55 +9259,6 @@ typedef struct __attribute__ ((__packed__)) CursorData {
SpiceCursor _cursor;
} CursorData;
-static LocalCursor *_new_local_cursor(RedChannel *channel,
- SpiceCursorHeader *header, int data_size, SpicePoint16 position)
-{
- LocalCursor *local;
-
- local = (LocalCursor *)spice_malloc0(sizeof(LocalCursor) + data_size);
-
- red_channel_pipe_item_init(channel, &local->base.pipe_data,
- PIPE_ITEM_TYPE_LOCAL_CURSOR);
- local->base.refs = 1;
- local->base.type = CURSOR_TYPE_LOCAL;
-
- local->red_cursor.header = *header;
- local->red_cursor.header.unique = 0;
-
- local->red_cursor.flags = 0;
- local->red_cursor.data = (uint8_t*)(local+1);
-
- local->position = position;
- local->data_size = data_size;
- return local;
-}
-
-static void red_cursor_flush(RedWorker *worker)
-{
- RedCursorCmd *cursor_cmd;
- SpiceCursor *cursor;
- LocalCursor *local;
-
- if (!worker->cursor || worker->cursor->type == CURSOR_TYPE_LOCAL) {
- return;
- }
-
- ASSERT(worker->cursor->type == CURSOR_TYPE_DEV);
-
- cursor_cmd = worker->cursor->red_cursor;
- ASSERT(cursor_cmd->type == QXL_CURSOR_SET);
- cursor = &cursor_cmd->u.set.shape;
-
- local = _new_local_cursor(&worker->cursor_channel->common.base,
- &cursor->header, cursor->data_size,
- worker->cursor_position);
- ASSERT(local);
- memcpy(local->red_cursor.data, cursor->data, local->data_size);
-
- red_set_cursor(worker, &local->base);
- red_release_cursor(worker, &local->base);
-}
-
static void red_wait_outgoing_item(RedChannel *channel)
{
uint64_t end_time;
@@ -9744,7 +9645,6 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
red_current_flush(worker, x);
}
}
- red_cursor_flush(worker);
red_wait_outgoing_item((RedChannel *)worker->display_channel);
red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
message = RED_WORKER_MESSAGE_READY;
More information about the Spice-commits
mailing list