[pdm-devel] [PATCH yew-comp v2 1/2] pve: qemu: options/hardware: prepare and use version feature gating
Dominik Csapak
d.csapak at proxmox.com
Tue Dec 2 12:13:30 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 | 6 ++++
src/configuration/pve/qemu_options_panel.rs | 32 ++++++++++++++++---
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..03ec910 100644
--- a/src/configuration/pve/qemu_hardware_panel/mod.rs
+++ b/src/configuration/pve/qemu_hardware_panel/mod.rs
@@ -13,6 +13,7 @@ use pve_api_types::QemuConfig;
use yew::html::{IntoEventCallback, IntoPropValue};
use yew::virtual_dom::{VComp, VNode};
+use proxmox_deb_version::Version;
use pwt::prelude::*;
use pwt::props::SubmitCallback;
use pwt_macros::builder;
@@ -38,6 +39,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<Version>,
+
/// 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..be91e44 100644
--- a/src/configuration/pve/qemu_options_panel.rs
+++ b/src/configuration/pve/qemu_options_panel.rs
@@ -13,16 +13,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::Version;
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<Version>,
+
/// Use Proxmox Datacenter Manager API endpoints
#[builder(IntoPropValue, into_prop_value)]
#[prop_or_default]
@@ -52,8 +61,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<Version>,
+ 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 +86,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(Version::new(NEWEST_KNOWN_VERSION, None));
+
+ if version >= Version::new("9.1", None) {
+ properties.push(crate::form::pve::qemu_intel_tdx_property(mobile));
+ }
+
+ properties
}
impl Component for PveQemuOptionsPanel {
@@ -82,8 +103,9 @@ impl Component for PveQemuOptionsPanel {
fn create(ctx: &Context<Self>) -> Self {
let props = ctx.props();
+ let version = props.pve_manager_version.clone();
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