Delete VNC socket file when deleting domain
This commit is contained in:
		@@ -165,6 +165,15 @@ impl Handler<DeleteDomainReq> for LibVirtActor {
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        let domain = Domain::lookup_by_uuid_string(&self.m, &msg.id.as_string())?;
 | 
			
		||||
        let domain_name = domain.get_name()?;
 | 
			
		||||
 | 
			
		||||
        // Remove VNC socket
 | 
			
		||||
        let vnc_socket = AppConfig::get().vnc_socket_for_domain(&domain_name);
 | 
			
		||||
        if vnc_socket.exists() {
 | 
			
		||||
            std::fs::remove_file(vnc_socket)?;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Delete the domain
 | 
			
		||||
        domain.undefine_flags(match msg.keep_files {
 | 
			
		||||
            true => sys::VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,
 | 
			
		||||
            false => sys::VIR_DOMAIN_UNDEFINE_NVRAM,
 | 
			
		||||
 
 | 
			
		||||
@@ -172,6 +172,11 @@ impl AppConfig {
 | 
			
		||||
        self.storage_path().join("vnc")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Get VM vnc sockets path for domain
 | 
			
		||||
    pub fn vnc_socket_for_domain(&self, name: &str) -> PathBuf {
 | 
			
		||||
        self.vnc_sockets_path().join(format!("vnc-{}", name))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Get VM vnc sockets directory
 | 
			
		||||
    pub fn disks_storage_path(&self) -> PathBuf {
 | 
			
		||||
        self.storage_path().join("disks")
 | 
			
		||||
 
 | 
			
		||||
@@ -174,8 +174,7 @@ impl VMInfo {
 | 
			
		||||
            true => Some(GraphicsXML {
 | 
			
		||||
                r#type: "vnc".to_string(),
 | 
			
		||||
                socket: AppConfig::get()
 | 
			
		||||
                    .vnc_sockets_path()
 | 
			
		||||
                    .join(format!("vnc-{}", self.name))
 | 
			
		||||
                    .vnc_socket_for_domain(&self.name)
 | 
			
		||||
                    .to_string_lossy()
 | 
			
		||||
                    .to_string(),
 | 
			
		||||
            }),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user