From nobody Tue Jan 21 04:07:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736325242845208.79567591265788; Wed, 8 Jan 2025 00:34:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CEF28940; Wed, 8 Jan 2025 03:34:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BAEF011D9; Wed, 8 Jan 2025 03:33:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id AAAB511C7; Wed, 8 Jan 2025 03:33:39 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2B0DAC98 for ; Wed, 8 Jan 2025 03:33:39 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590--qA3PAhxM6qRqlKu7gT88w-1; Wed, 08 Jan 2025 03:33:37 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B0F719560AE for ; Wed, 8 Jan 2025 08:33:36 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.45.225.135]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AA7ED1956094 for ; Wed, 8 Jan 2025 08:33:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736325218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PixprJNVQBOlpQRyruYcRuvYf8Bjfe7/YgjBijwiT7Q=; b=ZOCycWhLRBYWnUdC7O5q/JfhOnDT3tF1wFQ01DD1FFdQrUq2bUru7V0/pmhg0PGgBHTsI9 uNrAHF9WL+/NrS7rTE198oEWckVnezgm0+t54z4cpweNEfHsN1AG4su/wH0iAYHsf0c6uH GIgtav9Hx9ma0XhBov+4DK79ryrdRoo= X-MC-Unique: -qA3PAhxM6qRqlKu7gT88w-1 X-Mimecast-MFC-AGG-ID: -qA3PAhxM6qRqlKu7gT88w From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] conf: Restrict model type to enum members Date: Wed, 8 Jan 2025 09:33:29 +0100 Message-ID: <7ff59d7457bc11510c9016701d2ed737d99b37f7.1736322972.git.ajulis@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HsNLJ5edroFt6LqIEDRxGRz3hiP2k3mPpO7T5ZY9g38_1736325216 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RS6RUMPKAQZUPDWLJFK6HO7LPCHXFWK3 X-Message-ID-Hash: RS6RUMPKAQZUPDWLJFK6HO7LPCHXFWK3 X-MailFrom: ajulis@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736325244406116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Historically, we supported any string as the model type for network devices. This approach allowed us to stay up-to-date with QEMU's frequent introduction of new model types. However, this solution now causes more problems than benefits. A clearly nonsensical model name can pass validation but result in a QEMU internal error when the VM is started. This patch restricts model types to members of the 'virDomainNetModelType' enum. The enum has been extended to include all model types currently supported by QEMU. If QEMU introduces new models in the future, the enum must be updated to support them. Resolves: https://issues.redhat.com/browse/RHEL-72082 Signed-off-by: Adam Julis --- I'm not sure if the virtio-net-pci should be in this enum, since its not located in qemu repo in hw/net/ but in hw/virtio/. When I manually tested it, the qemu this option supported. The last two members have not been supported for several years but I wanted to keep backward compatibilit= y. src/conf/domain_conf.c | 23 +++++++++++++++++++++++ src/conf/domain_conf.h | 23 +++++++++++++++++++++++ src/conf/domain_validate.c | 7 +++++++ 3 files changed, 53 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index af88d0bcfd..5e8ca0015d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -613,6 +613,29 @@ VIR_ENUM_IMPL(virDomainNetModel, "82540EM", "82545EM", "82543GC", + "dp8393x", + "eepro100", + "ftgmac100", + "igbvf", + "lasi_i82596", + "mcf_fec", + "mipsnet", + "ne2000-isa", + "ne2000-pci", + "npcm7xx_emc", + "npcm_gmac", + "opencores_eth", + "pcnet-pci", + "rocker", + "spapr_llan", + "sungem", + "sunhme", + "tulip", + "virtio-net", + "xen_nic", + "virtio-net-pci", + "etraxfs_eth", + "milkymist-minimac2", ); =20 VIR_ENUM_IMPL(virDomainNetDriver, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9f7c28343f..d7f0073ba5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -951,6 +951,29 @@ typedef enum { VIR_DOMAIN_NET_MODEL_82540EM, VIR_DOMAIN_NET_MODEL_82545EM, VIR_DOMAIN_NET_MODEL_82543GC, + VIR_DOMAIN_NET_MODEL_DP8393X, + VIR_DOMAIN_NET_MODEL_EEPRO100, + VIR_DOMAIN_NET_MODEL_FTGMAC100, + VIR_DOMAIN_NET_MODEL_IGBVF, + VIR_DOMAIN_NET_MODEL_LASI_I82596, + VIR_DOMAIN_NET_MODEL_MCF_FEC, + VIR_DOMAIN_NET_MODEL_MIPSNET, + VIR_DOMAIN_NET_MODEL_NE2000_ISA, + VIR_DOMAIN_NET_MODEL_NE2000_PCI, + VIR_DOMAIN_NET_MODEL_NPCM7XX_EMC, + VIR_DOMAIN_NET_MODEL_NPCM_GMAC, + VIR_DOMAIN_NET_MODEL_OPENCORES_ETH, + VIR_DOMAIN_NET_MODEL_PCNET_PCI, + VIR_DOMAIN_NET_MODEL_ROCKER, + VIR_DOMAIN_NET_MODEL_SPARP_LLAN, + VIR_DOMAIN_NET_MODEL_SUNGEM, + VIR_DOMAIN_NET_MODEL_SUNHME, + VIR_DOMAIN_NET_MODEL_TULIP, + VIR_DOMAIN_NET_MODEL_VIRTIO_NET, + VIR_DOMAIN_NET_MODEL_XEN_NIC, + VIR_DOMAIN_NET_MODEL_VIRTIO_NET_PCI, + VIR_DOMAIN_NET_MODEL_ETRAXFS_ETH, + VIR_DOMAIN_NET_MODEL_MILKYMIST_MINIMAC2, =20 VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1034bb57f5..fed013835d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2218,6 +2218,13 @@ virDomainNetDefValidate(const virDomainNetDef *net) break; =20 case VIR_DOMAIN_NET_TYPE_NETWORK: + if (net->modelstr) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported model type '%s'"), + net->modelstr); + return -1; + } + break; case VIR_DOMAIN_NET_TYPE_VDPA: case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_CLIENT: --=20 2.47.1