diff --git a/Sources/Containerization/UnixSocketRelay.swift b/Sources/Containerization/UnixSocketRelay.swift index 2388ec7c..27201004 100644 --- a/Sources/Containerization/UnixSocketRelay.swift +++ b/Sources/Containerization/UnixSocketRelay.swift @@ -254,7 +254,7 @@ extension SocketRelay { closeOnDeinit: false ) log?.info( - "initiating connection from host to guest", + "initiating connection from guest to host", metadata: [ "vport": "\(port)", "hostFd": "\(hostSocket.fileDescriptor)", @@ -322,7 +322,7 @@ extension SocketRelay { } connSource.setCancelHandler { - self.log?.info( + self.log?.debug( "host cancel received", metadata: [ "hostFd": "\(hostConn.fileDescriptor)", @@ -334,6 +334,12 @@ extension SocketRelay { self.state.withLock { _ in connSource.cancel() if vsockConnectionSource.isCancelled { + self.log?.info( + "close file descriptors", + metadata: [ + "hostFd": "\(hostConn.fileDescriptor)", + "guestFd": "\(guestFd)", + ]) try? hostConn.close() close(guestFd) } @@ -341,7 +347,7 @@ extension SocketRelay { } vsockConnectionSource.setCancelHandler { - self.log?.info( + self.log?.debug( "guest cancel received", metadata: [ "hostFd": "\(hostConn.fileDescriptor)", @@ -377,14 +383,14 @@ extension SocketRelay { log: Logger? = nil ) { if source.data == 0 { - log?.info( + log?.debug( "source EOF", metadata: [ "sourceFd": "\(sourceFd)", "dstFd": "\(destinationFd)", ]) if !source.isCancelled { - log?.info( + log?.debug( "canceling DispatchSourceRead", metadata: [ "sourceFd": "\(sourceFd)", @@ -392,7 +398,7 @@ extension SocketRelay { ]) source.cancel() if shutdown(destinationFd, SHUT_WR) != 0 { - log?.info( + log?.warning( "failed to shut down reads", metadata: [ "errno": "\(errno)", @@ -406,7 +412,7 @@ extension SocketRelay { } do { - log?.debug( + log?.trace( "source copy", metadata: [ "sourceFd": "\(sourceFd)", @@ -424,8 +430,8 @@ extension SocketRelay { if !source.isCancelled { source.cancel() if shutdown(destinationFd, SHUT_RDWR) != 0 { - log?.info( - "failed to shut down destination", + log?.warning( + "failed to shut down destination after I/O error", metadata: [ "errno": "\(errno)", "sourceFd": "\(sourceFd)", diff --git a/vminitd/Sources/vminitd/VsockProxy.swift b/vminitd/Sources/vminitd/VsockProxy.swift index 0c0b11df..31aa9d1c 100644 --- a/vminitd/Sources/vminitd/VsockProxy.swift +++ b/vminitd/Sources/vminitd/VsockProxy.swift @@ -268,7 +268,7 @@ extension VsockProxy { // and no more EPOLLOUT events on the server fd eofFromClient = true if shutdown(serverFile.fileDescriptor, SHUT_WR) != 0 { - self.log?.info( + self.log?.warning( "failed to shut down client reads", metadata: [ "vport": "\(self.port)", @@ -320,7 +320,7 @@ extension VsockProxy { // and no more EPOLLOUT events on the client fd eofFromServer = true if shutdown(clientFile.fileDescriptor, SHUT_WR) != 0 { - self.log?.info( + self.log?.warning( "failed to shut down server reads", metadata: [ "vport": "\(self.port)", @@ -353,7 +353,7 @@ extension VsockProxy { ) -> (Bool, Bool) { do { let (readBytes, writeBytes, action) = try OSFile.splice(from: &fromFile, to: &toFile) - log?.debug( + log?.trace( "transferred data", metadata: [ "description": "\(description)", @@ -369,7 +369,7 @@ extension VsockProxy { // we should see no more EPOLLIN events on the client fd // and no more EPOLLOUT events on the server fd if shutdown(toFile.fileDescriptor, SHUT_WR) != 0 { - log?.info( + log?.warning( "failed to shut down reads", metadata: [ "description": "\(description)",