virtcontainers: introducing HybridVSock type

This new socket type is currently supported only by the firecracker hypervisor.
For more details about its internal implementation see:
https://github.com/firecracker-microvm/firecracker/blob/master/docs/vsock.md

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-09-11 15:46:41 +00:00
parent 2a8af23de6
commit 880bb2b7b8
3 changed files with 28 additions and 0 deletions

View File

@ -104,6 +104,10 @@ const (
// memoryDevice is memory device type // memoryDevice is memory device type
memoryDev memoryDev
// hybridVirtioVsockDev is a hybrid virtio-vsock device supported
// only on certain hypervisors, like firecracker.
hybridVirtioVsockDev
) )
type memoryDevice struct { type memoryDevice struct {

View File

@ -342,6 +342,8 @@ func (k *kataAgent) agentURL() (string, error) {
return s.HostPath, nil return s.HostPath, nil
case kataVSOCK: case kataVSOCK:
return s.String(), nil return s.String(), nil
case types.HybridVSock:
return s.String(), nil
default: default:
return "", fmt.Errorf("Invalid socket type") return "", fmt.Errorf("Invalid socket type")
} }
@ -398,6 +400,11 @@ func (k *kataAgent) configure(h hypervisor, id, sharePath string, builtin bool,
return err return err
} }
k.vmSocket = s k.vmSocket = s
case types.HybridVSock:
err = h.addDevice(s, hybridVirtioVsockDev)
if err != nil {
return err
}
default: default:
return vcTypes.ErrInvalidConfigType return vcTypes.ErrInvalidConfigType
} }

View File

@ -29,6 +29,8 @@ const (
StateStopped StateString = "stopped" StateStopped StateString = "stopped"
) )
const HybridVSockScheme = "hvsock"
// SandboxState is a sandbox state structure // SandboxState is a sandbox state structure
type SandboxState struct { type SandboxState struct {
State StateString `json:"state"` State StateString `json:"state"`
@ -161,6 +163,21 @@ func (v *Volumes) String() string {
return strings.Join(volSlice, " ") return strings.Join(volSlice, " ")
} }
// HybridVSock defines a hybrid vsocket to communicate between
// the host and any process inside the VM.
// This is a virtio-vsock implementation based on AF_VSOCK on the
// guest side and multiple AF_UNIX sockets on the host side.
// This kind of socket is not supported in all hypervisors.
// Firecracker supports it.
type HybridVSock struct {
UdsPath string
Port uint32
}
func (s *HybridVSock) String() string {
return fmt.Sprintf("%s://%s:%d", HybridVSockScheme, s.UdsPath, s.Port)
}
// Socket defines a socket to communicate between // Socket defines a socket to communicate between
// the host and any process inside the VM. // the host and any process inside the VM.
type Socket struct { type Socket struct {