Change graphics driver model used for VNC connections

This commit is contained in:
Pierre HUBERT 2023-12-11 16:12:41 +01:00
parent 78ed6114c8
commit 299b63cd32
2 changed files with 40 additions and 12 deletions

View File

@ -90,10 +90,14 @@ pub struct DomainInputXML {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename = "devices")]
pub struct DevicesXML {
/// Graphics (used for VNC
/// Graphics (used for VNC)
#[serde(skip_serializing_if = "Option::is_none")]
pub graphics: Option<GraphicsXML>,
/// Graphics (used for VNC)
#[serde(skip_serializing_if = "Option::is_none")]
pub video: Option<VideoXML>,
/// Disks (used for storage)
#[serde(default, rename = "disk", skip_serializing_if = "Vec::is_empty")]
pub disks: Vec<DiskXML>,
@ -107,7 +111,7 @@ pub struct DevicesXML {
pub inputs: Vec<DomainInputXML>,
}
/// Screen information
/// Graphics information
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename = "graphics")]
pub struct GraphicsXML {
@ -117,6 +121,21 @@ pub struct GraphicsXML {
pub socket: String,
}
/// Video device information
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename = "video")]
pub struct VideoXML {
pub model: VideoModelXML,
}
/// Video model device information
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename = "model")]
pub struct VideoModelXML {
#[serde(rename(serialize = "@type"))]
pub r#type: String,
}
/// Disk information
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename = "disk")]

View File

@ -5,7 +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, XMLUuid, ACPIXML, OSXML,
NetworkIPXML, NetworkXML, OSLoaderXML, OSTypeXML, VideoModelXML, VideoXML, XMLUuid, ACPIXML,
OSXML,
};
use crate::libvirt_rest_structures::LibVirtStructError::StructureExtraction;
use crate::utils::disks_utils::Disk;
@ -170,15 +171,22 @@ impl VMInfo {
})
}
let vnc_graphics = match self.vnc_access {
true => Some(GraphicsXML {
r#type: "vnc".to_string(),
socket: AppConfig::get()
.vnc_socket_for_domain(&self.name)
.to_string_lossy()
.to_string(),
}),
false => None,
let (vnc_graphics, vnc_video) = match self.vnc_access {
true => (
Some(GraphicsXML {
r#type: "vnc".to_string(),
socket: AppConfig::get()
.vnc_socket_for_domain(&self.name)
.to_string_lossy()
.to_string(),
}),
Some(VideoXML {
model: VideoModelXML {
r#type: "qxl".to_string(),
},
}),
),
false => (None, None),
};
// Check disks name for duplicates
@ -268,6 +276,7 @@ impl VMInfo {
devices: DevicesXML {
graphics: vnc_graphics,
video: vnc_video,
disks,
net_interfaces: networks,
inputs: vec![