@@ -291,6 +291,7 @@ fn main() -> Result<ExitCode> {
291291 }
292292 }
293293
294+ let mut enable_hidpipe = false ;
294295 if let Ok ( run_path) = env:: var ( "XDG_RUNTIME_DIR" ) {
295296 let pulse_path = Path :: new ( & run_path) . join ( "pulse/native" ) ;
296297 if pulse_path. exists ( ) {
@@ -309,19 +310,22 @@ fn main() -> Result<ExitCode> {
309310 }
310311
311312 let hidpipe_path = Path :: new ( & run_path) . join ( "hidpipe" ) ;
312- spawn_hidpipe_server ( hidpipe_path. clone ( ) ) . context ( "Failed to spawn hidpipe thread" ) ?;
313- let hidpipe_path = CString :: new (
314- hidpipe_path
315- . to_str ( )
316- . expect ( "hidpipe_path should not contain invalid UTF-8" ) ,
317- )
318- . context ( "Failed to process `hidpipe` path as it contains NUL character" ) ?;
313+ enable_hidpipe =
314+ spawn_hidpipe_server ( hidpipe_path. clone ( ) ) . context ( "Failed to spawn hidpipe thread" ) ?;
315+ if enable_hidpipe {
316+ let hidpipe_path = CString :: new (
317+ hidpipe_path
318+ . to_str ( )
319+ . expect ( "hidpipe_path should not contain invalid UTF-8" ) ,
320+ )
321+ . context ( "Failed to process `hidpipe` path as it contains NUL character" ) ?;
319322
320- // SAFETY: `hidpipe_path` is a pointer to a `CString` with long enough lifetime.
321- let err = unsafe { krun_add_vsock_port ( ctx_id, HIDPIPE_SOCKET , hidpipe_path. as_ptr ( ) ) } ;
322- if err < 0 {
323- let err = Errno :: from_raw_os_error ( -err) ;
324- return Err ( err) . context ( "Failed to configure vsock for hidpipe socket" ) ;
323+ // SAFETY: `hidpipe_path` is a pointer to a `CString` with long enough lifetime.
324+ let err = unsafe { krun_add_vsock_port ( ctx_id, HIDPIPE_SOCKET , hidpipe_path. as_ptr ( ) ) } ;
325+ if err < 0 {
326+ let err = Errno :: from_raw_os_error ( -err) ;
327+ return Err ( err) . context ( "Failed to configure vsock for hidpipe socket" ) ;
328+ }
325329 }
326330
327331 let socket_dir = Path :: new ( & run_path) . join ( "krun/socket" ) ;
@@ -413,6 +417,7 @@ fn main() -> Result<ExitCode> {
413417 cwd,
414418 init_commands,
415419 user_init_commands : options. user_init_commands ,
420+ enable_hidpipe,
416421 } ;
417422 let mut muvm_config_file = NamedTempFile :: new ( )
418423 . context ( "Failed to create a temporary file to store the muvm guest config" ) ?;
0 commit comments