aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc MarĂ­ <marc.mari.barcelo@gmail.com>2015-02-24 22:59:14 +0100
committerKevin Wolf <kwolf@redhat.com>2015-03-10 14:02:23 +0100
commit9b7d2d8b076ff12f0d7b4246aec8f421b4150aae (patch)
tree8cc7e19da69da7131351e5e07cee46323bc58bef
parent1e34cf9681ec549e26f30daaabc1ce58d60446f7 (diff)
downloadqemu-9b7d2d8b076ff12f0d7b4246aec8f421b4150aae.zip
qemu-9b7d2d8b076ff12f0d7b4246aec8f421b4150aae.tar.gz
qemu-9b7d2d8b076ff12f0d7b4246aec8f421b4150aae.tar.bz2
tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test
Check the QVIRTIO_F_ANY_LAYOUT flag before performing operations with 2 descriptor layout. This is to follow the specification strictly. This patch depends on: [PATCH v5 0/5] libqos: Virtio MMIO driver Signed-off-by: Marc MarĂ­ <marc.mari.barcelo@gmail.com> Message-id: 1424815154-27243-1-git-send-email-marc.mari.barcelo@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--tests/virtio-blk-test.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 3b943fc..4078321 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -191,7 +191,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
qvirtio_set_driver_ok(bus, dev);
- /* Write and read with 2 descriptor layout */
+ /* Write and read with 3 descriptor layout */
/* Write request */
req.type = QVIRTIO_BLK_T_OUT;
req.ioprio = 1;
@@ -203,8 +203,10 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
g_free(req.data);
- free_head = qvirtqueue_add(vq, req_addr, 528, false, true);
+ free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
+ qvirtqueue_add(vq, req_addr + 16, 512, false, true);
qvirtqueue_add(vq, req_addr + 528, 1, true, false);
+
qvirtqueue_kick(bus, dev, vq, free_head);
qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
@@ -224,7 +226,8 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
g_free(req.data);
free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
- qvirtqueue_add(vq, req_addr + 16, 513, true, false);
+ qvirtqueue_add(vq, req_addr + 16, 512, true, true);
+ qvirtqueue_add(vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(bus, dev, vq, free_head);
@@ -239,56 +242,55 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
guest_free(alloc, req_addr);
- /* Write and read with 3 descriptor layout */
- /* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
- req.ioprio = 1;
- req.sector = 1;
- req.data = g_malloc0(512);
- strcpy(req.data, "TEST");
+ if (features & QVIRTIO_F_ANY_LAYOUT) {
+ /* Write and read with 2 descriptor layout */
+ /* Write request */
+ req.type = QVIRTIO_BLK_T_OUT;
+ req.ioprio = 1;
+ req.sector = 1;
+ req.data = g_malloc0(512);
+ strcpy(req.data, "TEST");
- req_addr = virtio_blk_request(alloc, &req, 512);
-
- g_free(req.data);
+ req_addr = virtio_blk_request(alloc, &req, 512);
- free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
- qvirtqueue_add(vq, req_addr + 16, 512, false, true);
- qvirtqueue_add(vq, req_addr + 528, 1, true, false);
+ g_free(req.data);
- qvirtqueue_kick(bus, dev, vq, free_head);
+ free_head = qvirtqueue_add(vq, req_addr, 528, false, true);
+ qvirtqueue_add(vq, req_addr + 528, 1, true, false);
+ qvirtqueue_kick(bus, dev, vq, free_head);
- qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
- status = readb(req_addr + 528);
- g_assert_cmpint(status, ==, 0);
+ qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+ status = readb(req_addr + 528);
+ g_assert_cmpint(status, ==, 0);
- guest_free(alloc, req_addr);
+ guest_free(alloc, req_addr);
- /* Read request */
- req.type = QVIRTIO_BLK_T_IN;
- req.ioprio = 1;
- req.sector = 1;
- req.data = g_malloc0(512);
+ /* Read request */
+ req.type = QVIRTIO_BLK_T_IN;
+ req.ioprio = 1;
+ req.sector = 1;
+ req.data = g_malloc0(512);
- req_addr = virtio_blk_request(alloc, &req, 512);
+ req_addr = virtio_blk_request(alloc, &req, 512);
- g_free(req.data);
+ g_free(req.data);
- free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
- qvirtqueue_add(vq, req_addr + 16, 512, true, true);
- qvirtqueue_add(vq, req_addr + 528, 1, true, false);
+ free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
+ qvirtqueue_add(vq, req_addr + 16, 513, true, false);
- qvirtqueue_kick(bus, dev, vq, free_head);
+ qvirtqueue_kick(bus, dev, vq, free_head);
- qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
- status = readb(req_addr + 528);
- g_assert_cmpint(status, ==, 0);
+ qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+ status = readb(req_addr + 528);
+ g_assert_cmpint(status, ==, 0);
- data = g_malloc0(512);
- memread(req_addr + 16, data, 512);
- g_assert_cmpstr(data, ==, "TEST");
- g_free(data);
+ data = g_malloc0(512);
+ memread(req_addr + 16, data, 512);
+ g_assert_cmpstr(data, ==, "TEST");
+ g_free(data);
- guest_free(alloc, req_addr);
+ guest_free(alloc, req_addr);
+ }
}
static void pci_basic(void)
@@ -521,7 +523,8 @@ static void pci_msix(void)
g_free(req.data);
- free_head = qvirtqueue_add(&vqpci->vq, req_addr, 528, false, true);
+ free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
+ qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
@@ -544,7 +547,8 @@ static void pci_msix(void)
g_free(req.data);
free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
- qvirtqueue_add(&vqpci->vq, req_addr + 16, 513, true, false);
+ qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, true, true);
+ qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
@@ -625,7 +629,8 @@ static void pci_idx(void)
g_free(req.data);
- free_head = qvirtqueue_add(&vqpci->vq, req_addr, 528, false, true);
+ free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
+ qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
@@ -645,7 +650,8 @@ static void pci_idx(void)
/* Notify after processing the third request */
qvirtqueue_set_used_event(&vqpci->vq, 2);
- free_head = qvirtqueue_add(&vqpci->vq, req_addr, 528, false, true);
+ free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
+ qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
@@ -668,11 +674,11 @@ static void pci_idx(void)
g_free(req.data);
free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
- qvirtqueue_add(&vqpci->vq, req_addr + 16, 513, true, false);
+ qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, true, true);
+ qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
-
qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq,
QVIRTIO_BLK_TIMEOUT_US);