diff --git a/Sources/Containerization/LinuxContainer.swift b/Sources/Containerization/LinuxContainer.swift index 2e1e92b2..88f51f59 100644 --- a/Sources/Containerization/LinuxContainer.swift +++ b/Sources/Containerization/LinuxContainer.swift @@ -678,13 +678,15 @@ extension LinuxContainer { var socket = socket let rootInGuest = URL(filePath: self.root) + let port: UInt32 if socket.direction == .into { + port = self.hostVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue socket.destination = rootInGuest.appending(path: socket.destination.path) } else { + port = self.guestVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue socket.source = rootInGuest.appending(path: socket.source.path) } - let port = self.hostVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue try await relayManager.start(port: port, socket: socket) try await relayAgent.relaySocket(port: port, configuration: socket) } diff --git a/Sources/Containerization/LinuxPod.swift b/Sources/Containerization/LinuxPod.swift index 1fddc682..172eb04b 100644 --- a/Sources/Containerization/LinuxPod.swift +++ b/Sources/Containerization/LinuxPod.swift @@ -705,13 +705,15 @@ extension LinuxPod { // Adjust paths to be relative to the container's rootfs let rootInGuest = URL(filePath: Self.guestRootfsPath(containerID)) + let port: UInt32 if socket.direction == .into { + port = self.hostVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue socket.destination = rootInGuest.appending(path: socket.destination.path) } else { + port = self.guestVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue socket.source = rootInGuest.appending(path: socket.source.path) } - let port = self.hostVsockPorts.wrappingAdd(1, ordering: .relaxed).oldValue try await relayManager.start(port: port, socket: socket) try await relayAgent.relaySocket(port: port, configuration: socket) }