From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id E6EA51FF0B2 for ; Fri, 09 Oct 2026 11:00:37 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 036D821625; Fri, 09 Oct 2026 11:00:19 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs 2/2] ve-config: guest: add fallback enum variant Date: Fri, 9 Oct 2026 11:00:04 +0200 Message-ID: <20261009090006.104013-3-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261009090006.104013-1-s.hanreich@proxmox.com> References: <20261009090006.104013-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791536414725 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.615 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: LENCFE3AWB6SY5CSUOEF7MONHQXMMCWU X-Message-ID-Hash: LENCFE3AWB6SY5CSUOEF7MONHQXMMCWU X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In order for ve-config to stay forward-compatible with the addition of new network interface types, introduce a fallback variant to contain any potential unknown variants that may be introduced in the future. Since the netX properties in qemu-server use KeyAliasInfo, and the struct does not provide the possibility of allowing arbitrary keys, this does not allow using arbitrary models when using the short form - which is currently prevalent in the configuration files. Signed-off-by: Stefan Hanreich --- Notes: Practically not really an improvement, but I had it initially and thought it wouldn't hurt to include it in the series nonetheles. If not desired or deemed to useless, this patch can be dropped when applying. Cargo.toml | 1 + proxmox-ve-config/Cargo.toml | 1 + proxmox-ve-config/src/guest/vm.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4655b178..2f9058dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ regex = "1.7" serde = { version = "1" } thiserror = "2.0.0" +proxmox-fixed-string = { version = "0.1.1" } proxmox-frr = { version = "0.5.1", path = "proxmox-frr" } proxmox-network-types = { version = "1.1.2" } proxmox-schema = { version = "5" } diff --git a/proxmox-ve-config/Cargo.toml b/proxmox-ve-config/Cargo.toml index 7e3939d4..3d5aa9eb 100644 --- a/proxmox-ve-config/Cargo.toml +++ b/proxmox-ve-config/Cargo.toml @@ -19,6 +19,7 @@ serde = { workspace = true, features = [ "derive" ] } serde_json = "1" proxmox-base64 = "1" +proxmox-fixed-string.workspace = true proxmox-frr = { workspace = true, optional = true } proxmox-network-types = { workspace = true, features = [ "api-types" ] } proxmox-schema = { workspace = true, features = [ "api-types" ] } diff --git a/proxmox-ve-config/src/guest/vm.rs b/proxmox-ve-config/src/guest/vm.rs index cebcb9e6..3ce04c73 100644 --- a/proxmox-ve-config/src/guest/vm.rs +++ b/proxmox-ve-config/src/guest/vm.rs @@ -2,7 +2,8 @@ use std::collections::BTreeMap; use std::io; use std::str::FromStr; -use anyhow::{Error, bail}; +use anyhow::{Context, Error, bail}; +use proxmox_fixed_string::FixedString; use serde::Deserialize; use proxmox_network_types::ip_address::{Ipv4Cidr, Ipv6Cidr}; @@ -32,6 +33,7 @@ pub enum NetworkDeviceModel { Ne2kIsa, Ne2kPci, Pcnet, + UnknownEnumValue(FixedString), } proxmox_serde::forward_deserialize_to_from_str!(NetworkDeviceModel); @@ -56,7 +58,12 @@ impl FromStr for NetworkDeviceModel { "ne2k_isa" => Ok(NetworkDeviceModel::Ne2kIsa), "ne2k_pci" => Ok(NetworkDeviceModel::Ne2kPci), "pcnet" => Ok(NetworkDeviceModel::Pcnet), - _ => bail!("Invalid network device model: {s}"), + _ => { + let unknown_variant = FixedString::try_from(s) + .with_context(|| format!("unable to parse network device model {s}"))?; + + Ok(NetworkDeviceModel::UnknownEnumValue(unknown_variant)) + } } } } -- 2.47.3