File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use clap::{Parser, ValueEnum};
99use color_eyre:: eyre;
1010use color_eyre:: { eyre:: Context , Result } ;
1111use std:: fs;
12+ use std:: io:: Write ;
1213use std:: str:: FromStr ;
1314use tracing:: { debug, info} ;
1415
@@ -1296,8 +1297,13 @@ fn create_libvirt_domain_from_disk(
12961297 . with_context ( || "Failed to build domain XML" ) ?;
12971298
12981299 // Write XML to temporary file
1299- let xml_path = format ! ( "/tmp/{}.xml" , domain_name) ;
1300- std:: fs:: write ( & xml_path, domain_xml) . with_context ( || "Failed to write domain XML" ) ?;
1300+ let mut tmp_domain_file = tempfile:: NamedTempFile :: with_prefix ( "bcvk-libvirt" ) ?;
1301+ tmp_domain_file
1302+ . as_file_mut ( )
1303+ . write_all ( domain_xml. as_bytes ( ) )
1304+ . with_context ( || "Failed to write domain XML" ) ?;
1305+ let xml_path: & Utf8Path = tmp_domain_file. path ( ) . try_into ( ) ?;
1306+ let xml_path = xml_path. as_str ( ) ;
13011307
13021308 let connect_uri = global_opts. connect . as_deref ( ) ;
13031309
@@ -1323,8 +1329,5 @@ fn create_libvirt_domain_from_disk(
13231329 ) ?;
13241330 }
13251331
1326- // Clean up temporary XML file
1327- let _ = std:: fs:: remove_file ( & xml_path) ;
1328-
13291332 Ok ( ( ) )
13301333}
You can’t perform that action at this time.
0 commit comments