From 3fc17e96fcb990945d602479d8d04bee1061e0f1 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Mon, 12 Aug 2019 12:13:52 -0700 Subject: [PATCH] vsock: Propogate error for vsock ioctl Make error handling better by propogating error. Fixes #1953 Signed-off-by: Archana Shinde --- virtcontainers/utils/utils_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtcontainers/utils/utils_linux.go b/virtcontainers/utils/utils_linux.go index 47fc9481c..efc109e3f 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) }