From patchwork Mon Feb 18 14:03:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 10818099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EED31575 for ; Mon, 18 Feb 2019 14:22:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8796D2AEE0 for ; Mon, 18 Feb 2019 14:22:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85BF82AEEA; Mon, 18 Feb 2019 14:22:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6939B2AEC2 for ; Mon, 18 Feb 2019 14:22:34 +0000 (UTC) Received: from localhost ([127.0.0.1]:59340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvjoW-0006pR-9k for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Feb 2019 09:22:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvjZ2-00026T-AG for qemu-devel@nongnu.org; Mon, 18 Feb 2019 09:06:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvjZ0-0005am-AF for qemu-devel@nongnu.org; Mon, 18 Feb 2019 09:06:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45580) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvjYm-0005Oc-LH; Mon, 18 Feb 2019 09:06:16 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3243C315D3F; Mon, 18 Feb 2019 14:06:10 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-116-155.ams2.redhat.com [10.36.116.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 415651001F52; Mon, 18 Feb 2019 14:06:06 +0000 (UTC) From: Stefano Garzarella To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 15:03:01 +0100 Message-Id: <20190218140301.197408-11-sgarzare@redhat.com> In-Reply-To: <20190218140301.197408-1-sgarzare@redhat.com> References: <20190218140301.197408-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Feb 2019 14:06:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 10/10] tests/virtio-blk: add test for DISCARD command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , "Dr . David Alan Gilbert" , Max Reitz , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the DISCARD feature is enabled, we try this command in the test_basic(), checking only the status returned by the request. Signed-off-by: Stefano Garzarella Reviewed-by: Stefan Hajnoczi --- 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 cfc560be46..0bdbee32ba 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 */