Skip to content

Commit 59be75e

Browse files
elmarcokraxel
authored andcommitted
vhost-user-gpu: fix cursor move/update
"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]>
1 parent 96ee096 commit 59be75e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

contrib/vhost-user-gpu/vhost-user-gpu.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,8 @@ update_cursor_data_simple(VuGpu *g, uint32_t resource_id, gpointer data)
892892
static void
893893
vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
894894
{
895-
bool move = cursor->hdr.type != VIRTIO_GPU_CMD_MOVE_CURSOR;
896-
897-
g_debug("%s move:%d\n", G_STRFUNC, move);
898-
899-
if (move) {
895+
switch (cursor->hdr.type) {
896+
case VIRTIO_GPU_CMD_MOVE_CURSOR: {
900897
VhostUserGpuMsg msg = {
901898
.request = cursor->resource_id ?
902899
VHOST_USER_GPU_CURSOR_POS : VHOST_USER_GPU_CURSOR_POS_HIDE,
@@ -907,8 +904,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
907904
.y = cursor->pos.y,
908905
}
909906
};
907+
g_debug("%s: move", G_STRFUNC);
910908
vg_send_msg(g, &msg, -1);
911-
} else {
909+
break;
910+
}
911+
case VIRTIO_GPU_CMD_UPDATE_CURSOR: {
912912
VhostUserGpuMsg msg = {
913913
.request = VHOST_USER_GPU_CURSOR_UPDATE,
914914
.size = sizeof(VhostUserGpuCursorUpdate),
@@ -922,6 +922,7 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
922922
.hot_y = cursor->hot_y,
923923
}
924924
};
925+
g_debug("%s: update", G_STRFUNC);
925926
if (g->virgl) {
926927
vg_virgl_update_cursor_data(g, cursor->resource_id,
927928
msg.payload.cursor_update.data);
@@ -930,6 +931,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
930931
msg.payload.cursor_update.data);
931932
}
932933
vg_send_msg(g, &msg, -1);
934+
break;
935+
}
936+
default:
937+
g_debug("%s: unknown cmd %d", G_STRFUNC, cursor->hdr.type);
938+
break;
933939
}
934940
}
935941

0 commit comments

Comments
 (0)