From patchwork Mon Jul 13 06:04:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 494235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 651A6140776 for ; Mon, 13 Jul 2015 16:05:46 +1000 (AEST) Received: from localhost ([::1]:53045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEWs4-0004mh-BG for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2015 02:05:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEWqx-0003O5-6l for qemu-devel@nongnu.org; Mon, 13 Jul 2015 02:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEWqw-0004aI-4o for qemu-devel@nongnu.org; Mon, 13 Jul 2015 02:04:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEWqv-0004Zc-Vr for qemu-devel@nongnu.org; Mon, 13 Jul 2015 02:04:34 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 95CF0344F44 for ; Mon, 13 Jul 2015 06:04:33 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-4-152.pek2.redhat.com [10.72.4.152]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6D64Pm0027638; Mon, 13 Jul 2015 02:04:30 -0400 From: Jason Wang To: stefanha@redhat.com, qemu-devel@nongnu.org Date: Mon, 13 Jul 2015 14:04:20 +0800 Message-Id: <1436767460-2679-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1436767460-2679-1-git-send-email-jasowang@redhat.com> References: <1436767460-2679-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , famz@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH V2 2/2] tests: test rx recovery from cont X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Rx should be recovered after cont. Signed-off-by: Jason Wang --- Changes from V1: - query status before sending cont, this makes sure that the packet were queued. --- tests/virtio-net-test.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index b7d6f0b..3c412e2 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -140,6 +140,49 @@ static void tx_test(const QVirtioBus *bus, QVirtioDevice *dev, g_assert_cmpstr(buffer, ==, "TEST"); } +static void rx_stop_cont_test(const QVirtioBus *bus, QVirtioDevice *dev, + QGuestAllocator *alloc, QVirtQueue *vq, + int socket) +{ + uint64_t req_addr; + uint32_t free_head; + char test[] = "TEST"; + char buffer[64]; + int len = htonl(sizeof(test)); + struct iovec iov[] = { + { + .iov_base = &len, + .iov_len = sizeof(len), + }, { + .iov_base = test, + .iov_len = sizeof(test), + }, + }; + int ret; + + req_addr = guest_alloc(alloc, 64); + + free_head = qvirtqueue_add(vq, req_addr, 64, true, false); + qvirtqueue_kick(bus, dev, vq, free_head); + + /* We could check the status, but this command is more importantly to + * ensure the packet data gets queued in QEMU, before we do 'cont'. + */ + qmp("{ 'execute' : 'query-status'}"); + qmp("{ 'execute' : 'stop'}"); + + ret = iov_send(socket, iov, 2, 0, sizeof(len) + sizeof(test)); + g_assert_cmpint(ret, ==, sizeof(test) + sizeof(len)); + + qmp("{ 'execute' : 'cont'}"); + + qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_NET_TIMEOUT_US); + memread(req_addr + VNET_HDR_SIZE, buffer, sizeof(test)); + g_assert_cmpstr(buffer, ==, "TEST"); + + guest_free(alloc, req_addr); +} + static void send_recv_test(const QVirtioBus *bus, QVirtioDevice *dev, QGuestAllocator *alloc, QVirtQueue *rvq, QVirtQueue *tvq, int socket) @@ -148,6 +191,13 @@ static void send_recv_test(const QVirtioBus *bus, QVirtioDevice *dev, tx_test(bus, dev, alloc, tvq, socket); } +static void stop_cont_test(const QVirtioBus *bus, QVirtioDevice *dev, + QGuestAllocator *alloc, QVirtQueue *rvq, + QVirtQueue *tvq, int socket) +{ + rx_stop_cont_test(bus, dev, alloc, rvq, socket); +} + static void pci_basic(gconstpointer data) { QVirtioPCIDevice *dev; @@ -206,6 +256,8 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); #ifndef _WIN32 qtest_add_data_func("/virtio/net/pci/basic", send_recv_test, pci_basic); + qtest_add_data_func("/virtio/net/pci/rx_stop_cont", + stop_cont_test, pci_basic); #endif qtest_add_func("/virtio/net/pci/hotplug", hotplug);