Can add TPM2 chipset
This commit is contained in:
		@@ -86,6 +86,24 @@ pub struct DomainInputXML {
 | 
			
		||||
    pub r#type: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize)]
 | 
			
		||||
#[serde(rename = "backend")]
 | 
			
		||||
pub struct TPMBackendXML {
 | 
			
		||||
    #[serde(rename(serialize = "@type"))]
 | 
			
		||||
    pub r#type: String,
 | 
			
		||||
 | 
			
		||||
    #[serde(rename(serialize = "@version"))]
 | 
			
		||||
    pub r#version: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize)]
 | 
			
		||||
#[serde(rename = "tpm")]
 | 
			
		||||
pub struct TPMDeviceXML {
 | 
			
		||||
    #[serde(rename(serialize = "@model"))]
 | 
			
		||||
    pub model: String,
 | 
			
		||||
    pub backend: TPMBackendXML,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Devices information
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize)]
 | 
			
		||||
#[serde(rename = "devices")]
 | 
			
		||||
@@ -109,6 +127,10 @@ pub struct DevicesXML {
 | 
			
		||||
    /// Input devices
 | 
			
		||||
    #[serde(default, rename = "input", skip_serializing_if = "Vec::is_empty")]
 | 
			
		||||
    pub inputs: Vec<DomainInputXML>,
 | 
			
		||||
 | 
			
		||||
    /// TPM device
 | 
			
		||||
    #[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub tpm: Option<TPMDeviceXML>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Graphics information
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@ use crate::libvirt_lib_structures::{
 | 
			
		||||
    DomainCPUTopology, DomainCPUXML, DomainInputXML, DomainMemoryXML, DomainNetInterfaceXML,
 | 
			
		||||
    DomainVCPUXML, DomainXML, FeaturesXML, GraphicsXML, NetIntSourceXML, NetworkDHCPRangeXML,
 | 
			
		||||
    NetworkDHCPXML, NetworkDNSForwarderXML, NetworkDNSXML, NetworkDomainXML, NetworkForwardXML,
 | 
			
		||||
    NetworkIPXML, NetworkXML, OSLoaderXML, OSTypeXML, VideoModelXML, VideoXML, XMLUuid, ACPIXML,
 | 
			
		||||
    OSXML,
 | 
			
		||||
    NetworkIPXML, NetworkXML, OSLoaderXML, OSTypeXML, TPMBackendXML, TPMDeviceXML, VideoModelXML,
 | 
			
		||||
    VideoXML, XMLUuid, ACPIXML, OSXML,
 | 
			
		||||
};
 | 
			
		||||
use crate::libvirt_rest_structures::LibVirtStructError::StructureExtraction;
 | 
			
		||||
use crate::utils::disks_utils::Disk;
 | 
			
		||||
@@ -94,6 +94,8 @@ pub struct VMInfo {
 | 
			
		||||
    pub disks: Vec<Disk>,
 | 
			
		||||
    /// Network cards
 | 
			
		||||
    pub networks: Vec<Network>,
 | 
			
		||||
    /// Add a TPM v2.0 module
 | 
			
		||||
    pub tpm_module: bool,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl VMInfo {
 | 
			
		||||
@@ -290,6 +292,16 @@ impl VMInfo {
 | 
			
		||||
                        r#type: "tablet".to_string(),
 | 
			
		||||
                    },
 | 
			
		||||
                ],
 | 
			
		||||
                tpm: match self.tpm_module {
 | 
			
		||||
                    true => Some(TPMDeviceXML {
 | 
			
		||||
                        model: "tpm-tis".to_string(),
 | 
			
		||||
                        backend: TPMBackendXML {
 | 
			
		||||
                            r#type: "emulator".to_string(),
 | 
			
		||||
                            version: "2.0".to_string(),
 | 
			
		||||
                        },
 | 
			
		||||
                    }),
 | 
			
		||||
                    false => None,
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            memory: DomainMemoryXML {
 | 
			
		||||
@@ -380,6 +392,8 @@ impl VMInfo {
 | 
			
		||||
                    ))),
 | 
			
		||||
                })
 | 
			
		||||
                .collect::<Result<Vec<_>, _>>()?,
 | 
			
		||||
 | 
			
		||||
            tpm_module: domain.devices.tpm.is_some(),
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,7 @@ interface VMInfoInterface {
 | 
			
		||||
  iso_files: string[];
 | 
			
		||||
  disks: VMDisk[];
 | 
			
		||||
  networks: VMNetInterface[];
 | 
			
		||||
  tpm_module: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class VMInfo implements VMInfoInterface {
 | 
			
		||||
@@ -71,6 +72,7 @@ export class VMInfo implements VMInfoInterface {
 | 
			
		||||
  iso_files: string[];
 | 
			
		||||
  disks: VMDisk[];
 | 
			
		||||
  networks: VMNetInterface[];
 | 
			
		||||
  tpm_module: boolean;
 | 
			
		||||
 | 
			
		||||
  constructor(int: VMInfoInterface) {
 | 
			
		||||
    this.name = int.name;
 | 
			
		||||
@@ -86,6 +88,7 @@ export class VMInfo implements VMInfoInterface {
 | 
			
		||||
    this.iso_files = int.iso_files;
 | 
			
		||||
    this.disks = int.disks;
 | 
			
		||||
    this.networks = int.networks;
 | 
			
		||||
    this.tpm_module = int.tpm_module;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static NewEmpty(): VMInfo {
 | 
			
		||||
@@ -99,6 +102,7 @@ export class VMInfo implements VMInfoInterface {
 | 
			
		||||
      iso_files: [],
 | 
			
		||||
      disks: [],
 | 
			
		||||
      networks: [],
 | 
			
		||||
      tpm_module: true,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -187,6 +187,17 @@ function VMDetailsInner(
 | 
			
		||||
            p.onChange?.();
 | 
			
		||||
          }}
 | 
			
		||||
        />
 | 
			
		||||
        <br />
 | 
			
		||||
 | 
			
		||||
        <CheckboxInput
 | 
			
		||||
          editable={p.editable}
 | 
			
		||||
          label="Enable TPM 2.0 module"
 | 
			
		||||
          checked={p.vm.tpm_module}
 | 
			
		||||
          onValueChange={(v) => {
 | 
			
		||||
            p.vm.tpm_module = v;
 | 
			
		||||
            p.onChange?.();
 | 
			
		||||
          }}
 | 
			
		||||
        />
 | 
			
		||||
 | 
			
		||||
        {p.vm.uuid && (
 | 
			
		||||
          <ResAutostartInput
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user