Merge pull request #1989 from nitkon/vsock

vsock: set VHOST_VSOCK_SET_GUEST_CID for ppc64le
This commit is contained in:
Salvador Fuentes 2019-09-02 12:40:18 -05:00 committed by GitHub
commit 4176a7c947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 4 deletions

View File

@ -16,10 +16,6 @@ import (
"golang.org/x/sys/unix"
)
// from <linux/vhost.h>
// VHOST_VSOCK_SET_GUEST_CID = _IOW(VHOST_VIRTIO, 0x60, __u64)
const ioctlVhostVsockSetGuestCid = 0x4008AF60
var ioctlFunc = Ioctl
// maxUInt represents the maximum valid value for the context ID.
@ -78,6 +74,7 @@ func FindContextID() (*os.File, uint64, error) {
}
}
ioctlVhostVsockSetGuestCid := getIoctlVhostVsockGuestCid()
// 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 {

View File

@ -0,0 +1,16 @@
// +build amd64 arm64 s390x !ppc64le
// Copyright (c) 2019 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package utils
// from <linux/vhost.h>
// VHOST_VSOCK_SET_GUEST_CID = _IOW(VHOST_VIRTIO, 0x60, __u64)
const ioctlVhostVsockSetGuestCid = 0x4008AF60
func getIoctlVhostVsockGuestCid() uintptr {
return ioctlVhostVsockSetGuestCid
}

View File

@ -0,0 +1,18 @@
// Copyright (c) 2019 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package utils
// from <linux/vhost.h>
// VHOST_VSOCK_SET_GUEST_CID = _IOW(VHOST_VIRTIO, 0x60, __u64)
// _IOC_WRITE is 1 for arch generic and 4 for powerpc
// Code reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/include/uapi/asm/ioctl.h
// Explanation: https://github.com/kata-containers/runtime/pull/1989#issuecomment-525993135
const ioctlVhostVsockSetGuestCid = 0x8008AF60
func getIoctlVhostVsockGuestCid() uintptr {
return ioctlVhostVsockSetGuestCid
}