Merge pull request #952 from alicefr/utils_linux_fix

virtcontainers: change uint32 to uint64 for ioctl
This commit is contained in:
Frank Cao 2018-11-30 09:56:39 +08:00 committed by GitHub
commit 6edb3618f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -24,7 +24,7 @@ var ioctlFunc = ioctl
var maxUInt uint32 = 1<<32 - 1
func ioctl(fd uintptr, request int, arg1 uint32) error {
func ioctl(fd uintptr, request int, arg1 uint64) error {
if _, _, errno := unix.Syscall(
unix.SYS_IOCTL,
fd,
@ -72,14 +72,14 @@ func FindContextID() (*os.File, uint32, error) {
// Looking for the first available context ID.
for cid := contextID; cid <= maxUInt; cid++ {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, cid); err == nil {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uint64(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, cid); err == nil {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uint64(cid)); err == nil {
return vsockFd, cid, nil
}
}

View File

@ -15,7 +15,7 @@ import (
func TestFindContextID(t *testing.T) {
assert := assert.New(t)
ioctlFunc = func(fd uintptr, request int, arg1 uint32) error {
ioctlFunc = func(fd uintptr, request int, arg1 uint64) error {
return errors.New("ioctl")
}