From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 27/27] tests/virtio-blk: add test for DISCARD command
Date: Fri, 22 Feb 2019 14:07:56 +0000 [thread overview]
Message-ID: <20190222140756.29834-28-stefanha@redhat.com> (raw)
In-Reply-To: <20190222140756.29834-1-stefanha@redhat.com>
From: Stefano Garzarella <sgarzare@redhat.com>
If the DISCARD feature is enabled, we try this command in the
test_basic(), checking only the status returned by the request.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20190221103314.58500-11-sgarzare@redhat.com
Message-Id: <20190221103314.58500-11-sgarzare@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/virtio-blk-test.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index f43d971099..8d2fc9c710 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -317,6 +317,33 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc,
guest_free(alloc, req_addr);
}
+ if (features & (1u << VIRTIO_BLK_F_DISCARD)) {
+ struct virtio_blk_discard_write_zeroes dwz_hdr;
+
+ req.type = VIRTIO_BLK_T_DISCARD;
+ req.data = (char *) &dwz_hdr;
+ dwz_hdr.sector = 0;
+ dwz_hdr.num_sectors = 1;
+ dwz_hdr.flags = 0;
+
+ virtio_blk_fix_dwz_hdr(dev, &dwz_hdr);
+
+ req_addr = virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr));
+
+ free_head = qvirtqueue_add(vq, req_addr, 16, false, true);
+ qvirtqueue_add(vq, req_addr + 16, sizeof(dwz_hdr), false, true);
+ qvirtqueue_add(vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, false);
+
+ qvirtqueue_kick(dev, vq, free_head);
+
+ qvirtio_wait_used_elem(dev, vq, free_head, NULL,
+ QVIRTIO_BLK_TIMEOUT_US);
+ status = readb(req_addr + 16 + sizeof(dwz_hdr));
+ g_assert_cmpint(status, ==, 0);
+
+ guest_free(alloc, req_addr);
+ }
+
if (features & (1u << VIRTIO_F_ANY_LAYOUT)) {
/* Write and read with 2 descriptor layout */
/* Write request */
--
2.20.1
next prev parent reply other threads:[~2019-02-22 14:10 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 14:07 [Qemu-devel] [PULL 00/27] Block patches Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 01/27] block: enhance QEMUIOVector structure Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 02/27] block/io: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 03/27] block/block-backend: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 04/27] block/backup: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 05/27] block/commit: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 06/27] block/stream: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 07/27] block/parallels: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 08/27] block/qcow: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 09/27] block/qcow2: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 10/27] block/qed: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 11/27] block/vmdk: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 12/27] qemu-img: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 13/27] migration/block: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 14/27] tests/test-bdrv-drain: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 15/27] hw/ide: drop iov field from IDEState Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 16/27] hw/ide: drop iov field from IDEBufferedRequest Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 17/27] hw/ide: drop iov field from IDEDMA Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 18/27] virtio-blk: add acct_failed param to virtio_blk_handle_rw_error() Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 19/27] virtio-blk: add host_features field in VirtIOBlock Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 20/27] virtio-blk: add "discard" and "write-zeroes" properties Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 21/27] virtio-net: make VirtIOFeature usable for other virtio devices Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 22/27] virtio-blk: set config size depending on the features enabled Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 23/27] virtio-blk: add DISCARD and WRITE_ZEROES features Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 24/27] tests/virtio-blk: change assert on data_size in virtio_blk_request() Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 25/27] tests/virtio-blk: add virtio_blk_fix_dwz_hdr() function Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 26/27] tests/virtio-blk: add test for WRITE_ZEROES command Stefan Hajnoczi
2019-02-22 14:07 ` Stefan Hajnoczi [this message]
2019-02-26 14:06 ` [Qemu-devel] [PULL 00/27] Block patches Peter Maydell
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=20190222140756.29834-28-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).