From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675319011; cv=none; d=zohomail.com; s=zohoarc; b=bporyuSK7wIQEy7CEOU+NNcoxQcM+mha0OhxfOijLyD07ksJcrQH61UggPdzBo+z9cIYb+x8KS7J8dZ091I/FodMEc7K2WHrcDfU0E00wzv5a9vTF5ZE3ewmqP5wqn/5l6tfJb9DvXRxCBZw5KXT/3nhpT+9HwG2SGSifIcRObs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675319011; 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=i/xYcSWYZO4bmGyDT4REm34S3JShy3xnNC5DP82UVEM=; b=Xt3HiBmM0fjzjel42wFZMc68wgVYTSP3pFWwgtnIyCxfgYxVYg97rB6ZN/r0W9KcgKm4OhnRP5Byv8vn3dOFrMShfc3v+7an9rDmf35oUL77TPKhMiIN5DdcQxQrZjmhMGB3Eoe2cQjdtMzQ40kT2bY+PxjtD2LzNNUUG5Qx3kg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675319011888709.0044005259123; Wed, 1 Feb 2023 22:23:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSya-0005ii-Bb; Thu, 02 Feb 2023 01:21:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyY-0005iF-Hd for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyW-0006bJ-Q1 for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:38 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-jgydWRzeNZ--rYbsiZ8K-w-1; Thu, 02 Feb 2023 01:21:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77E4485C6F4; Thu, 2 Feb 2023 06:21:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B59E404BEC0; Thu, 2 Feb 2023 06:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318896; 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=i/xYcSWYZO4bmGyDT4REm34S3JShy3xnNC5DP82UVEM=; b=cqig3MNNA0u57cdngD3Q5qXqboaC/koo8BlM1h5r8ikIzVmOibtav44+FQNXLHe7GqXy4J 8f6Ib0GYuh1BDmB0dRm/sdpigstFgW4dYX+z8R/ViWqmWphhldw0b9KtXou/5d3dhcWrRu b4iRpmrsZX0+Gv80QlVlxkofehpoHZg= X-MC-Unique: jgydWRzeNZ--rYbsiZ8K-w-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Thomas Huth , Jason Wang Subject: [PULL 01/11] net: Move the code to collect available NIC models to a separate function Date: Thu, 2 Feb 2023 14:21:16 +0800 Message-Id: <20230202062126.67550-2-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675319013380100007 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The code that collects the available NIC models is not really specific to PCI anymore and will be required in the next patch, too, so let's move this into a new separate function in net.c instead. Signed-off-by: Thomas Huth Signed-off-by: Jason Wang --- hw/pci/pci.c | 29 +---------------------------- include/net/net.h | 14 ++++++++++++++ net/net.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 39a7bb3..8e01fc7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1789,7 +1789,6 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *r= ootbus, const char *default_devaddr) { const char *devaddr =3D nd->devaddr ? nd->devaddr : default_devaddr; - GSList *list; GPtrArray *pci_nic_models; PCIBus *bus; PCIDevice *pci_dev; @@ -1804,33 +1803,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *= rootbus, nd->model =3D g_strdup("virtio-net-pci"); } =20 - list =3D object_class_get_list_sorted(TYPE_PCI_DEVICE, false); - pci_nic_models =3D g_ptr_array_new(); - while (list) { - DeviceClass *dc =3D OBJECT_CLASS_CHECK(DeviceClass, list->data, - TYPE_DEVICE); - GSList *next; - if (test_bit(DEVICE_CATEGORY_NETWORK, dc->categories) && - dc->user_creatable) { - const char *name =3D object_class_get_name(list->data); - /* - * A network device might also be something else than a NIC, s= ee - * e.g. the "rocker" device. Thus we have to look for the "net= dev" - * property, too. Unfortunately, some devices like virtio-net = only - * create this property during instance_init, so we have to cr= eate - * a temporary instance here to be able to check it. - */ - Object *obj =3D object_new_with_class(OBJECT_CLASS(dc)); - if (object_property_find(obj, "netdev")) { - g_ptr_array_add(pci_nic_models, (gpointer)name); - } - object_unref(obj); - } - next =3D list->next; - g_slist_free_1(list); - list =3D next; - } - g_ptr_array_add(pci_nic_models, NULL); + pci_nic_models =3D qemu_get_nic_models(TYPE_PCI_DEVICE); =20 if (qemu_show_nic_models(nd->model, (const char **)pci_nic_models->pda= ta)) { exit(0); diff --git a/include/net/net.h b/include/net/net.h index dc20b31..3a57caa 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -202,6 +202,20 @@ void net_socket_rs_init(SocketReadState *rs, bool vnet_hdr); NetClientState *qemu_get_peer(NetClientState *nc, int queue_index); =20 +/** + * qemu_get_nic_models: + * @device_type: Defines which devices should be taken into consideration + * (e.g. TYPE_DEVICE for all devices, or TYPE_PCI_DEVICE for= PCI) + * + * Get an array of pointers to names of NIC devices that are available in + * the QEMU binary. The array is terminated with a NULL pointer entry. + * The caller is responsible for freeing the memory when it is not required + * anymore, e.g. with g_ptr_array_free(..., true). + * + * Returns: Pointer to the array that contains the pointers to the names. + */ +GPtrArray *qemu_get_nic_models(const char *device_type); + /* NIC info */ =20 #define MAX_NICS 8 diff --git a/net/net.c b/net/net.c index 2d01472..8f083cf 100644 --- a/net/net.c +++ b/net/net.c @@ -899,6 +899,40 @@ static int nic_get_free_idx(void) return -1; } =20 +GPtrArray *qemu_get_nic_models(const char *device_type) +{ + GPtrArray *nic_models =3D g_ptr_array_new(); + GSList *list =3D object_class_get_list_sorted(device_type, false); + + while (list) { + DeviceClass *dc =3D OBJECT_CLASS_CHECK(DeviceClass, list->data, + TYPE_DEVICE); + GSList *next; + if (test_bit(DEVICE_CATEGORY_NETWORK, dc->categories) && + dc->user_creatable) { + const char *name =3D object_class_get_name(list->data); + /* + * A network device might also be something else than a NIC, s= ee + * e.g. the "rocker" device. Thus we have to look for the "net= dev" + * property, too. Unfortunately, some devices like virtio-net = only + * create this property during instance_init, so we have to cr= eate + * a temporary instance here to be able to check it. + */ + Object *obj =3D object_new_with_class(OBJECT_CLASS(dc)); + if (object_property_find(obj, "netdev")) { + g_ptr_array_add(nic_models, (gpointer)name); + } + object_unref(obj); + } + next =3D list->next; + g_slist_free_1(list); + list =3D next; + } + g_ptr_array_add(nic_models, NULL); + + return nic_models; +} + int qemu_show_nic_models(const char *arg, const char *const *models) { int i; --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318933; cv=none; d=zohomail.com; s=zohoarc; b=UwFJ12crZ90M+aP291R3fLncDNhNi/jIdECEZjoKvUK80crwoEk4y91nFAzV9R8qYCr4fT1FQu3kCQqHdgxeTeV/vUwrfIus/28IT5U8kMDiRtL0JfblYvwLOmLJ19Cw1G73etZ9wcqGkYqpdS/+SAIxxRK2hsYz7A2nQpHRcP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318933; 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=44+Q+1WsrAdzEQnwhO6pt4RZpDnxjNtVyovH3zpiJbk=; b=EMVj34Q/8mas11Jjx8UWL6yoAfOguA1wXNBI/EFkEa4c8Nl6RKfs2o+Xn2xGVRnwB6C8eJ8Sf9OVxlIGHPxlK9SM4zTbMCt0eNMiYQc6XLQLUNGmW/cKer7cG8xhrlvJRmwWN2BYICOWswy2TI6PJhJDGqIbmlTHMAES7IEHYII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318933655429.1724626576256; Wed, 1 Feb 2023 22:22:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSye-0005kq-Hw; Thu, 02 Feb 2023 01:21:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyc-0005jh-GD for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSya-0006dO-W7 for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:42 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-hXSlEkktPwC1Ej5pPaslww-1; Thu, 02 Feb 2023 01:21:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6FDE101A52E; Thu, 2 Feb 2023 06:21:35 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161ED404BEC0; Thu, 2 Feb 2023 06:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318899; 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=44+Q+1WsrAdzEQnwhO6pt4RZpDnxjNtVyovH3zpiJbk=; b=I6tBBAlWXuxOQe/cE4aduH6r3p8Y8BV2yvWT1wzgko/tx9J/vFraYbU03tiw3JrbK9nYMn eR2xbhBp5fRkhMUG7GG9hkUF1BOoYg4S1XmJ7MvybaF2ut4fatPPoCY40rlggDj2+X3FPE RzXpXORj1ExpYn5e9RF9nkYoNkZAXq4= X-MC-Unique: hXSlEkktPwC1Ej5pPaslww-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Thomas Huth , Jason Wang Subject: [PULL 02/11] net: Restore printing of the help text with "-nic help" Date: Thu, 2 Feb 2023 14:21:17 +0800 Message-Id: <20230202062126.67550-3-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318935051100005 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Running QEMU with "-nic help" used to work in QEMU 5.2 and earlier versions (it showed the available netdev backends), but this feature got broken duri= ng some refactoring in version 6.0. Let's restore the old behavior, and while we're at it, let's also print the available NIC models here now since this option can be used to configure both, netdev backend and model in one go. Fixes: ad6f932fe8 ("net: do not exit on "netdev_add help" monitor command") Signed-off-by: Thomas Huth Signed-off-by: Jason Wang --- net/net.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index 8f083cf..888986a 100644 --- a/net/net.c +++ b/net/net.c @@ -1568,8 +1568,18 @@ static int net_param_nic(void *dummy, QemuOpts *opts= , Error **errp) const char *type; =20 type =3D qemu_opt_get(opts, "type"); - if (type && g_str_equal(type, "none")) { - return 0; /* Nothing to do, default_net is cleared in vl.c */ + if (type) { + if (g_str_equal(type, "none")) { + return 0; /* Nothing to do, default_net is cleared in vl.c = */ + } + if (is_help_option(type)) { + GPtrArray *nic_models =3D qemu_get_nic_models(TYPE_DEVICE); + show_netdevs(); + printf("\n"); + qemu_show_nic_models(type, (const char **)nic_models->pdata); + g_ptr_array_free(nic_models, true); + exit(0); + } } =20 idx =3D nic_get_free_idx(); --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675319010; cv=none; d=zohomail.com; s=zohoarc; b=XnjnBteebziiUN34L+HiS6t06kwZugXRFj7BTZFUO8lZeIb4mOw47HXOdMcTzfq7Pa2l3G04g/Ks8LalgwEDp6DAqQobO2Y9MBWCJVJsE6Fuk+abD+AnjD+V0RlZ/V2mqwAyyJkd4eezuV34AIJAFXVDP/iPCnAZ4y13PiCQWEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675319010; 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=ICmt8V8QIc6OjvA65okAqY3Jb+ehyL5vIYaD9OOJaM8=; b=Nn7kYVy6MHPSoqBfPRPX8IjLsiak3QiZV7XopRfLwQwExseMi7Jt70G7/G9sZZSJ4vvi1Wyfz+OGI4noV2Fimg1wOgbCjCr+7lBb1HOhVFrbnrNuXwGDeMFD6UyMZ3urfusft+XvtINbmNDn1d9irnskIan2AszyFLJJdXu5SHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675319010778614.7362253677346; Wed, 1 Feb 2023 22:23:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyv-0005pa-9d; Thu, 02 Feb 2023 01:22:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyt-0005p5-9y for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyq-0006f1-S7 for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:59 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-anO1sHyTPsGBmMcyiqg2-w-1; Thu, 02 Feb 2023 01:21:44 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 165143C02B79; Thu, 2 Feb 2023 06:21:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 860D6404BEC0; Thu, 2 Feb 2023 06:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318916; 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=ICmt8V8QIc6OjvA65okAqY3Jb+ehyL5vIYaD9OOJaM8=; b=SS3mUhRiI8PTa+TfIBHtEYvelkiwgcpYf8ecpRmA4Fq6BkxMn8qlymvoDKVVB2X8LtD3Ds DNSPE0fe8g0nHMq5NI0VFaaA9ay47s4cZLFKeaFBAlEGyi8DUFsu1s8qCALrRLGI+fsJrG z3MID0WVoxK1+zBHMwUc4eAQhhDkf/0= X-MC-Unique: anO1sHyTPsGBmMcyiqg2-w-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Thomas Huth , Claudio Fontana , Jason Wang Subject: [PULL 03/11] net: Replace "Supported NIC models" with "Available NIC models" Date: Thu, 2 Feb 2023 14:21:18 +0800 Message-Id: <20230202062126.67550-4-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675319011346100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Just because a NIC model is compiled into the QEMU binary does not necessary mean that it can be used with each and every machine. So let's rather talk about "available" models instead of "supported" models, just to avoid confusion. Reviewed-by: Claudio Fontana Signed-off-by: Thomas Huth Signed-off-by: Jason Wang --- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index 888986a..baa2548 100644 --- a/net/net.c +++ b/net/net.c @@ -941,7 +941,7 @@ int qemu_show_nic_models(const char *arg, const char *c= onst *models) return 0; } =20 - printf("Supported NIC models:\n"); + printf("Available NIC models:\n"); for (i =3D 0 ; models[i]; i++) { printf("%s\n", models[i]); } --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318970; cv=none; d=zohomail.com; s=zohoarc; b=FP3ofh3B9/hOKZ6n8okKg2+vZ7yeFDK3lGomvGwqgDb2k53cJSfSRNY8aUi32TmAEe5vsqAFvwPTtHGY/BFQ52niCv3Ef2H4M1/3G9Ns2wETXX3sKQ+Th8wL4SKyitkS8jGaDMoI3YRuejkeLvE9b2PoZa8AtiPbjjeYPoWJQuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318970; 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=XoR1EqS98VfAlVzMxZNoy/1pmw2KIRavs+YTl38ELCA=; b=GumAkRVfhfQWt5ce87/fvJ8IxKGXVIxvSllzvnYdgbIUdz+QoY4AWAY4lLR9RsW01LTgFJVR8TLbPgzR1I22/hXY14oCWKKZfDTlupLISD3hD53wSoGbPjYQrZ7feqGGDMkUg8g3HQ9NUE2g1+N1VCkqmXhFrM3mwCKYa+woRjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318970285248.13146807448118; Wed, 1 Feb 2023 22:22:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyl-0005lo-B7; Thu, 02 Feb 2023 01:21:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyj-0005lW-Rz for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyi-0006ds-7o for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:49 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-576-eG9WCxdQMlms_fUeqOi0Hw-1; Thu, 02 Feb 2023 01:21:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE47838012CB; Thu, 2 Feb 2023 06:21:45 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9310404BEC0; Thu, 2 Feb 2023 06:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318907; 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=XoR1EqS98VfAlVzMxZNoy/1pmw2KIRavs+YTl38ELCA=; b=PHDu+Ig+5rHrjLRhaKZifXF5itUD8Dv+iih1THDC4QKM02pvgqdpZHs2LZInOs1z3+bOYx MVdc7L+7MX2rkvM0dl2wwTEP1DkOqmcCQ/ueJ/EOZldkaZ7CEyzbBCNLzXeSSwSuSscS/L imxPbJVM9NX+1hLWofwc8z/VqzPb5zk= X-MC-Unique: eG9WCxdQMlms_fUeqOi0Hw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Qiang Liu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 04/11] hw/net/lan9118: log [read|write]b when mode_16bit is enabled rather than abort Date: Thu, 2 Feb 2023 14:21:19 +0800 Message-Id: <20230202062126.67550-5-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318971162100001 From: Qiang Liu This patch replaces hw_error to guest error log for [read|write]b accesses when mode_16bit is enabled. This avoids aborting qemu. Fixes: 1248f8d4cbc3 ("hw/lan9118: Add basic 16-bit mode support.") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1433 Reported-by: Qiang Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Qiang Liu Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/lan9118.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index f1cba55..e5c4af1 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -15,7 +15,6 @@ #include "migration/vmstate.h" #include "net/net.h" #include "net/eth.h" -#include "hw/hw.h" #include "hw/irq.h" #include "hw/net/lan9118.h" #include "hw/ptimer.h" @@ -32,12 +31,8 @@ #ifdef DEBUG_LAN9118 #define DPRINTF(fmt, ...) \ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0) -#define BADF(fmt, ...) \ -do { hw_error("lan9118: error: " fmt , ## __VA_ARGS__);} while (0) #else #define DPRINTF(fmt, ...) do {} while(0) -#define BADF(fmt, ...) \ -do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0) #endif =20 /* The tx and rx fifo ports are a range of aliased 32-bit registers */ @@ -848,7 +843,8 @@ static uint32_t do_phy_read(lan9118_state *s, int reg) case 30: /* Interrupt mask */ return s->phy_int_mask; default: - BADF("PHY read reg %d\n", reg); + qemu_log_mask(LOG_GUEST_ERROR, + "do_phy_read: PHY read reg %d\n", reg); return 0; } } @@ -876,7 +872,8 @@ static void do_phy_write(lan9118_state *s, int reg, uin= t32_t val) phy_update_irq(s); break; default: - BADF("PHY write reg %d =3D 0x%04x\n", reg, val); + qemu_log_mask(LOG_GUEST_ERROR, + "do_phy_write: PHY write reg %d =3D 0x%04x\n", reg, = val); } } =20 @@ -1209,7 +1206,8 @@ static void lan9118_16bit_mode_write(void *opaque, hw= addr offset, return; } =20 - hw_error("lan9118_write: Bad size 0x%x\n", size); + qemu_log_mask(LOG_GUEST_ERROR, + "lan9118_16bit_mode_write: Bad size 0x%x\n", size); } =20 static uint64_t lan9118_readl(void *opaque, hwaddr offset, @@ -1324,7 +1322,8 @@ static uint64_t lan9118_16bit_mode_read(void *opaque,= hwaddr offset, return lan9118_readl(opaque, offset, size); } =20 - hw_error("lan9118_read: Bad size 0x%x\n", size); + qemu_log_mask(LOG_GUEST_ERROR, + "lan9118_16bit_mode_read: Bad size 0x%x\n", size); return 0; } =20 --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318981; cv=none; d=zohomail.com; s=zohoarc; b=Nf5uQgensnN5iTTfR66TnkeESYjPlEjz/9g6wDqQHBu+guvp7Y8ip9ARsrcVctHXX4h8MgfN8L7rdxmW9ImNUHRwgZTgVUsGt1FKieGxw3rTBqlb2u3VWwLyaO0ecyY1KusUrpid5qSPxoiFGs/d0G+aoJyX2lhfaPUG8zT2KVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318981; 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=Vc+cpwghIdhzjJMh8b7ZSYwJLUU3TZcFB8a50pFS96E=; b=NRN639EhJe8w2RdCDYK1FHhHdse8lxpTfQbafAnYLpdbvOvGEgM4Ha+cQ3WVASMxiQdPVQ6cJN6qmqzJWca7TUDr5p1LrcuVdDPOxQFYlEp2zwOBPJbF68c5z13rxUaCONdIO/wF0fq20sGU+uAVhvuCa+uly0j/pyquLorL/Uk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318981906808.491788531966; Wed, 1 Feb 2023 22:23:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyp-0005nQ-T7; Thu, 02 Feb 2023 01:21:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyo-0005mT-GR for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSym-0006eO-RS for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:54 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-8FLAeoJyO1yfwuppwPivFA-1; Thu, 02 Feb 2023 01:21:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7680080C8C2; Thu, 2 Feb 2023 06:21:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB1F404BEC0; Thu, 2 Feb 2023 06:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318912; 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=Vc+cpwghIdhzjJMh8b7ZSYwJLUU3TZcFB8a50pFS96E=; b=JlaHXEhl4lG4jSehUNBfdzKEHRBcT6T2gwaNXVg7ad1DRhk26kwiBc6RoUBEKOtHoBlt6F +7w48/ialXspj7DrhxE83KqVMTihfLZykZsBJ3kp89Eg8ubc5AJ+Mlu0QvSaJoSJPntabz WZLx909BV34n0poodaU2AN8z4cpAeFs= X-MC-Unique: 8FLAeoJyO1yfwuppwPivFA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Fiona Ebner , Jason Wang Subject: [PULL 05/11] hw/net/vmxnet3: allow VMXNET3_MAX_MTU itself as a value Date: Thu, 2 Feb 2023 14:21:20 +0800 Message-Id: <20230202062126.67550-6-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318983408100007 Content-Type: text/plain; charset="utf-8" From: Fiona Ebner Currently, VMXNET3_MAX_MTU itself (being 9000) is not considered a valid value for the MTU, but a guest running ESXi 7.0 might try to set it and fail the assert [0]. In the Linux kernel, dev->max_mtu itself is a valid value for the MTU and for the vmxnet3 driver it's 9000, so a guest running Linux will also fail the assert when trying to set an MTU of 9000. VMXNET3_MAX_MTU and s->mtu don't seem to be used in relation to buffer allocations/accesses, so allowing the upper limit itself as a value should be fine. [0]: https://forum.proxmox.com/threads/114011/ Fixes: d05dcd94ae ("net: vmxnet3: validate configuration values during acti= vate (CVE-2021-20203)") Signed-off-by: Fiona Ebner Signed-off-by: Jason Wang --- hw/net/vmxnet3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index d2ab527..56559cd 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1441,7 +1441,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) vmxnet3_setup_rx_filtering(s); /* Cache fields from shared memory */ s->mtu =3D VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu= ); - assert(VMXNET3_MIN_MTU <=3D s->mtu && s->mtu < VMXNET3_MAX_MTU); + assert(VMXNET3_MIN_MTU <=3D s->mtu && s->mtu <=3D VMXNET3_MAX_MTU); VMW_CFPRN("MTU is %u", s->mtu); =20 s->max_rx_frags =3D --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318975; cv=none; d=zohomail.com; s=zohoarc; b=AKYcYT3Os4h2QAwYJbRNkNvyGv6kF9pvhKTGep6cfHehTOaKgyymSMg9c9DZKKm6361LMYMiOpE8rpaT/qIrRe/3oQeVcMRROZXjzw9AcOXf1CIaMTu1NI3WM2JBAOkTxz9Pf5L8m5OE217D3vAot2FmDMuoNA7SdVK6opVflCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318975; 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=QJW3mqWgOGg6y2rioCOHh498Rm7Se1bPgF5dSmxc4co=; b=Z0YJPiXxzWbQU8H1GmaJmWPeDCuA/xScfkLPQBdsf0xWB+Ai+38CGMEndUc+8uZKl7aOA9O2GxuyGFbh5MKx3HkPIascWj09chLrSedtBonCLXxlU+NI54Ac/zn73JcYt920jDUj694z3zn92XuwX1VPwhgd9RhtxZV1GRj9ITk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16753189756151003.8683654941553; Wed, 1 Feb 2023 22:22:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyq-0005oH-5l; Thu, 02 Feb 2023 01:21:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyo-0005mX-LS for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyn-0006eT-5e for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:54 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-ZyUCP_WZOa-2Rg7npPXRPA-1; Thu, 02 Feb 2023 01:21:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF31C101A52E; Thu, 2 Feb 2023 06:21:50 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15D85404BEC0; Thu, 2 Feb 2023 06:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318912; 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=QJW3mqWgOGg6y2rioCOHh498Rm7Se1bPgF5dSmxc4co=; b=VkT9avosz/5URPopeJbLfhAecx0I4wGjUIZJ4K0VXwyA2fUrd7dD/Y3wfz8u80FZcS2xSr 3BKt9DpdySb58LOwrdEld6TQY0BG/NbIQBPSV+cfPosq8j+Dbc/ZweYi+UqolZ9KeDcqdU tjIPFh8bsrO0JDTzMCYccASGIi76WdM= X-MC-Unique: ZyUCP_WZOa-2Rg7npPXRPA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Christian Svensson , Jason Wang Subject: [PULL 06/11] net: Increase L2TPv3 buffer to fit jumboframes Date: Thu, 2 Feb 2023 14:21:21 +0800 Message-Id: <20230202062126.67550-7-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318977192100003 Content-Type: text/plain; charset="utf-8" From: Christian Svensson Increase the allocated buffer size to fit larger packets. Given that jumboframes can commonly be up to 9000 bytes the closest suitable value seems to be 16 KiB. Tested by running qemu towards a Linux L2TPv3 endpoint and pushing jumboframe traffic through the interfaces. Signed-off-by: Christian Svensson Signed-off-by: Jason Wang --- net/l2tpv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 53b2d32..b5547cb 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -42,7 +42,7 @@ */ =20 #define BUFFER_ALIGN sysconf(_SC_PAGESIZE) -#define BUFFER_SIZE 2048 +#define BUFFER_SIZE 16384 #define IOVSIZE 2 #define MAX_L2TPV3_MSGCNT 64 #define MAX_L2TPV3_IOVCNT (MAX_L2TPV3_MSGCNT * IOVSIZE) --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318986; cv=none; d=zohomail.com; s=zohoarc; b=f2M4zD0Bk/YShKxCsI6bSRENEFNBmC/ihFkdCWcLMymzsSn5KbEpeH7Xh0q8Jve3O0cxAGQs83kPXjQr35NMGUVOm/6y7PrbX4mL8P+ieHT4bLplwmigY43pK3+nr0QR9lyFIhAwJpWQNE5/La6Age6NUsAr3Vq23lq364sDMfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318986; 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=479NoBReSy7LS6aRxv7AH28X+pdJVc67AOSSoyYozO0=; b=foFUHjL+kTxgcIGnZueAX1TrWl8EvUkdC5g/p36dKoi8AOSjtmeAlI+sM40YTkdQmod+Y+6utzMhTDmSSK1GWmbxKS2/SjBGAqHGNgTZrMgVkJgzuVZllUEqcSWWkKrfgZjul1Ldydhs3fuUOPk4dho6E2wO0rIw74CXrvkfaKc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318986112824.1592507181243; Wed, 1 Feb 2023 22:23:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyu-0005pV-U3; Thu, 02 Feb 2023 01:22:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyt-0005p4-7S for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyr-0006fA-NM for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:21:58 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-6Rb4HVrtOmaz8n4gYBC_sw-1; Thu, 02 Feb 2023 01:21:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7731E181E3F0; Thu, 2 Feb 2023 06:21:53 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9078F404BEC0; Thu, 2 Feb 2023 06:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318917; 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=479NoBReSy7LS6aRxv7AH28X+pdJVc67AOSSoyYozO0=; b=ZZbL3rLJYuuqazEcFv5lwqTd4OM/eUBIofY1Mv4cIwRFhCZbDFmEDvnCiEvAUXPcK1rCJ+ 4Ulgjqobry4V5oa6cX750Cmzz8/9a+PVaAuRmKhIkWE+Ft3OYanXw0Vb9sd7lDntOExsAg IFEtpSejPLSogcnuNR6c0WUaa+3wgaI= X-MC-Unique: 6Rb4HVrtOmaz8n4gYBC_sw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Joelle van Dyne , Jason Wang Subject: [PULL 07/11] vmnet: stop recieving events when VM is stopped Date: Thu, 2 Feb 2023 14:21:22 +0800 Message-Id: <20230202062126.67550-8-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318987260100003 Content-Type: text/plain; charset="utf-8" From: Joelle van Dyne When the VM is stopped using the HMP command "stop", soon the handler will stop reading from the vmnet interface. This causes a flood of `VMNET_INTERFACE_PACKETS_AVAILABLE` events to arrive and puts the host CPU at 100%. We fix this by removing the event handler from vmnet when the VM is no longer in a running state and restore it when we return to a running state. Signed-off-by: Joelle van Dyne Signed-off-by: Jason Wang --- net/vmnet-common.m | 48 +++++++++++++++++++++++++++++++++++------------- net/vmnet_int.h | 2 ++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 2cb60b9..2958283 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -17,6 +17,7 @@ #include "clients.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "sysemu/runstate.h" =20 #include #include @@ -242,6 +243,35 @@ static void vmnet_bufs_init(VmnetState *s) } } =20 +/** + * Called on state change to un-register/re-register handlers + */ +static void vmnet_vm_state_change_cb(void *opaque, bool running, RunState = state) +{ + VmnetState *s =3D opaque; + + if (running) { + vmnet_interface_set_event_callback( + s->vmnet_if, + VMNET_INTERFACE_PACKETS_AVAILABLE, + s->if_queue, + ^(interface_event_t event_id, xpc_object_t event) { + assert(event_id =3D=3D VMNET_INTERFACE_PACKETS_AVAILABLE); + /* + * This function is being called from a non qemu thread, so + * we only schedule a BH, and do the rest of the io comple= tion + * handling from vmnet_send_bh() which runs in a qemu cont= ext. + */ + qemu_bh_schedule(s->send_bh); + }); + } else { + vmnet_interface_set_event_callback( + s->vmnet_if, + VMNET_INTERFACE_PACKETS_AVAILABLE, + NULL, + NULL); + } +} =20 int vmnet_if_create(NetClientState *nc, xpc_object_t if_desc, @@ -329,19 +359,9 @@ int vmnet_if_create(NetClientState *nc, s->packets_send_current_pos =3D 0; s->packets_send_end_pos =3D 0; =20 - vmnet_interface_set_event_callback( - s->vmnet_if, - VMNET_INTERFACE_PACKETS_AVAILABLE, - s->if_queue, - ^(interface_event_t event_id, xpc_object_t event) { - assert(event_id =3D=3D VMNET_INTERFACE_PACKETS_AVAILABLE); - /* - * This function is being called from a non qemu thread, so - * we only schedule a BH, and do the rest of the io completion - * handling from vmnet_send_bh() which runs in a qemu context. - */ - qemu_bh_schedule(s->send_bh); - }); + vmnet_vm_state_change_cb(s, 1, RUN_STATE_RUNNING); + + s->change =3D qemu_add_vm_change_state_handler(vmnet_vm_state_change_c= b, s); =20 return 0; } @@ -356,6 +376,8 @@ void vmnet_cleanup_common(NetClientState *nc) return; } =20 + vmnet_vm_state_change_cb(s, 0, RUN_STATE_SHUTDOWN); + qemu_del_vm_change_state_handler(s->change); if_stopped_sem =3D dispatch_semaphore_create(0); vmnet_stop_interface( s->vmnet_if, diff --git a/net/vmnet_int.h b/net/vmnet_int.h index adf6e8c..ffba921 100644 --- a/net/vmnet_int.h +++ b/net/vmnet_int.h @@ -46,6 +46,8 @@ typedef struct VmnetState { int packets_send_end_pos; =20 struct iovec iov_buf[VMNET_PACKETS_LIMIT]; + + VMChangeStateEntry *change; } VmnetState; =20 const char *vmnet_status_map_str(vmnet_return_t status); --=20 2.7.4 From nobody Fri Apr 26 11:53:29 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318979; cv=none; d=zohomail.com; s=zohoarc; b=CqcDjAwWGVfY+PBrY0XBOQt8DVedaTl0mMCFTkwWclyaZz2NtEP4tD1WM3gvQTt6Gm7UfKaKVrZ81kS3cvxC4RBlT4l82sinP3mHSmdetuUL2VuqLdbOm5Y2KSfqD2YU5o9qpkJ3GLmu2rlI9gg6zyoeSMW00z2LcjWkXoAsBwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318979; 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=TwNHaHxJN+PwwFzTbjQzvXD6UyPedYFtyj+WeZcwq8M=; b=DNlQ0mGct8pD+Q3D0cz8OeJXcRF7EENtdo3kJIcycwb8zYTPzdkVM0+CsDYpRkHimFKbyZZBHGiBxc6iNxYTT8cCJb0JHF0cGVbIHbksegXUfFMZjqqDY90Ju43o4kPpBOX7KGusUd/5vx33b3oF63F0nrT5zI4WPhixpWyFp0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318979724292.32531427117715; Wed, 1 Feb 2023 22:22:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyx-0005qI-Iw; Thu, 02 Feb 2023 01:22:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyw-0005q8-9g for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyu-0006fi-M5 for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:02 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-Pr6b6GBrPV2g5fXPwMYnxw-1; Thu, 02 Feb 2023 01:21:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5BDF101A55E; Thu, 2 Feb 2023 06:21:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16633404BEC0; Thu, 2 Feb 2023 06:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318920; 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=TwNHaHxJN+PwwFzTbjQzvXD6UyPedYFtyj+WeZcwq8M=; b=MkQ/uwConcJf+ZnYaGcBoF9LEbFFXvRdwAMNo9hyKGTxR/P4FRsWRHBrgPK4VHy9TTQ9nJ qJpNRamrBr7s0j+2ieFQlJ7jQvjMkywFdiHoxzUR3ZYRNE0pGX5bQ2gbL4NJZOaZAVqWTF w511cQfGjw+7k83UedplR3hzCYXHHpY= X-MC-Unique: Pr6b6GBrPV2g5fXPwMYnxw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Qiang Liu , Jason Wang Subject: [PULL 08/11] hw/net/can/xlnx-zynqmp-can: fix assertion failures in transfer_fifo() Date: Thu, 2 Feb 2023 14:21:23 +0800 Message-Id: <20230202062126.67550-9-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318981219100003 Content-Type: text/plain; charset="utf-8" From: Qiang Liu Check fifos before poping data from and pushing data into it. Fixes: 98e5d7a2b726 ("hw/net/can: Introduce Xilinx ZynqMP CAN controller") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1425 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1427 Reported-by: Qiang Liu Signed-off-by: Qiang Liu Signed-off-by: Jason Wang --- hw/net/can/xlnx-zynqmp-can.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c index e93e6c5..55d3221 100644 --- a/hw/net/can/xlnx-zynqmp-can.c +++ b/hw/net/can/xlnx-zynqmp-can.c @@ -451,6 +451,12 @@ static void transfer_fifo(XlnxZynqMPCANState *s, Fifo3= 2 *fifo) } =20 while (!fifo32_is_empty(fifo)) { + if (fifo32_num_used(fifo) < (4 * CAN_FRAME_SIZE)) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + qemu_log_mask(LOG_GUEST_ERROR, "%s: data left in the fifo is n= ot" + " enough for transfer.\n", path); + break; + } for (i =3D 0; i < CAN_FRAME_SIZE; i++) { data[i] =3D fifo32_pop(fifo); } @@ -463,7 +469,8 @@ static void transfer_fifo(XlnxZynqMPCANState *s, Fifo32= *fifo) * acknowledged. The XlnxZynqMPCAN core receives any message * that it transmits. */ - if (fifo32_is_full(&s->rx_fifo)) { + if (fifo32_is_full(&s->rx_fifo) || + (fifo32_num_free(&s->rx_fifo) < (4 * CAN_FRAME_SIZE)))= { ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFL= W, 1); } else { for (i =3D 0; i < CAN_FRAME_SIZE; i++) { --=20 2.7.4 From nobody Fri Apr 26 11:53:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318946; cv=none; d=zohomail.com; s=zohoarc; b=KanLqOZ0KvB8x5MMR6oecEtRQzgTVVkYmxOR8zmzGPDbxXRMQAglIihPDs+wviLFIkwR3ScYxGheHE4TrIcGj7olxUEfy9khXGXcoQUIAWS1/UjjmwlwW2AQRuIFOkb8BUbsW6aGd2D6NZloz2Es/G6yrKMXIipO+LCusFM8Nj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318946; 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=KcjqmHDDK3j5rqMqmYOonwvtKfcqVb7kChZMopXMwnk=; b=DF4WgJNQ3s6+hEbSsem8O65FF+7h4MAF74imT0X8tCvC4qG3DTWqMx4jeu0/oXdM8S3rb1BMJuk8C8H2qqkmlIXGWJr5OPmt/UCE+YY4mHjABd5Pv7etOURLAwE3To8Ugkteppm0gsij5qFBvfJgNhsrkcNTjM7mes+VZVPL0ho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318946573351.5322321987444; Wed, 1 Feb 2023 22:22:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSyz-0005qu-CM; Thu, 02 Feb 2023 01:22:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyx-0005qH-Hd for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyv-0006fz-9M for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:03 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-xWtOmWD8NACTjad3qdM5sg-1; Thu, 02 Feb 2023 01:21:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A50385A5B1; Thu, 2 Feb 2023 06:21:59 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8519E404BEC0; Thu, 2 Feb 2023 06:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318920; 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=KcjqmHDDK3j5rqMqmYOonwvtKfcqVb7kChZMopXMwnk=; b=ZGFebwI+OFcb1AD7EzAsCOzVqUdoZmcXaexGiBTXSYxdj3gjArgX4/Qn/RnJycsCI0k6Nx YaCr5pizqkv7Tl+3A9nN2+D1lv8So8E8Elpc695FXThvru+EkwrGiDw2pW7UKDAOnDeXRg N4hiy/apvBWfkmF48TrNahGEJWapINs= X-MC-Unique: xWtOmWD8NACTjad3qdM5sg-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Laurent Vivier , "Michael S . Tsirkin" , Thomas Huth , Jason Wang Subject: [PULL 09/11] tests/qtest: netdev: test stream and dgram backends Date: Thu, 2 Feb 2023 14:21:24 +0800 Message-Id: <20230202062126.67550-10-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318946980100006 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Signed-off-by: Laurent Vivier Acked-by: Michael S. Tsirkin Acked-by: Thomas Huth Signed-off-by: Jason Wang --- tests/qtest/meson.build | 2 + tests/qtest/netdev-socket.c | 448 ++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 450 insertions(+) create mode 100644 tests/qtest/netdev-socket.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 1af63f8..e97616d 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -21,6 +21,7 @@ qtests_generic =3D [ 'test-hmp', 'qos-test', 'readconfig-test', + 'netdev-socket', ] if config_host.has_key('CONFIG_MODULES') qtests_generic +=3D [ 'modules-test' ] @@ -298,6 +299,7 @@ qtests =3D { 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), + 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), } =20 gvnc =3D dependency('gvnc-1.0', required: false) diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c new file mode 100644 index 0000000..6ba256e --- /dev/null +++ b/tests/qtest/netdev-socket.c @@ -0,0 +1,448 @@ +/* + * QTest testcase for netdev stream and dgram + * + * Copyright (c) 2022 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/sockets.h" +#include +#include "../unit/socket-helpers.h" +#include "libqtest.h" + +#define CONNECTION_TIMEOUT 5 + +#define EXPECT_STATE(q, e, t) \ +do { \ + char *resp =3D NULL; \ + g_test_timer_start(); \ + do { \ + g_free(resp); \ + resp =3D qtest_hmp(q, "info network"); \ + if (t) { \ + strrchr(resp, t)[0] =3D 0; \ + } \ + if (g_str_equal(resp, e)) { \ + break; \ + } \ + } while (g_test_timer_elapsed() < CONNECTION_TIMEOUT); \ + g_assert_cmpstr(resp, =3D=3D, e); \ + g_free(resp); \ +} while (0) + +static gchar *tmpdir; + +static int inet_get_free_port_socket_ipv4(int sock) +{ + struct sockaddr_in addr; + socklen_t len; + + memset(&addr, 0, sizeof(addr)); + addr.sin_family =3D AF_INET; + addr.sin_addr.s_addr =3D INADDR_ANY; + addr.sin_port =3D 0; + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + return -1; + } + + len =3D sizeof(addr); + if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) { + return -1; + } + + return ntohs(addr.sin_port); +} + +static int inet_get_free_port_socket_ipv6(int sock) +{ + struct sockaddr_in6 addr; + socklen_t len; + + memset(&addr, 0, sizeof(addr)); + addr.sin6_family =3D AF_INET6; + addr.sin6_addr =3D in6addr_any; + addr.sin6_port =3D 0; + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + return -1; + } + + len =3D sizeof(addr); + if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) { + return -1; + } + + return ntohs(addr.sin6_port); +} + +static int inet_get_free_port_multiple(int nb, int *port, bool ipv6) +{ + int sock[nb]; + int i; + + for (i =3D 0; i < nb; i++) { + sock[i] =3D socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0); + if (sock[i] < 0) { + break; + } + port[i] =3D ipv6 ? inet_get_free_port_socket_ipv6(sock[i]) : + inet_get_free_port_socket_ipv4(sock[i]); + if (port[i] =3D=3D -1) { + break; + } + } + + nb =3D i; + for (i =3D 0; i < nb; i++) { + closesocket(sock[i]); + } + + return nb; +} + +static int inet_get_free_port(bool ipv6) +{ + int nb, port; + + nb =3D inet_get_free_port_multiple(1, &port, ipv6); + g_assert_cmpint(nb, =3D=3D, 1); + + return port; +} + +static void test_stream_inet_ipv4(void) +{ + QTestState *qts0, *qts1; + char *expect; + int port; + + port =3D inet_get_free_port(false); + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue,addr.type=3D= inet," + "addr.ipv4=3Don,addr.ipv6=3Doff," + "addr.host=3D127.0.0.1,addr.port=3D%d", port); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,server=3Dfalse,id=3Dst0,addr.type= =3Dinet," + "addr.ipv4=3Don,addr.ipv6=3Doff," + "addr.host=3D127.0.0.1,addr.port=3D%d", port); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Dstream,tcp:127.0.0.1= :%d\r\n", + port); + EXPECT_STATE(qts1, expect, 0); + g_free(expect); + + /* the port is unknown, check only the address */ + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,tcp:127.0.0.1", ':'); + + qtest_quit(qts1); + qtest_quit(qts0); +} + +static void test_stream_inet_ipv6(void) +{ + QTestState *qts0, *qts1; + char *expect; + int port; + + port =3D inet_get_free_port(true); + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue,addr.type=3D= inet," + "addr.ipv4=3Doff,addr.ipv6=3Don," + "addr.host=3D::1,addr.port=3D%d", port); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,server=3Dfalse,id=3Dst0,addr.type= =3Dinet," + "addr.ipv4=3Doff,addr.ipv6=3Don," + "addr.host=3D::1,addr.port=3D%d", port); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Dstream,tcp:::1:%d\r\= n", + port); + EXPECT_STATE(qts1, expect, 0); + g_free(expect); + + /* the port is unknown, check only the address */ + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,tcp:::1", ':'); + + qtest_quit(qts1); + qtest_quit(qts0); +} + +static void test_stream_unix(void) +{ + QTestState *qts0, *qts1; + char *expect; + gchar *path; + + path =3D g_strconcat(tmpdir, "/stream_unix", NULL); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue," + "addr.type=3Dunix,addr.path=3D%s,", + path); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dfalse," + "addr.type=3Dunix,addr.path=3D%s", + path); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Dstream,unix:%s\r\n",= path); + EXPECT_STATE(qts1, expect, 0); + EXPECT_STATE(qts0, expect, 0); + g_free(expect); + g_free(path); + + qtest_quit(qts1); + qtest_quit(qts0); +} + +#ifdef CONFIG_LINUX +static void test_stream_unix_abstract(void) +{ + QTestState *qts0, *qts1; + char *expect; + gchar *path; + + path =3D g_strconcat(tmpdir, "/stream_unix_abstract", NULL); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue," + "addr.type=3Dunix,addr.path=3D%s," + "addr.abstract=3Don", + path); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dfalse," + "addr.type=3Dunix,addr.path=3D%s,addr.abstract=3Don= ", + path); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Dstream,unix:%s\r\n",= path); + EXPECT_STATE(qts1, expect, 0); + EXPECT_STATE(qts0, expect, 0); + g_free(expect); + g_free(path); + + qtest_quit(qts1); + qtest_quit(qts0); +} +#endif + +#ifndef _WIN32 +static void test_stream_fd(void) +{ + QTestState *qts0, *qts1; + int sock[2]; + int ret; + + ret =3D socketpair(AF_LOCAL, SOCK_STREAM, 0, sock); + g_assert_true(ret =3D=3D 0); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,addr.type=3Dfd,addr.str=3D= %d", + sock[0]); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,unix:\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,addr.type=3Dfd,addr.str=3D= %d", + sock[1]); + + EXPECT_STATE(qts1, "st0: index=3D0,type=3Dstream,unix:\r\n", 0); + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,unix:\r\n", 0); + + qtest_quit(qts1); + qtest_quit(qts0); + + closesocket(sock[0]); + closesocket(sock[1]); +} +#endif + +static void test_dgram_inet(void) +{ + QTestState *qts0, *qts1; + char *expect; + int port[2]; + int nb; + + nb =3D inet_get_free_port_multiple(2, port, false); + g_assert_cmpint(nb, =3D=3D, 2); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0," + "local.type=3Dinet,local.host=3D127.0.0.1,local.por= t=3D%d," + "remote.type=3Dinet,remote.host=3D127.0.0.1,remote.= port=3D%d", + port[0], port[1]); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram," + "udp=3D127.0.0.1:%d/127.0.0.1:%d\r\n", + port[0], port[1]); + EXPECT_STATE(qts0, expect, 0); + g_free(expect); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0," + "local.type=3Dinet,local.host=3D127.0.0.1,local.por= t=3D%d," + "remote.type=3Dinet,remote.host=3D127.0.0.1,remote.= port=3D%d", + port[1], port[0]); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram," + "udp=3D127.0.0.1:%d/127.0.0.1:%d\r\n", + port[1], port[0]); + EXPECT_STATE(qts1, expect, 0); + g_free(expect); + + qtest_quit(qts1); + qtest_quit(qts0); +} + +#ifndef _WIN32 +static void test_dgram_mcast(void) +{ + QTestState *qts; + + qts =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0," + "remote.type=3Dinet,remote.host=3D230.0.0.1,remote.p= ort=3D1234"); + + EXPECT_STATE(qts, "st0: index=3D0,type=3Ddgram,mcast=3D230.0.0.1:1234\= r\n", 0); + + qtest_quit(qts); +} + +static void test_dgram_unix(void) +{ + QTestState *qts0, *qts1; + char *expect; + gchar *path0, *path1; + + path0 =3D g_strconcat(tmpdir, "/dgram_unix0", NULL); + path1 =3D g_strconcat(tmpdir, "/dgram_unix1", NULL); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0,local.type=3Dunix,local.pat= h=3D%s," + "remote.type=3Dunix,remote.path=3D%s", + path0, path1); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram,udp=3D%s:%s\r\= n", + path0, path1); + EXPECT_STATE(qts0, expect, 0); + g_free(expect); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0,local.type=3Dunix,local.pat= h=3D%s," + "remote.type=3Dunix,remote.path=3D%s", + path1, path0); + + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram,udp=3D%s:%s\r\= n", + path1, path0); + EXPECT_STATE(qts1, expect, 0); + g_free(expect); + + unlink(path0); + g_free(path0); + unlink(path1); + g_free(path1); + + qtest_quit(qts1); + qtest_quit(qts0); +} + +static void test_dgram_fd(void) +{ + QTestState *qts0, *qts1; + char *expect; + int ret; + int sv[2]; + + ret =3D socketpair(PF_UNIX, SOCK_DGRAM, 0, sv); + g_assert_cmpint(ret, !=3D, -1); + + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0,local.type=3Dfd,local.str= =3D%d", + sv[0]); + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram,fd=3D%d unix\r= \n", sv[0]); + EXPECT_STATE(qts0, expect, 0); + g_free(expect); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev dgram,id=3Dst0,local.type=3Dfd,local.str= =3D%d", + sv[1]); + + + expect =3D g_strdup_printf("st0: index=3D0,type=3Ddgram,fd=3D%d unix\r= \n", sv[1]); + EXPECT_STATE(qts1, expect, 0); + g_free(expect); + + qtest_quit(qts1); + qtest_quit(qts0); + + closesocket(sv[0]); + closesocket(sv[1]); +} +#endif + +int main(int argc, char **argv) +{ + int ret; + bool has_ipv4, has_ipv6, has_afunix; + g_autoptr(GError) err =3D NULL; + + socket_init(); + g_test_init(&argc, &argv, NULL); + + if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) { + g_error("socket_check_protocol_support() failed\n"); + } + + tmpdir =3D g_dir_make_tmp("netdev-socket.XXXXXX", &err); + if (tmpdir =3D=3D NULL) { + g_error("Can't create temporary directory in %s: %s", + g_get_tmp_dir(), err->message); + } + + if (has_ipv4) { + qtest_add_func("/netdev/stream/inet/ipv4", test_stream_inet_ipv4); + qtest_add_func("/netdev/dgram/inet", test_dgram_inet); +#ifndef _WIN32 + qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast); +#endif + } + if (has_ipv6) { + qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6); + } + + socket_check_afunix_support(&has_afunix); + if (has_afunix) { +#ifndef _WIN32 + qtest_add_func("/netdev/dgram/unix", test_dgram_unix); +#endif + qtest_add_func("/netdev/stream/unix", test_stream_unix); +#ifdef CONFIG_LINUX + qtest_add_func("/netdev/stream/unix/abstract", + test_stream_unix_abstract); +#endif +#ifndef _WIN32 + qtest_add_func("/netdev/stream/fd", test_stream_fd); + qtest_add_func("/netdev/dgram/fd", test_dgram_fd); +#endif + } + + ret =3D g_test_run(); + + g_rmdir(tmpdir); + g_free(tmpdir); + + return ret; +} --=20 2.7.4 From nobody Fri Apr 26 11:53:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318943; cv=none; d=zohomail.com; s=zohoarc; b=O+bbEQOgMvG5AezCmDJC9YsHoDm0NIwbL9ggDK5tP8biS0bxXxwqk/3a/6rvvOikb6R/efrqDP+n4Uk0ZQK/0n7KbgaRYwQdXqN468yQaBdvv/4xcWTBS+gzKBTpCrwukB2cc1/Uzr8xUPqRGyakqWsOsiChnoc/tDOsQiETi+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318943; 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=KZVOhmO/cGIX8metIU3go5xZ+Yj4DXyxgCMAXotSpKc=; b=VrCDulofYAWvgWRNqUjxbDlXTM9W992ZlXAnoxzVrUbde+PFxdOIe511RuBfN52aTEBfltJe7kiIi2wHP02r9Gt7jI5gY4Q2q30SIgRvwgGbhYXUJcRPfAlN571qvaAoJgK7tQcThPd9QKEcTHj2RB2XiU+LHN20JMi3rzoTeDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675318943338722.7234065082986; Wed, 1 Feb 2023 22:22:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSz1-0005rZ-Ly; Thu, 02 Feb 2023 01:22:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyz-0005qw-NJ for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSyx-0006hk-Nf for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:05 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-zIubg_15OZWIkZ9T61arjw-1; Thu, 02 Feb 2023 01:22:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B66F1C06EC5; Thu, 2 Feb 2023 06:22:01 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D7EC404BEC0; Thu, 2 Feb 2023 06:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318923; 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=KZVOhmO/cGIX8metIU3go5xZ+Yj4DXyxgCMAXotSpKc=; b=CdAdoIlj45XhLAM9VS5K4ZfTvEHC7cGA5fc1gvIEL3qWrg6Cm+UP8aQbEhy0rRly5n4ZBj 8joqbZ2pbSSX+qgZkDx9ndk5GHfsAsxZaA9xEp5RjU3sCQdx5g/y6bSmAhMbU46hyw7p1e XxuCSTrbfybzOxjPD5tH02uEyW3xR6I= X-MC-Unique: zIubg_15OZWIkZ9T61arjw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Laurent Vivier , Jason Wang Subject: [PULL 10/11] net: stream: add a new option to automatically reconnect Date: Thu, 2 Feb 2023 14:21:25 +0800 Message-Id: <20230202062126.67550-11-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318945013100002 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier In stream mode, if the server shuts down there is currently no way to reconnect the client to a new server without removing the NIC device and the netdev backend (or to reboot). This patch introduces a reconnect option that specifies a delay to try to reconnect with the same parameters. Add a new test in qtest to test the reconnect option and the connect/disconnect events. Signed-off-by: Laurent Vivier Signed-off-by: Jason Wang --- net/stream.c | 53 ++++++++++++++++++++++- qapi/net.json | 7 ++- qemu-options.hx | 6 +-- tests/qtest/netdev-socket.c | 101 ++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 162 insertions(+), 5 deletions(-) diff --git a/net/stream.c b/net/stream.c index 37ff727..9204b4c 100644 --- a/net/stream.c +++ b/net/stream.c @@ -39,6 +39,8 @@ #include "io/channel-socket.h" #include "io/net-listener.h" #include "qapi/qapi-events-net.h" +#include "qapi/qapi-visit-sockets.h" +#include "qapi/clone-visitor.h" =20 typedef struct NetStreamState { NetClientState nc; @@ -49,11 +51,15 @@ typedef struct NetStreamState { guint ioc_write_tag; SocketReadState rs; unsigned int send_index; /* number of bytes sent*/ + uint32_t reconnect; + guint timer_tag; + SocketAddress *addr; } NetStreamState; =20 static void net_stream_listen(QIONetListener *listener, QIOChannelSocket *cioc, void *opaque); +static void net_stream_arm_reconnect(NetStreamState *s); =20 static gboolean net_stream_writable(QIOChannel *ioc, GIOCondition condition, @@ -170,6 +176,7 @@ static gboolean net_stream_send(QIOChannel *ioc, qemu_set_info_str(&s->nc, "%s", ""); =20 qapi_event_send_netdev_stream_disconnected(s->nc.name); + net_stream_arm_reconnect(s); =20 return G_SOURCE_REMOVE; } @@ -187,6 +194,14 @@ static gboolean net_stream_send(QIOChannel *ioc, static void net_stream_cleanup(NetClientState *nc) { NetStreamState *s =3D DO_UPCAST(NetStreamState, nc, nc); + if (s->timer_tag) { + g_source_remove(s->timer_tag); + s->timer_tag =3D 0; + } + if (s->addr) { + qapi_free_SocketAddress(s->addr); + s->addr =3D NULL; + } if (s->ioc) { if (QIO_CHANNEL_SOCKET(s->ioc)->fd !=3D -1) { if (s->ioc_read_tag) { @@ -346,12 +361,37 @@ static void net_stream_client_connected(QIOTask *task= , gpointer opaque) error: object_unref(OBJECT(s->ioc)); s->ioc =3D NULL; + net_stream_arm_reconnect(s); +} + +static gboolean net_stream_reconnect(gpointer data) +{ + NetStreamState *s =3D data; + QIOChannelSocket *sioc; + + s->timer_tag =3D 0; + + sioc =3D qio_channel_socket_new(); + s->ioc =3D QIO_CHANNEL(sioc); + qio_channel_socket_connect_async(sioc, s->addr, + net_stream_client_connected, s, + NULL, NULL); + return G_SOURCE_REMOVE; +} + +static void net_stream_arm_reconnect(NetStreamState *s) +{ + if (s->reconnect && s->timer_tag =3D=3D 0) { + s->timer_tag =3D g_timeout_add_seconds(s->reconnect, + net_stream_reconnect, s); + } } =20 static int net_stream_client_init(NetClientState *peer, const char *model, const char *name, SocketAddress *addr, + uint32_t reconnect, Error **errp) { NetStreamState *s; @@ -364,6 +404,10 @@ static int net_stream_client_init(NetClientState *peer, s->ioc =3D QIO_CHANNEL(sioc); s->nc.link_down =3D true; =20 + s->reconnect =3D reconnect; + if (reconnect) { + s->addr =3D QAPI_CLONE(SocketAddress, addr); + } qio_channel_socket_connect_async(sioc, addr, net_stream_client_connected, s, NULL, NULL); @@ -380,7 +424,14 @@ int net_init_stream(const Netdev *netdev, const char *= name, sock =3D &netdev->u.stream; =20 if (!sock->has_server || !sock->server) { - return net_stream_client_init(peer, "stream", name, sock->addr, er= rp); + return net_stream_client_init(peer, "stream", name, sock->addr, + sock->has_reconnect ? sock->reconnec= t : 0, + errp); + } + if (sock->has_reconnect) { + error_setg(errp, "'reconnect' option is incompatible with " + "socket in server mode"); + return -1; } return net_stream_server_init(peer, "stream", name, sock->addr, errp); } diff --git a/qapi/net.json b/qapi/net.json index 522ac58..d6eb300 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -585,6 +585,10 @@ # @addr: socket address to listen on (server=3Dtrue) # or connect to (server=3Dfalse) # @server: create server socket (default: false) +# @reconnect: For a client socket, if a socket is disconnected, +# then attempt a reconnect after the given number of seconds. +# Setting this to zero disables this function. (default: 0) +# (since 8.0) # # Only SocketAddress types 'unix', 'inet' and 'fd' are supported. # @@ -593,7 +597,8 @@ { 'struct': 'NetdevStreamOptions', 'data': { 'addr': 'SocketAddress', - '*server': 'bool' } } + '*server': 'bool', + '*reconnect': 'uint32' } } =20 ## # @NetdevDgramOptions: diff --git a/qemu-options.hx b/qemu-options.hx index d59d197..5617140 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2769,9 +2769,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev socket,id=3Dstr[,fd=3Dh][,udp=3Dhost:port][,localaddr=3Dhost:= port]\n" " configure a network backend to connect to another net= work\n" " using an UDP tunnel\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host= =3Dhost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don= |off][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off]\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path= =3Dpath[,abstract=3Don|off][,tight=3Don|off]\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Df= ile-descriptor\n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host= =3Dhost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don= |off][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off][,reconnect= =3Dseconds]\n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path= =3Dpath[,abstract=3Don|off][,tight=3Don|off][,reconnect=3Dseconds]\n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Df= ile-descriptor[,reconnect=3Dseconds]\n" " configure a network backend to connect to another net= work\n" " using a socket connection in stream mode.\n" "-netdev dgram,id=3Dstr,remote.type=3Dinet,remote.host=3Dmaddr,remote.= port=3Dport[,local.type=3Dinet,local.host=3Daddr]\n" diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c index 6ba256e..acc32c3 100644 --- a/tests/qtest/netdev-socket.c +++ b/tests/qtest/netdev-socket.c @@ -11,6 +11,10 @@ #include #include "../unit/socket-helpers.h" #include "libqtest.h" +#include "qapi/qmp/qstring.h" +#include "qemu/sockets.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-visit-sockets.h" =20 #define CONNECTION_TIMEOUT 5 =20 @@ -142,6 +146,101 @@ static void test_stream_inet_ipv4(void) qtest_quit(qts0); } =20 +static void wait_stream_connected(QTestState *qts, const char *id, + SocketAddress **addr) +{ + QDict *resp, *data; + QString *qstr; + QObject *obj; + Visitor *v =3D NULL; + + resp =3D qtest_qmp_eventwait_ref(qts, "NETDEV_STREAM_CONNECTED"); + g_assert_nonnull(resp); + data =3D qdict_get_qdict(resp, "data"); + g_assert_nonnull(data); + + qstr =3D qobject_to(QString, qdict_get(data, "netdev-id")); + g_assert_nonnull(data); + + g_assert(!strcmp(qstring_get_str(qstr), id)); + + obj =3D qdict_get(data, "addr"); + + v =3D qobject_input_visitor_new(obj); + visit_type_SocketAddress(v, NULL, addr, NULL); + visit_free(v); + qobject_unref(resp); +} + +static void wait_stream_disconnected(QTestState *qts, const char *id) +{ + QDict *resp, *data; + QString *qstr; + + resp =3D qtest_qmp_eventwait_ref(qts, "NETDEV_STREAM_DISCONNECTED"); + g_assert_nonnull(resp); + data =3D qdict_get_qdict(resp, "data"); + g_assert_nonnull(data); + + qstr =3D qobject_to(QString, qdict_get(data, "netdev-id")); + g_assert_nonnull(data); + + g_assert(!strcmp(qstring_get_str(qstr), id)); + qobject_unref(resp); +} + +static void test_stream_inet_reconnect(void) +{ + QTestState *qts0, *qts1; + int port; + SocketAddress *addr; + + port =3D inet_get_free_port(false); + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue,addr.type=3D= inet," + "addr.ipv4=3Don,addr.ipv6=3Doff," + "addr.host=3D127.0.0.1,addr.port=3D%d", port); + + EXPECT_STATE(qts0, "st0: index=3D0,type=3Dstream,\r\n", 0); + + qts1 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,server=3Dfalse,id=3Dst0,addr.type= =3Dinet," + "addr.ipv4=3Don,addr.ipv6=3Doff,reconnect=3D1," + "addr.host=3D127.0.0.1,addr.port=3D%d", port); + + wait_stream_connected(qts0, "st0", &addr); + g_assert_cmpint(addr->type, =3D=3D, SOCKET_ADDRESS_TYPE_INET); + g_assert_cmpstr(addr->u.inet.host, =3D=3D, "127.0.0.1"); + qapi_free_SocketAddress(addr); + + /* kill server */ + qtest_quit(qts0); + + /* check client has been disconnected */ + wait_stream_disconnected(qts1, "st0"); + + /* restart server */ + qts0 =3D qtest_initf("-nodefaults -M none " + "-netdev stream,id=3Dst0,server=3Dtrue,addr.type=3D= inet," + "addr.ipv4=3Don,addr.ipv6=3Doff," + "addr.host=3D127.0.0.1,addr.port=3D%d", port); + + /* wait connection events*/ + wait_stream_connected(qts0, "st0", &addr); + g_assert_cmpint(addr->type, =3D=3D, SOCKET_ADDRESS_TYPE_INET); + g_assert_cmpstr(addr->u.inet.host, =3D=3D, "127.0.0.1"); + qapi_free_SocketAddress(addr); + + wait_stream_connected(qts1, "st0", &addr); + g_assert_cmpint(addr->type, =3D=3D, SOCKET_ADDRESS_TYPE_INET); + g_assert_cmpstr(addr->u.inet.host, =3D=3D, "127.0.0.1"); + g_assert_cmpint(atoi(addr->u.inet.port), =3D=3D, port); + qapi_free_SocketAddress(addr); + + qtest_quit(qts1); + qtest_quit(qts0); +} + static void test_stream_inet_ipv6(void) { QTestState *qts0, *qts1; @@ -418,6 +517,8 @@ int main(int argc, char **argv) #ifndef _WIN32 qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast); #endif + qtest_add_func("/netdev/stream/inet/reconnect", + test_stream_inet_reconnect); } if (has_ipv6) { qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6); --=20 2.7.4 From nobody Fri Apr 26 11:53:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675318945; cv=none; d=zohomail.com; s=zohoarc; b=WyNIHivMXA5iUBVEnG/Z45vwJwNvHijfVQD7AIRowCgX0g2dlGYzs0CudKYkmMMUol8N/mQBFSJXw1eIgL9iPBq80rS9m7fod9gvxqCbzHykxleUh7pDIjlvPCbaLXmpRwlq1J79g3/j8rywbgqrJ/b9wGBQBVy5j+4QUvr7i0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675318945; 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=DSWyl+JQ+g2bk0l3ZTYBnaA+DxoOXvy4fW45aw/Or2s=; b=hpEeBjHqAulZcwNpm/Pah6k8zPEESbkR5zHgqP9SY6kgGdsFGd8jfCCNiAF3IgDzgZCwTiy8rl3GhsDOpbfD+fAMn2/tzSNIC9jQDhV3wrVUKu6xDf/bZa16/CfStI/VwMUSNFl4w4XTNRSS9zWy5PjaEkKWPf9DRv2lNkqrBDg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167531894547943.43904434675312; Wed, 1 Feb 2023 22:22:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNSz3-0005rq-8h; Thu, 02 Feb 2023 01:22:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSz2-0005rb-0c for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNSz0-0006jO-Ja for qemu-devel@nongnu.org; Thu, 02 Feb 2023 01:22:07 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-KAw1w_K4PUScsXM6PQhNqw-1; Thu, 02 Feb 2023 01:22:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4AC3A811E9C; Thu, 2 Feb 2023 06:22:04 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-0.pek2.redhat.com [10.72.14.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18BB4404BEC0; Thu, 2 Feb 2023 06:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675318926; 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=DSWyl+JQ+g2bk0l3ZTYBnaA+DxoOXvy4fW45aw/Or2s=; b=UzfaveOd61cgdo5yQiUKQf225SY3TJU5THbECsY5DqMM3DhSXKWGH3XIsHUISTPfk5A4sA tVV0FwZMYM87P9c3baq/MCDKsv8b0WjOQhOJY3Ow45Cx3utoTRpDdQW9/58af7wLGcZxgK wTPZCoLOts8WNv3PWfyeqmmGYbn32iU= X-MC-Unique: KAw1w_K4PUScsXM6PQhNqw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , "Michael S . Tsirkin" , Jason Wang Subject: [PULL 11/11] vdpa: fix VHOST_BACKEND_F_IOTLB_ASID flag check Date: Thu, 2 Feb 2023 14:21:26 +0800 Message-Id: <20230202062126.67550-12-jasowang@redhat.com> In-Reply-To: <20230202062126.67550-1-jasowang@redhat.com> References: <20230202062126.67550-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675318946959100005 From: Eugenio P=C3=A9rez VHOST_BACKEND_F_IOTLB_ASID is the feature bit, not the bitmask. Since the device under test also provided VHOST_BACKEND_F_IOTLB_MSG_V2 and VHOST_BACKEND_F_IOTLB_BATCH, this went unnoticed. Fixes: c1a1008685 ("vdpa: always start CVQ in SVQ mode if possible") Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a13a34..de5ed8f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -384,7 +384,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) g_strerror(errno), errno); return -1; } - if (!(backend_features & VHOST_BACKEND_F_IOTLB_ASID) || + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) || !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { return 0; } --=20 2.7.4