File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use krun_guest::user::setup_user;
1313use krun_guest:: x11:: setup_x11_forwarding;
1414use log:: debug;
1515use rustix:: process:: { getrlimit, setrlimit, Resource } ;
16+ use utils:: env:: find_in_path;
1617
1718fn main ( ) -> Result < ( ) > {
1819 env_logger:: init ( ) ;
@@ -37,11 +38,16 @@ fn main() -> Result<()> {
3738 if let Err ( err) = mount_filesystems ( ) {
3839 return Err ( err) . context ( "Failed to mount filesystems, bailing out" ) ;
3940 }
41+ Command :: new ( "/usr/lib/systemd/systemd-udevd" ) . spawn ( ) ?;
4042
4143 setup_fex ( ) ?;
4244
4345 configure_network ( ) ?;
4446
47+ if let Some ( hidpipe_client_path) = find_in_path ( "hidpipe-client" ) ? {
48+ Command :: new ( hidpipe_client_path) . arg ( format ! ( "{}" , options. uid) ) . spawn ( ) ?;
49+ }
50+
4551 let run_path = match setup_user ( options. username , options. uid , options. gid ) {
4652 Ok ( p) => p,
4753 Err ( err) => return Err ( err) . context ( "Failed to set up user, bailing out" ) ,
Original file line number Diff line number Diff line change @@ -179,6 +179,21 @@ fn main() -> Result<()> {
179179 return Err ( err) . context ( "Failed to configure vsock for pulse socket" ) ;
180180 }
181181 }
182+ let hidpipe_path = Path :: new ( & run_path) . join ( "hidpipe" ) ;
183+ if hidpipe_path. exists ( ) {
184+ let hidpipe_path = CString :: new (
185+ hidpipe_path
186+ . to_str ( )
187+ . expect ( "hidpipe_path should not contain invalid UTF-8" ) ,
188+ )
189+ . context ( "Failed to process `hidpipe` path as it contains NUL character" ) ?;
190+ // SAFETY: `hidpipe_path` is a pointer to a `CString` with long enough lifetime.
191+ let err = unsafe { krun_add_vsock_port ( ctx_id, 3334 , hidpipe_path. as_ptr ( ) ) } ;
192+ if err < 0 {
193+ let err = Errno :: from_raw_os_error ( -err) ;
194+ return Err ( err) . context ( "Failed to configure vsock for hidpipe socket" ) ;
195+ }
196+ }
182197 }
183198
184199 // Forward the native X11 display into the guest as a socket
You can’t perform that action at this time.
0 commit comments