diff options
| author | Christian Schoenebeck <qemu_oss@crudebyte.com> | 2026-05-18 19:36:01 +0200 |
|---|---|---|
| committer | Michael Tokarev <mjt@tls.msk.ru> | 2026-06-01 21:02:55 +0300 |
| commit | c56c4b8d1c021362816755113a60c5fa52eee674 (patch) | |
| tree | 8bf722f41a4af91a2db538ae73a810cd535a5372 | |
| parent | a3368416269e38f4bf3d3ce65d36ce25938134ec (diff) | |
| download | qemu-c56c4b8d1c021362816755113a60c5fa52eee674.tar.gz qemu-c56c4b8d1c021362816755113a60c5fa52eee674.zip | |
tests/qtest/libqos: add qvirtqueue_reset_pool() for descriptor pool reset
Add a function to reset the virtqueue descriptor pool state without
reinitializing the device. This is useful for tests that issue a high
number of requests and are limited by the simplified virtio test
driver's descriptor tracking, which decrements num_free but never
increments it back.
The function is safe for synchronous test code where requests are
sent and completed before the next request is issued.
Acked-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/96cf23eea1204b34443218fe76bd4a5eaf9163e8.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
(cherry picked from commit be33c56898f8b18617cff91525f0b68abee8de07)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
| -rw-r--r-- | tests/qtest/libqos/virtio.c | 23 | ||||
| -rw-r--r-- | tests/qtest/libqos/virtio.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 2e7979652f..dfa94700cb 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -442,6 +442,29 @@ bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx, return true; } +/* + * qvirtqueue_reset_pool: + * @vq: The virtqueue to reset + * + * Reset the descriptor pool state without reinitializing the device. + * This is useful for tests that issue a high number of requests and + * are limited by the simplified virtio test driver's descriptor tracking, + * which decrements num_free but never increments it back. + * + * This is only safe for synchronous test code where requests are + * sent and completed before the next request is issued. Do not use + * with asynchronous code where multiple requests may be in-flight. + * + * Note: This only resets the available descriptor pool (free_head, + * num_free). The used ring position (last_used_idx) is NOT reset + * and should continue to track consumed responses across iterations. + */ +void qvirtqueue_reset_pool(QVirtQueue *vq) +{ + vq->free_head = 0; + vq->num_free = vq->size; +} + void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t idx) { g_assert(vq->event); diff --git a/tests/qtest/libqos/virtio.h b/tests/qtest/libqos/virtio.h index 7adc7cbd10..d6486ba7f9 100644 --- a/tests/qtest/libqos/virtio.h +++ b/tests/qtest/libqos/virtio.h @@ -148,6 +148,8 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len); +void qvirtqueue_reset_pool(QVirtQueue *vq); + void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t idx); void qvirtio_start_device(QVirtioDevice *vdev); |
