Skip to content

Commit

Permalink
tools/virtio: initialize spinlocks in vring_test.c
Browse files Browse the repository at this point in the history
The virtio_device vqs_list spinlocks must be initialized before use to
prevent functions that manipulate the device virtualqueues, such as
vring_new_virtqueue(), from blocking indefinitely.

Signed-off-by: Ricardo Cañuelo <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Xuan Zhuo <[email protected]>
  • Loading branch information
Ricardo Cañuelo authored and mstsirkin committed Dec 28, 2022
1 parent b9e0539 commit c262f75
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/virtio/vringh_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static int parallel_test(u64 features,

gvdev.vdev.features = features;
INIT_LIST_HEAD(&gvdev.vdev.vqs);
spin_lock_init(&gvdev.vdev.vqs_list_lock);
gvdev.to_host_fd = to_host[1];
gvdev.notifies = 0;

Expand Down Expand Up @@ -455,6 +456,7 @@ int main(int argc, char *argv[])
getrange = getrange_iov;
vdev.features = 0;
INIT_LIST_HEAD(&vdev.vqs);
spin_lock_init(&vdev.vqs_list_lock);

while (argv[1]) {
if (strcmp(argv[1], "--indirect") == 0)
Expand Down

0 comments on commit c262f75

Please sign in to comment.