aboutsummaryrefslogtreecommitdiff
path: root/tests/virtio-net-test.c
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2016-10-17 12:30:23 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2016-10-28 09:36:58 +1100
commita980f7f2c2f4d7e9a1eba4f804cd66dbd458b6d4 (patch)
tree35784487e8711440578954fb5e7113686b2bf694 /tests/virtio-net-test.c
parent8b4b80c37630e976f2dd02a7d42bd9bea1ce676e (diff)
tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests
This patch replaces calls to qtest_start() and qtest_end() by calls to qtest_pc_boot() and qtest_shutdown(). This allows to initialize memory allocator and PCI interface functions. This will ease to enable virtio tests on other architectures by only adding a specific qtest_XXX_boot() (like qtest_spapr_boot()). Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests/virtio-net-test.c')
-rw-r--r--tests/virtio-net-test.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 6fa385e90e..6bec784f81 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -12,12 +12,9 @@
#include "qemu-common.h"
#include "qemu/sockets.h"
#include "qemu/iov.h"
-#include "libqos/pci-pc.h"
+#include "libqos/libqos-pc.h"
#include "libqos/virtio.h"
#include "libqos/virtio-pci.h"
-#include "libqos/malloc.h"
-#include "libqos/malloc-pc.h"
-#include "libqos/malloc-generic.h"
#include "qemu/bswap.h"
#include "hw/virtio/virtio-net.h"
#include "standard-headers/linux/virtio_ids.h"
@@ -53,16 +50,12 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)
return dev;
}
-static QPCIBus *pci_test_start(int socket)
+static QOSState *pci_test_start(int socket)
{
- char *cmdline;
+ const char *cmd = "-netdev socket,fd=%d,id=hs0 -device "
+ "virtio-net-pci,netdev=hs0";
- cmdline = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device "
- "virtio-net-pci,netdev=hs0", socket);
- qtest_start(cmdline);
- g_free(cmdline);
-
- return qpci_init_pc(NULL);
+ return qtest_pc_boot(cmd, socket);
}
static void driver_init(QVirtioDevice *dev)
@@ -205,9 +198,8 @@ static void stop_cont_test(QVirtioDevice *dev,
static void pci_basic(gconstpointer data)
{
QVirtioPCIDevice *dev;
- QPCIBus *bus;
+ QOSState *qs;
QVirtQueuePCI *tx, *rx;
- QGuestAllocator *alloc;
void (*func) (QVirtioDevice *dev,
QGuestAllocator *alloc,
QVirtQueue *rvq,
@@ -218,26 +210,23 @@ static void pci_basic(gconstpointer data)
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);
g_assert_cmpint(ret, !=, -1);
- bus = pci_test_start(sv[1]);
- dev = virtio_net_pci_init(bus, PCI_SLOT);
+ qs = pci_test_start(sv[1]);
+ dev = virtio_net_pci_init(qs->pcibus, PCI_SLOT);
- alloc = pc_alloc_init();
- rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, 0);
- tx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, 1);
+ rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 0);
+ tx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 1);
driver_init(&dev->vdev);
- func(&dev->vdev, alloc, &rx->vq, &tx->vq, sv[0]);
+ func(&dev->vdev, qs->alloc, &rx->vq, &tx->vq, sv[0]);
/* End test */
close(sv[0]);
- qvirtqueue_cleanup(dev->vdev.bus, &tx->vq, alloc);
- qvirtqueue_cleanup(dev->vdev.bus, &rx->vq, alloc);
- pc_alloc_uninit(alloc);
+ qvirtqueue_cleanup(dev->vdev.bus, &tx->vq, qs->alloc);
+ qvirtqueue_cleanup(dev->vdev.bus, &rx->vq, qs->alloc);
qvirtio_pci_device_disable(dev);
g_free(dev->pdev);
g_free(dev);
- qpci_free_pc(bus);
- test_end();
+ qtest_shutdown(qs);
}
#endif