diff --git a/virtweb_backend/src/libvirt_lib_structures.rs b/virtweb_backend/src/libvirt_lib_structures.rs index acc1138..7debd72 100644 --- a/virtweb_backend/src/libvirt_lib_structures.rs +++ b/virtweb_backend/src/libvirt_lib_structures.rs @@ -32,6 +32,8 @@ pub struct OSXML { pub struct OSTypeXML { #[serde(rename(serialize = "@arch"))] pub arch: String, + #[serde(rename(serialize = "@machine"))] + pub machine: String, #[serde(rename = "$value")] pub body: String, } @@ -93,7 +95,8 @@ pub struct DiskXML { pub target: DiskTargetXML, pub readonly: DiskReadOnlyXML, pub boot: DiskBootXML, - pub address: DiskAddressXML, + #[serde(skip_serializing_if = "Option::is_none")] + pub address: Option, } #[derive(serde::Serialize, serde::Deserialize)] @@ -137,14 +140,26 @@ pub struct DiskBootXML { pub struct DiskAddressXML { #[serde(rename(serialize = "@type"))] pub r#type: String, - #[serde(rename(serialize = "@controller"))] - pub r#controller: String, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename(serialize = "@controller") + )] + pub r#controller: Option, #[serde(rename(serialize = "@bus"))] pub r#bus: String, - #[serde(rename(serialize = "@target"))] - pub r#target: String, - #[serde(rename(serialize = "@unit"))] - pub r#unit: String, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename(serialize = "@target") + )] + pub r#target: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename(serialize = "@unit") + )] + pub r#unit: Option, } /// Domain RAM information diff --git a/virtweb_backend/src/libvirt_rest_structures.rs b/virtweb_backend/src/libvirt_rest_structures.rs index c334f83..82617e2 100644 --- a/virtweb_backend/src/libvirt_rest_structures.rs +++ b/virtweb_backend/src/libvirt_rest_structures.rs @@ -1,9 +1,9 @@ use crate::app_config::AppConfig; use crate::constants; use crate::libvirt_lib_structures::{ - DevicesXML, DiskAddressXML, DiskBootXML, DiskDriverXML, DiskReadOnlyXML, DiskSourceXML, - DiskTargetXML, DiskXML, DomainMemoryXML, DomainXML, DomainXMLUuid, FeaturesXML, GraphicsXML, - OSLoaderXML, OSTypeXML, ACPIXML, OSXML, + DevicesXML, DiskBootXML, DiskDriverXML, DiskReadOnlyXML, DiskSourceXML, DiskTargetXML, DiskXML, + DomainMemoryXML, DomainXML, DomainXMLUuid, FeaturesXML, GraphicsXML, OSLoaderXML, OSTypeXML, + ACPIXML, OSXML, }; use crate::libvirt_rest_structures::LibVirtStructError::StructureExtraction; use crate::utils::files_utils; @@ -133,19 +133,19 @@ impl VMInfo { }, target: DiskTargetXML { dev: "hdc".to_string(), - bus: "ide".to_string(), + bus: "usb".to_string(), }, readonly: DiskReadOnlyXML {}, boot: DiskBootXML { order: "1".to_string(), }, - address: DiskAddressXML { - r#type: "drive".to_string(), - controller: "0".to_string(), - bus: "1".to_string(), - target: "0".to_string(), - unit: "0".to_string(), - }, + address: None, /*DiskAddressXML { + r#type: "drive".to_string(), + controller: "0".to_string(), + bus: "1".to_string(), + target: "0".to_string(), + unit: "0".to_string(), + },*/ }) } @@ -176,6 +176,7 @@ impl VMInfo { VMArchitecture::X86_64 => "x86_64", } .to_string(), + machine: "q35".to_string(), body: "hvm".to_string(), }, firmware: "efi".to_string(),