mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-01 17:52:40 +00:00
virtcontainers: Use vsock if host support it
When the hypervisor option `use_vsock` is true the runtime will check for vsock support. If vsock is supported, not proxy will be used and the shims will connect to the VM using VSOCKS. This flag is true by default, so will use VSOCK when possible and no proxy will be started. fixes #383 Signed-off-by: Jose Carlos Venegas Munoz jose.carlos.venegas.munoz@intel.com Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
3c15bc50d0
commit
33643797ad
@ -214,6 +214,10 @@ func getHostInfo() (HostInfo, error) {
|
||||
}
|
||||
|
||||
func getProxyInfo(config oci.RuntimeConfig) (ProxyInfo, error) {
|
||||
if config.ProxyType == vc.NoProxyType {
|
||||
return ProxyInfo{Type: string(config.ProxyType)}, nil
|
||||
}
|
||||
|
||||
version, err := getCommandVersion(defaultProxyPath)
|
||||
if err != nil {
|
||||
version = unknown
|
||||
|
@ -68,6 +68,9 @@ const (
|
||||
// SerialPortDev is the serial port device type.
|
||||
serialPortDev
|
||||
|
||||
// vSockPCIDev is the vhost vsock PCI device type.
|
||||
vSockPCIDev
|
||||
|
||||
// VFIODevice is VFIO device type
|
||||
vfioDev
|
||||
|
||||
|
@ -47,13 +47,16 @@ var (
|
||||
kataGuestSandboxDir = "/run/kata-containers/sandbox/"
|
||||
type9pFs = "9p"
|
||||
vsockSocketScheme = "vsock"
|
||||
kata9pDevType = "9p"
|
||||
kataBlkDevType = "blk"
|
||||
kataSCSIDevType = "scsi"
|
||||
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"}
|
||||
shmDir = "shm"
|
||||
kataEphemeralDevType = "ephemeral"
|
||||
ephemeralPath = filepath.Join(kataGuestSandboxDir, kataEphemeralDevType)
|
||||
// port numbers below 1024 are called privileged ports. Only a process with
|
||||
// CAP_NET_BIND_SERVICE capability may bind to these port numbers.
|
||||
vSockPort = 1024
|
||||
kata9pDevType = "9p"
|
||||
kataBlkDevType = "blk"
|
||||
kataSCSIDevType = "scsi"
|
||||
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"}
|
||||
shmDir = "shm"
|
||||
kataEphemeralDevType = "ephemeral"
|
||||
ephemeralPath = filepath.Join(kataGuestSandboxDir, kataEphemeralDevType)
|
||||
)
|
||||
|
||||
// KataAgentConfig is a structure storing information needed
|
||||
@ -66,6 +69,7 @@ type KataAgentConfig struct {
|
||||
type kataVSOCK struct {
|
||||
contextID uint32
|
||||
port uint32
|
||||
vhostFd *os.File
|
||||
}
|
||||
|
||||
func (s *kataVSOCK) String() string {
|
||||
@ -203,7 +207,16 @@ func (k *kataAgent) configure(h hypervisor, id, sharePath string, builtin bool,
|
||||
return err
|
||||
}
|
||||
case kataVSOCK:
|
||||
// TODO Add an hypervisor vsock
|
||||
var err error
|
||||
s.vhostFd, s.contextID, err = utils.FindContextID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.port = uint32(vSockPort)
|
||||
if err := h.addDevice(s, vSockPCIDev); err != nil {
|
||||
return err
|
||||
}
|
||||
k.vmSocket = s
|
||||
default:
|
||||
return fmt.Errorf("Invalid config type")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user