From nobody Sat Apr 27 17:44:01 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=1676612738; cv=none; d=zohomail.com; s=zohoarc; b=ir1SYZtLb+N0XboKUTRDhECNE3PVzs2QqoRQuhv+xBU4Ry22fRT3mpSsOBK4ddftLulbK8H5QrRiIsp1Ftde10pZ8vw2kYzXYAC61swGeKlsdQ4KagK94xsWOXphTx1PU133FDTN3CKcGEgBmx0x4AolAKNzQYQ6+k/kM6o48CU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612738; 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=Xz/5bAkleicl62MdzztWocE2YfMrKDcRo4PcgO3ivss=; b=j7tCkZ2zKIdvsxWbRS0SjqRBBQLE4BzXSD/UYgIAKnBRo1JtTjVJiCYyyfws8EPjXQ6Dzp936xS+W3GDN05dNtjUFZvz4G3CPVJmREnbgbMowQPp/vWjFR6VxQS95qdh3DwzZ6rccWnsUUfhn8g4LyIgFC8k6D4zKDrCAI5e/1E= 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 1676612738806959.1078050358351; Thu, 16 Feb 2023 21:45:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXP-0000aZ-RC; Fri, 17 Feb 2023 00:44: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 1pStXH-0000Xw-14 for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:55 -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 1pStXF-0001Mv-Fg for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:54 -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-365-id2zVPdlNqakwu8sM773BQ-1; Fri, 17 Feb 2023 00:43:43 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8BCA1C04B77; Fri, 17 Feb 2023 05:43:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE218492B15; Fri, 17 Feb 2023 05:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612632; 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=Xz/5bAkleicl62MdzztWocE2YfMrKDcRo4PcgO3ivss=; b=F0q41SSOe5O3f+pKtAS70AKdCXd+Us1BhvdU3Xo6fPttIGaQM2iquhZWWPC9MOeBE3DmSG 9ueVP9uFOdNBFp6j6Vk98zIgaLoxQQ6FZd1Fmh+Zsbg5m8a/K6JjRxe00Q5u1PgpGn/F1U dTGorbSuLFwMO3DVVet0oBp0AInH1YM= X-MC-Unique: id2zVPdlNqakwu8sM773BQ-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Thomas Huth , Jason Wang Subject: [PULL V3 1/9] net: Move the code to collect available NIC models to a separate function Date: Fri, 17 Feb 2023 13:43:27 +0800 Message-Id: <20230217054335.57595-2-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612739016100001 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 208c16f..cc51f98 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 fad589c..1d88621 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -203,6 +203,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 251fc5a..476a4b7 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 Sat Apr 27 17:44:01 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=1676612716; cv=none; d=zohomail.com; s=zohoarc; b=XxxIVOHkGmhm33UfS2RpC8unLzBQSUZW6Hg438XHsuNObj8TPWu3nN4AG807VHYB+sm2R4OtHmIDvKdmTv5AJQiK69Cs3jPjr+nQznoV1jGnbKfxenquNDhlruinDXzqWH+edoqO9mxGLECNNblvH/Ndj300qIYfVxAlFTdbtms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612716; 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=b6zLyjzW2coplxQWhNEa5xZCZZqJPHDht9T2ys6BfN0=; b=JDbKA5HtG88cvVpIWlWYyFy3l4a51l99iNG89GC3qwtsObj4sebEQfJyV32+o/xzzXy5fFg9sjTB+w//cJ8evN+sa1FeizW2OvCrMjbRic/4wSzCpTPeBWUEuiCkkF5HmGoKJaYoTuVcKkA2LWriU0tjoBd94mEtBECyO5JeaP0= 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 1676612716421265.80128353100383; Thu, 16 Feb 2023 21:45:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXN-0000Yu-Bh; Fri, 17 Feb 2023 00:44: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 1pStXD-0000XM-NA for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:53 -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 1pStXB-0001Kq-Fp for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:50 -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-57-NMAK7mB9OsKWRimPtgmHeQ-1; Fri, 17 Feb 2023 00:43:46 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 797303C01E0A; Fri, 17 Feb 2023 05:43:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7072C492B15; Fri, 17 Feb 2023 05:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612628; 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=b6zLyjzW2coplxQWhNEa5xZCZZqJPHDht9T2ys6BfN0=; b=FwdDmIGdnfjHFv/z8GFJJ824ZUvH3Lg5eUc3GUwys8xSVLsViJ0XV184wShpQ7sqH9KUCC Eek/nC6AhfJCBLTl621PqhMx2N5Zc5oQqWLzaVvnWnjnTofqTNrXH32KxQhC7OqSrRQ2b7 eqjwTAB/zTuwXSJWRm3WeEzy8pOCzeE= X-MC-Unique: NMAK7mB9OsKWRimPtgmHeQ-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Thomas Huth , Jason Wang Subject: [PULL V3 2/9] net: Restore printing of the help text with "-nic help" Date: Fri, 17 Feb 2023 13:43:28 +0800 Message-Id: <20230217054335.57595-3-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612716948100001 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 476a4b7..e8cd95c 100644 --- a/net/net.c +++ b/net/net.c @@ -1542,8 +1542,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 Sat Apr 27 17:44:01 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=1676612689; cv=none; d=zohomail.com; s=zohoarc; b=FFRnL8193+OP/sl7GmP3AY8CIxdDr2YyQ6hZoArdVIwFW1Iu+TU5KRMr1VPjJdJabnDaMEhvoYC07onmiWRXkOV1Z4jSDNO/37W/CiCsyQO0BEhX8ToK1MhoSy3M/HE555lu3MXUmmGGdSGkyIVB4dQTcD4HzEObE7XU7mhpcKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612689; 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=EZ6C4QLNHha/qzT/ijhl998I8+LXO8V5Tgy4E13dubs=; b=k8EPNnGvZu/qRH0qvCIxApoSiJex3pnbK4FGEDiH/wUXYstxjQUZ7avY/NQ4Sv+jERW0aGhSiTj7J5yfRpQNU9IZcGAOhaQjJkb7uMrTFvyBzutcH7q5WWB++VpCrZILHo0yyFA2w/HakumaCe6GJqE5eftbPcC39bXumJy5CvI= 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 1676612689534155.15323840334815; Thu, 16 Feb 2023 21:44:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXO-0000Zx-QZ; Fri, 17 Feb 2023 00:44:02 -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 1pStXH-0000Xx-6M for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:55 -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 1pStXF-0001N5-Rg for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43: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-192-fdf8HOT8NJaV1rIWao99TA-1; Fri, 17 Feb 2023 00:43:49 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DF5E85A588; Fri, 17 Feb 2023 05:43:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CEF5492B15; Fri, 17 Feb 2023 05:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612633; 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=EZ6C4QLNHha/qzT/ijhl998I8+LXO8V5Tgy4E13dubs=; b=HX0c28grJuZD3aUX8GPnLakv3EYXNJV9y6HlALrys+Tdf3ky99ENqvlDuSC9xBce3g88ai 2a67LH34VTQKsyXBNrahyNATZf2Ch0IwHhXhaWkTCtNdDECjwmqv/jMgKumSK9UizL6mJd i6BfxWMMyxH50V1LxHQXixUBv98vBB4= X-MC-Unique: fdf8HOT8NJaV1rIWao99TA-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Thomas Huth , Claudio Fontana , Jason Wang Subject: [PULL V3 3/9] net: Replace "Supported NIC models" with "Available NIC models" Date: Fri, 17 Feb 2023 13:43:29 +0800 Message-Id: <20230217054335.57595-4-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612690672100005 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 e8cd95c..ebc7ce0 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 Sat Apr 27 17:44:01 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=1676612689; cv=none; d=zohomail.com; s=zohoarc; b=GLXgtFGJimjVbCRJuGWLQg+wnWxPXAgueehCBzbdNopG/e6Kkeqsaolwg3fOLulw3//kdpBx8woPreNZKcCM9B9E8uVr8B2zOZ9vtdDlnR0NHbCOSv1IZWPuixIWxllWNhEqnqDoVg6/7uPu3Rxza5On6dJfGn9pYB7B0Wxj0Xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612689; 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=n7bNkXMP+OOdmH7zwLl15ZjnCl9zEEfC/SOtdVxDcVxC7XbcIqQsxM40XGsE0qRkvvp2Jzv8ddh0k7g8cqki/C01QVXHUetdNwxEs05tktwlEY2s+vN/2abn5FctidQp4+s+ayuxoDbdkBh3VnZbcp9rcdm/VzVcDUo4b/L4jb4= 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 1676612689837282.724646468155; Thu, 16 Feb 2023 21:44:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXQ-0000bG-S8; Fri, 17 Feb 2023 00:44:04 -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 1pStXK-0000Ya-Cb for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:59 -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 1pStXI-0001Nc-Lk for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:43:58 -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-664-UV5nevidPkeTIin8tEeKHA-1; Fri, 17 Feb 2023 00:43:52 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 687BF1C04B77; Fri, 17 Feb 2023 05:43:52 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26408492B15; Fri, 17 Feb 2023 05:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612636; 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=KzniqFKZ7eX1Cij44Kboxmz1rVZ0VVCI+zpRdI8ciI6lcgOGuzTtR9K4WHDXKOj7cp188j ooFkdnQ/Ywu7jD7yV+cYe38q0MmVZj8+C2L0UhlhCLIvRfuDfSj5H23NbqcgVs1bzjZxZ+ ax9VdmU9YSy7geJ3thrNkokI1gm4YUw= X-MC-Unique: UV5nevidPkeTIin8tEeKHA-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Qiang Liu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL V3 4/9] hw/net/lan9118: log [read|write]b when mode_16bit is enabled rather than abort Date: Fri, 17 Feb 2023 13:43:30 +0800 Message-Id: <20230217054335.57595-5-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-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.10 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: 1676612690679100006 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 Sat Apr 27 17:44:01 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=1676612773; cv=none; d=zohomail.com; s=zohoarc; b=jhri7REY1prTQ0fzd9umrfOPSZrfVzRVSzfLLVAuNfiS4WW5jaJQYETYUyDbugT5shzWn2Uaa2yq5mJz1ZcrKifUy49ylFBTz86WxSED4YPzxfsuktL9ch0e/Dx0Fq9YrzBfuNOYJyH4551Vn8WIVN1i/ewy+goYJ7gCWzgGk3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612773; 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=J6GSVLKFCrDFSaM9vh8Qdt+G2btOMAYE0HErPq0QRarTclfgdHo0Rs+IK96rVnY5G1Z9QgTQwU8JxvyxEaxE4V9W8zQVM5390uGRT8kihVF+Iw318SYBCv5qH7N4RYD1EfDZBaY2K7OK9lYSSI+2t88tv3rl1W0tebPCkRVMQA4= 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 1676612773723480.0055075729608; Thu, 16 Feb 2023 21:46:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXP-0000aT-Ka; Fri, 17 Feb 2023 00:44: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 1pStXO-0000Zn-Mq for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:02 -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 1pStXN-0001Np-0s for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:02 -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-395-HyOghvsvMNa7Ja2h-9B3-A-1; Fri, 17 Feb 2023 00:43:55 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 368E93C01E0D; Fri, 17 Feb 2023 05:43:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1104B492B15; Fri, 17 Feb 2023 05:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612639; 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=bm1W9bmHDYpaatW5jq5M+VSYxd8D43aZZC1kECjbBbtmZrdsekB9kPdJs60gAwsVNzQOPK nMd15MZHUQUdMBBu1k8vPC1nql1JVqyxD7nLYX8wpZ6RrHtHo2lFUBrM4nAcDauveYF9XR 5zMz5+qQi2BUilmV78y0eGHEotHiyQc= X-MC-Unique: HyOghvsvMNa7Ja2h-9B3-A-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Fiona Ebner , Jason Wang Subject: [PULL V3 5/9] hw/net/vmxnet3: allow VMXNET3_MAX_MTU itself as a value Date: Fri, 17 Feb 2023 13:43:31 +0800 Message-Id: <20230217054335.57595-6-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612775129100007 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 Sat Apr 27 17:44:01 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=1676612704; cv=none; d=zohomail.com; s=zohoarc; b=LziJm/oWXggF88fp38jB/8MA17x2CDuwiYmZt4G0kBwxtaEcGhOBBqpBAaLEkRC8519OBzb8qczl1qbb8LDWtB7c3t72y53jb1Z60JZWXhySHlPIKaiMzBzZgJKRw7JFepMc9PE2OsT7wWoLLogp3GfsWPTSlVC3A1Q9miRAwTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612704; 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=WWGd7EjPQX19iF979Nz06LK7cy/0gaiBmHJqhm0GMs0P8cXwjjwQ/ctdyKlPn2IB+CtfVqCzZhidgOr52uw3X3ZYwFxISK8Y8YsdHQbRM7kemHsWXXadW3uvCjGQNoGNWrEu61O1p6OjeAxbNC8RbVoVWTwVjE4V7lF+af2eM9g= 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 1676612704527395.15718636834833; Thu, 16 Feb 2023 21:45:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXS-0000c5-5U; Fri, 17 Feb 2023 00:44:06 -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 1pStXQ-0000ae-2f for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:04 -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 1pStXO-0001OE-Hp for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44: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-452-a159LsFpNBOXXdsiYJT40A-1; Fri, 17 Feb 2023 00:43:58 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E096E800B24; Fri, 17 Feb 2023 05:43:57 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D248D492B15; Fri, 17 Feb 2023 05:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612642; 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=KKXYfcXDg40ywHmxBS3cWNBAioEfIwFxD3RdYSxe3vif0C+N7F4xElGaeifXVmA6stdSjK GKjgg9qFWNSUfwaQ3wKgzLECKjtO44nDLPb8MlxKJEkDgwO5JTrkH2OEZ4LfXKw4ZHJWl8 uQ9i3oVoZ7pqPeZdmgdfuXAV1JdCDGk= X-MC-Unique: a159LsFpNBOXXdsiYJT40A-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Christian Svensson , Jason Wang Subject: [PULL V3 6/9] net: Increase L2TPv3 buffer to fit jumboframes Date: Fri, 17 Feb 2023 13:43:32 +0800 Message-Id: <20230217054335.57595-7-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612704880100001 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 Sat Apr 27 17:44:01 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=1676612691; cv=none; d=zohomail.com; s=zohoarc; b=AzC416oedvtNlAdhviR8U4+OQyNNqBsoPhdm4xkAaeFLJnrN8MZ/EnMlSJu18m4m5CXOcGLq1pucUx0cPCh591x9/zv589YMsWrQE5I8zxr2rFHP/nhOL+OfMByd2lrWXvT3ysXqC13TOISR8gaRJSlYebNoZay9g4hScK3MZYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612691; 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=JuAj2RerwCW16Em+2Oozz0Rt6lQtGEWwdHG10QBo1xI=; b=nl00REWf4YEtic5rciGAmjCPHJ85mMXEeEQo1b0LIW/QC3Cyq21tTo267mhLMXnV0r/jr4xRz374H+h4H0pKQb7lo/NHRSA7Jb0a2cQvPLDZfSOK06u/poQuX2pkxPo9quJcDcx3VTdBYFM26HYTjAjGW8Tb4sPqG+SAt2w8s4I= 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 1676612691419354.38164920032375; Thu, 16 Feb 2023 21:44:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXT-0000cl-L6; Fri, 17 Feb 2023 00:44: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 1pStXR-0000bl-FL for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44: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 1pStXP-0001OX-SA for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:05 -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-428-xxKGE2OlM1udcZY86bhX8A-1; Fri, 17 Feb 2023 00:44:01 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC51685A588; Fri, 17 Feb 2023 05:44:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 893F9492B15; Fri, 17 Feb 2023 05:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612643; 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=JuAj2RerwCW16Em+2Oozz0Rt6lQtGEWwdHG10QBo1xI=; b=da54vqCG1CDQI3PmUuzCepqICfX3aXzS3H3XJCGukLcrDXP2BAWo1xHHw1NeJRBkISUDnN e1yiNNkHzbDuk5RxFmlt1pt9onym7PwDqUOZgRh2SQsFd2ADVK4fZqZZA2DqFZNQ5fYLMY eP52CvrT6LmB1FgcVcpmJdZWCT9+Hsc= X-MC-Unique: xxKGE2OlM1udcZY86bhX8A-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Joelle van Dyne , Jason Wang Subject: [PULL V3 7/9] vmnet: stop recieving events when VM is stopped Date: Fri, 17 Feb 2023 13:43:33 +0800 Message-Id: <20230217054335.57595-8-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612692731100011 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 d0b9059..a8a033d 100644 --- a/net/vmnet_int.h +++ b/net/vmnet_int.h @@ -45,6 +45,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 Sat Apr 27 17:44:01 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=1676612740; cv=none; d=zohomail.com; s=zohoarc; b=GrVH9EZ9oU1ae7+4FVK2HghnrkJPIINOxl5FMdkWTDWQ+8JezOuSm1neaWqrV65YzgvERc3zEuD86E3JVPaEv+F1pc+rC2QXVFvs6w7mspLRg/F6zlvmUYqA9k7CibYHSI67zZnU3VbPlijluGpD2IizmCb/YzoEfW2lw70uBDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612740; 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=50Ef8btjS4ogRc7RNRQAHxslQ4Wb6SfDqeCsRCUfI0s=; b=B+keQy4WawYJ3iZKLne0IO5xEvwPSQayk+OX3UMs44OATCEriVNrQrOR/IuI3VD+t7IE4VZpxkLop1Vqxwjs/JByx2TgJJ30B5xD26RePkSmpfa9hbpPbeVdDFmmZiLhZP8OiagSpojWVDbyijagbG4xDqpPqhp+q5arBKuNOTg= 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 1676612740585457.52405735978357; Thu, 16 Feb 2023 21:45:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXX-0000iQ-MU; Fri, 17 Feb 2023 00:44:11 -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 1pStXV-0000eB-NO for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:09 -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 1pStXT-0001QO-NR for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:09 -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-221-3bnhe4U6MQm8KzFLB3RAnQ-1; Fri, 17 Feb 2023 00:44:03 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DAB83C01DA2; Fri, 17 Feb 2023 05:44:03 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75188492B15; Fri, 17 Feb 2023 05:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612647; 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=50Ef8btjS4ogRc7RNRQAHxslQ4Wb6SfDqeCsRCUfI0s=; b=IVDQmV7VMt0mxhd8ALW+IEkQju6k7oOPzA1B+OSyCOu965VBE0o9eOrsdteIzX+9+J9xnX QFzgq68EimT2zhlM76ylVTXvdaJaOzsqHwrtyhPUxhrT1k/UMT8MUtwlvTgRN2AbON+vHc XVsMaCVWJKwinJiK8hoMsPKg3TaX7pM= X-MC-Unique: 3bnhe4U6MQm8KzFLB3RAnQ-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, Laurent Vivier , Jason Wang Subject: [PULL V3 8/9] net: stream: add a new option to automatically reconnect Date: Fri, 17 Feb 2023 13:43:34 +0800 Message-Id: <20230217054335.57595-9-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1676612741040100007 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 cafd8be..beeb447 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2762,9 +2762,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 1d98dca..270e424 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 60 =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 Sat Apr 27 17:44:01 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=1676612771; cv=none; d=zohomail.com; s=zohoarc; b=ZejS7vqHN3qHQiFO6unysmqaCuwZqwdqaf3erV0DOrT3hXLJ4oKDvhMwd7wRNsADJJal0acia2b9n4dIF+nIkOVlxAERWGwOm1jKN5bMK/kMBRfLQbSiGQB57UF2prxgtbAgxtTDkeoBxkBbFbZbRhdy1L8Q3Wo7KSvU+8L6s0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676612771; 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=fsQL2lyV5cskSMgcpULIzYPFZTv1wWahm7SOGJPjqh/+1U1aK7kDoZsYK1YMzzTLxyiwRvN9iNQoCHHzsu0hrZK39G0H/f3gK+LimOT1ZAbi8bH2ECz+vC0CVZBEA1mFlPiQJ5nIwxHYiuMGEA+kN5pN3bJtVwaUPjYckC8uToQ= 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 1676612771568945.4009578517729; Thu, 16 Feb 2023 21:46:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pStXY-0000jY-Pe; Fri, 17 Feb 2023 00:44:12 -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 1pStXW-0000gT-AG for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:10 -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 1pStXU-0001QV-PT for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:44:09 -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-59-IphE1WsJPbuQ8dQaSCSzBw-1; Fri, 17 Feb 2023 00:44:06 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E566802C1D; Fri, 17 Feb 2023 05:44:06 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15DEE492B15; Fri, 17 Feb 2023 05:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676612648; 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=SzMt+zuCL85U05Hx0kERfOiwoJa0aAU/c8QWs+WesrauyIivTMooRjxhmrPV979RTr72FT wq6P28AER4wM6JapxFKRu7EPbIcc8bYhzwznCaFt2TxTV64ePgIzapHjlNpaebqQekHhna EYfClIKPbNa4LqIQl2JqD9U3kqTxosI= X-MC-Unique: IphE1WsJPbuQ8dQaSCSzBw-1 From: Jason Wang To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , "Michael S . Tsirkin" , Jason Wang Subject: [PULL V3 9/9] vdpa: fix VHOST_BACKEND_F_IOTLB_ASID flag check Date: Fri, 17 Feb 2023 13:43:35 +0800 Message-Id: <20230217054335.57595-10-jasowang@redhat.com> In-Reply-To: <20230217054335.57595-1-jasowang@redhat.com> References: <20230217054335.57595-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.10 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: 1676612773110100003 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