@@ -68,6 +68,7 @@ fn create_hd(
6868 image_file : impl AsRef < Path > ,
6969 backing_file : Option < impl AsRef < Path > > ,
7070 size : & str ,
71+ work_dir : Option < impl AsRef < Path > > ,
7172) -> Result < ( ) > {
7273 let mut command = Command :: new ( "qemu-img" ) ;
7374 command. arg ( "create" ) . arg ( "-f" ) . arg ( "qcow2" ) ;
@@ -79,6 +80,11 @@ fn create_hd(
7980 }
8081 command. arg ( image_file. as_ref ( ) ) ;
8182 command. arg ( size) ;
83+
84+ // Set working directory if provided
85+ if let Some ( work_dir) = work_dir {
86+ command. current_dir ( work_dir. as_ref ( ) ) ;
87+ }
8288 let output = command. output ( ) ?;
8389 if !output. status . success ( ) {
8490 bail ! (
@@ -233,7 +239,7 @@ impl VmConfig {
233239 let disk_size = format ! ( "{}G" , self . manifest. disk_size) ;
234240 let hda_path = workdir. hda_path ( ) ;
235241 if !hda_path. exists ( ) {
236- create_hd ( & hda_path, self . image . hda . as_ref ( ) , & disk_size) ?;
242+ create_hd ( & hda_path, self . image . hda . as_ref ( ) , & disk_size, Some ( & workdir ) ) ?;
237243 }
238244 if !cfg. user . is_empty ( ) {
239245 fs_err:: set_permissions ( & hda_path, Permissions :: from_mode ( 0o660 ) ) ?;
0 commit comments