mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-30 20:44:26 +01:00
164bd8ctest/fmt: drop extra newlines73555a4qmp: add query-status API234e0edqemu: fix memory prealloc handling30bfcaaqemu: add debug logfile dep now checks for dependency recersively. runtime-spec and gogo protobuf are also updated as being required by kata agent. Solving failure: No versions of github.com/kata-containers/agent met constraints: 94e2a254a94a77c02280f4f84d7f82269be163ce: Could not introduce github.com/kata-containers/agent@94e2a254a94a77c02280f4f84d7f82269be163ce, as it has a dependency on github.com/opencontainers/runtime-spec with constraint a1b50f621a48ad13f8f696a162f684a241307db0, which has no overlap with existing constraint 5806c35637336642129d03657419829569abc5aa from (root) Solving failure: No versions of github.com/kata-containers/agent met constraints: 94e2a254a94a77c02280f4f84d7f82269be163ce: Could not introduce github.com/kata-containers/agent@94e2a254a94a77c02280f4f84d7f82269be163ce, as it has a dependency on github.com/gogo/protobuf with constraint 4cbf7e384e768b4e01799441fdf2a706a5635ae7, which has no overlap with existing constraint 342cbe0a04158f6dcb03ca0079991a51a4248c02 from (root) Signed-off-by: Peng Tao <bergwolf@hyper.sh>
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
//+build linux
|
|
|
|
package vsock
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// newConn creates a Conn using a connFD, immediately setting the connFD to
|
|
// non-blocking mode for use with the runtime network poller.
|
|
func newConn(cfd connFD, local, remote *Addr) (*Conn, error) {
|
|
// Note: if any calls fail after this point, cfd.Close should be invoked
|
|
// for cleanup because the socket is now non-blocking.
|
|
if err := cfd.SetNonblocking(local.fileName()); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Conn{
|
|
fd: cfd,
|
|
local: local,
|
|
remote: remote,
|
|
}, nil
|
|
}
|
|
|
|
// dial is the entry point for Dial on Linux.
|
|
func dial(cid, port uint32) (*Conn, error) {
|
|
cfd, err := newConnFD()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return dialLinux(cfd, cid, port)
|
|
}
|
|
|
|
// dialLinux is the entry point for tests on Linux.
|
|
func dialLinux(cfd connFD, cid, port uint32) (c *Conn, err error) {
|
|
defer func() {
|
|
if err != nil {
|
|
// If any system calls fail during setup, the socket must be closed
|
|
// to avoid file descriptor leaks.
|
|
_ = cfd.EarlyClose()
|
|
}
|
|
}()
|
|
|
|
rsa := &unix.SockaddrVM{
|
|
CID: cid,
|
|
Port: port,
|
|
}
|
|
|
|
if err := cfd.Connect(rsa); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
lsa, err := cfd.Getsockname()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
lsavm := lsa.(*unix.SockaddrVM)
|
|
|
|
local := &Addr{
|
|
ContextID: lsavm.CID,
|
|
Port: lsavm.Port,
|
|
}
|
|
|
|
remote := &Addr{
|
|
ContextID: cid,
|
|
Port: port,
|
|
}
|
|
|
|
return newConn(cfd, local, remote)
|
|
}
|