[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 24/27] tests/virtio-blk: change assert on data_size i
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-block] [PULL 24/27] tests/virtio-blk: change assert on data_size in virtio_blk_request() |
Date: |
Fri, 22 Feb 2019 14:07:53 +0000 |
From: Stefano Garzarella <address@hidden>
The size of data in the virtio_blk_request must be a multiple
of 512 bytes for IN and OUT requests, or a multiple of the size
of struct virtio_blk_discard_write_zeroes for DISCARD and
WRITE_ZEROES requests.
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Stefano Garzarella <address@hidden>
Message-id: address@hidden
Message-Id: <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/virtio-blk-test.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 04c608764b..0739498da7 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -144,7 +144,20 @@ static uint64_t virtio_blk_request(QGuestAllocator *alloc,
QVirtioDevice *d,
uint64_t addr;
uint8_t status = 0xFF;
- g_assert_cmpuint(data_size % 512, ==, 0);
+ switch (req->type) {
+ case VIRTIO_BLK_T_IN:
+ case VIRTIO_BLK_T_OUT:
+ g_assert_cmpuint(data_size % 512, ==, 0);
+ break;
+ case VIRTIO_BLK_T_DISCARD:
+ case VIRTIO_BLK_T_WRITE_ZEROES:
+ g_assert_cmpuint(data_size %
+ sizeof(struct virtio_blk_discard_write_zeroes), ==,
0);
+ break;
+ default:
+ g_assert_cmpuint(data_size, ==, 0);
+ }
+
addr = guest_alloc(alloc, sizeof(*req) + data_size);
virtio_blk_fix_request(d, req);
--
2.20.1
- [Qemu-block] [PULL 16/27] hw/ide: drop iov field from IDEBufferedRequest, (continued)
- [Qemu-block] [PULL 16/27] hw/ide: drop iov field from IDEBufferedRequest, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 18/27] virtio-blk: add acct_failed param to virtio_blk_handle_rw_error(), Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 17/27] hw/ide: drop iov field from IDEDMA, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 25/27] tests/virtio-blk: add virtio_blk_fix_dwz_hdr() function, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 26/27] tests/virtio-blk: add test for WRITE_ZEROES command, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 20/27] virtio-blk: add "discard" and "write-zeroes" properties, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 21/27] virtio-net: make VirtIOFeature usable for other virtio devices, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 19/27] virtio-blk: add host_features field in VirtIOBlock, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 23/27] virtio-blk: add DISCARD and WRITE_ZEROES features, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 27/27] tests/virtio-blk: add test for DISCARD command, Stefan Hajnoczi, 2019/02/22
- [Qemu-block] [PULL 24/27] tests/virtio-blk: change assert on data_size in virtio_blk_request(),
Stefan Hajnoczi <=
- Re: [Qemu-block] [PULL 00/27] Block patches, Peter Maydell, 2019/02/26