diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-06-28 19:47:20 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-06-30 11:03:45 +0100 |
commit | e77abbe98b944990b3ab49c671ec15371904e206 (patch) | |
tree | 477c69eb898acd1255c8a40b4db77bb321c6f823 /tests/libqos/virtio.h | |
parent | afbccba608cec3e78c8eb31f6b7d2cd0c9908e05 (diff) | |
download | qemu-e77abbe98b944990b3ab49c671ec15371904e206.zip qemu-e77abbe98b944990b3ab49c671ec15371904e206.tar.gz qemu-e77abbe98b944990b3ab49c671ec15371904e206.tar.bz2 |
libqos: add virtio used ring support
Existing tests do not touch the virtqueue used ring. Instead they poll
the virtqueue ISR register and peek into their request's device-specific
status field.
It turns out that the virtqueue ISR register can be set to 1 more than
once for a single notification (see commit
83d768b5640946b7da55ce8335509df297e2c7cd "virtio: set ISR on dataplane
notifications"). This causes problems for tests that assume a 1:1
correspondence between the ISR being 1 and request completion.
Peeking at device-specific status fields is also problematic if the
device has no field that can be abused for EINPROGRESS polling
semantics. This is the case if all the field's values may be set by the
device; there's no magic constant left for polling.
It's time to process the used ring for completed requests, just like a
real virtio guest driver. This patch adds the necessary APIs.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
Tested-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20170628184724.21378-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/virtio.h')
-rw-r--r-- | tests/libqos/virtio.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 829de5e..8fbcd18 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -32,6 +32,7 @@ typedef struct QVirtQueue { uint32_t free_head; uint32_t num_free; uint32_t align; + uint16_t last_used_idx; bool indirect; bool event; } QVirtQueue; @@ -120,6 +121,10 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d, QVirtQueue *vq, uint64_t addr, gint64 timeout_us); +void qvirtio_wait_used_elem(QVirtioDevice *d, + QVirtQueue *vq, + uint32_t desc_idx, + gint64 timeout_us); void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us); QVirtQueue *qvirtqueue_setup(QVirtioDevice *d, QGuestAllocator *alloc, uint16_t index); @@ -135,6 +140,7 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write, bool next); uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect); void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head); +bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx); void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx); #endif |