From b4f765d4867bd66fa85b5e1223f054e7d9c076c4 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Wed, 27 Dec 2023 10:27:19 +0100 Subject: [PATCH] Change network model type to support GigaByte transfers --- virtweb_backend/src/libvirt_lib_structures.rs | 10 ++++++++++ virtweb_backend/src/libvirt_rest_structures.rs | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/virtweb_backend/src/libvirt_lib_structures.rs b/virtweb_backend/src/libvirt_lib_structures.rs index 34ac820..8671b91 100644 --- a/virtweb_backend/src/libvirt_lib_structures.rs +++ b/virtweb_backend/src/libvirt_lib_structures.rs @@ -77,13 +77,23 @@ pub struct NetIntSourceXML { pub network: String, } +#[derive(serde::Serialize, serde::Deserialize)] +#[serde(rename = "model")] +pub struct NetIntModelXML { + #[serde(rename(serialize = "@type"))] + pub r#type: String, +} + #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename = "interface")] pub struct DomainNetInterfaceXML { #[serde(rename(serialize = "@type"))] pub r#type: String, pub mac: NetMacAddress, + #[serde(skip_serializing_if = "Option::is_none")] pub source: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub model: Option, } #[derive(serde::Serialize, serde::Deserialize)] diff --git a/virtweb_backend/src/libvirt_rest_structures.rs b/virtweb_backend/src/libvirt_rest_structures.rs index 99a6856..c9438b4 100644 --- a/virtweb_backend/src/libvirt_rest_structures.rs +++ b/virtweb_backend/src/libvirt_rest_structures.rs @@ -3,8 +3,8 @@ use crate::constants; use crate::libvirt_lib_structures::{ DevicesXML, DiskBootXML, DiskDriverXML, DiskReadOnlyXML, DiskSourceXML, DiskTargetXML, DiskXML, DomainCPUTopology, DomainCPUXML, DomainInputXML, DomainMemoryXML, DomainNetInterfaceXML, - DomainVCPUXML, DomainXML, FeaturesXML, GraphicsXML, NetIntSourceXML, NetMacAddress, - NetworkBridgeXML, NetworkDHCPHostXML, NetworkDHCPRangeXML, NetworkDHCPXML, + DomainVCPUXML, DomainXML, FeaturesXML, GraphicsXML, NetIntModelXML, NetIntSourceXML, + NetMacAddress, NetworkBridgeXML, NetworkDHCPHostXML, NetworkDHCPRangeXML, NetworkDHCPXML, NetworkDNSForwarderXML, NetworkDNSXML, NetworkDomainXML, NetworkForwardXML, NetworkIPXML, NetworkXML, OSLoaderXML, OSTypeXML, TPMBackendXML, TPMDeviceXML, VideoModelXML, VideoXML, XMLUuid, ACPIXML, OSXML, @@ -250,6 +250,9 @@ impl VMInfo { }, r#type: "user".to_string(), source: None, + model: Some(NetIntModelXML { + r#type: "virtio".to_string(), + }), }, NetworkType::DefinedNetwork { network } => DomainNetInterfaceXML { mac: NetMacAddress { @@ -259,6 +262,9 @@ impl VMInfo { source: Some(NetIntSourceXML { network: network.to_string(), }), + model: Some(NetIntModelXML { + r#type: "virtio".to_string(), + }), }, }) }