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(),
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user