qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-block@nongnu.org, sgarzare@redhat.com,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Thomas Huth <thuth@redhat.com>, Pankaj Gupta <pagupta@redhat.com>
Subject: [Qemu-devel] [RFC PULL 5/6] tests/virtio-blk: change assert on data_size in virtio_blk_request()
Date: Tue, 12 Feb 2019 22:03:29 +0800	[thread overview]
Message-ID: <20190212140330.1467-6-stefanha@redhat.com> (raw)
In-Reply-To: <20190212140330.1467-1-stefanha@redhat.com>

From: Stefano Garzarella <sgarzare@redhat.com>

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>
Acked-by: Pankaj Gupta <pagupta@redhat.com>
Message-id: 20190208134950.187665-6-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 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

  parent reply	other threads:[~2019-02-12 14:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 14:03 [Qemu-devel] [RFC PULL 0/6] Block pull request for testing Stefan Hajnoczi
2019-02-12 14:03 ` [Qemu-devel] [RFC PULL 1/6] virtio-blk: add acct_failed param to virtio_blk_handle_rw_error() Stefan Hajnoczi
2019-02-12 14:03 ` [Qemu-devel] [RFC PULL 2/6] virtio-blk: add host_features field in VirtIOBlock Stefan Hajnoczi
2019-02-12 14:03 ` [Qemu-devel] [RFC PULL 3/6] virtio-blk: add "discard" and "write-zeroes" properties Stefan Hajnoczi
2019-02-12 14:03 ` [Qemu-devel] [RFC PULL 4/6] virtio-blk: add DISCARD and WRITE_ZEROES features Stefan Hajnoczi
2019-02-12 14:03 ` Stefan Hajnoczi [this message]
2019-02-12 14:03 ` [Qemu-devel] [RFC PULL 6/6] tests/virtio-blk: add test for WRITE_ZEROES command Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2019-02-12 14:12 [Qemu-devel] [RFC PULL 0/6] Block sgarzare test patches Stefan Hajnoczi
2019-02-12 14:12 ` [Qemu-devel] [RFC PULL 5/6] tests/virtio-blk: change assert on data_size in virtio_blk_request() Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212140330.1467-6-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=mst@redhat.com \
    --cc=pagupta@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).