[pdm-devel] [PATCH proxmox-yew-comp 1/1] pve: qemu: handle fallback enum variants

Stefan Hanreich s.hanreich at proxmox.com
Wed Nov 12 10:22:08 CET 2025


pve-api-types introduced a fallback variant for all enums returned by
the Proxmox VE API. Add code for handling those new variants to the
use sites of those enums.

For AMD SEV and BIOS it is sufficient to print the unknown values,
since the Comboboxes prevent the re-submission of unknown values
anyway, due to the force_selection property being set to true.

For the OS type, we cannot uniquely identify if an OS is Windows or
not, since it is possible for an unknown value to be either Windows or
something else. For that case, the respective input field (machine
type), that needs this information to render content, is simply
disabled.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 .../qemu_property/qemu_amd_sev_property.rs    |  1 +
 .../pve/qemu_property/qemu_bios_property.rs   |  1 +
 .../qemu_property/qemu_machine_property.rs    | 20 +++++++++++--------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/form/pve/qemu_property/qemu_amd_sev_property.rs b/src/form/pve/qemu_property/qemu_amd_sev_property.rs
index 72d2dfd..30be125 100644
--- a/src/form/pve/qemu_property/qemu_amd_sev_property.rs
+++ b/src/form/pve/qemu_property/qemu_amd_sev_property.rs
@@ -118,6 +118,7 @@ pub fn qemu_amd_sev_property(mobile: bool) -> EditableProperty {
                         PveQemuSevFmtType::Std => "AMD SEV",
                         PveQemuSevFmtType::Es => "AMD SEV-ES",
                         PveQemuSevFmtType::Snp => "AMD SEV-SNP",
+                        PveQemuSevFmtType::UnknownEnumValue(value) => &format!("unknown '{value}'"),
                     };
                     format!("{text} ({v})").into()
                 }
diff --git a/src/form/pve/qemu_property/qemu_bios_property.rs b/src/form/pve/qemu_property/qemu_bios_property.rs
index 1ae78b3..4acfda4 100644
--- a/src/form/pve/qemu_property/qemu_bios_property.rs
+++ b/src/form/pve/qemu_property/qemu_bios_property.rs
@@ -59,6 +59,7 @@ pub fn qemu_bios_property(mobile: bool) -> EditableProperty {
                 Ok(bios) => match bios {
                     QemuConfigBios::Seabios => "SeaBIOS".into(),
                     QemuConfigBios::Ovmf => "OVMF (UEFI)".into(),
+                    QemuConfigBios::UnknownEnumValue(value) => format!("unknown '{value}'").into(),
                 },
                 Err(_) => v.into(),
             },
diff --git a/src/form/pve/qemu_property/qemu_machine_property.rs b/src/form/pve/qemu_property/qemu_machine_property.rs
index 31ace00..02c1bdb 100644
--- a/src/form/pve/qemu_property/qemu_machine_property.rs
+++ b/src/form/pve/qemu_property/qemu_machine_property.rs
@@ -15,7 +15,7 @@ use crate::form::pve::QemuMachineVersionSelector;
 use crate::pve_api_types::QemuMachineType;
 use crate::{EditableProperty, PropertyEditorState, RenderPropertyInputPanelFn};
 
-fn ostype_is_windows(ostype: &QemuConfigOstype) -> bool {
+fn ostype_is_windows(ostype: &QemuConfigOstype) -> Option<bool> {
     match ostype {
         QemuConfigOstype::Wxp
         | QemuConfigOstype::W2k
@@ -25,11 +25,12 @@ fn ostype_is_windows(ostype: &QemuConfigOstype) -> bool {
         | QemuConfigOstype::Win7
         | QemuConfigOstype::Win8
         | QemuConfigOstype::Win10
-        | QemuConfigOstype::Win11 => true,
+        | QemuConfigOstype::Win11 => Some(true),
         QemuConfigOstype::L24
         | QemuConfigOstype::L26
         | QemuConfigOstype::Solaris
-        | QemuConfigOstype::Other => false,
+        | QemuConfigOstype::Other => Some(false),
+        QemuConfigOstype::UnknownEnumValue(_) => None,
     }
 }
 
@@ -91,12 +92,14 @@ fn input_panel(mobile: bool) -> RenderPropertyInputPanelFn {
         };
 
         let add_version_selector = |panel: &mut InputPanel, ty| {
-            let disabled = machine_type != ty;
+            let is_windows = ostype_is_windows(&ostype);
+            let disabled = machine_type != ty || is_windows.is_none();
             let name = get_version_prop_name(ty.to_string());
+
             let field = QemuMachineVersionSelector::new(ty)
                 .name(name)
-                .disabled(machine_type != ty)
-                .required(ostype_is_windows(&ostype))
+                .disabled(disabled)
+                .required(is_windows.unwrap_or_default())
                 .submit(false);
             panel.add_field_with_options(
                 FieldPosition::Left,
@@ -181,8 +184,9 @@ pub fn qemu_machine_property(mobile: bool) -> EditableProperty {
                 serde_json::from_value(record["ostype"].clone()).ok();
             let ostype = ostype.unwrap_or(QemuConfigOstype::Other);
             match (v.as_str(), ostype_is_windows(&ostype)) {
-                (None | Some("pc"), true) => "pc-i440fx-5.1".into(),
-                (Some("q35"), true) => "pc-q35-5.1".into(),
+                (_, None) => format!("unknown ostype: {v}").into(),
+                (None | Some("pc"), Some(true)) => "pc-i440fx-5.1".into(),
+                (Some("q35"), Some(true)) => "pc-q35-5.1".into(),
                 (Some(machine), _) => machine.into(),
                 (None, _) => placeholder().into(),
             }
-- 
2.47.3




More information about the pdm-devel mailing list