Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
vsock: Propogate error for vsock ioctl
Browse files Browse the repository at this point in the history
Make error handling better by propogating error.

Fixes #1953

Signed-off-by: Archana Shinde <[email protected]>
  • Loading branch information
amshinde committed Aug 12, 2019
1 parent 4cf1fa6 commit 3fc17e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions virtcontainers/utils/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ func FindContextID() (*os.File, uint64, error) {

// Looking for the first available context ID.
for cid := contextID; cid <= maxUInt; cid++ {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uintptr(unsafe.Pointer(&cid))); err == nil {
if err = ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uintptr(unsafe.Pointer(&cid))); err == nil {
return vsockFd, cid, nil
}
}

// Last chance to get a free context ID.
for cid := contextID - 1; cid >= firstContextID; cid-- {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uintptr(unsafe.Pointer(&cid))); err == nil {
if err = ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uintptr(unsafe.Pointer(&cid))); err == nil {
return vsockFd, cid, nil
}
}

vsockFd.Close()
return nil, 0, fmt.Errorf("Could not get a unique context ID for the vsock")
return nil, 0, fmt.Errorf("Could not get a unique context ID for the vsock : %s", err)
}

0 comments on commit 3fc17e9

Please sign in to comment.