mirror of https://gitee.com/openkylin/qemu.git
tests/virtio-blk: change assert on data_size in virtio_blk_request()
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 <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20190221103314.58500-8-sgarzare@redhat.com Message-Id: <20190221103314.58500-8-sgarzare@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
37b06f8d46
commit
f6cd8a6366
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue