[pdm-devel] [PATCH yew-comp 1/2] qemu: options/hardware: prepare and use version feature gating

Dominik Csapak d.csapak at proxmox.com
Tue Dec 2 11:00:00 CET 2025


use the pve-manager version to feature gate the intel-tdx property for
now, but also prepare the hardware panel so we can already start passing
the version to it. If we need it there, we already have it then.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Cargo.toml                                    |  1 +
 .../pve/qemu_hardware_panel/mod.rs            |  5 +++
 src/configuration/pve/qemu_options_panel.rs   | 33 ++++++++++++++++---
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 622bb09..600fafa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -88,6 +88,7 @@ proxmox-node-status = { version = "1", features = [] }
 
 pve-api-types = "8.1.2"
 pbs-api-types = "1"
+proxmox-deb-version = "0.1.0"
 
 [features]
 default = []
diff --git a/src/configuration/pve/qemu_hardware_panel/mod.rs b/src/configuration/pve/qemu_hardware_panel/mod.rs
index 38bc6fd..c04c01f 100644
--- a/src/configuration/pve/qemu_hardware_panel/mod.rs
+++ b/src/configuration/pve/qemu_hardware_panel/mod.rs
@@ -38,6 +38,11 @@ pub struct QemuHardwarePanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries.
+    pve_manager_version: Option<String>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
diff --git a/src/configuration/pve/qemu_options_panel.rs b/src/configuration/pve/qemu_options_panel.rs
index 4843ed9..b45d9bd 100644
--- a/src/configuration/pve/qemu_options_panel.rs
+++ b/src/configuration/pve/qemu_options_panel.rs
@@ -1,3 +1,4 @@
+use std::cmp::Ordering;
 use std::rc::Rc;
 
 use pwt::props::SubmitCallback;
@@ -13,16 +14,25 @@ use crate::pending_property_view::{pending_typed_load, PendingPropertyGrid, Pend
 use crate::EditableProperty;
 use crate::{http_put, percent_encoding::percent_encode_component};
 
+use proxmox_deb_version::cmp_versions;
 use pve_api_types::QemuConfig;
 
 use pwt_macros::builder;
 
+// newest known pve-manager version we care for
+const NEWEST_KNOWN_VERSION: &str = "9.1.2";
+
 #[derive(Clone, PartialEq, Properties)]
 #[builder]
 pub struct QemuOptionsPanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries
+    pve_manager_version: Option<String>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
@@ -52,8 +62,13 @@ pub struct PveQemuOptionsPanel {
     properties: Rc<Vec<EditableProperty>>,
 }
 
-fn properties(node: &str, vmid: u32, mobile: bool) -> Vec<EditableProperty> {
-    vec![
+fn properties(
+    node: &str,
+    vmid: u32,
+    pve_manager_version: Option<&str>,
+    mobile: bool,
+) -> Vec<EditableProperty> {
+    let mut properties = vec![
         crate::form::pve::qemu_name_property(vmid, mobile),
         crate::form::pve::qemu_onboot_property(mobile),
         crate::form::pve::qemu_startup_property(mobile),
@@ -72,8 +87,15 @@ fn properties(node: &str, vmid: u32, mobile: bool) -> Vec<EditableProperty> {
         crate::form::pve::qemu_spice_enhancement_property(mobile),
         crate::form::pve::qemu_vmstatestorage_property(node, mobile),
         crate::form::pve::qemu_amd_sev_property(mobile),
-        crate::form::pve::qemu_intel_tdx_property(mobile),
-    ]
+    ];
+
+    let version = pve_manager_version.unwrap_or(NEWEST_KNOWN_VERSION);
+
+    if cmp_versions(version, "9.1") != Ok(Ordering::Less) {
+        properties.push(crate::form::pve::qemu_intel_tdx_property(mobile));
+    }
+
+    properties
 }
 
 impl Component for PveQemuOptionsPanel {
@@ -82,8 +104,9 @@ impl Component for PveQemuOptionsPanel {
 
     fn create(ctx: &Context<Self>) -> Self {
         let props = ctx.props();
+        let version = props.pve_manager_version.as_deref();
         Self {
-            properties: Rc::new(properties(&props.node, props.vmid, props.mobile)),
+            properties: Rc::new(properties(&props.node, props.vmid, version, props.mobile)),
         }
     }
 
-- 
2.47.3





More information about the pdm-devel mailing list