Browse Source

tests/libqos: introduce virtio_start_device

This function is intended to group all the qvirtio_* functions that
start the qvirtio devices.
Applied in all tests using this combination of functions.

Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/80/head
Emanuele Giuseppe Esposito 8 years ago
committed by Paolo Bonzini
parent
commit
34c977489d
  1. 7
      tests/libqos/virtio.c
  2. 1
      tests/libqos/virtio.h
  3. 4
      tests/vhost-user-test.c
  4. 4
      tests/virtio-9p-test.c
  5. 9
      tests/virtio-blk-test.c
  6. 4
      tests/virtio-net-test.c
  7. 4
      tests/virtio-scsi-test.c

7
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);
}

1
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

4
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);

4
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);

9
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);

4
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;
}

4
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);

Loading…
Cancel
Save