From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821283; cv=none; d=zohomail.com; s=zohoarc; b=LU0Z+aJ86bVBQFbxFH0t5A3ifA7vLsRekzAp+qYMHCTPmvqGfOp7XhylJqIKYgLvBCVI2uZjdm0Ntue+ix7n46kDoV1UrJZxJydvEA4N81kYSEPT1+KDypjhW1xHhTqBus7e5EM3WLvR3ClcsnEfJCpZeqtuVPKAAVbZiPdy8IQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821283; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=w85ALhbZJIWqBZs4TodH+Ktr0CFpkx0wPRvmrKgX/54=; b=TPG1l6T3Y62B/z8lL7eBpPunY2oPocRncpUebK4Y2f1JA7blN2YaNy7b+feiLa3bOUY3o2kw3mtIRAucDviZisQLX+83CYxoxQIWTapiPZR8y81/8L3gBLitDhYTEgo6ljKn2nbqSdwO6K4+GBfywuCkJQE4rfhb4fyCrPlv0Eo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821283810881.812092057013; Wed, 15 Jul 2020 06:54:43 -0700 (PDT) Received: from localhost ([::1]:58138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhru-0004CY-DJ for importer@patchew.org; Wed, 15 Jul 2020 09:54:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhqr-0002nx-T1 for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45682 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhqp-0005Ju-IF for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-mN0sqVA3PWavkmrTMDebzA-1; Wed, 15 Jul 2020 09:53:32 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81650E91C; Wed, 15 Jul 2020 13:53:31 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B1FB5C57D; Wed, 15 Jul 2020 13:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=w85ALhbZJIWqBZs4TodH+Ktr0CFpkx0wPRvmrKgX/54=; b=Av7d6JyTL7B+SSBqGftDVotZ9Rs6RPzvuoPX1zio8V1LbrCG+EtvpCX/g/lMmsVE4ss8eH oQkDTVDnsK41MtZadgUxeNjie7JJ6q3pTKdAWQ8qLuZNaCQXyc0wOoDjS3hpffpN+t6Z+H dlNMJmWrW+ktundD3Ew3z6lRpr911oU= X-MC-Unique: mN0sqVA3PWavkmrTMDebzA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 1/7] virtio-net: fix removal of failover device Date: Wed, 15 Jul 2020 21:53:15 +0800 Message-Id: <1594821201-3708-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 05:07:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Juan Quintela If you have a networking device and its virtio failover device, and you remove them in this order: - virtio device - the real device You get qemu crash. See bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=3D1820120 Bug exist on qemu 4.2 and 5.0. But in 5.0 don't shows because commit 77b06bba62034a87cc61a9c8de1309ae3e527d97 somehow papers over it. CC: Jason Wang CC: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Acked-by: Laurent Vivier Signed-off-by: Juan Quintela Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 10cc958..4895af1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3416,6 +3416,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) g_free(n->vlans); =20 if (n->failover) { + device_listener_unregister(&n->primary_listener); g_free(n->primary_device_id); g_free(n->standby_id); qobject_unref(n->primary_device_dict); --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821371; cv=none; d=zohomail.com; s=zohoarc; b=KYsjkmqD7j/6pKSTT5zdTqJP3HW0RwX5gq8GUmf+RNtXUSkITtJGc7OzI4Sfb7FqlnNSxs3Sqfj8isLkM7Fnlg5abK53Tt+TRxRqf/u4h9Ca7eibT84S92P3NLueVh+QeK5yCk6Z+N+kQxXbEFmsKpagMCXxTc8XRHyrS+CKy5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821371; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RNCgE96fDYOzx5n6sI6hbRMfVSc2P45tRV6eEOJvkhE=; b=EQSgkxBionQocNE4j3bSBb0JkgPwY3vb1UXkhZYPqDTBU4HHKl06dnufK9EY/a8+KdMpAdj2VyJCgFgfYRi1Fe/Cyhi12KstRh2lCLn5T+3VR4Gf7ecUJcT+s3ie5mOAlU1BPJUi15YHujDIXJS3RjXjIpwaNAvrCjpPI8KfZak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821371455857.7161897001456; Wed, 15 Jul 2020 06:56:11 -0700 (PDT) Received: from localhost ([::1]:37982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhtK-0007Z0-6A for importer@patchew.org; Wed, 15 Jul 2020 09:56:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhqt-0002pV-AJ for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46500 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhqr-0005KF-Ni for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-sKqTKsxuPiKcrNTIxeA6tw-1; Wed, 15 Jul 2020 09:53:34 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8A4518C63D2; Wed, 15 Jul 2020 13:53:33 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FE855C57D; Wed, 15 Jul 2020 13:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=RNCgE96fDYOzx5n6sI6hbRMfVSc2P45tRV6eEOJvkhE=; b=dR+7hIngeDyJ6Ob8K9+i269ZdFeOejO7GWuYmpWy9AmJrNfsVoPE2B9MKbayyAE178j4Lc sB93jkmrto78zKssHGBbWz5oe/IwurLifmB9qTKejQ5u2IdLIsSS70SmmA5TFq+x1IyFc9 /zLfl8vmUCy7/jUqjy/mYRwRq+k5SfQ= X-MC-Unique: sKqTKsxuPiKcrNTIxeA6tw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 2/7] hw/net: Added CSO for IPv6 Date: Wed, 15 Jul 2020 21:53:16 +0800 Message-Id: <1594821201-3708-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 02:37:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Andrew , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Andrew Added fix for checksum offload for IPv6 if a backend doesn't have a virtual header. This patch is a part of IPv6 fragmentation. Signed-off-by: Andrew Melnychenko Signed-off-by: Jason Wang --- hw/net/net_tx_pkt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 162f802..331c73c 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -468,8 +468,8 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) /* num of iovec without vhdr */ uint32_t iov_len =3D pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1; uint16_t csl; - struct ip_header *iphdr; size_t csum_offset =3D pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_o= ffset; + uint16_t l3_proto =3D eth_get_l3_proto(iov, 1, iov->iov_len); =20 /* Put zero to checksum field */ iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); @@ -477,9 +477,18 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) /* Calculate L4 TCP/UDP checksum */ csl =3D pkt->payload_len; =20 + csum_cntr =3D 0; + cso =3D 0; /* add pseudo header to csum */ - iphdr =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base; - csum_cntr =3D eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso); + if (l3_proto =3D=3D ETH_P_IP) { + csum_cntr =3D eth_calc_ip4_pseudo_hdr_csum( + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base, + csl, &cso); + } else if (l3_proto =3D=3D ETH_P_IPV6) { + csum_cntr =3D eth_calc_ip6_pseudo_hdr_csum( + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base, + csl, pkt->l4proto, &cso); + } =20 /* data checksum */ csum_cntr +=3D --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821290; cv=none; d=zohomail.com; s=zohoarc; b=D7YqeNyixulzg/JRYMhX9FgVDcCqepxfgJEG7ABKxuJrBrA7StW9JDWQNHhqL89ygvv1eXXTzYBMj2VRFi8rcKkFqXqOz5bIwttEhy59DPburH6t4DnY0wlCjLGntXFmB9HSADExhnG7e3xlCI1qMwlw5w80wjqJZwbT5yUqwo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821290; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=pycJaOGH+mrtlDuxINiTiyF5nVH/YR0uKzGwEx3SrCg=; b=f4JESr5cltRrOS+/8OiQeCd4bCbSFJFhP7Z/n/lCvHY+FYTOktPuKSvy3210ijjeOhx/uEMWBXC/GKar8QCikJpt6g5nmRIKApEQusf0z1Y3vEmjcA0wD+It8JIPS64qyxRwe+EbZMTlUjt5TOE2xS1yUzOq63u0aRXPtlxjxbg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821290646489.8928999254093; Wed, 15 Jul 2020 06:54:50 -0700 (PDT) Received: from localhost ([::1]:58786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhs1-0004SV-Ak for importer@patchew.org; Wed, 15 Jul 2020 09:54:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhqx-0002wt-Ew for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48705 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhqv-0005LB-Io for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-tGlrKLi_OzeBdZUfSO2KwA-1; Wed, 15 Jul 2020 09:53:38 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D828518C63C0; Wed, 15 Jul 2020 13:53:37 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 558B35C57D; Wed, 15 Jul 2020 13:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=pycJaOGH+mrtlDuxINiTiyF5nVH/YR0uKzGwEx3SrCg=; b=CaelTgtk56ZCoJRZXKcLzG6qxUOXmgEE1CSa6ygv264If2jnsH/vBmSGSwH67IJqj8oQ3v RQWH6IG79cG73IFvGpI/5vKNPnVbCdncA3iNl1r1XsRGQF6NE6bP794Tid+mE7fEn2qlDk Kn/bFNFW3LiPUIk3YC7k1IW+2LlVPjE= X-MC-Unique: tGlrKLi_OzeBdZUfSO2KwA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 3/7] net/colo-compare.c: Expose compare "max_queue_size" to users Date: Wed, 15 Jul 2020 21:53:17 +0800 Message-Id: <1594821201-3708-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 05:07:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen This patch allow users to set the "max_queue_size" according to their environment. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 43 ++++++++++++++++++++++++++++++++++++++++++- qemu-options.hx | 5 +++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 398b754..cc15f23 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -59,6 +59,7 @@ static bool colo_compare_active; static QemuMutex event_mtx; static QemuCond event_complete_cond; static int event_unhandled_count; +static uint32_t max_queue_size; =20 /* * + CompareState ++ @@ -222,7 +223,7 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max= _ack) */ static int colo_insert_packet(GQueue *queue, Packet *pkt, uint32_t *max_ac= k) { - if (g_queue_get_length(queue) <=3D MAX_QUEUE_SIZE) { + if (g_queue_get_length(queue) <=3D max_queue_size) { if (pkt->ip->ip_p =3D=3D IPPROTO_TCP) { fill_pkt_tcp_info(pkt, max_ack); g_queue_insert_sorted(queue, @@ -1134,6 +1135,37 @@ static void compare_set_expired_scan_cycle(Object *o= bj, Visitor *v, s->expired_scan_cycle =3D value; } =20 +static void get_max_queue_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + uint32_t value =3D max_queue_size; + + visit_type_uint32(v, name, &value, errp); +} + +static void set_max_queue_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Error *local_err =3D NULL; + uint32_t value; + + visit_type_uint32(v, name, &value, &local_err); + if (local_err) { + goto out; + } + if (!value) { + error_setg(&local_err, "Property '%s.%s' requires a positive value= ", + object_get_typename(obj), name); + goto out; + } + max_queue_size =3D value; + +out: + error_propagate(errp, local_err); +} + static void compare_pri_rs_finalize(SocketReadState *pri_rs) { CompareState *s =3D container_of(pri_rs, CompareState, pri_rs); @@ -1251,6 +1283,11 @@ static void colo_compare_complete(UserCreatable *uc,= Error **errp) s->expired_scan_cycle =3D REGULAR_PACKET_CHECK_MS; } =20 + if (!max_queue_size) { + /* Set default queue size to 1024 */ + max_queue_size =3D MAX_QUEUE_SIZE; + } + if (find_and_check_chardev(&chr, s->pri_indev, errp) || !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) { return; @@ -1370,6 +1407,10 @@ static void colo_compare_init(Object *obj) compare_get_expired_scan_cycle, compare_set_expired_scan_cycle, NULL, NULL); =20 + object_property_add(obj, "max_queue_size", "uint32", + get_max_queue_size, + set_max_queue_size, NULL, NULL); + s->vnet_hdr =3D false; object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr, compare_set_vnet_hdr); diff --git a/qemu-options.hx b/qemu-options.hx index d2c1e95..310885c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4695,7 +4695,7 @@ SRST stored. The file format is libpcap, so it can be analyzed with tools such as tcpdump or Wireshark. =20 - ``-object colo-compare,id=3Did,primary_in=3Dchardevid,secondary_in=3Dc= hardevid,outdev=3Dchardevid,iothread=3Did[,vnet_hdr_support][,notify_dev=3D= id][,compare_timeout=3D@var{ms}][,expired_scan_cycle=3D@var{ms}`` + ``-object colo-compare,id=3Did,primary_in=3Dchardevid,secondary_in=3Dc= hardevid,outdev=3Dchardevid,iothread=3Did[,vnet_hdr_support][,notify_dev=3D= id][,compare_timeout=3D@var{ms}][,expired_scan_cycle=3D@var{ms}][,max_queue= _size=3D@var{size}]`` Colo-compare gets packet from primary\_inchardevid and secondary\_inchardevid, than compare primary packet with secondary packet. If the packets are same, we will output @@ -4707,7 +4707,8 @@ SRST vnet\_hdr\_len. Then compare\_timeout=3D@var{ms} determines the maximum delay colo-compare wait for the packet. The expired\_scan\_cycle=3D@var{ms} to set the period of scanning - expired primary node network packets. + expired primary node network packets. The max\_queue\_size=3D@var{= size} + is to set the max compare queue size depend on user environment. If you want to use Xen COLO, will need the notify\_dev to notify Xen colo-frame to do checkpoint. =20 --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821378; cv=none; d=zohomail.com; s=zohoarc; b=VVpCW1D2ZYba6C07ZOU4Zzo21Cbz/2v2pVyt5EYj+oV0NEUWzGZ1RwayOHta5ffqMP9cDgbdJoJn2xgeah186bTbdtpHf5GWJLAbYaG9H8BDzApYlBkstzTAX8EDev/lEw3vMldsg+Wpzn60/xBu9L3jsiigImWbWd55jDJIyRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821378; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Lq9mQPyQwbSn+iqpXBcaFyj2QHswrHoP5SMMuUcrpeY=; b=oLupHe+1pkzQtzBTyB11QSAdnsInQz35v4t06OPh+rplLna1uzo3Nr9fkGPcveV8z5s2on/ovASBsE5Xo3WvMlehKDLCCYR8tGHt4j0RJctPjjqS9T4aV7Q6UROwBMeESzTqy303p6RsTYW1IzVc5EPgqDrUJgr9GsFqPmFJBqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821378426390.7296381666803; Wed, 15 Jul 2020 06:56:18 -0700 (PDT) Received: from localhost ([::1]:38502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhtR-0007mA-8B for importer@patchew.org; Wed, 15 Jul 2020 09:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhr2-000380-Lf for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33687 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhr1-0005MN-0K for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-yLVPSY96OGyzBOuIFvmulw-1; Wed, 15 Jul 2020 09:53:42 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DCF880BCAD; Wed, 15 Jul 2020 13:53:41 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63C2E5C57D; Wed, 15 Jul 2020 13:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Lq9mQPyQwbSn+iqpXBcaFyj2QHswrHoP5SMMuUcrpeY=; b=JylMIGuoIMYzbdfUx01QKCFkdV/bs5jtMQsXeniEuFQn8ZWmiCu5Ay4XZLMY0IanoLCAgs JmR7DSq+eo4rm/spP6gSN8wBkLmmZh37UUQhY0Df9bsBnYVpguHR2yOgI3Wfc5B+q1mkoM nVf08s/g3mvzOLgSuVcQ1QYPWWBmxxA= X-MC-Unique: yLVPSY96OGyzBOuIFvmulw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 4/7] qemu-options.hx: Clean up and fix typo for colo-compare Date: Wed, 15 Jul 2020 21:53:18 +0800 Message-Id: <1594821201-3708-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 02:37:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Fix some typo and optimized some descriptions. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- qemu-options.hx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 310885c..65147ad 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4696,24 +4696,24 @@ SRST tools such as tcpdump or Wireshark. =20 ``-object colo-compare,id=3Did,primary_in=3Dchardevid,secondary_in=3Dc= hardevid,outdev=3Dchardevid,iothread=3Did[,vnet_hdr_support][,notify_dev=3D= id][,compare_timeout=3D@var{ms}][,expired_scan_cycle=3D@var{ms}][,max_queue= _size=3D@var{size}]`` - Colo-compare gets packet from primary\_inchardevid and - secondary\_inchardevid, than compare primary packet with - secondary packet. If the packets are same, we will output - primary packet to outdevchardevid, else we will notify - colo-frame do checkpoint and send primary packet to - outdevchardevid. In order to improve efficiency, we need to put - the task of comparison in another thread. If it has the - vnet\_hdr\_support flag, colo compare will send/recv packet with - vnet\_hdr\_len. Then compare\_timeout=3D@var{ms} determines the - maximum delay colo-compare wait for the packet. - The expired\_scan\_cycle=3D@var{ms} to set the period of scanning - expired primary node network packets. The max\_queue\_size=3D@var{= size} - is to set the max compare queue size depend on user environment. - If you want to use Xen COLO, will need the notify\_dev to + Colo-compare gets packet from primary\_in chardevid and + secondary\_in, then compare whether the payload of primary packet + and secondary packet are the same. If same, it will output + primary packet to out\_dev, else it will notify COLO-framework to = do + checkpoint and send primary packet to out\_dev. In order to + improve efficiency, we need to put the task of comparison in + another iothread. If it has the vnet\_hdr\_support flag, + colo compare will send/recv packet with vnet\_hdr\_len. + The compare\_timeout=3D@var{ms} determines the maximum time of the + colo-compare hold the packet. The expired\_scan\_cycle=3D@var{ms} + is to set the period of scanning expired primary node network pack= ets. + The max\_queue\_size=3D@var{size} is to set the max compare queue + size depend on user environment. + If user want to use Xen COLO, need to add the notify\_dev to notify Xen colo-frame to do checkpoint. =20 - we must use it with the help of filter-mirror and - filter-redirector. + COLO-compare must be used with the help of filter-mirror, + filter-redirector and filter-rewriter. =20 :: =20 --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821368; cv=none; d=zohomail.com; s=zohoarc; b=E5cb5h4Lm2Dii3fvhuHc5k2hvvHWa7icp02FWZzCyofo+GY0uHuHGhxqIUpTo+WsnZaVLXQet990fqb1GPod8eAN1uPphastLN0UWga3KMncozzIga84bZ9ZAjp/jt4aCEW2Latys3OnKDmvft9K6ppkt67rhG2gOmc38oKU46s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821368; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rcS9JhqiNRxIxolYBZdtW2tdwI0vimd9/hYJ9NxOy5Y=; b=HMhluY7OlPGTbnf1HRRgrvRpjfUr5pF4lNt+enaxNWRo7elhSBa98nzsupYLiRyInggYCCRC636maB49QgHGCL6engZCagVQCM9hV4wgf+kq9DDDcmT0dT1Fri4H58qwZhWfRL8WvMWuzP8rXKHE7CAcLLCQ5iu13KagnEmX6BQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15948213689361005.1953354163101; Wed, 15 Jul 2020 06:56:08 -0700 (PDT) Received: from localhost ([::1]:37782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhtH-0007U3-GQ for importer@patchew.org; Wed, 15 Jul 2020 09:56:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhr3-00039X-AZ for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39261 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhr0-0005ML-V0 for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-SvgJtXYuMN6ct6jxnwb70w-1; Wed, 15 Jul 2020 09:53:44 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42878E91A; Wed, 15 Jul 2020 13:53:43 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E36D1755E; Wed, 15 Jul 2020 13:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rcS9JhqiNRxIxolYBZdtW2tdwI0vimd9/hYJ9NxOy5Y=; b=XVKoCYeYOuw8yZpdyM8bGXRcd7FFR9FbShiSGkO6qmTuvHlJDeseWs3OwPfrt32rx43MXJ bYDURDvT5XQcWZJ2Yszog8OgZoqR53zXec3Yw+iRpztLezE4Xsjf1uYwCHnx7HlhMrZh3J hoTSCviEoQC59M0RH1g7atQR9AkJS9U= X-MC-Unique: SvgJtXYuMN6ct6jxnwb70w-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 5/7] net: check if the file descriptor is valid before using it Date: Wed, 15 Jul 2020 21:53:19 +0800 Message-Id: <1594821201-3708-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 05:07:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Laurent Vivier qemu_set_nonblock() checks that the file descriptor can be used and, if not, crashes QEMU. An assert() is used for that. The use of assert() is used to detect programming error and the coredump will allow to debug the problem. But in the case of the tap device, this assert() can be triggered by a misconfiguration by the user. At startup, it's not a real problem, but it can also happen during the hot-plug of a new device, and here it's a problem because we can crash a perfectly healthy system. For instance: # ip link add link virbr0 name macvtap0 type macvtap mode bridge # ip link set macvtap0 up # TAP=3D/dev/tap$(ip -o link show macvtap0 | cut -d: -f1) # qemu-system-x86_64 -machine q35 -device pcie-root-port,id=3Dpcie-root-po= rt-0 -monitor stdio 9<> $TAP (qemu) netdev_add type=3Dtap,id=3Dhostnet0,vhost=3Don,fd=3D9 (qemu) device_add driver=3Dvirtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,bus= =3Dpcie-root-port-0 (qemu) device_del net0 (qemu) netdev_del hostnet0 (qemu) netdev_add type=3Dtap,id=3Dhostnet1,vhost=3Don,fd=3D9 qemu-system-x86_64: .../util/oslib-posix.c:247: qemu_set_nonblock: Asserti= on `f !=3D -1' failed. Aborted (core dumped) To avoid that, add a function, qemu_try_set_nonblock(), that allows to repo= rt the problem without crashing. In the same way, we also update the function for vhostfd in net_init_tap_on= e() and for fd in net_init_socket() (both descriptors are provided by the user and = can be wrong). Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- include/qemu/sockets.h | 1 + net/socket.c | 9 ++++++-- net/tap.c | 25 ++++++++++++++++++---- util/oslib-posix.c | 26 ++++++++++++++++------- util/oslib-win32.c | 57 ++++++++++++++++++++++++++++------------------= ---- 5 files changed, 79 insertions(+), 39 deletions(-) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 57cd049..7d1f813 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -18,6 +18,7 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *= addrlen); int socket_set_cork(int fd, int v); int socket_set_nodelay(int fd); void qemu_set_block(int fd); +int qemu_try_set_nonblock(int fd); void qemu_set_nonblock(int fd); int socket_set_fast_reuse(int fd); =20 diff --git a/net/socket.c b/net/socket.c index c923540..2d21fdd 100644 --- a/net/socket.c +++ b/net/socket.c @@ -725,13 +725,18 @@ int net_init_socket(const Netdev *netdev, const char = *name, } =20 if (sock->has_fd) { - int fd; + int fd, ret; =20 fd =3D monitor_fd_param(cur_mon, sock->fd, errp); if (fd =3D=3D -1) { return -1; } - qemu_set_nonblock(fd); + ret =3D qemu_try_set_nonblock(fd); + if (ret < 0) { + error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d= ", + name, fd); + return -1; + } if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast, errp)) { return -1; diff --git a/net/tap.c b/net/tap.c index f9dcc2e..32e4813 100644 --- a/net/tap.c +++ b/net/tap.c @@ -690,6 +690,8 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, } =20 if (vhostfdname) { + int ret; + vhostfd =3D monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd =3D=3D -1) { if (tap->has_vhostforce && tap->vhostforce) { @@ -699,7 +701,12 @@ static void net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, } return; } - qemu_set_nonblock(vhostfd); + ret =3D qemu_try_set_nonblock(vhostfd); + if (ret < 0) { + error_setg_errno(errp, -ret, "%s: Can't use file descripto= r %d", + name, fd); + return; + } } else { vhostfd =3D open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { @@ -767,6 +774,7 @@ int net_init_tap(const Netdev *netdev, const char *name, Error *err =3D NULL; const char *vhostfdname; char ifname[128]; + int ret =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -795,7 +803,12 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - qemu_set_nonblock(fd); + ret =3D qemu_try_set_nonblock(fd); + if (ret < 0) { + error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d= ", + name, fd); + return -1; + } =20 vnet_hdr =3D tap_probe_vnet_hdr(fd); =20 @@ -810,7 +823,6 @@ int net_init_tap(const Netdev *netdev, const char *name, char **fds; char **vhost_fds; int nfds =3D 0, nvhosts =3D 0; - int ret =3D 0; =20 if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_helper || tap->has_queues || @@ -842,7 +854,12 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, goto free_fail; } =20 - qemu_set_nonblock(fd); + ret =3D qemu_try_set_nonblock(fd); + if (ret < 0) { + error_setg_errno(errp, -ret, "%s: Can't use file descripto= r %d", + name, fd); + goto free_fail; + } =20 if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fd); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e60aea8..36bf859 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -260,25 +260,35 @@ void qemu_set_block(int fd) assert(f !=3D -1); } =20 -void qemu_set_nonblock(int fd) +int qemu_try_set_nonblock(int fd) { int f; f =3D fcntl(fd, F_GETFL); - assert(f !=3D -1); - f =3D fcntl(fd, F_SETFL, f | O_NONBLOCK); -#ifdef __OpenBSD__ if (f =3D=3D -1) { + return -errno; + } + if (fcntl(fd, F_SETFL, f | O_NONBLOCK) =3D=3D -1) { +#ifdef __OpenBSD__ /* * Previous to OpenBSD 6.3, fcntl(F_SETFL) is not permitted on * memory devices and sets errno to ENODEV. * It's OK if we fail to set O_NONBLOCK on devices like /dev/null, * because they will never block anyway. */ - assert(errno =3D=3D ENODEV); - } -#else - assert(f !=3D -1); + if (errno =3D=3D ENODEV) { + return 0; + } #endif + return -errno; + } + return 0; +} + +void qemu_set_nonblock(int fd) +{ + int f; + f =3D qemu_try_set_nonblock(fd); + assert(f =3D=3D 0); } =20 int socket_set_fast_reuse(int fd) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 3b49d27..7eedbe5 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -132,31 +132,6 @@ struct tm *localtime_r(const time_t *timep, struct tm = *result) } #endif /* CONFIG_LOCALTIME_R */ =20 -void qemu_set_block(int fd) -{ - unsigned long opt =3D 0; - WSAEventSelect(fd, NULL, 0); - ioctlsocket(fd, FIONBIO, &opt); -} - -void qemu_set_nonblock(int fd) -{ - unsigned long opt =3D 1; - ioctlsocket(fd, FIONBIO, &opt); - qemu_fd_register(fd); -} - -int socket_set_fast_reuse(int fd) -{ - /* Enabling the reuse of an endpoint that was used by a socket still in - * TIME_WAIT state is usually performed by setting SO_REUSEADDR. On Wi= ndows - * fast reuse is the default and SO_REUSEADDR does strange things. So = we - * don't have to do anything here. More info can be found at: - * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.as= px */ - return 0; -} - - static int socket_error(void) { switch (WSAGetLastError()) { @@ -233,6 +208,38 @@ static int socket_error(void) } } =20 +void qemu_set_block(int fd) +{ + unsigned long opt =3D 0; + WSAEventSelect(fd, NULL, 0); + ioctlsocket(fd, FIONBIO, &opt); +} + +int qemu_try_set_nonblock(int fd) +{ + unsigned long opt =3D 1; + if (ioctlsocket(fd, FIONBIO, &opt) !=3D NO_ERROR) { + return -socket_error(); + } + qemu_fd_register(fd); + return 0; +} + +void qemu_set_nonblock(int fd) +{ + (void)qemu_try_set_nonblock(fd); +} + +int socket_set_fast_reuse(int fd) +{ + /* Enabling the reuse of an endpoint that was used by a socket still in + * TIME_WAIT state is usually performed by setting SO_REUSEADDR. On Wi= ndows + * fast reuse is the default and SO_REUSEADDR does strange things. So = we + * don't have to do anything here. More info can be found at: + * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.as= px */ + return 0; +} + int inet_aton(const char *cp, struct in_addr *ia) { uint32_t addr =3D inet_addr(cp); --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821448; cv=none; d=zohomail.com; s=zohoarc; b=ThNtLk7NAfn6ASbTuiszTA/HCh2jAU9cUYaNo6voEAJ2RRR1okCpRC+zuvx7HoLww+bCYq1zCf9mC5Smu0e5Wy5/pg9BB/zh3nKfFT+ak3jZWP5i4pzovNMOytGKiCbkBlKWPduxAvl1KLj++XeCKVpSGww7EQTkx/MbojJd2Js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821448; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Ppe8HFaAkuBHGro/MdNGmoORxrsqNsi5jhVHWKTZR5Y=; b=L+/XE/vxULboCsRpgjmXorej7edmeFwpSoBFXuaFn1Hq1Tqf4MhQh+5IPrWcDv6V79xIwUxCIcqui6+ZrL6jfQz0P15SAw4qoUrXpo+1OPe0Ho9Al7bPdTIHs9LIJpynjCDkY0ha9KXzNi/98moJ3p1wA+VrxBwVhvYL4+EgP4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821448801156.33393991884157; Wed, 15 Jul 2020 06:57:28 -0700 (PDT) Received: from localhost ([::1]:43124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhuX-0001H5-Iy for importer@patchew.org; Wed, 15 Jul 2020 09:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhrD-0003Vk-6l for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:59 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46790 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhrB-0005Mr-9b for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:53:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-07HNpE0yOmGUqk0zfLcGZg-1; Wed, 15 Jul 2020 09:53:54 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83E76E91C; Wed, 15 Jul 2020 13:53:53 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2DC861477; Wed, 15 Jul 2020 13:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Ppe8HFaAkuBHGro/MdNGmoORxrsqNsi5jhVHWKTZR5Y=; b=h3brp/m+biMWvAxw7In6tCiYmy5K6mDUQ3yaO9XZDrEkCesOFAFnfiZrtMvM9NYJN3xhZo P760apgnWaYrLb0smFFlDVqqZugDaC+BPn7tga+OIJUKUurX+NAogLbFvvPuXyhWhSqhqF 3KpuR3zw+zDRtUU9XmK+1/+t94TMC/0= X-MC-Unique: 07HNpE0yOmGUqk0zfLcGZg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 6/7] net: detect errors from probing vnet hdr flag for TAP devices Date: Wed, 15 Jul 2020 21:53:20 +0800 Message-Id: <1594821201-3708-7-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 05:07:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Jason Wang , "Daniel P. Berrange" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" When QEMU sets up a tap based network device backend, it mostly ignores err= ors reported from various ioctl() calls it makes, assuming the TAP file descrip= tor is valid. This assumption can easily be violated when the user is passing i= n a pre-opened file descriptor. At best, the ioctls may fail with a -EBADF, but= if the user passes in a bogus FD number that happens to clash with a FD number= that QEMU has opened internally for another reason, a wide variety of errnos may result, as the TUNGETIFF ioctl number may map to a completely different com= mand on a different type of file. By ignoring all these errors, QEMU sets up a zombie network backend that wi= ll never pass any data. Even worse, when QEMU shuts down, or that network back= end is hot-removed, it will close this bogus file descriptor, which could belon= g to another QEMU device backend. There's no obvious guaranteed reliable way to detect that a FD genuinely is= a TAP device, as opposed to a UNIX socket, or pipe, or something else. Checki= ng the errno from probing vnet hdr flag though, does catch the big common case= s. ie calling TUNGETIFF will return EBADF for an invalid FD, and ENOTTY when F= D is a UNIX socket, or pipe which catches accidental collisions with FDs used for stdio, or monitor socket. Previously the example below where bogus fd 9 collides with the FD used for= the chardev saw: $ ./x86_64-softmmu/qemu-system-x86_64 -netdev tap,id=3Dhostnet0,fd=3D9 \ -chardev socket,id=3Dcharchannel0,path=3D/tmp/qga,server,nowait \ -monitor stdio -vnc :0 qemu-system-x86_64: -netdev tap,id=3Dhostnet0,fd=3D9: TUNGETIFF ioctl() fai= led: Inappropriate ioctl for device TUNSETOFFLOAD ioctl() failed: Bad address QEMU 2.9.1 monitor - type 'help' for more information (qemu) Warning: netdev hostnet0 has no peer which gives a running QEMU with a zombie network backend. With this change applied we get an error message and QEMU immediately exits before carrying on and making a bigger disaster: $ ./x86_64-softmmu/qemu-system-x86_64 -netdev tap,id=3Dhostnet0,fd=3D9 \ -chardev socket,id=3Dcharchannel0,path=3D/tmp/qga,server,nowait \ -monitor stdio -vnc :0 qemu-system-x86_64: -netdev tap,id=3Dhostnet0,vhost=3Don,fd=3D9: Unable to = query TUNGETIFF on FD 9: Inappropriate ioctl for device Reported-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrange Tested-by: Dr. David Alan Gilbert Message-id: 20171027085548.3472-1-berrange@redhat.com [lv: to simplify, don't check on EINVAL with TUNGETIFF as it exists since v= 2.6.27] Signed-off-by: Laurent Vivier Signed-off-by: Jason Wang --- net/tap-bsd.c | 2 +- net/tap-linux.c | 8 +++++--- net/tap-solaris.c | 2 +- net/tap-stub.c | 2 +- net/tap.c | 25 ++++++++++++++++++++----- net/tap_int.h | 2 +- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index a5c3707..77aaf67 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -211,7 +211,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap= , Error **errp) { } =20 -int tap_probe_vnet_hdr(int fd) +int tap_probe_vnet_hdr(int fd, Error **errp) { return 0; } diff --git a/net/tap-linux.c b/net/tap-linux.c index e0dd442..b0635e9 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -147,13 +147,15 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *t= ap, Error **errp) } } =20 -int tap_probe_vnet_hdr(int fd) +int tap_probe_vnet_hdr(int fd, Error **errp) { struct ifreq ifr; =20 if (ioctl(fd, TUNGETIFF, &ifr) !=3D 0) { - error_report("TUNGETIFF ioctl() failed: %s", strerror(errno)); - return 0; + /* TUNGETIFF is available since kernel v2.6.27 */ + error_setg_errno(errp, errno, + "Unable to query TUNGETIFF on FD %d", fd); + return -1; } =20 return ifr.ifr_flags & IFF_VNET_HDR; diff --git a/net/tap-solaris.c b/net/tap-solaris.c index d03165c..0475a58 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -207,7 +207,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap= , Error **errp) { } =20 -int tap_probe_vnet_hdr(int fd) +int tap_probe_vnet_hdr(int fd, Error **errp) { return 0; } diff --git a/net/tap-stub.c b/net/tap-stub.c index a9ab8f8..de525a2 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -37,7 +37,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, = Error **errp) { } =20 -int tap_probe_vnet_hdr(int fd) +int tap_probe_vnet_hdr(int fd, Error **errp) { return 0; } diff --git a/net/tap.c b/net/tap.c index 32e4813..14dc904 100644 --- a/net/tap.c +++ b/net/tap.c @@ -598,7 +598,11 @@ int net_init_bridge(const Netdev *netdev, const char *= name, } =20 qemu_set_nonblock(fd); - vnet_hdr =3D tap_probe_vnet_hdr(fd); + vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + if (vnet_hdr < 0) { + close(fd); + return -1; + } s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); =20 snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s,br=3D%s"= , helper, @@ -810,7 +814,11 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - vnet_hdr =3D tap_probe_vnet_hdr(fd); + vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + if (vnet_hdr < 0) { + close(fd); + return -1; + } =20 net_init_tap_one(tap, peer, "tap", name, NULL, script, downscript, @@ -862,8 +870,11 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, } =20 if (i =3D=3D 0) { - vnet_hdr =3D tap_probe_vnet_hdr(fd); - } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd)) { + vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + if (vnet_hdr < 0) { + goto free_fail; + } + } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd, NULL)) { error_setg(errp, "vnet_hdr not consistent across given tap fds"); ret =3D -1; @@ -908,7 +919,11 @@ free_fail: } =20 qemu_set_nonblock(fd); - vnet_hdr =3D tap_probe_vnet_hdr(fd); + vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + if (vnet_hdr < 0) { + close(fd); + return -1; + } =20 net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, diff --git a/net/tap_int.h b/net/tap_int.h index e3194b2..225a49e 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -34,7 +34,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen); =20 void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); -int tap_probe_vnet_hdr(int fd); +int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_vnet_hdr_len(int fd, int len); int tap_probe_has_ufo(int fd); void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int= ufo); --=20 2.5.0 From nobody Fri May 17 06:07:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594821311; cv=none; d=zohomail.com; s=zohoarc; b=Rdt5xkBZlDlotswFXRq0wycHy+WH/+dUoo14NWFc3N8u3YLrtuWpfvQLCWj1DIyjiVYKJz3ySR97ulfOctMsu+mfhlIq7YzJjqbsHDy7qBhm1s5wXWYHs1Zoipnd+e7MSTCx7HBBj8saSJQ9k//PjLavIF5YmDElNDi6KAoF+Xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594821311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UCpLC9mLtv8FHVzch1Ud6HoahLCd2y07h991imOgfAU=; b=SbTPBRawHwRyGs9qN8AuwPpLT5cqFiwU8+aatyZMYMk8qadrwfGCbh1flek8OngXkqmV5UAxAN2YNN18NTP5K/ZaIbK+6wRcBVFWyrcrPf9kjydpYne4zYTlHjEIZAM+2v25qqpLDK1E2emG8wuo+aDesUE/zUrWcHMy4wkprcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594821311686716.0096472364912; Wed, 15 Jul 2020 06:55:11 -0700 (PDT) Received: from localhost ([::1]:60954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvhsM-0005Lm-GH for importer@patchew.org; Wed, 15 Jul 2020 09:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvhrH-0003dz-6O for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:54:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48844 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jvhrF-0005NQ-K2 for qemu-devel@nongnu.org; Wed, 15 Jul 2020 09:54:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-5ts1U-zsPSq00_XbkwADkg-1; Wed, 15 Jul 2020 09:53:56 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B97528015F4; Wed, 15 Jul 2020 13:53:55 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FB315C57D; Wed, 15 Jul 2020 13:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594821241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UCpLC9mLtv8FHVzch1Ud6HoahLCd2y07h991imOgfAU=; b=cKUVbERdPyEl093jXbvLQcaxnSSpYoix8G+2LADLk2ifWCuKg7kTbqhvHK+Z1Jcr2IYaH8 HVlXingtQRnSVmP25Nnl83WNsbeh5i6cDZVfsMBXa4ywAsNLqOz/T9hkG2ih2ElGjrIfOE PCnVJ0fmGQSkosOs8599BAb1umjF1pM= X-MC-Unique: 5ts1U-zsPSq00_XbkwADkg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 7/7] ftgmac100: fix dblac write test Date: Wed, 15 Jul 2020 21:53:21 +0800 Message-Id: <1594821201-3708-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1594821201-3708-1-git-send-email-jasowang@redhat.com> References: <1594821201-3708-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=jasowang@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/15 02:37:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , erik-smit , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: erik-smit The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes. Signed-off-by: erik-smit Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Jason Wang --- hw/net/ftgmac100.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 043ba61..5f4b26f 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -810,16 +810,18 @@ static void ftgmac100_write(void *opaque, hwaddr addr, s->phydata =3D value & 0xffff; break; case FTGMAC100_DBLAC: /* DMA Burst Length and Arbitration Control */ - if (FTGMAC100_DBLAC_TXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) { + if (FTGMAC100_DBLAC_TXDES_SIZE(value) < sizeof(FTGMAC100Desc)) { qemu_log_mask(LOG_GUEST_ERROR, - "%s: transmit descriptor too small : %d bytes\n", - __func__, FTGMAC100_DBLAC_TXDES_SIZE(s->dblac)); + "%s: transmit descriptor too small: %" PRIx64 + " bytes\n", __func__, + FTGMAC100_DBLAC_TXDES_SIZE(value)); break; } - if (FTGMAC100_DBLAC_RXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) { + if (FTGMAC100_DBLAC_RXDES_SIZE(value) < sizeof(FTGMAC100Desc)) { qemu_log_mask(LOG_GUEST_ERROR, - "%s: receive descriptor too small : %d bytes\n", - __func__, FTGMAC100_DBLAC_RXDES_SIZE(s->dblac)); + "%s: receive descriptor too small : %" PRIx64 + " bytes\n", __func__, + FTGMAC100_DBLAC_RXDES_SIZE(value)); break; } s->dblac =3D value; --=20 2.5.0