From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:49990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt4Vc-0002Xy-Ld for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:52:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gt4Va-0002yt-S9 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:52:00 -0500 From: Stefan Hajnoczi Date: Mon, 11 Feb 2019 13:50:39 +0800 Message-Id: <20190211055040.13528-9-stefanha@redhat.com> In-Reply-To: <20190211055040.13528-1-stefanha@redhat.com> References: <20190211055040.13528-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 8/9] tests/virtio-blk: change assert on data_size in virtio_blk_request() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Eduardo Habkost , Laurent Vivier , Max Reitz , "Michael S. Tsirkin" , Paolo Bonzini , qemu-block@nongnu.org, Kevin Wolf , Stefano Garzarella , Pankaj Gupta From: Stefano Garzarella 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 Reviewed-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Signed-off-by: Stefano Garzarella Acked-by: Pankaj Gupta Message-id: 20190208134950.187665-6-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- 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 =3D 0xFF; =20 - g_assert_cmpuint(data_size % 512, =3D=3D, 0); + switch (req->type) { + case VIRTIO_BLK_T_IN: + case VIRTIO_BLK_T_OUT: + g_assert_cmpuint(data_size % 512, =3D=3D, 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),= =3D=3D, 0); + break; + default: + g_assert_cmpuint(data_size, =3D=3D, 0); + } + addr =3D guest_alloc(alloc, sizeof(*req) + data_size); =20 virtio_blk_fix_request(d, req); --=20 2.20.1