From: Stefan Hanreich <s.hanreich@proxmox.com>
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 [thread overview]
Message-ID: <20261009090006.104013-3-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261009090006.104013-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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
prev parent reply other threads:[~2026-10-09 9:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 9:00 [PATCH proxmox-ve-rs 0/2] fix network interface name parsing Stefan Hanreich
2026-10-09 9:00 ` [PATCH proxmox-ve-rs 1/2] fix #7584: ve-config: guest: add missing network interface models Stefan Hanreich
2026-10-09 9:00 ` Stefan Hanreich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261009090006.104013-3-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox