Skip to main content

clientapi_pve/models/
pve_machine_config.rs

1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PveMachineConfig {
16
17    /// Specifies the vIOMMU address space bit width.  Intel vIOMMU supports a bit width of either 39 or 48 bits and VirtIO vIOMMU supports any bit width between 32 and 64 bits.
18    #[serde(rename = "aw-bits", skip_serializing_if = "Option::is_none")]
19    pub aw_bits: Option<f64>,
20
21    /// Enables S3 power state. Defaults to false beginning with machine types 9.2+pve1, true before.
22    #[serde(rename = "enable-s3", skip_serializing_if = "Option::is_none")]
23    pub enable_s3: Option<models::PveBoolean>,
24
25    /// Enables S4 power state. Defaults to false beginning with machine types 9.2+pve1, true before.
26    #[serde(rename = "enable-s4", skip_serializing_if = "Option::is_none")]
27    pub enable_s4: Option<models::PveBoolean>,
28
29    /// Specifies the QEMU machine type.
30    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
31    pub r#type: Option<String>,
32
33    /// Enable and set guest vIOMMU variant (Intel vIOMMU needs q35 to be set as machine type).
34    #[serde(rename = "viommu", skip_serializing_if = "Option::is_none")]
35    pub viommu: Option<models::PveViommuEnum>,
36
37
38}
39
40impl PveMachineConfig {
41    pub fn new() -> PveMachineConfig {
42        PveMachineConfig {
43            
44            aw_bits: None,
45            
46            enable_s3: None,
47            
48            enable_s4: None,
49            
50            r#type: None,
51            
52            viommu: None,
53            
54        }
55    }
56}
57
58
59impl PveMachineConfig {
60    /// Serialise this PveMachineConfig into Proxmox's CLI-style shorthand
61    /// string (`key=value,…`). The property marked `x-pve-default-key`
62    /// is emitted positionally without a `key=` prefix; aliases collapse
63    /// multiple property names to the same wire key.
64    ///
65    /// Example: `PveMachineConfig `
66    /// → `"virtio,bridge=vmbr0"`
67    pub fn to_shorthand(&self) -> String {
68        let mut parts: Vec<String> = Vec::new();
69        
70        
71        if let Some(ref v) = self.r#type {
72            parts.push(format!("{}", v));
73        }
74        
75        
76        
77        if let Some(ref v) = self.aw_bits {
78            parts.push(format!("aw-bits={}", v));
79        }
80        
81        
82        if let Some(ref v) = self.enable_s3 {
83            parts.push(format!("enable-s3={}", v));
84        }
85        
86        
87        if let Some(ref v) = self.enable_s4 {
88            parts.push(format!("enable-s4={}", v));
89        }
90        
91        
92        if let Some(ref v) = self.viommu {
93            parts.push(format!("viommu={}", v));
94        }
95        
96        parts.join(",")
97    }
98}
99