From nobody Thu May 2 13:26:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502225473014622.1286386526822; Tue, 8 Aug 2017 13:51:13 -0700 (PDT) Received: from localhost ([::1]:44477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBT5-0000hw-Rf for importer@patchew.org; Tue, 08 Aug 2017 16:51:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBQd-0006xy-AF for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfBQc-0007R6-5g for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfBQb-0007QA-Vw for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8043D552DC for ; Tue, 8 Aug 2017 20:39:15 +0000 (UTC) Received: from localhost (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01A2861F40; Tue, 8 Aug 2017 20:39:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8043D552DC Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 22:38:56 +0200 Message-Id: <20170808203900.7661-2-jfreimann@redhat.com> In-Reply-To: <20170808203900.7661-1-jfreimann@redhat.com> References: <20170808203900.7661-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Aug 2017 20:39:15 +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] [PATCH v2 1/5] 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: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 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 1e5b5ca3da..93d95353d7 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.3 From nobody Thu May 2 13:26:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502225352367375.10439616408155; Tue, 8 Aug 2017 13:49:12 -0700 (PDT) Received: from localhost ([::1]:44463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBR8-00075S-Vl for importer@patchew.org; Tue, 08 Aug 2017 16:49:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBPN-00068D-UQ for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfBPK-0006BJ-4Q for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:47:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfBPJ-00068M-RH for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:47:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4585F6146C for ; Tue, 8 Aug 2017 20:39:31 +0000 (UTC) Received: from localhost (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C73160317; Tue, 8 Aug 2017 20:39:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4585F6146C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 22:38:57 +0200 Message-Id: <20170808203900.7661-3-jfreimann@redhat.com> In-Reply-To: <20170808203900.7661-1-jfreimann@redhat.com> References: <20170808203900.7661-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 08 Aug 2017 20:39:31 +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] [PATCH v2 2/5] net: fix -netdev socket, fd= for UDP sockets 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: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch fixes -netdev socket,fd=3D for UDP sockets Currently -netdev socket,fd=3D<...> results in qemu: error: specified mcastaddr "127.0.0.1" (0x7f000001) does not contain a multicast address qemu-system-x86_64: -netdev socket,id=3Dn1,fd=3D3: Device 'socket' could not be initialized To fix these we need to allow specifying multicast and fd arguments for the same netdev. With this the user can specify "-netdev fd=3D3,mcast=3D" Cc: Jason Wang Fixes: 3d830459b1eccdb61b75e2712fd364012ce5a115 Signed-off-by: Jens Freimann Reviewed-by: Michael S. Tsirkin --- net/socket.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/net/socket.c b/net/socket.c index f85ef7d61b..18af2ab5f3 100644 --- a/net/socket.c +++ b/net/socket.c @@ -320,11 +320,11 @@ static NetClientInfo net_dgram_socket_info =3D { static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, const char *model, const char *name, - int fd, int is_connected) + int fd, int is_connected, + const char *mcast) { struct sockaddr_in saddr; int newfd; - socklen_t saddr_len =3D sizeof(saddr); NetClientState *nc; NetSocketState *s; =20 @@ -333,8 +333,13 @@ static NetSocketState *net_socket_fd_init_dgram(NetCli= entState *peer, * by ONLY ONE process: we must "clone" this dgram socket --jjo */ =20 - if (is_connected) { - if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) =3D=3D= 0) { + if (is_connected && mcast !=3D NULL) { + if (parse_host_port(&saddr, mcast) < 0) { + fprintf(stderr, + "qemu: error: init_dgram: fd=3D%d failed parse_hos= t_port()\n", + fd); + goto err; + } /* must be bound */ if (saddr.sin_addr.s_addr =3D=3D 0) { fprintf(stderr, "qemu: error: init_dgram: fd=3D%d unbound,= " @@ -351,12 +356,6 @@ static NetSocketState *net_socket_fd_init_dgram(NetCli= entState *peer, dup2(newfd, fd); close(newfd); =20 - } else { - fprintf(stderr, - "qemu: error: init_dgram: fd=3D%d failed getsockname()= : %s\n", - fd, strerror(errno)); - goto err; - } } =20 nc =3D qemu_new_net_client(&net_dgram_socket_info, peer, model, name); @@ -432,7 +431,7 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, =20 static NetSocketState *net_socket_fd_init(NetClientState *peer, const char *model, const char *n= ame, - int fd, int is_connected) + int fd, int is_connected, const = char *mc) { int so_type =3D -1, optlen=3Dsizeof(so_type); =20 @@ -445,7 +444,7 @@ static NetSocketState *net_socket_fd_init(NetClientStat= e *peer, } switch(so_type) { case SOCK_DGRAM: - return net_socket_fd_init_dgram(peer, model, name, fd, is_connecte= d); + return net_socket_fd_init_dgram(peer, model, name, fd, is_connecte= d, mc); case SOCK_STREAM: return net_socket_fd_init_stream(peer, model, name, fd, is_connect= ed); default: @@ -567,7 +566,7 @@ static int net_socket_connect_init(NetClientState *peer, break; } } - s =3D net_socket_fd_init(peer, model, name, fd, connected); + s =3D net_socket_fd_init(peer, model, name, fd, connected, NULL); if (!s) return -1; snprintf(s->nc.info_str, sizeof(s->nc.info_str), @@ -602,7 +601,7 @@ static int net_socket_mcast_init(NetClientState *peer, if (fd < 0) return -1; =20 - s =3D net_socket_fd_init(peer, model, name, fd, 0); + s =3D net_socket_fd_init(peer, model, name, fd, 0, NULL); if (!s) return -1; =20 @@ -652,7 +651,7 @@ static int net_socket_udp_init(NetClientState *peer, } qemu_set_nonblock(fd); =20 - s =3D net_socket_fd_init(peer, model, name, fd, 0); + s =3D net_socket_fd_init(peer, model, name, fd, 0, NULL); if (!s) { return -1; } @@ -675,9 +674,9 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, assert(netdev->type =3D=3D NET_CLIENT_DRIVER_SOCKET); sock =3D &netdev->u.socket; =20 - if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mc= ast + - sock->has_udp !=3D 1) { - error_report("exactly one of fd=3D, listen=3D, connect=3D, mcast= =3D or udp=3D" + if (sock->has_listen + sock->has_connect + sock->has_mcast + + sock->has_udp > 1) { + error_report("exactly one of listen=3D, connect=3D, mcast=3D or ud= p=3D" " is required"); return -1; } @@ -696,7 +695,7 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, return -1; } qemu_set_nonblock(fd); - if (!net_socket_fd_init(peer, "socket", name, fd, 1)) { + if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast))= { return -1; } return 0; --=20 2.13.3 From nobody Thu May 2 13:26:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502225581169546.3717288446619; Tue, 8 Aug 2017 13:53:01 -0700 (PDT) Received: from localhost ([::1]:44483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBUp-0001ya-VI for importer@patchew.org; Tue, 08 Aug 2017 16:52:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBQd-0006xw-8x for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfBQc-0007RF-7K for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfBQc-0007QK-10 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3C03A723 for ; Tue, 8 Aug 2017 20:39:42 +0000 (UTC) Received: from localhost (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0E715E261; Tue, 8 Aug 2017 20:39:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D3C03A723 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 22:38:58 +0200 Message-Id: <20170808203900.7661-4-jfreimann@redhat.com> In-Reply-To: <20170808203900.7661-1-jfreimann@redhat.com> References: <20170808203900.7661-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Aug 2017 20:39:43 +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] [PATCH v2 3/5] libvhost-user: quit when no more data received 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: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jens Freimann End processing of messages when VHOST_USER_NONE is received. Without this we run into a vubr_panic() call and get "PANIC: Unhandled request: 0" Signed-off-by: Jens Freimann --- contrib/libvhost-user/libvhost-user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 9efb9dac0e..35fa0c5e56 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -161,7 +161,7 @@ vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *= vmsg) rc =3D recvmsg(conn_fd, &msg, 0); } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); =20 - if (rc <=3D 0) { + if (rc < 0) { vu_panic(dev, "Error while recvmsg: %s", strerror(errno)); return false; } @@ -806,6 +806,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg) return vu_get_queue_num_exec(dev, vmsg); case VHOST_USER_SET_VRING_ENABLE: return vu_set_vring_enable_exec(dev, vmsg); + case VHOST_USER_NONE: + break; default: vmsg_close_fds(vmsg); vu_panic(dev, "Unhandled request: %d", vmsg->request); --=20 2.13.3 From nobody Thu May 2 13:26:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502225670706873.282468016935; Tue, 8 Aug 2017 13:54:30 -0700 (PDT) Received: from localhost ([::1]:44486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBWG-000349-Rr for importer@patchew.org; Tue, 08 Aug 2017 16:54:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBRf-0007rP-9i for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:49:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfBRe-0007zu-7g for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:49:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfBRe-0007zC-1l for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0363CC058EBF for ; Tue, 8 Aug 2017 20:39:45 +0000 (UTC) Received: from localhost (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D5B25D739; Tue, 8 Aug 2017 20:39:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0363CC058EBF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 22:38:59 +0200 Message-Id: <20170808203900.7661-5-jfreimann@redhat.com> In-Reply-To: <20170808203900.7661-1-jfreimann@redhat.com> References: <20170808203900.7661-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 08 Aug 2017 20:39:45 +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] [PATCH v2 4/5] libqtest: always set up signal handler for SIGABRT 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: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently abort handlers only work for the first test function in a testcase, because the list of abort handlers is not properly cleared when qtest_quit() is called. qtest_quit() only deletes the kill_qemu_hook but doesn't completely clear the abrt_hooks list. The effect is that abrt_hooks.is_setup is never set to false and in a following test the abrt_hooks list is not initialized and setup_sigabrt_handler() is not called. One way to solve this is to clear the list in qtest_quit(), but that means only asserts between qtest_start and qtest_quit will be catched by the abort handler. We can make abort handlers work in all cases if we always setup the signal handler for SIGABRT in qtest_init. Signed-off-by: Jens Freimann --- tests/libqtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 4a5492a603..b9a1f180e1 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -140,8 +140,8 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *d= ata) /* Only install SIGABRT handler once */ if (!abrt_hooks.is_setup) { g_hook_list_init(&abrt_hooks, sizeof(GHook)); - setup_sigabrt_handler(); } + setup_sigabrt_handler(); =20 hook =3D g_hook_alloc(&abrt_hooks); hook->func =3D fn; --=20 2.13.3 From nobody Thu May 2 13:26:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502225477109411.19138308733295; Tue, 8 Aug 2017 13:51:17 -0700 (PDT) Received: from localhost ([::1]:44478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBT9-0000ke-RP for importer@patchew.org; Tue, 08 Aug 2017 16:51:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfBQd-0006xn-5B for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfBQY-0007Nn-6D for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44978) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfBQX-0007Ms-TJ for qemu-devel@nongnu.org; Tue, 08 Aug 2017 16:48:34 -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 51E33C047B7E for ; Tue, 8 Aug 2017 20:39:58 +0000 (UTC) Received: from localhost (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B11AF503CA; Tue, 8 Aug 2017 20:39:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51E33C047B7E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 22:39:00 +0200 Message-Id: <20170808203900.7661-6-jfreimann@redhat.com> In-Reply-To: <20170808203900.7661-1-jfreimann@redhat.com> References: <20170808203900.7661-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.31]); Tue, 08 Aug 2017 20:39:58 +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] [PATCH v2 5/5] 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: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 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 | 115 +++++++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 117 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index eb4895f94a..4004b10cc3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -705,7 +705,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 @@ -834,6 +835,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 cf6e225330..cf6f435bbe 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -5,7 +5,8 @@ * * Authors: * Michael S. Tsirkin , - * Victor Kaplansky + * Victor Kaplansky , + * 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. @@ -13,14 +14,125 @@ =20 #include "qemu/osdep.h" #include +#include #include "qemu-common.h" #include "libqtest.h" #include "boot-sector.h" +#include =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_FROM_ENVP | + 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; @@ -65,6 +177,7 @@ int main(int argc, char *argv[]) if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { qtest_add_func("pxe/e1000", test_pxe_e1000); qtest_add_func("pxe/virtio", test_pxe_virtio_pci); + qtest_add_func("pxe/vhost-user", test_pxe_vhost_user); } else if (strcmp(arch, "ppc64") =3D=3D 0) { qtest_add_func("pxe/virtio", test_pxe_virtio_pci); qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan); --=20 2.13.3