From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D8FDD1FF179 for ; Wed, 12 Nov 2025 10:22:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 20DC41BB3F; Wed, 12 Nov 2025 10:23:02 +0100 (CET) From: Stefan Hanreich To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 10:22:08 +0100 Message-ID: <20251112092225.17890-5-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112092225.17890-1-s.hanreich@proxmox.com> References: <20251112092225.17890-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.173 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pdm-devel] [PATCH proxmox-yew-comp 1/1] pve: qemu: handle fallback enum variants X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- .../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 { 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 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel