From patchwork Fri Sep 2 18:59:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9311521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FB7960772 for ; Fri, 2 Sep 2016 19:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7258929815 for ; Fri, 2 Sep 2016 19:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66EB929854; Fri, 2 Sep 2016 19:04:08 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F083C29815 for ; Fri, 2 Sep 2016 19:04:07 +0000 (UTC) Received: from localhost ([::1]:43481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bftl1-0007HW-1L for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Sep 2016 15:04:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bftkJ-00070f-DB for qemu-devel@nongnu.org; Fri, 02 Sep 2016 15:03:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bftkH-0000N2-WF for qemu-devel@nongnu.org; Fri, 02 Sep 2016 15:03:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bftkH-0000Mw-Nu; Fri, 02 Sep 2016 15:03:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D82480F6C; Fri, 2 Sep 2016 19:03:21 +0000 (UTC) Received: from localhost (ovpn-116-23.phx2.redhat.com [10.3.116.23]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u82J3KlA007127; Fri, 2 Sep 2016 15:03:20 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, Paolo Bonzini Date: Fri, 2 Sep 2016 15:59:43 -0300 Message-Id: <1472842784-15399-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1472842784-15399-1-git-send-email-ehabkost@redhat.com> References: <1472842784-15399-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 02 Sep 2016 19:03:21 +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 v2 1/2] vhost-user-test: Use libqos instead of pxe-virtio.rom 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: mprivozn@redhat.com, Bandan Das , Markus Armbruster , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP vhost-user-test relies on iPXE just to initialize the virtio-net device, and doesn't do any actual packet tx/rx testing. In addition to that, the test relies on TCG, which is imcompatible with vhost. The test only worked by accident: a bug the memory backend initialization made memory regions not have the DIRTY_MEMORY_CODE bit set in dirty_log_mask. This changes vhost-user-test to initialize the virtio-net device using libqos, and not use TCG nor pxe-virtio.rom. Signed-off-by: Eduardo Habkost --- Changes series v1 -> series v2: * (new patch) --- tests/Makefile.include | 2 +- tests/vhost-user-test.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 14be491..03382b5 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -622,7 +622,7 @@ tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y) tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y) tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o tests/postcopy-test$(EXESUF): tests/postcopy-test.o -tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) $(test-io-obj-y) +tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y) tests/test-write-threshold$(EXESUF): tests/test-write-threshold.o $(test-block-obj-y) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 27b10c1..b89a551 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -16,8 +16,13 @@ #include "qemu/sockets.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" +#include "libqos/libqos.h" +#include "libqos/pci-pc.h" +#include "libqos/virtio-pci.h" #include +#include +#include #include /* GLIB version compatibility flags */ @@ -29,14 +34,13 @@ #define HAVE_MONOTONIC_TIME #endif -#define QEMU_CMD_ACCEL " -machine accel=tcg" #define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM,"\ "mem-path=%s,share=on -numa node,memdev=mem" #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce" -#define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0,romfile=./pc-bios/pxe-virtio.rom" +#define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0" -#define QEMU_CMD QEMU_CMD_ACCEL QEMU_CMD_MEM QEMU_CMD_CHR \ +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ QEMU_CMD_NETDEV QEMU_CMD_NET #define HUGETLBFS_MAGIC 0x958458f6 @@ -136,6 +140,30 @@ typedef struct TestServer { static const char *tmpfs; static const char *root; +static void init_virtio_dev(TestServer *s) +{ + QPCIBus *bus; + QVirtioPCIDevice *dev; + uint32_t features; + + bus = qpci_init_pc(); + g_assert_nonnull(bus); + + dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET); + g_assert_nonnull(dev); + + qvirtio_pci_device_enable(dev); + qvirtio_reset(&qvirtio_pci, &dev->vdev); + qvirtio_set_acknowledge(&qvirtio_pci, &dev->vdev); + qvirtio_set_driver(&qvirtio_pci, &dev->vdev); + + features = qvirtio_get_features(&qvirtio_pci, &dev->vdev); + features = features & VIRTIO_NET_F_MAC; + qvirtio_set_features(&qvirtio_pci, &dev->vdev, features); + + qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev); +} + static void wait_for_fds(TestServer *s) { gint64 end_time; @@ -548,6 +576,7 @@ static void test_migrate(void) from = qtest_start(cmd); g_free(cmd); + init_virtio_dev(s); wait_for_fds(s); size = get_log_size(s); g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)); @@ -662,6 +691,7 @@ static void test_reconnect_subprocess(void) qtest_start(cmd); g_free(cmd); + init_virtio_dev(s); wait_for_fds(s); wait_for_rings_started(s, 2); @@ -728,6 +758,7 @@ int main(int argc, char **argv) s = qtest_start(qemu_cmd); g_free(qemu_cmd); + init_virtio_dev(server); qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem); qtest_add_func("/vhost-user/migrate", test_migrate);