diff options
-rw-r--r-- | tests/libqos/virtio.c | 7 | ||||
-rw-r--r-- | tests/libqos/virtio.h | 1 | ||||
-rw-r--r-- | tests/vhost-user-test.c | 4 | ||||
-rw-r--r-- | tests/virtio-9p-test.c | 4 | ||||
-rw-r--r-- | tests/virtio-blk-test.c | 9 | ||||
-rw-r--r-- | tests/virtio-net-test.c | 4 | ||||
-rw-r--r-- | tests/virtio-scsi-test.c | 4 |
7 files changed, 14 insertions, 19 deletions
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index 0dad5c19ac..c1ff0206d5 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -365,3 +365,10 @@ const char *qvirtio_get_dev_type(void) return "pci"; } } + +void qvirtio_start_device(QVirtioDevice *vdev) +{ + qvirtio_reset(vdev); + qvirtio_set_acknowledge(vdev); + qvirtio_set_driver(vdev); +} diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 69b5b13840..2c68668de0 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -146,5 +146,6 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len); void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx); const char *qvirtio_get_dev_type(void); +void qvirtio_start_device(QVirtioDevice *vdev); #endif diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 4cd0a97f13..770e1e6484 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -204,9 +204,7 @@ static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t features_ma g_assert_nonnull(s->dev); qvirtio_pci_device_enable(s->dev); - qvirtio_reset(&s->dev->vdev); - qvirtio_set_acknowledge(&s->dev->vdev); - qvirtio_set_driver(&s->dev->vdev); + qvirtio_start_device(&s->dev->vdev); s->alloc = pc_alloc_init(qts); diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index a2b31085f6..d275c74106 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -65,9 +65,7 @@ static QVirtIO9P *qvirtio_9p_pci_start(void) v9p->dev = (QVirtioDevice *) dev; qvirtio_pci_device_enable(dev); - qvirtio_reset(v9p->dev); - qvirtio_set_acknowledge(v9p->dev); - qvirtio_set_driver(v9p->dev); + qvirtio_start_device(v9p->dev); v9p->vq = qvirtqueue_setup(v9p->dev, v9p->qs->alloc, 0); diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 8d2fc9c710..0680bd040e 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -122,10 +122,7 @@ static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot) g_assert_cmphex(dev->pdev->devfn, ==, ((slot << 3) | PCI_FN)); qvirtio_pci_device_enable(dev); - qvirtio_reset(&dev->vdev); - qvirtio_set_acknowledge(&dev->vdev); - qvirtio_set_driver(&dev->vdev); - + qvirtio_start_device(&dev->vdev); return dev; } @@ -833,9 +830,7 @@ static void mmio_basic(void) g_assert(dev != NULL); g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK); - qvirtio_reset(&dev->vdev); - qvirtio_set_acknowledge(&dev->vdev); - qvirtio_set_driver(&dev->vdev); + qvirtio_start_device(&dev->vdev); alloc = generic_alloc_init(MMIO_RAM_ADDR, MMIO_RAM_SIZE, MMIO_PAGE_SIZE); vq = qvirtqueue_setup(&dev->vdev, alloc, 0); diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index e9783e6707..d4a32a4c44 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -44,9 +44,7 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET); qvirtio_pci_device_enable(dev); - qvirtio_reset(&dev->vdev); - qvirtio_set_acknowledge(&dev->vdev); - qvirtio_set_driver(&dev->vdev); + qvirtio_start_device(&dev->vdev); return dev; } diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 0d4f25d369..961925cec1 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -159,9 +159,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot) g_assert_cmphex(vs->dev->device_type, ==, VIRTIO_ID_SCSI); qvirtio_pci_device_enable(dev); - qvirtio_reset(vs->dev); - qvirtio_set_acknowledge(vs->dev); - qvirtio_set_driver(vs->dev); + qvirtio_start_device(vs->dev); vs->num_queues = qvirtio_config_readl(vs->dev, 0); |