[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virt
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test |
Date: |
Fri, 27 Feb 2015 18:19:07 +0000 |
From: Marc MarĂ <address@hidden>
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Ă <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/virtio-blk-test.c | 118 +++++++++++++++++++++++++-----------------------
1 file changed, 62 insertions(+), 56 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,59 +191,11 @@ static void test_basic(const QVirtioBus *bus,
QVirtioDevice *dev,
qvirtio_set_driver_ok(bus, dev);
- /* Write and read with 2 descriptor layout */
- /* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
- req.ioprio = 1;
- req.sector = 0;
- req.data = g_malloc0(512);
- strcpy(req.data, "TEST");
-
- req_addr = virtio_blk_request(alloc, &req, 512);
-
- g_free(req.data);
-
- 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);
-
- guest_free(alloc, req_addr);
-
- /* Read request */
- req.type = QVIRTIO_BLK_T_IN;
- req.ioprio = 1;
- req.sector = 0;
- req.data = g_malloc0(512);
-
- req_addr = virtio_blk_request(alloc, &req, 512);
-
- g_free(req.data);
-
- 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);
-
- 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);
-
- 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.sector = 0;
req.data = g_malloc0(512);
strcpy(req.data, "TEST");
@@ -266,7 +218,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice
*dev,
/* Read request */
req.type = QVIRTIO_BLK_T_IN;
req.ioprio = 1;
- req.sector = 1;
+ req.sector = 0;
req.data = g_malloc0(512);
req_addr = virtio_blk_request(alloc, &req, 512);
@@ -289,6 +241,56 @@ static void test_basic(const QVirtioBus *bus,
QVirtioDevice *dev,
g_free(data);
guest_free(alloc, req_addr);
+
+ 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);
+
+ 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);
+
+ guest_free(alloc, req_addr);
+
+ /* 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);
+
+ g_free(req.data);
+
+ 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);
+
+ 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);
+
+ 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);
--
2.1.0
- [Qemu-devel] [PULL 55/69] libqos/ahci: add ahci command helpers, (continued)
- [Qemu-devel] [PULL 55/69] libqos/ahci: add ahci command helpers, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 57/69] qtest/ahci: Add PIO and LBA48 tests, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 59/69] qtest/ahci: add qcow2 support to ahci-test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 61/69] qtest/ahci: Add simple flush test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 62/69] qtest/ahci: Allow override of default CLI options, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 60/69] qtest/ahci: test different disk sectors, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 64/69] libqtest: add qmp_async, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 65/69] libqos: add blkdebug_prepare_script, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 66/69] qtest/ahci: add flush retry test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 68/69] libqos: Solve bug in interrupt checking when using MSIX in virtio-pci.c, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 67/69] sheepdog: fix confused return values, Stefan Hajnoczi, 2015/02/27
- Re: [Qemu-devel] [PULL 00/69] Block patches, Stefan Hajnoczi, 2015/02/27