From nobody Thu May 16 00:31:27 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509022015775307.87244757918654; Thu, 26 Oct 2017 05:46:55 -0700 (PDT) Received: from localhost ([::1]:52687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7hYQ-0007df-Tb for importer@patchew.org; Thu, 26 Oct 2017 08:46:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7hWz-0006lF-77 for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7hWu-0004eF-8d for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7hWu-0004cs-2L for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 131C2D9651 for ; Thu, 26 Oct 2017 12:44:59 +0000 (UTC) Received: from localhost (unknown [10.40.205.1]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 461A07F5FD; Thu, 26 Oct 2017 12:44:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 131C2D9651 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Thu, 26 Oct 2017 14:44:24 +0200 Message-Id: <20171026124425.17957-2-jfreimann@redhat.com> In-Reply-To: <20171026124425.17957-1-jfreimann@redhat.com> References: <20171026124425.17957-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 26 Oct 2017 12:44:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [v3 1/2] tests/vhost-user-bridge: disable debug output by default 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: maxime.coquelin@redhat.com, victork@redhat.com, jasowang@redhat.com, stefanha@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jens Freimann vhost-user-bridge prints out a lot of information, including dumps of all transmitted data. When called from a testcase this output clutters the actual test results, so let's make the default no debug output. Reviewed-by: Maxime Coquelin Signed-off-by: Jens Freimann --- tests/vhost-user-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index d820033a72..4b18e84b42 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -34,7 +34,7 @@ #include "standard-headers/linux/virtio_net.h" #include "contrib/libvhost-user/libvhost-user.h" =20 -#define VHOST_USER_BRIDGE_DEBUG 1 +#define VHOST_USER_BRIDGE_DEBUG 0 =20 #define DPRINT(...) \ do { \ --=20 2.13.6 From nobody Thu May 16 00:31:27 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509022031578339.29453616574233; Thu, 26 Oct 2017 05:47:11 -0700 (PDT) Received: from localhost ([::1]:52688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7hYl-0007ta-Oo for importer@patchew.org; Thu, 26 Oct 2017 08:46:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7hXF-00071d-1q for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7hXA-00050W-0C for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7hX9-0004yy-NL for qemu-devel@nongnu.org; Thu, 26 Oct 2017 08:45:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B321425C43 for ; Thu, 26 Oct 2017 12:45:14 +0000 (UTC) Received: from localhost (unknown [10.40.205.1]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B1695C885; Thu, 26 Oct 2017 12:45:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B321425C43 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Thu, 26 Oct 2017 14:44:25 +0200 Message-Id: <20171026124425.17957-3-jfreimann@redhat.com> In-Reply-To: <20171026124425.17957-1-jfreimann@redhat.com> References: <20171026124425.17957-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Oct 2017 12:45:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge 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: maxime.coquelin@redhat.com, victork@redhat.com, jasowang@redhat.com, stefanha@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jens Freimann Add a PXE testcase tunneling traffic through vhost-user-bridge process. Create a vhost-user-bridge process and connect it to qemu via a socket. Signed-off-by: Jens Freimann --- tests/Makefile.include | 4 +- tests/pxe-test.c | 111 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 114 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 70dc711bca..6cdb783753 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -740,7 +740,8 @@ tests/boot-order-test$(EXESUF): tests/boot-order-test.o= $(libqos-obj-y) tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ tests/boot-sector.o tests/acpi-utils.o $(libqos-obj-y) -tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj= -y) +tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o \ + tests/vhost-user-bridge$(EXESUF) $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/m25p80-test$(EXESUF): tests/m25p80-test.o @@ -849,6 +850,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-q= test-%: subdir-%-softmmu $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,) $(call quiet-command,QTEST_QEMU_BINARY=3D$*-softmmu/qemu-system-$* \ QTEST_QEMU_IMG=3Dqemu-img$(EXESUF) \ + QTEST_VUBR_BINARY=3D./tests/vhost-user-bridge$(EXESUF) \ MALLOC_PERTURB_=3D$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} \ gtester $(GTESTER_OPTIONS) -m=3D$(SPEED) $(check-qtest-$*-y) $(check-qte= st-generic-y),"GTESTER","$@") $(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y) $(gcov-files-generic-y);= do \ diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 937f29e631..d2646ee86d 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -7,6 +7,7 @@ * Michael S. Tsirkin , * Victor Kaplansky * Thomas Huth + * Jens Freimann * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -14,14 +15,123 @@ =20 #include "qemu/osdep.h" #include +#include #include "qemu-common.h" #include "libqtest.h" #include "boot-sector.h" =20 +#define LPORT 5555 +#define RPORT 4444 #define NETNAME "net0" +#define QEMU_CMD_MEM "--enable-kvm -m %d "\ + "-object memory-backend-file,id=3Dmem,size=3D%dM,"\ + "mem-path=3D%s,share=3Don -numa node,memdev=3Dmem = -mem-prealloc " +#define QEMU_CMD_CHR " -chardev socket,id=3D%s,path=3D%s" +#define QEMU_CMD_NETDEV " -device virtio-net-pci,netdev=3Dnet0 "\ + " -netdev vhost-user,id=3Dnet0,chardev=3D%s,vhostf= orce "\ + " -netdev user,id=3Dn0,tftp=3D./,bootfile=3D%s "\ + " -netdev socket,id=3Dn1,fd=3D%d" +#define QEMU_CMD_NET " -device virtio-net-pci,netdev=3Dn0 "\ + " -device virtio-net-pci,netdev=3Dn1 " + +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ + QEMU_CMD_NETDEV QEMU_CMD_NET + +#define VUBR_SOCK "vubr.sock" +#define MEMSZ 1024 =20 static char disk[] =3D "tests/pxe-test-disk-XXXXXX"; =20 +static int vubr_create_socket(struct sockaddr_in *si_remote, int rport) +{ + int sock; + + si_remote->sin_addr.s_addr =3D htonl(INADDR_LOOPBACK); + sock =3D socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (sock =3D=3D -1) { + g_test_message("socket creation failed\n"); + return -1; + } + if (connect(sock, (struct sockaddr *) si_remote, sizeof(*si_remote))) { + g_test_message("connect failed: %s", strerror(errno)); + return -1; + } + + return sock; +} + +static void vubr_watch(GPid pid, gint status, gpointer data) +{ + g_assert_cmpint(status, =3D=3D, 0); + g_spawn_close_pid(pid); +} + +static void abrt_handler(void *data) +{ + int *pid =3D data; + + g_spawn_close_pid(*pid); + kill(*pid, SIGTERM); + waitpid(*pid, NULL, 0); +} + +static void test_pxe_vhost_user(void) +{ + char template[] =3D "/tmp/vhost-user-bridge-XXXXXX"; + gchar * vubr_args[] =3D {NULL, NULL, NULL, NULL}; + struct sockaddr_in si_remote =3D { + .sin_family =3D AF_INET, + .sin_port =3D htons(RPORT), + }; + const char *hugefs =3D NULL; + const char *tmpfs =3D NULL; + GError *error =3D NULL; + char *vubr_binary; + char *qemu_args; + GPid vubr_pid; + int sock =3D -1; + + qtest_add_abrt_handler(abrt_handler, &vubr_pid); + tmpfs =3D mkdtemp(template); + if (!tmpfs) { + g_test_message("mkdtemp on path(%s): %s\n", + template, strerror(errno)); + } + vubr_binary =3D getenv("QTEST_VUBR_BINARY"); + g_assert(vubr_binary); + vubr_args[0] =3D g_strdup_printf("%s", vubr_binary); + vubr_args[1] =3D g_strdup_printf("-u"); + vubr_args[2] =3D g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK); + g_spawn_async(NULL, vubr_args, NULL, + G_SPAWN_SEARCH_PATH | + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, &vubr_pid, &error); + g_assert_no_error(error); + g_child_watch_add(vubr_pid, vubr_watch, NULL); + + hugefs =3D getenv("QTEST_HUGETLBFS_PATH"); + if (!hugefs) { + hugefs =3D tmpfs; + } + sock =3D vubr_create_socket(&si_remote, RPORT); + g_assert_cmpint(sock, !=3D, -1); + qemu_args =3D g_strdup_printf(QEMU_CMD, MEMSZ, MEMSZ, (hugefs), + "char0", vubr_args[2], "char0", + disk, sock); + qtest_start(qemu_args); + boot_sector_test(); + qtest_quit(global_qtest); + g_free(qemu_args); + g_free(vubr_args[0]); + g_free(vubr_args[1]); + g_free(vubr_args[2]); + g_assert_cmpint(g_remove(g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK)), + =3D=3D, 0); + g_assert_cmpint(g_remove(g_strdup_printf("%s", disk)), =3D=3D, 0); + g_assert_cmpint(g_rmdir(tmpfs), =3D=3D, 0); + g_assert_cmpint(kill(vubr_pid, SIGTERM), =3D=3D, 0); +} + static void test_pxe_one(const char *params, bool ipv6) { char *args; @@ -77,6 +187,7 @@ int main(int argc, char *argv[]) qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4); qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4); qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4); + qtest_add_func("pxe/vhost-user", test_pxe_vhost_user); } } else if (strcmp(arch, "ppc64") =3D=3D 0) { qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan); --=20 2.13.6