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:
Julio Montes 2018-07-25 09:45:24 -05:00
parent 3c15bc50d0
commit 33643797ad
3 changed files with 28 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -47,6 +47,9 @@ var (
kataGuestSandboxDir = "/run/kata-containers/sandbox/"
type9pFs = "9p"
vsockSocketScheme = "vsock"
// 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"
@ -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")
}