summaryrefslogtreecommitdiffstats
path: root/tests/libqos/virtio-pci.c
diff options
context:
space:
mode:
authorMarc MarĂ­ <marc.mari.barcelo@gmail.com>2014-09-01 12:07:57 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2014-09-08 11:12:43 +0100
commitf294b029aa2beb1c67116e04bff5d331f0b18288 (patch)
treec310d6a49c2e00e2316d8cbac5400aab2838642a /tests/libqos/virtio-pci.c
parentbf3c63d2010c5ef52f8b988bee2a1486a056795f (diff)
downloadhqemu-f294b029aa2beb1c67116e04bff5d331f0b18288.zip
hqemu-f294b029aa2beb1c67116e04bff5d331f0b18288.tar.gz
libqos: Added indirect descriptor support to virtio implementation
Add functions necessary for working with indirect descriptors. Add test using new functions. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Marc MarĂ­ <marc.mari.barcelo@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/virtio-pci.c')
-rw-r--r--tests/libqos/virtio-pci.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 12b06a2..cf15f7a 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -107,6 +107,12 @@ static void qvirtio_pci_set_features(QVirtioDevice *d, uint32_t features)
qpci_io_writel(dev->pdev, dev->addr + QVIRTIO_GUEST_FEATURES, features);
}
+static uint32_t qvirtio_pci_get_guest_features(QVirtioDevice *d)
+{
+ QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
+ return qpci_io_readl(dev->pdev, dev->addr + QVIRTIO_GUEST_FEATURES);
+}
+
static uint8_t qvirtio_pci_get_status(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
@@ -146,10 +152,12 @@ static void qvirtio_pci_set_queue_address(QVirtioDevice *d, uint32_t pfn)
static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
QGuestAllocator *alloc, uint16_t index)
{
+ uint32_t feat;
uint64_t addr;
QVirtQueue *vq;
vq = g_malloc0(sizeof(*vq));
+ feat = qvirtio_pci_get_guest_features(d);
qvirtio_pci_queue_select(d, index);
vq->index = index;
@@ -157,6 +165,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
vq->free_head = 0;
vq->num_free = vq->size;
vq->align = QVIRTIO_PCI_ALIGN;
+ vq->indirect = (feat & QVIRTIO_F_RING_INDIRECT_DESC) != 0;
/* Check different than 0 */
g_assert_cmpint(vq->size, !=, 0);
@@ -186,6 +195,7 @@ const QVirtioBus qvirtio_pci = {
.config_readq = qvirtio_pci_config_readq,
.get_features = qvirtio_pci_get_features,
.set_features = qvirtio_pci_set_features,
+ .get_guest_features = qvirtio_pci_get_guest_features,
.get_status = qvirtio_pci_get_status,
.set_status = qvirtio_pci_set_status,
.get_isr_status = qvirtio_pci_get_isr_status,
OpenPOWER on IntegriCloud