From 8ac9e205bd516d9cedbf28852d77c14ce977b74b Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 9 May 2016 13:47:34 +0100 Subject: libqos: use virtio_ids.h for device ID definitions Avoid redefining device IDs. Use the standard Linux headers that are already in the source tree. Signed-off-by: Stefan Hajnoczi Message-id: 1462798061-30382-2-git-send-email-stefanha@redhat.com --- tests/virtio-net-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/virtio-net-test.c') diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index e5c144818e..e49c13ea5f 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -20,6 +20,7 @@ #include "libqos/malloc-generic.h" #include "qemu/bswap.h" #include "hw/virtio/virtio-net.h" +#include "standard-headers/linux/virtio_ids.h" #define PCI_SLOT_HP 0x06 #define PCI_SLOT 0x04 @@ -39,9 +40,9 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) { QVirtioPCIDevice *dev; - dev = qvirtio_pci_device_find(bus, QVIRTIO_NET_DEVICE_ID); + dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET); g_assert(dev != NULL); - g_assert_cmphex(dev->vdev.device_type, ==, QVIRTIO_NET_DEVICE_ID); + g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET); qvirtio_pci_device_enable(dev); qvirtio_reset(&qvirtio_pci, &dev->vdev); -- cgit v1.2.3 From ee3b850a70613a9e0cedef8c79f76e9ee45cbef3 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 9 May 2016 13:47:37 +0100 Subject: libqos: drop duplicated virtio_ring.h bit definitions Note that virtio_ring.h defines feature bits using their bit number: #define VIRTIO_RING_F_INDIRECT_DESC 28 On the other hand libqos virtio.h uses the bit mask: #define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000 The patch makes the necessary adjustments. I have used "1u << BITMASK" instead of "1ULL << BITMASK" because the 64-bit feature fields are not implemented in libqos virtio. Signed-off-by: Stefan Hajnoczi Message-id: 1462798061-30382-5-git-send-email-stefanha@redhat.com --- tests/virtio-net-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/virtio-net-test.c') diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index e49c13ea5f..17124509a3 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -21,6 +21,7 @@ #include "qemu/bswap.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_ring.h" #define PCI_SLOT_HP 0x06 #define PCI_SLOT 0x04 @@ -70,8 +71,8 @@ static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev) features = qvirtio_get_features(bus, dev); features = features & ~(QVIRTIO_F_BAD_FEATURE | - QVIRTIO_F_RING_INDIRECT_DESC | - QVIRTIO_F_RING_EVENT_IDX); + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_RING_F_EVENT_IDX)); qvirtio_set_features(bus, dev, features); qvirtio_set_driver_ok(bus, dev); -- cgit v1.2.3 From f1d3b99154138741161fc52f5a8c373bf71613c6 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 5 May 2016 16:53:35 +0100 Subject: libqos: add qvirtqueue_cleanup() qvirtqueue_setup() allocates the vring and virtqueue state. So far there has been no function to free it. Callers have been using guest_free() for the vring but forgot to free the QVirtQueue state. This patch solves the memory leak by introducing qvirtqueue_cleanup(). Signed-off-by: Stefan Hajnoczi --- tests/virtio-net-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/virtio-net-test.c') diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 17124509a3..0d2c63f8ab 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -229,7 +229,7 @@ static void pci_basic(gconstpointer data) /* End test */ close(sv[0]); - guest_free(alloc, tx->vq.desc); + qvirtqueue_cleanup(&qvirtio_pci, &tx->vq, alloc); pc_alloc_uninit(alloc); qvirtio_pci_device_disable(dev); g_free(dev); -- cgit v1.2.3