diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2022-04-06 18:33:56 +0100 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2022-04-20 09:01:21 +0200 |
commit | 5b4f72f5e8620547e765ce8b1f2b4734022e8ab9 (patch) | |
tree | 72fcf50e423ee66f6a0bc6f1f5629caa6915a899 /tests | |
parent | b911c30c566dee48a27bc1bfa1ee6df3a729cbbb (diff) | |
download | qemu-5b4f72f5e8620547e765ce8b1f2b4734022e8ab9.zip qemu-5b4f72f5e8620547e765ce8b1f2b4734022e8ab9.tar.gz qemu-5b4f72f5e8620547e765ce8b1f2b4734022e8ab9.tar.bz2 |
tests/qtest: properly initialise the vring used idx
Eric noticed while attempting to enable the vhost-user-blk-test for
Aarch64 that that things didn't work unless he put in a dummy
guest_malloc() at the start of the test. Without it
qvirtio_wait_used_elem() would assert when it reads a junk value for
idx resulting in:
qvirtqueue_get_buf: idx:2401 last_idx:0
qvirtqueue_get_buf: 0x7ffcb6d3fe74, (nil)
qvirtio_wait_used_elem: 3000000/0
ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
Bail out! ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
What was actually happening is the guest_malloc() effectively pushed
the allocation of the vring into the next page which just happened to
have clear memory. After much tedious tracing of the code I could see
that qvring_init() does attempt initialise a bunch of the vring
structures but skips the vring->used.idx value. It is probably not
wise to assume guest memory is zeroed anyway. Once the ring is
properly initialised the hack is no longer needed to get things
working.
Thanks-to: John Snow <jsnow@redhat.com> for helping debug
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220406173356.1891500-1-alex.bennee@linaro.org>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtest/libqos/virtio.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 6fe7bf9..fba9186 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -260,6 +260,8 @@ void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq, /* vq->used->flags */ qvirtio_writew(vq->vdev, qts, vq->used, 0); + /* vq->used->idx */ + qvirtio_writew(vq->vdev, qts, vq->used + 2, 0); /* vq->used->avail_event */ qvirtio_writew(vq->vdev, qts, vq->used + 2 + sizeof(struct vring_used_elem) * vq->size, 0); |