diff --git a/virtcontainers/utils/utils_linux.go b/virtcontainers/utils/utils_linux.go index 47fc9481ce..efc109e3f8 100644 --- a/virtcontainers/utils/utils_linux.go +++ b/virtcontainers/utils/utils_linux.go @@ -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) }