diff --git a/virtweb_backend/src/actors/libvirt_actor.rs b/virtweb_backend/src/actors/libvirt_actor.rs index 5606dfa..8e67d1d 100644 --- a/virtweb_backend/src/actors/libvirt_actor.rs +++ b/virtweb_backend/src/actors/libvirt_actor.rs @@ -102,7 +102,7 @@ impl Handler for LibVirtActor { let domain = Domain::lookup_by_uuid_string(&self.m, &msg.0.as_string())?; let xml = domain.get_xml_desc(VIR_DOMAIN_XML_SECURE)?; log::debug!("XML = {}", xml); - Ok(serde_xml_rs::from_str(&xml)?) + DomainXML::parse_xml(&xml) } } @@ -436,7 +436,7 @@ impl Handler for LibVirtActor { let network = Network::lookup_by_uuid_string(&self.m, &msg.0.as_string())?; let xml = network.get_xml_desc(0)?; log::debug!("XML = {}", xml); - Ok(serde_xml_rs::from_str(&xml)?) + NetworkXML::parse_xml(&xml) } } diff --git a/virtweb_backend/src/libvirt_lib_structures/domain.rs b/virtweb_backend/src/libvirt_lib_structures/domain.rs index 6f3dde2..6711003 100644 --- a/virtweb_backend/src/libvirt_lib_structures/domain.rs +++ b/virtweb_backend/src/libvirt_lib_structures/domain.rs @@ -308,6 +308,11 @@ pub struct DomainXML { } impl DomainXML { + /// Decode Domain structure from XML definition + pub fn parse_xml(xml: &str) -> anyhow::Result { + Ok(serde_xml_rs::from_str(xml)?) + } + /// Turn this domain into its XML definition pub fn into_xml(mut self) -> anyhow::Result { // A issue with the disks & network interface definition serialization needs them to be serialized aside diff --git a/virtweb_backend/src/libvirt_lib_structures/network.rs b/virtweb_backend/src/libvirt_lib_structures/network.rs index 71fc82d..6bc275e 100644 --- a/virtweb_backend/src/libvirt_lib_structures/network.rs +++ b/virtweb_backend/src/libvirt_lib_structures/network.rs @@ -155,6 +155,9 @@ pub struct NetworkXML { } impl NetworkXML { + pub fn parse_xml(xml: &str) -> anyhow::Result { + Ok(serde_xml_rs::from_str(xml)?) + } pub fn into_xml(mut self) -> anyhow::Result { // A issue with the IPs definition serialization needs them to be serialized aside let mut ips_xml = Vec::with_capacity(self.ips.len());