aboutsummaryrefslogtreecommitdiff
path: root/tests/virtio-blk-test.c
diff options
context:
space:
mode:
authorMarc MarĂ­ <marc.mari.barcelo@gmail.com>2014-09-01 12:07:58 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2014-09-08 11:12:43 +0100
commite11199554c568822c3ede3e3b4820ac3a146b1d9 (patch)
tree2c031c8f3cf1657f385a44ff02502c358d3694e1 /tests/virtio-blk-test.c
parentf294b029aa2beb1c67116e04bff5d331f0b18288 (diff)
libqos: Added test case for configuration changes in virtio-blk test
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/virtio-blk-test.c')
-rw-r--r--tests/virtio-blk-test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 2f9cc2b7e7..672580b206 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -377,6 +377,39 @@ static void pci_indirect(void)
test_end();
}
+static void pci_config(void)
+{
+ QVirtioPCIDevice *dev;
+ QPCIBus *bus;
+ int n_size = TEST_IMAGE_SIZE / 2;
+ void *addr;
+ uint64_t capacity;
+
+ bus = test_start();
+
+ dev = virtio_blk_init(bus);
+
+ /* MSI-X is not enabled */
+ addr = dev->addr + QVIRTIO_DEVICE_SPECIFIC_NO_MSIX;
+
+ capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, addr);
+ g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
+
+ qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
+
+ qmp("{ 'execute': 'block_resize', 'arguments': { 'device': 'drive0', "
+ " 'size': %d } }", n_size);
+ g_assert(qvirtio_wait_isr(&qvirtio_pci, &dev->vdev, 0x2,
+ QVIRTIO_BLK_TIMEOUT));
+
+ capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, addr);
+ g_assert_cmpint(capacity, ==, n_size / 512);
+
+ qvirtio_pci_device_disable(dev);
+ g_free(dev);
+ test_end();
+}
+
int main(int argc, char **argv)
{
int ret;
@@ -385,6 +418,7 @@ int main(int argc, char **argv)
g_test_add_func("/virtio/blk/pci/basic", pci_basic);
g_test_add_func("/virtio/blk/pci/indirect", pci_indirect);
+ g_test_add_func("/virtio/blk/pci/config", pci_config);
ret = g_test_run();