File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,8 +47,16 @@ struct Exec: AsyncParsableCommand {
4747 try ! group. syncShutdownGracefully ( )
4848 }
4949
50+ // Change the current working directory to a VM's base directory
51+ // to work around Unix domain socket 104 byte limitation [1]
52+ //
53+ // [1]: https://blog.8-p.info/en/2020/06/11/unix-domain-socket-length/
54+ if let baseURL = vmDir. controlSocketURL. baseURL {
55+ FileManager . default. changeCurrentDirectoryPath ( baseURL. path ( ) )
56+ }
57+
5058 let channel = try GRPCChannelPool . with (
51- target: . unixDomainSocket( vmDir. controlSocketURL. path ( ) ) ,
59+ target: . unixDomainSocket( vmDir. controlSocketURL. relativePath ) ,
5260 transportSecurity: . plaintext,
5361 eventLoopGroup: group,
5462 )
Original file line number Diff line number Diff line change @@ -68,7 +68,15 @@ struct IP: AsyncParsableCommand {
6868 throw RuntimeError . Generic ( " Cannot perform IP resolution via Tart Guest Agent when control socket URL is not set " )
6969 }
7070
71- if let ip = try await AgentResolver . ResolveIP ( controlSocketURL) {
71+ // Change the current working directory to a VM's base directory
72+ // to work around Unix domain socket 104 byte limitation [1]
73+ //
74+ // [1]: https://blog.8-p.info/en/2020/06/11/unix-domain-socket-length/
75+ if let baseURL = controlSocketURL. baseURL {
76+ FileManager . default. changeCurrentDirectoryPath ( baseURL. path ( ) )
77+ }
78+
79+ if let ip = try await AgentResolver . ResolveIP ( controlSocketURL. relativePath) {
7280 return ip
7381 }
7482 }
Original file line number Diff line number Diff line change @@ -21,8 +21,16 @@ class ControlSocket {
2121 // if any, otherwise we may get the "address already in use" error
2222 try ? FileManager . default. removeItem ( atPath: controlSocketURL. path ( ) )
2323
24+ // Change the current working directory to a VM's base directory
25+ // to work around Unix domain socket 104 byte limitation [1]
26+ //
27+ // [1]: https://blog.8-p.info/en/2020/06/11/unix-domain-socket-length/
28+ if let baseURL = controlSocketURL. baseURL {
29+ FileManager . default. changeCurrentDirectoryPath ( baseURL. path ( ) )
30+ }
31+
2432 let serverChannel = try await ServerBootstrap ( group: eventLoopGroup)
25- . bind ( unixDomainSocketPath: controlSocketURL. path ( ) ) { childChannel in
33+ . bind ( unixDomainSocketPath: controlSocketURL. relativePath ) { childChannel in
2634 childChannel. eventLoop. makeCompletedFuture {
2735 return try NIOAsyncChannel < ByteBuffer , ByteBuffer > (
2836 wrappingChannelSynchronously: childChannel
Original file line number Diff line number Diff line change @@ -6,23 +6,23 @@ import Cirruslabs_TartGuestAgent_Apple_Swift
66import Cirruslabs_TartGuestAgent_Grpc_Swift
77
88class AgentResolver {
9- static func ResolveIP( _ controlSocketURL : URL ) async throws -> IPv4Address ? {
9+ static func ResolveIP( _ controlSocketPath : String ) async throws -> IPv4Address ? {
1010 do {
11- return try await resolveIP ( controlSocketURL )
11+ return try await resolveIP ( controlSocketPath )
1212 } catch let error as GRPCConnectionPoolError {
1313 return nil
1414 }
1515 }
1616
17- private static func resolveIP( _ controlSocketURL : URL ) async throws -> IPv4Address ? {
17+ private static func resolveIP( _ controlSocketPath : String ) async throws -> IPv4Address ? {
1818 // Create a gRPC channel connected to the VM's control socket
1919 let group = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
2020 defer {
2121 try ! group. syncShutdownGracefully ( )
2222 }
2323
2424 let channel = try GRPCChannelPool . with (
25- target: . unixDomainSocket( controlSocketURL . path ( ) ) ,
25+ target: . unixDomainSocket( controlSocketPath ) ,
2626 transportSecurity: . plaintext,
2727 eventLoopGroup: group,
2828 )
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ struct VMDirectory: Prunable {
2727 baseURL. appendingPathComponent ( " manifest.json " )
2828 }
2929 var controlSocketURL : URL {
30- baseURL . appendingPathComponent ( " control.sock " )
30+ URL ( fileURLWithPath : " control.sock " , relativeTo : baseURL )
3131 }
3232
3333 var explicitlyPulledMark : URL {
You can’t perform that action at this time.
0 commit comments