Skip to content

Commit

Permalink
vhost-user-gpu: fix cursor move/update
Browse files Browse the repository at this point in the history
"move" is incorrectly initialized.

Fix it by using a switch statement and also treating unknown commands
with a fallback.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
elmarco authored and kraxel committed Mar 26, 2021
1 parent 96ee096 commit 59be75e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions contrib/vhost-user-gpu/vhost-user-gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,8 @@ update_cursor_data_simple(VuGpu *g, uint32_t resource_id, gpointer data)
static void
vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
{
bool move = cursor->hdr.type != VIRTIO_GPU_CMD_MOVE_CURSOR;

g_debug("%s move:%d\n", G_STRFUNC, move);

if (move) {
switch (cursor->hdr.type) {
case VIRTIO_GPU_CMD_MOVE_CURSOR: {
VhostUserGpuMsg msg = {
.request = cursor->resource_id ?
VHOST_USER_GPU_CURSOR_POS : VHOST_USER_GPU_CURSOR_POS_HIDE,
Expand All @@ -907,8 +904,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
.y = cursor->pos.y,
}
};
g_debug("%s: move", G_STRFUNC);
vg_send_msg(g, &msg, -1);
} else {
break;
}
case VIRTIO_GPU_CMD_UPDATE_CURSOR: {
VhostUserGpuMsg msg = {
.request = VHOST_USER_GPU_CURSOR_UPDATE,
.size = sizeof(VhostUserGpuCursorUpdate),
Expand All @@ -922,6 +922,7 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
.hot_y = cursor->hot_y,
}
};
g_debug("%s: update", G_STRFUNC);
if (g->virgl) {
vg_virgl_update_cursor_data(g, cursor->resource_id,
msg.payload.cursor_update.data);
Expand All @@ -930,6 +931,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
msg.payload.cursor_update.data);
}
vg_send_msg(g, &msg, -1);
break;
}
default:
g_debug("%s: unknown cmd %d", G_STRFUNC, cursor->hdr.type);
break;
}
}

Expand Down

0 comments on commit 59be75e

Please sign in to comment.