@@ -310,6 +310,32 @@ pub struct KeyProviderConfig {
310310 pub port : u16 ,
311311}
312312
313+ const CLIENT_CONF_PATH : & str = "/etc/dstack/client.conf" ;
314+ fn read_qemu_path_from_client_conf ( ) -> Option < PathBuf > {
315+ #[ derive( Debug , Deserialize ) ]
316+ struct ClientQemuSection {
317+ path : Option < String > ,
318+ }
319+ #[ derive( Debug , Deserialize ) ]
320+ struct ClientIniConfig {
321+ qemu : Option < ClientQemuSection > ,
322+ }
323+
324+ let raw = fs_err:: read_to_string ( CLIENT_CONF_PATH ) . ok ( ) ?;
325+ let parsed: ClientIniConfig = serde_ini:: from_str ( & raw ) . ok ( ) ?;
326+ let path = parsed. qemu ?. path ?;
327+ let path = path. trim ( ) . trim_matches ( '"' ) . trim_matches ( '\'' ) ;
328+ if path. is_empty ( ) {
329+ return None ;
330+ }
331+ let path = PathBuf :: from ( path) ;
332+ if path. exists ( ) {
333+ Some ( path)
334+ } else {
335+ None
336+ }
337+ }
338+
313339impl Config {
314340 pub fn extract_or_default ( figment : & Figment ) -> Result < Self > {
315341 let mut me: Self = figment. extract ( ) ?;
@@ -323,11 +349,18 @@ impl Config {
323349 me. run_path = app_home. join ( "vm" ) ;
324350 }
325351 if me. cvm . qemu_path == PathBuf :: default ( ) {
326- let cpu_arch = std:: env:: consts:: ARCH ;
327- let qemu_path = which:: which ( format ! ( "qemu-system-{}" , cpu_arch) )
328- . context ( "Failed to find qemu executable" ) ?;
329- me. cvm . qemu_path = qemu_path;
352+ // Prefer the path from dstack client config if present
353+ if let Some ( qemu_path) = read_qemu_path_from_client_conf ( ) {
354+ info ! ( "Found QEMU path from client config: {CLIENT_CONF_PATH:?}" ) ;
355+ me. cvm . qemu_path = qemu_path;
356+ } else {
357+ let cpu_arch = std:: env:: consts:: ARCH ;
358+ let qemu_path = which:: which ( format ! ( "qemu-system-{}" , cpu_arch) )
359+ . context ( "Failed to find qemu executable" ) ?;
360+ me. cvm . qemu_path = qemu_path;
361+ }
330362 }
363+ info ! ( "QEMU path: {}" , me. cvm. qemu_path. display( ) ) ;
331364 }
332365 Ok ( me)
333366 }
0 commit comments