aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/virtio.h
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2016-05-09 13:47:38 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2016-06-20 11:44:12 +0100
commit780b11a097ada54306d43d6e64450e8d7e7a76e4 (patch)
treecc4ab98e70bd7cfb7bbb8148a7ab9d7fe66b60d6 /tests/libqos/virtio.h
parentee3b850a70613a9e0cedef8c79f76e9ee45cbef3 (diff)
downloadqemu-780b11a097ada54306d43d6e64450e8d7e7a76e4.zip
qemu-780b11a097ada54306d43d6e64450e8d7e7a76e4.tar.gz
qemu-780b11a097ada54306d43d6e64450e8d7e7a76e4.tar.bz2
libqos: drop duplicated virtio_vring.h structs
The descriptor element, used, and avail vring structs are defined in virtio_ring.h. There is no need to duplicate them in libqos virtio. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1462798061-30382-6-git-send-email-stefanha@redhat.com
Diffstat (limited to 'tests/libqos/virtio.h')
-rw-r--r--tests/libqos/virtio.h39
1 files changed, 7 insertions, 32 deletions
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 2af8036..c73fd8c 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -11,6 +11,7 @@
#define LIBQOS_VIRTIO_H
#include "libqos/malloc.h"
+#include "standard-headers/linux/virtio_ring.h"
#define QVIRTIO_F_BAD_FEATURE 0x40000000
@@ -19,36 +20,10 @@ typedef struct QVirtioDevice {
uint16_t device_type;
} QVirtioDevice;
-typedef struct QVRingDesc {
- uint64_t addr;
- uint32_t len;
- uint16_t flags;
- uint16_t next;
-} QVRingDesc;
-
-typedef struct QVRingAvail {
- uint16_t flags;
- uint16_t idx;
- uint16_t ring[0]; /* This is an array of uint16_t */
- uint16_t used_event;
-} QVRingAvail;
-
-typedef struct QVRingUsedElem {
- uint32_t id;
- uint32_t len;
-} QVRingUsedElem;
-
-typedef struct QVRingUsed {
- uint16_t flags;
- uint16_t idx;
- QVRingUsedElem ring[0]; /* This is an array of QVRingUsedElem structs */
- uint16_t avail_event;
-} QVRingUsed;
-
typedef struct QVirtQueue {
- uint64_t desc; /* This points to an array of QVRingDesc */
- uint64_t avail; /* This points to a QVRingAvail */
- uint64_t used; /* This points to a QVRingDesc */
+ uint64_t desc; /* This points to an array of struct vring_desc */
+ uint64_t avail; /* This points to a struct vring_avail */
+ uint64_t used; /* This points to a struct vring_desc */
uint16_t index;
uint32_t size;
uint32_t free_head;
@@ -59,7 +34,7 @@ typedef struct QVirtQueue {
} QVirtQueue;
typedef struct QVRingIndirectDesc {
- uint64_t desc; /* This points to an array fo QVRingDesc */
+ uint64_t desc; /* This points to an array fo struct vring_desc */
uint16_t index;
uint16_t elem;
} QVRingIndirectDesc;
@@ -110,9 +85,9 @@ typedef struct QVirtioBus {
static inline uint32_t qvring_size(uint32_t num, uint32_t align)
{
- return ((sizeof(struct QVRingDesc) * num + sizeof(uint16_t) * (3 + num)
+ return ((sizeof(struct vring_desc) * num + sizeof(uint16_t) * (3 + num)
+ align - 1) & ~(align - 1))
- + sizeof(uint16_t) * 3 + sizeof(struct QVRingUsedElem) * num;
+ + sizeof(uint16_t) * 3 + sizeof(struct vring_used_elem) * num;
}
uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,