virtcontainers

package
v0.0.0-...-6ac1958 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2018 License: Apache-2.0, Apache-2.0 Imports: 44 Imported by: 0

README

Build Status Build Status Build Status Build Status Go Report Card Coverage Status GoDoc

Table of Contents

What is it ?

virtcontainers is a Go library that can be used to build hardware-virtualized container runtimes.

Background

The few existing VM-based container runtimes (Clear Containers, runv, rkt's kvm stage 1) all share the same hardware virtualization semantics but use different code bases to implement them. virtcontainers's goal is to factorize this code into a common Go library.

Ideally, VM-based container runtime implementations would become translation layers from the runtime specification they implement (e.g. the OCI runtime-spec or the Kubernetes CRI) to the virtcontainers API.

virtcontainers is Clear Containers's runtime foundational package for their runtime implementation

Out of scope

Implementing a container runtime is out of scope for this project. Any tools or executables in this repository are only provided for demonstration or testing purposes.

virtcontainers and Kubernetes CRI

virtcontainers's API is loosely inspired by the Kubernetes CRI because we believe it provides the right level of abstractions for containerized pods. However, despite the API similarities between the two projects, the goal of virtcontainers is not to build a CRI implementation, but instead to provide a generic, runtime-specification agnostic, hardware-virtualized containers library that other projects could leverage to implement CRI themselves.

Design

Pods

The virtcontainers execution unit is a pod, i.e. virtcontainers users start pods where containers will be running.

virtcontainers creates a pod by starting a virtual machine and setting the pod up within that environment. Starting a pod means launching all containers with the VM pod runtime environment.

Hypervisors

The virtcontainers package relies on hypervisors to start and stop virtual machine where pods will be running. An hypervisor is defined by an Hypervisor interface implementation, and the default implementation is the QEMU one.

Agents

During the lifecycle of a container, the runtime running on the host needs to interact with the virtual machine guest OS in order to start new commands to be executed as part of a given container workload, set new networking routes or interfaces, fetch a container standard or error output, and so on. There are many existing and potential solutions to resolve that problem and virtcontainers abstracts this through the Agent interface.

Shim

In some cases the runtime will need a translation shim between the higher level container stack (e.g. Docker) and the virtual machine holding the container workload. This is needed for container stacks that make strong assumptions on the nature of the container they're monitoring. In cases where they assume containers are simply regular host processes, a shim layer is needed to translate host specific semantics into e.g. agent controlled virtual machine ones.

Proxy

When hardware virtualized containers have limited I/O multiplexing capabilities, runtimes may decide to rely on an external host proxy to support cases where several runtime instances are talking to the same container.

API

The high level virtcontainers API is the following one:

Pod API

  • CreatePod(podConfig PodConfig) creates a Pod. The virtual machine is started and the Pod is prepared.

  • DeletePod(podID string) deletes a Pod. The virtual machine is shut down and all information related to the Pod are removed. The function will fail if the Pod is running. In that case StopPod() has to be called first.

  • StartPod(podID string) starts an already created Pod. The Pod and all its containers are started.

  • RunPod(podConfig PodConfig) creates and starts a Pod. This performs CreatePod() + StartPod().

  • StopPod(podID string) stops an already running Pod. The Pod and all its containers are stopped.

  • PausePod(podID string) pauses an existing Pod.

  • ResumePod(podID string) resume a paused Pod.

  • StatusPod(podID string) returns a detailed Pod status.

  • ListPod() lists all Pods on the host. It returns a detailed status for every Pod.

Container API

  • CreateContainer(podID string, containerConfig ContainerConfig) creates a Container on an existing Pod.

  • DeleteContainer(podID, containerID string) deletes a Container from a Pod. If the Container is running it has to be stopped first.

  • StartContainer(podID, containerID string) starts an already created Container. The Pod has to be running.

  • StopContainer(podID, containerID string) stops an already running Container.

  • EnterContainer(podID, containerID string, cmd Cmd) enters an already running Container and runs a given command.

  • StatusContainer(podID, containerID string) returns a detailed Container status.

  • KillContainer(podID, containerID string, signal syscall.Signal, all bool) sends a signal to all or one container inside a Pod.

An example tool using the virtcontainers API is provided in the hack/virtc package.

Networking

virtcontainers supports the 2 major container networking models: the Container Network Model (CNM) and the Container Network Interface (CNI).

Typically the former is the Docker default networking model while the later is used on Kubernetes deployments.

virtcontainers callers can select one or the other, on a per pod basis, by setting their PodConfig's NetworkModel field properly.

CNM

High-level CNM Diagram

CNM lifecycle

  1. RequestPool

  2. CreateNetwork

  3. RequestAddress

  4. CreateEndPoint

  5. CreateContainer

  6. Create config.json

  7. Create PID and network namespace

  8. ProcessExternalKey

  9. JoinEndPoint

  10. LaunchContainer

  11. Launch

  12. Run container

Detailed CNM Diagram

Runtime network setup with CNM

  1. Read config.json

  2. Create the network namespace (code)

  3. Call the prestart hook (from inside the netns) (code)

  4. Scan network interfaces inside netns and get the name of the interface created by prestart hook (code)

  5. Create bridge, TAP, and link all together with network interface previously created (code)

  6. Start VM inside the netns and start the container (code)

Drawbacks of CNM

There are three drawbacks about using CNM instead of CNI:

  • The way we call into it is not very explicit: Have to re-exec dockerd binary so that it can accept parameters and execute the prestart hook related to network setup.
  • Implicit way to designate the network namespace: Instead of explicitely giving the netns to dockerd, we give it the PID of our runtime so that it can find the netns from this PID. This means we have to make sure being in the right netns while calling the hook, otherwise the veth pair will be created with the wrong netns.
  • No results are back from the hook: We have to scan the network interfaces to discover which one has been created inside the netns. This introduces more latency in the code because it forces us to scan the network in the CreatePod path, which is critical for starting the VM as quick as possible.

CNI

CNI Diagram

Runtime network setup with CNI

  1. Create the network namespace (code)

  2. Get CNI plugin information (code)

  3. Start the plugin (providing previously created netns) to add a network described into /etc/cni/net.d/ directory. At that time, the CNI plugin will create the cni0 network interface and a veth pair between the host and the created netns. It links cni0 to the veth pair before to exit. (code)

  4. Create bridge, TAP, and link all together with network interface previously created (code)

  5. Start VM inside the netns and start the container (code)

Storage

Container workloads are shared with the virtualized environment through 9pfs. The devicemapper storage driver is a special case. The driver uses dedicated block devices rather than formatted filesystems, and operates at the block level rather than the file level. This knowledge has been used to directly use the underlying block device instead of the overlay file system for the container root file system. The block device maps to the top read-write layer for the overlay. This approach gives much better I/O performance compared to using 9pfs to share the container file system.

The approach above does introduce a limitation in terms of dynamic file copy in/out of the container via docker cp operations. The copy operation from host to container accesses the mounted file system on the host side. This is not expected to work and may lead to inconsistencies as the block device will be simultaneously written to, from two different mounts. The copy operation from container to host will work, provided the user calls sync(1) from within the container prior to the copy to make sure any outstanding cached data is written to the block device.

docker cp [OPTIONS] CONTAINER:SRC_PATH HOST:DEST_PATH
docker cp [OPTIONS] HOST:SRC_PATH CONTAINER:DEST_PATH

Ability to hotplug block devices has been added, which makes it possible to use block devices for containers started after the VM has been launched.

How to check if container uses devicemapper block device as its rootfs

Start a container. Call mount(8) within the container. You should see '/' mounted on /dev/vda device.

Devices

Support has been added to pass VFIO assigned devices on the docker command line with --device. Support for passing other devices including block devices with --device has not been added added yet.

How to pass a device using VFIO-passthrough

  1. Requirements

IOMMU group represents the smallest set of devices for which the IOMMU has visibility and which is isolated from other groups. VFIO uses this information to enforce safe ownership of devices for userspace.

You will need Intel VT-d capable hardware. Check if IOMMU is enabled in your host kernel by verifying CONFIG_VFIO_NOIOMMU is not in the kernel config. If it is set, you will need to rebuild your kernel.

The following kernel configs need to be enabled:

CONFIG_VFIO_IOMMU_TYPE1=m 
CONFIG_VFIO=m
CONFIG_VFIO_PCI=m

In addition, you need to pass intel_iommu=on on the kernel command line.

  1. Identify BDF(Bus-Device-Function) of the PCI device to be assigned.
$ lspci -D | grep -e Ethernet -e Network
0000:01:00.0 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)

$ BDF=0000:01:00.0
  1. Find vendor and device id.
$ lspci -n -s $BDF
01:00.0 0200: 8086:1528 (rev 01)
  1. Find IOMMU group.
$ readlink /sys/bus/pci/devices/$BDF/iommu_group
../../../../kernel/iommu_groups/16
  1. Unbind the device from host driver.
$ echo $BDF | sudo tee /sys/bus/pci/devices/$BDF/driver/unbind
  1. Bind the device to vfio-pci.
$ sudo modprobe vfio-pci
$ echo 8086 1528 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id
$ echo $BDF | sudo tee --append /sys/bus/pci/drivers/vfio-pci/bind
  1. Check /dev/vfio
$ ls /dev/vfio
16 vfio
  1. Start a Clear Containers container passing the VFIO group on the docker command line.
docker run -it --device=/dev/vfio/16 centos/tools bash
  1. Running lspci within the container should show the device among the PCI devices. The driver for the device needs to be present within the Clear Containers kernel. If the driver is missing, you can add it to your custom container kernel using the osbuilder tooling.

Developers

For information on how to build, develop and test virtcontainers, see the developer documentation.

Documentation

Overview

Package virtcontainers manages hardware virtualized containers. Each container belongs to a set of containers sharing the same networking namespace and storage, also known as a pod.

Virtcontainers pods are hardware virtualized, i.e. they run on virtual machines. Virtcontainers will create one VM per pod, and containers will be created as processes within the pod VM.

The virtcontainers package manages both pods and containers lifecycles.

Example (CreateAndStartPod)

This example creates and starts a single container pod, using qemu as the hypervisor and hyperstart as the VM agent.

package main

import (
	"fmt"
	"strings"

	vc "github.com/kata-containers/runtime/virtcontainers"
)

const containerRootfs = "/var/lib/container/bundle/"

// This example creates and starts a single container pod,
// using qemu as the hypervisor and hyperstart as the VM agent.
func main() {
	envs := []vc.EnvVar{
		{
			Var:   "PATH",
			Value: "/bin:/usr/bin:/sbin:/usr/sbin",
		},
	}

	cmd := vc.Cmd{
		Args:    strings.Split("/bin/sh", " "),
		Envs:    envs,
		WorkDir: "/",
	}

	// Define the container command and bundle.
	container := vc.ContainerConfig{
		ID:     "1",
		RootFs: containerRootfs,
		Cmd:    cmd,
	}

	// Sets the hypervisor configuration.
	hypervisorConfig := vc.HypervisorConfig{
		KernelPath:     "/usr/share/kata-containers/vmlinux.container",
		ImagePath:      "/usr/share/kata-containers/kata-containers.img",
		HypervisorPath: "/usr/bin/qemu-system-x86_64",
	}

	// Use hyperstart default values for the agent.
	agConfig := vc.HyperConfig{}

	// VM resources
	vmConfig := vc.Resources{
		Memory: 1024,
	}

	// The pod configuration:
	// - One container
	// - Hypervisor is QEMU
	// - Agent is hyperstart
	podConfig := vc.PodConfig{
		VMConfig: vmConfig,

		HypervisorType:   vc.QemuHypervisor,
		HypervisorConfig: hypervisorConfig,

		AgentType:   vc.HyperstartAgent,
		AgentConfig: agConfig,

		Containers: []vc.ContainerConfig{container},
	}

	_, err := vc.RunPod(podConfig)
	if err != nil {
		fmt.Printf("Could not run pod: %s", err)
	}

	return
}

Index

Examples

Constants

View Source
const (
	// DeviceVFIO is the VFIO device type
	DeviceVFIO = "vfio"

	// DeviceBlock is the block device type
	DeviceBlock = "block"

	// DeviceGeneric is a generic device type
	DeviceGeneric = "generic"
)
View Source
const (
	//VhostUserSCSI - SCSI based vhost-user type
	VhostUserSCSI = "vhost-user-scsi-pci"
	//VhostUserNet - net based vhost-user type
	VhostUserNet = "virtio-net-pci"
	//VhostUserBlk represents a block vhostuser device type
	VhostUserBlk = "vhost-user-blk-pci"
)
View Source
const (
	// StateReady represents a pod/container that's ready to be run
	StateReady stateString = "ready"

	// StateRunning represents a pod/container that's currently running.
	StateRunning stateString = "running"

	// StatePaused represents a pod/container that has been paused.
	StatePaused stateString = "paused"

	// StateStopped represents a pod/container that has been stopped.
	StateStopped stateString = "stopped"
)
View Source
const (
	// VirtioBlock means use virtio-blk for hotplugging drives
	VirtioBlock = "virtio-blk"

	// VirtioSCSI means use virtio-scsi for hotplugging drives
	VirtioSCSI = "virtio-scsi"
)
View Source
const (
	// QemuPCLite is the QEMU pc-lite machine type for amd64
	QemuPCLite = "pc-lite"

	// QemuPC is the QEMU pc machine type for amd64
	QemuPC = "pc"

	// QemuQ35 is the QEMU Q35 machine type for amd64
	QemuQ35 = "q35"

	// QemuVirt is the QEMU virt machine type for aarch64
	QemuVirt = "virt"
)
View Source
const CniPrimaryInterface = "eth0"

CniPrimaryInterface Name chosen for the primary interface If CNI ever support multiple primary interfaces this should be revisited

Variables

View Source
var DefaultNetInterworkingModel = NetXConnectMacVtapModel

DefaultNetInterworkingModel is a package level default that determines how the VM should be connected to the the container network interface

View Source
var GetHostPathFunc = GetHostPath

GetHostPathFunc is function pointer used to mock GetHostPath in tests.

Functions

func ConstraintsToVCPUs

func ConstraintsToVCPUs(quota int64, period uint64) uint

ConstraintsToVCPUs converts CPU quota and period to vCPUs

func CreateContainer

func CreateContainer(podID string, containerConfig ContainerConfig) (VCPod, VCContainer, error)

CreateContainer is the virtcontainers container creation entry point. CreateContainer creates a container on a given pod.

func EnterContainer

func EnterContainer(podID, containerID string, cmd Cmd) (VCPod, VCContainer, *Process, error)

EnterContainer is the virtcontainers container command execution entry point. EnterContainer enters an already running container and runs a given command.

func GetHostPath

func GetHostPath(devInfo DeviceInfo) (string, error)

GetHostPath is used to fetcg the host path for the device. The path passed in the spec refers to the path that should appear inside the container. We need to find the actual device path on the host based on the major-minor numbers of the device.

func KillContainer

func KillContainer(podID, containerID string, signal syscall.Signal, all bool) error

KillContainer is the virtcontainers entry point to send a signal to a container running inside a pod. If all is true, all processes in the container will be sent the signal.

func RunningOnVMM

func RunningOnVMM(cpuInfoPath string) (bool, error)

RunningOnVMM checks if the system is running inside a VM.

func SerializeParams

func SerializeParams(params []Param, delim string) []string

SerializeParams converts []Param to []string

func SetLogger

func SetLogger(logger logrus.FieldLogger)

SetLogger sets the logger for virtcontainers package.

Types

type AgentType

type AgentType string

AgentType describes the type of guest agent a Pod should run.

const (
	// NoopAgentType is the No-Op agent.
	NoopAgentType AgentType = "noop"

	// HyperstartAgent is the Hyper hyperstart agent.
	HyperstartAgent AgentType = "hyperstart"

	// KataContainersAgent is the Kata Containers agent.
	KataContainersAgent AgentType = "kata"

	// SocketTypeVSOCK is a VSOCK socket type for talking to an agent.
	SocketTypeVSOCK = "vsock"

	// SocketTypeUNIX is a UNIX socket type for talking to an agent.
	// It typically means the agent is living behind a host proxy.
	SocketTypeUNIX = "unix"
)

func (*AgentType) Set

func (agentType *AgentType) Set(value string) error

Set sets an agent type based on the input string.

func (*AgentType) String

func (agentType *AgentType) String() string

String converts an agent type to a string.

type BlockDevice

type BlockDevice struct {
	DeviceType string
	DeviceInfo DeviceInfo

	// SCSI Address of the block device, in case the device is attached using SCSI driver
	// SCSI address is in the format SCSI-Id:LUN
	SCSIAddr string

	// Path at which the device appears inside the VM, outside of the container mount namespace
	VirtPath string
}

BlockDevice refers to a block storage device implementation.

type Bridge

type Bridge struct {
	// Address contains information about devices plugged and its address in the bridge
	Address map[uint32]string

	// Type is the type of the bridge (pci, pcie, etc)
	Type bridgeType

	//ID is used to identify the bridge in the hypervisor
	ID string
}

Bridge is a bridge where devices can be hot plugged

type CPUDevice

type CPUDevice struct {
	// ID is used to identify this CPU in the hypervisor options.
	ID string
}

CPUDevice represents a CPU device which was hot-added in a running VM

type Cmd

type Cmd struct {
	Args                []string
	Envs                []EnvVar
	SupplementaryGroups []string

	// Note that these fields *MUST* remain as strings.
	//
	// The reason being that we want runtimes to be able to support CLI
	// operations like "exec --user=". That option allows the
	// specification of a user (either as a string username or a numeric
	// UID), and may optionally also include a group (groupame or GID).
	//
	// Since this type is the interface to allow the runtime to specify
	// the user and group the workload can run as, these user and group
	// fields cannot be encoded as integer values since that would imply
	// the runtime itself would need to perform a UID/GID lookup on the
	// user-specified username/groupname. But that isn't practically
	// possible given that to do so would require the runtime to access
	// the image to allow it to interrogate the appropriate databases to
	// convert the username/groupnames to UID/GID values.
	//
	// Note that this argument applies solely to the _runtime_ supporting
	// a "--user=" option when running in a "standalone mode" - there is
	// no issue when the runtime is called by a container manager since
	// all the user and group mapping is handled by the container manager
	// and specified to the runtime in terms of UID/GID's in the
	// configuration file generated by the container manager.
	User         string
	PrimaryGroup string
	WorkDir      string
	Console      string
	Capabilities LinuxCapabilities

	Interactive     bool
	Detach          bool
	NoNewPrivileges bool
}

Cmd represents a command to execute in a running container.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container is composed of a set of containers and a runtime environment. A Container can be created, deleted, started, stopped, listed, entered, paused and restored.

func (*Container) GetAnnotations

func (c *Container) GetAnnotations() map[string]string

GetAnnotations returns container's annotations

func (*Container) GetPid

func (c *Container) GetPid() int

GetPid returns the pid related to this container's process.

func (*Container) GetToken

func (c *Container) GetToken() string

GetToken returns the token related to this container's process.

func (*Container) ID

func (c *Container) ID() string

ID returns the container identifier string.

func (*Container) Logger

func (c *Container) Logger() *logrus.Entry

Logger returns a logrus logger appropriate for logging Container messages

func (*Container) Pod

func (c *Container) Pod() VCPod

Pod returns the pod handler related to this container.

func (*Container) Process

func (c *Container) Process() Process

Process returns the container process.

func (*Container) SetPid

func (c *Container) SetPid(pid int) error

SetPid sets and stores the given pid as the pid of container's process.

type ContainerConfig

type ContainerConfig struct {
	ID string

	// RootFs is the container workload image on the host.
	RootFs string

	// ReadOnlyRootfs indicates if the rootfs should be mounted readonly
	ReadonlyRootfs bool

	// Cmd specifies the command to run on a container
	Cmd Cmd

	// Annotations allow clients to store arbitrary values,
	// for example to add additional status values required
	// to support particular specifications.
	Annotations map[string]string

	Mounts []Mount

	// Device configuration for devices that must be available within the container.
	DeviceInfos []DeviceInfo

	// Resources container resources
	Resources ContainerResources
}

ContainerConfig describes one container runtime configuration.

type ContainerResources

type ContainerResources struct {
	// CPUQuota specifies the total amount of time in microseconds
	// The number of microseconds per CPUPeriod that the container is guaranteed CPU access
	CPUQuota int64

	// CPUPeriod specifies the CPU CFS scheduler period of time in microseconds
	CPUPeriod uint64

	// CPUShares specifies container's weight vs. other containers
	CPUShares uint64
}

ContainerResources describes container resources

type ContainerStatus

type ContainerStatus struct {
	ID        string
	State     State
	PID       int
	StartTime time.Time
	RootFs    string

	// Annotations allow clients to store arbitrary values,
	// for example to add additional status values required
	// to support particular specifications.
	Annotations map[string]string
}

ContainerStatus describes a container status.

func StatusContainer

func StatusContainer(podID, containerID string) (ContainerStatus, error)

StatusContainer is the virtcontainers container status entry point. StatusContainer returns a detailed container status.

type ContainerType

type ContainerType string

ContainerType defines a type of container.

var (
	PodContainer         ContainerType = "pod_container"
	PodSandbox           ContainerType = "pod_sandbox"
	UnknownContainerType ContainerType = "unknown_container_type"
)

List different types of containers

func (ContainerType) IsPod

func (cType ContainerType) IsPod() bool

IsPod determines if the container type can be considered as a pod. We can consider a pod in case we have a PodSandbox or a RegularContainer.

type DNSInfo

type DNSInfo struct {
	Servers  []string
	Domain   string
	Searches []string
	Options  []string
}

DNSInfo describes the DNS setup related to a network interface.

type Device

type Device interface {
	// contains filtered or unexported methods
}

Device is the virtcontainers device interface.

type DeviceInfo

type DeviceInfo struct {
	// Device path on host
	HostPath string

	// Device path inside the container
	ContainerPath string

	// Type of device: c, b, u or p
	// c , u - character(unbuffered)
	// p - FIFO
	// b - block(buffered) special file
	// More info in mknod(1).
	DevType string

	// Major, minor numbers for device.
	Major int64
	Minor int64

	// FileMode permission bits for the device.
	FileMode os.FileMode

	// id of the device owner.
	UID uint32

	// id of the device group.
	GID uint32

	// Hotplugged is used to store device state indicating if the
	// device was hotplugged.
	Hotplugged bool

	// ID for the device that is passed to the hypervisor.
	ID string
}

DeviceInfo is an embedded type that contains device data common to all types of devices.

type Drive

type Drive struct {

	// Path to the disk-image/device which will be used with this drive
	File string

	// Format of the drive
	Format string

	// ID is used to identify this drive in the hypervisor options.
	ID string

	// Index assigned to the drive. In case of virtio-scsi, this is used as SCSI LUN index
	Index int
}

Drive represents a block storage drive which may be used in case the storage driver has an underlying block storage device.

type Endpoint

type Endpoint interface {
	Properties() NetworkInfo
	Name() string
	HardwareAddr() string
	Type() EndpointType

	SetProperties(NetworkInfo)
	Attach(hypervisor) error
	Detach() error
}

Endpoint represents a physical or virtual network interface.

type EndpointType

type EndpointType string

EndpointType identifies the type of the network endpoint.

const (
	// PhysicalEndpointType is the physical network interface.
	PhysicalEndpointType EndpointType = "physical"

	// VirtualEndpointType is the virtual network interface.
	VirtualEndpointType EndpointType = "virtual"

	// VhostUserEndpointType is the vhostuser network interface.
	VhostUserEndpointType EndpointType = "vhost-user"
)

func (*EndpointType) Set

func (endpointType *EndpointType) Set(value string) error

Set sets an endpoint type based on the input string.

func (*EndpointType) String

func (endpointType *EndpointType) String() string

String converts an endpoint type to a string.

type EnvVar

type EnvVar struct {
	Var   string
	Value string
}

EnvVar is a key/value structure representing a command environment variable.

type GenericDevice

type GenericDevice struct {
	DeviceType string
	DeviceInfo DeviceInfo
}

GenericDevice refers to a device that is neither a VFIO device or block device.

type Hook

type Hook struct {
	Path    string
	Args    []string
	Env     []string
	Timeout int
}

Hook represents an OCI hook, including its required parameters.

type Hooks

type Hooks struct {
	PreStartHooks  []Hook
	PostStartHooks []Hook
	PostStopHooks  []Hook
}

Hooks gathers all existing OCI hooks list.

func (*Hooks) Logger

func (h *Hooks) Logger() *logrus.Entry

Logger returns a logrus logger appropriate for logging Hooks messages

type HyperAgentState

type HyperAgentState struct {
	ProxyPid int
	URL      string
}

HyperAgentState is the structure describing the data stored from this agent implementation.

type HyperConfig

type HyperConfig struct {
	SockCtlName string
	SockTtyName string
}

HyperConfig is a structure storing information needed for hyperstart agent initialization.

type HypervisorConfig

type HypervisorConfig struct {
	// KernelParams are additional guest kernel parameters.
	KernelParams []Param

	// HypervisorParams are additional hypervisor parameters.
	HypervisorParams []Param

	// KernelPath is the guest kernel host path.
	KernelPath string

	// ImagePath is the guest image host path.
	ImagePath string

	// InitrdPath is the guest initrd image host path.
	// ImagePath and InitrdPath cannot be set at the same time.
	InitrdPath string

	// FirmwarePath is the bios host path
	FirmwarePath string

	// MachineAccelerators are machine specific accelerators
	MachineAccelerators string

	// HypervisorPath is the hypervisor executable host path.
	HypervisorPath string

	// BlockDeviceDriver specifies the driver to be used for block device
	// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
	BlockDeviceDriver string

	// HypervisorMachineType specifies the type of machine being
	// emulated.
	HypervisorMachineType string

	// DefaultVCPUs specifies default number of vCPUs for the VM.
	DefaultVCPUs uint32

	//DefaultMaxVCPUs specifies the maximum number of vCPUs for the VM.
	DefaultMaxVCPUs uint32

	// DefaultMem specifies default memory size in MiB for the VM.
	// Pod configuration VMConfig.Memory overwrites this.
	DefaultMemSz uint32

	// DefaultBridges specifies default number of bridges for the VM.
	// Bridges can be used to hot plug devices
	DefaultBridges uint32

	// DisableBlockDeviceUse disallows a block device from being used.
	DisableBlockDeviceUse bool

	// Debug changes the default hypervisor and kernel parameters to
	// enable debug output where available.
	Debug bool

	// MemPrealloc specifies if the memory should be pre-allocated
	MemPrealloc bool

	// HugePages specifies if the memory should be pre-allocated from huge pages
	HugePages bool

	// Realtime Used to enable/disable realtime
	Realtime bool

	// Mlock is used to control memory locking when Realtime is enabled
	// Realtime=true and Mlock=false, allows for swapping out of VM memory
	// enabling higher density
	Mlock bool

	// DisableNestingChecks is used to override customizations performed
	// when running on top of another VMM.
	DisableNestingChecks bool
	// contains filtered or unexported fields
}

HypervisorConfig is the hypervisor configuration.

func (*HypervisorConfig) AddKernelParam

func (conf *HypervisorConfig) AddKernelParam(p Param) error

AddKernelParam allows the addition of new kernel parameters to an existing hypervisor configuration.

func (*HypervisorConfig) CustomFirmwareAsset

func (conf *HypervisorConfig) CustomFirmwareAsset() bool

CustomFirmwareAsset returns true if the firmware asset is a custom one, false otherwise.

func (*HypervisorConfig) CustomHypervisorAsset

func (conf *HypervisorConfig) CustomHypervisorAsset() bool

CustomHypervisorAsset returns true if the hypervisor asset is a custom one, false otherwise.

func (*HypervisorConfig) CustomImageAsset

func (conf *HypervisorConfig) CustomImageAsset() bool

CustomImageAsset returns true if the image asset is a custom one, false otherwise.

func (*HypervisorConfig) CustomInitrdAsset

func (conf *HypervisorConfig) CustomInitrdAsset() bool

CustomInitrdAsset returns true if the initrd asset is a custom one, false otherwise.

func (*HypervisorConfig) CustomKernelAsset

func (conf *HypervisorConfig) CustomKernelAsset() bool

CustomKernelAsset returns true if the kernel asset is a custom one, false otherwise.

func (*HypervisorConfig) FirmwareAssetPath

func (conf *HypervisorConfig) FirmwareAssetPath() (string, error)

FirmwareAssetPath returns the guest firmware path

func (*HypervisorConfig) HypervisorAssetPath

func (conf *HypervisorConfig) HypervisorAssetPath() (string, error)

HypervisorAssetPath returns the VM hypervisor path

func (*HypervisorConfig) ImageAssetPath

func (conf *HypervisorConfig) ImageAssetPath() (string, error)

ImageAssetPath returns the guest image path

func (*HypervisorConfig) InitrdAssetPath

func (conf *HypervisorConfig) InitrdAssetPath() (string, error)

InitrdAssetPath returns the guest initrd path

func (*HypervisorConfig) KernelAssetPath

func (conf *HypervisorConfig) KernelAssetPath() (string, error)

KernelAssetPath returns the guest kernel path

type HypervisorType

type HypervisorType string

HypervisorType describes an hypervisor type.

const (
	// QemuHypervisor is the QEMU hypervisor.
	QemuHypervisor HypervisorType = "qemu"

	// MockHypervisor is a mock hypervisor for testing purposes
	MockHypervisor HypervisorType = "mock"
)

func (*HypervisorType) Set

func (hType *HypervisorType) Set(value string) error

Set sets an hypervisor type based on the input string.

func (*HypervisorType) String

func (hType *HypervisorType) String() string

String converts an hypervisor type to a string.

type KataAgentConfig

type KataAgentConfig struct {
	GRPCSocket string
}

KataAgentConfig is a structure storing information needed to reach the Kata Containers agent.

type KataAgentState

type KataAgentState struct {
	ProxyPid int
	URL      string
}

KataAgentState is the structure describing the data stored from this agent implementation.

type KataShimConfig

type KataShimConfig struct {
	Path  string
	Debug bool
}

KataShimConfig is the structure providing specific configuration for kataShim implementation.

type LinuxCapabilities

type LinuxCapabilities struct {
	// Bounding is the set of capabilities checked by the kernel.
	Bounding []string
	// Effective is the set of capabilities checked by the kernel.
	Effective []string
	// Inheritable is the capabilities preserved across execve.
	Inheritable []string
	// Permitted is the limiting superset for effective capabilities.
	Permitted []string
	// Ambient is the ambient set of capabilities that are kept.
	Ambient []string
}

LinuxCapabilities specify the capabilities to keep when executing the process inside the container.

type Mount

type Mount struct {
	Source      string
	Destination string

	// Type specifies the type of filesystem to mount.
	Type string

	// Options list all the mount options of the filesystem.
	Options []string

	// HostPath used to store host side bind mount path
	HostPath string

	// ReadOnly specifies if the mount should be read only or not
	ReadOnly bool
}

Mount describes a container mount.

type NetInterworkingModel

type NetInterworkingModel int

NetInterworkingModel defines the network model connecting the network interface to the virtual machine.

const (
	// NetXConnectDefaultModel Ask to use DefaultNetInterworkingModel
	NetXConnectDefaultModel NetInterworkingModel = iota

	// NetXConnectBridgedModel uses a linux bridge to interconnect
	// the container interface to the VM. This is the
	// safe default that works for most cases except
	// macvlan and ipvlan
	NetXConnectBridgedModel

	// NetXConnectMacVtapModel can be used when the Container network
	// interface can be bridged using macvtap
	NetXConnectMacVtapModel

	// NetXConnectEnlightenedModel can be used when the Network plugins
	// are enlightened to create VM native interfaces
	// when requested by the runtime
	// This will be used for vethtap, macvtap, ipvtap
	NetXConnectEnlightenedModel

	// NetXConnectInvalidModel is the last item to check valid values by IsValid()
	NetXConnectInvalidModel
)

func (NetInterworkingModel) IsValid

func (n NetInterworkingModel) IsValid() bool

IsValid checks if a model is valid

func (*NetInterworkingModel) SetModel

func (n *NetInterworkingModel) SetModel(modelName string) error

SetModel change the model string value

type NetlinkIface

type NetlinkIface struct {
	netlink.LinkAttrs
	Type string
}

NetlinkIface describes fully a network interface.

type NetworkConfig

type NetworkConfig struct {
	NetNSPath         string
	NumInterfaces     int
	InterworkingModel NetInterworkingModel
}

NetworkConfig is the network configuration related to a network.

type NetworkInfo

type NetworkInfo struct {
	Iface  NetlinkIface
	Addrs  []netlink.Addr
	Routes []netlink.Route
	DNS    DNSInfo
}

NetworkInfo gathers all information related to a network interface. It can be used to store the description of the underlying network.

type NetworkInterface

type NetworkInterface struct {
	Name     string
	HardAddr string
	Addrs    []netlink.Addr
}

NetworkInterface defines a network interface.

type NetworkInterfacePair

type NetworkInterfacePair struct {
	ID        string
	Name      string
	VirtIface NetworkInterface
	TAPIface  NetworkInterface
	NetInterworkingModel
	VMFds    []*os.File
	VhostFds []*os.File
}

NetworkInterfacePair defines a pair between VM and virtual network interfaces.

type NetworkModel

type NetworkModel string

NetworkModel describes the type of network specification.

const (
	// NoopNetworkModel is the No-Op network.
	NoopNetworkModel NetworkModel = "noop"

	// CNINetworkModel is the CNI network.
	CNINetworkModel NetworkModel = "CNI"

	// CNMNetworkModel is the CNM network.
	CNMNetworkModel NetworkModel = "CNM"
)

func (*NetworkModel) Set

func (networkType *NetworkModel) Set(value string) error

Set sets a network type based on the input string.

func (*NetworkModel) String

func (networkType *NetworkModel) String() string

String converts a network type to a string.

type NetworkNamespace

type NetworkNamespace struct {
	NetNsPath    string
	NetNsCreated bool
	Endpoints    []Endpoint
}

NetworkNamespace contains all data related to its network namespace.

func (NetworkNamespace) MarshalJSON

func (n NetworkNamespace) MarshalJSON() ([]byte, error)

MarshalJSON is the custom NetworkNamespace JSON marshalling routine. This is needed to properly marshall Endpoints array.

func (*NetworkNamespace) UnmarshalJSON

func (n *NetworkNamespace) UnmarshalJSON(b []byte) error

UnmarshalJSON is the custom NetworkNamespace unmarshalling routine. This is needed for unmarshalling the Endpoints interfaces array.

type Param

type Param struct {
	Key   string
	Value string
}

Param is a key/value representation for hypervisor and kernel parameters.

func DeserializeParams

func DeserializeParams(parameters []string) []Param

DeserializeParams converts []string to []Param

type PhysicalEndpoint

type PhysicalEndpoint struct {
	IfaceName          string
	HardAddr           string
	EndpointProperties NetworkInfo
	EndpointType       EndpointType
	BDF                string
	Driver             string
	VendorDeviceID     string
}

PhysicalEndpoint gathers a physical network interface and its properties

func (*PhysicalEndpoint) Attach

func (endpoint *PhysicalEndpoint) Attach(h hypervisor) error

Attach for physical endpoint binds the physical network interface to vfio-pci and adds device to the hypervisor with vfio-passthrough.

func (*PhysicalEndpoint) Detach

func (endpoint *PhysicalEndpoint) Detach() error

Detach for physical endpoint unbinds the physical network interface from vfio-pci and binds it back to the saved host driver.

func (*PhysicalEndpoint) HardwareAddr

func (endpoint *PhysicalEndpoint) HardwareAddr() string

HardwareAddr returns the mac address of the physical network interface.

func (*PhysicalEndpoint) Name

func (endpoint *PhysicalEndpoint) Name() string

Name returns name of the physical interface.

func (*PhysicalEndpoint) Properties

func (endpoint *PhysicalEndpoint) Properties() NetworkInfo

Properties returns the properties of the physical interface.

func (*PhysicalEndpoint) SetProperties

func (endpoint *PhysicalEndpoint) SetProperties(properties NetworkInfo)

SetProperties sets the properties of the physical endpoint.

func (*PhysicalEndpoint) Type

func (endpoint *PhysicalEndpoint) Type() EndpointType

Type indentifies the endpoint as a physical endpoint.

type Pod

type Pod struct {
	// contains filtered or unexported fields
}

Pod is composed of a set of containers and a runtime environment. A Pod can be created, deleted, started, paused, stopped, listed, entered, and restored.

func (*Pod) Annotations

func (p *Pod) Annotations(key string) (string, error)

Annotations returns any annotation that a user could have stored through the pod.

func (*Pod) GetAllContainers

func (p *Pod) GetAllContainers() []VCContainer

GetAllContainers returns all containers.

func (*Pod) GetAnnotations

func (p *Pod) GetAnnotations() map[string]string

GetAnnotations returns pod's annotations

func (*Pod) GetContainer

func (p *Pod) GetContainer(containerID string) VCContainer

GetContainer returns the container named by the containerID.

func (*Pod) ID

func (p *Pod) ID() string

ID returns the pod identifier string.

func (*Pod) Logger

func (p *Pod) Logger() *logrus.Entry

Logger returns a logrus logger appropriate for logging Pod messages

func (*Pod) SetAnnotations

func (p *Pod) SetAnnotations(annotations map[string]string) error

SetAnnotations sets or adds an annotations

type PodConfig

type PodConfig struct {
	ID string

	Hostname string

	// Field specific to OCI specs, needed to setup all the hooks
	Hooks Hooks

	// VMConfig is the VM configuration to set for this pod.
	VMConfig Resources

	HypervisorType   HypervisorType
	HypervisorConfig HypervisorConfig

	AgentType   AgentType
	AgentConfig interface{}

	ProxyType   ProxyType
	ProxyConfig ProxyConfig

	ShimType   ShimType
	ShimConfig interface{}

	NetworkModel  NetworkModel
	NetworkConfig NetworkConfig

	// Volumes is a list of shared volumes between the host and the Pod.
	Volumes []Volume

	// Containers describe the list of containers within a Pod.
	// This list can be empty and populated by adding containers
	// to the Pod a posteriori.
	Containers []ContainerConfig

	// Annotations keys must be unique strings and must be name-spaced
	// with e.g. reverse domain notation (org.clearlinux.key).
	Annotations map[string]string
}

PodConfig is a Pod configuration.

type PodStatus

type PodStatus struct {
	ID               string
	State            State
	Hypervisor       HypervisorType
	HypervisorConfig HypervisorConfig
	Agent            AgentType
	ContainersStatus []ContainerStatus

	// Annotations allow clients to store arbitrary values,
	// for example to add additional status values required
	// to support particular specifications.
	Annotations map[string]string
}

PodStatus describes a pod status.

func ListPod

func ListPod() ([]PodStatus, error)

ListPod is the virtcontainers pod listing entry point.

func StatusPod

func StatusPod(podID string) (PodStatus, error)

StatusPod is the virtcontainers pod status entry point.

type Process

type Process struct {
	// Token is the process execution context ID. It must be
	// unique per pod.
	// Token is used to manipulate processes for containers
	// that have not started yet, and later identify them
	// uniquely within a pod.
	Token string

	// Pid is the process ID as seen by the host software
	// stack, e.g. CRI-O, containerd. This is typically the
	// shim PID.
	Pid int

	StartTime time.Time
}

Process gathers data related to a container process.

type ProcessList

type ProcessList []byte

ProcessList represents the list of running processes inside the container

func ProcessListContainer

func ProcessListContainer(podID, containerID string, options ProcessListOptions) (ProcessList, error)

ProcessListContainer is the virtcontainers entry point to list processes running inside a container

type ProcessListOptions

type ProcessListOptions struct {
	// Format describes the output format to list the running processes.
	// Formats are unrelated to ps(1) formats, only two formats can be specified:
	// "json" and "table"
	Format string

	// Args contains the list of arguments to run ps(1) command.
	// If Args is empty the agent will use "-ef" as options to ps(1).
	Args []string
}

ProcessListOptions contains the options used to list running processes inside the container

type ProxyConfig

type ProxyConfig struct {
	Path  string
	Debug bool
}

ProxyConfig is a structure storing information needed from any proxy in order to be properly initialized.

type ProxyType

type ProxyType string

ProxyType describes a proxy type.

const (
	// NoopProxyType is the noopProxy.
	NoopProxyType ProxyType = "noopProxy"

	// NoProxyType is the noProxy.
	NoProxyType ProxyType = "noProxy"

	// CCProxyType is the ccProxy.
	CCProxyType ProxyType = "ccProxy"

	// KataProxyType is the kataProxy.
	KataProxyType ProxyType = "kataProxy"
)

func (*ProxyType) Set

func (pType *ProxyType) Set(value string) error

Set sets a proxy type based on the input string.

func (*ProxyType) String

func (pType *ProxyType) String() string

String converts a proxy type to a string.

type QemuState

type QemuState struct {
	Bridges []Bridge
	// HotpluggedCPUs is the list of CPUs that were hot-added
	HotpluggedVCPUs []CPUDevice
	UUID            string
}

QemuState keeps Qemu's state

type Resources

type Resources struct {
	// Memory is the amount of available memory in MiB.
	Memory uint
}

Resources describes VM resources configuration.

type ShimConfig

type ShimConfig struct {
	Path  string
	Debug bool
}

ShimConfig is the structure providing specific configuration for shim implementations.

type ShimParams

type ShimParams struct {
	Container string
	Token     string
	URL       string
	Console   string
	Terminal  bool
	Detach    bool
	PID       int
	CreateNS  []ns.NSType
	EnterNS   []ns.Namespace
}

ShimParams is the structure providing specific parameters needed for the execution of the shim binary.

type ShimType

type ShimType string

ShimType describes a shim type.

const (
	// CCShimType is the ccShim.
	CCShimType ShimType = "ccShim"

	// NoopShimType is the noopShim.
	NoopShimType ShimType = "noopShim"

	// KataShimType is the Kata Containers shim type.
	KataShimType ShimType = "kataShim"
)

func (*ShimType) Set

func (pType *ShimType) Set(value string) error

Set sets a shim type based on the input string.

func (*ShimType) String

func (pType *ShimType) String() string

String converts a shim type to a string.

type Socket

type Socket struct {
	DeviceID string
	ID       string
	HostPath string
	Name     string
}

Socket defines a socket to communicate between the host and any process inside the VM.

type Sockets

type Sockets []Socket

Sockets is a Socket list.

func (*Sockets) Set

func (s *Sockets) Set(sockStr string) error

Set assigns socket values from string to a Socket.

func (*Sockets) String

func (s *Sockets) String() string

String converts a Socket to a string.

type SpawnerType

type SpawnerType string

SpawnerType describes the type of guest agent a Pod should run.

const (
	// NsEnter is the nsenter spawner type
	NsEnter SpawnerType = "nsenter"
)

func (*SpawnerType) Set

func (spawnerType *SpawnerType) Set(value string) error

Set sets an agent type based on the input string.

func (*SpawnerType) String

func (spawnerType *SpawnerType) String() string

String converts an agent type to a string.

type State

type State struct {
	State stateString `json:"state"`

	// Index of the block device passed to hypervisor.
	BlockIndex int `json:"blockIndex"`

	// File system of the rootfs incase it is block device
	Fstype string `json:"fstype"`

	// Bool to indicate if the drive for a container was hotplugged.
	HotpluggedDrive bool `json:"hotpluggedDrive"`
}

State is a pod state structure.

type SystemMountsInfo

type SystemMountsInfo struct {
	// Indicates if /dev has been passed as a bind mount for the host /dev
	BindMountDev bool

	// Size of /dev/shm assigned on the host.
	DevShmSize uint
}

SystemMountsInfo describes additional information for system mounts that the agent needs to handle

type TypedDevice

type TypedDevice struct {
	Type string

	// Data is assigned the Device object.
	// This being declared as RawMessage prevents it from being  marshalled/unmarshalled.
	// We do that explicitly depending on Type.
	Data json.RawMessage
}

TypedDevice is used as an intermediate representation for marshalling and unmarshalling Device implementations.

type TypedJSONEndpoint

type TypedJSONEndpoint struct {
	Type EndpointType
	Data json.RawMessage
}

TypedJSONEndpoint is used as an intermediate representation for marshalling and unmarshalling Endpoint objects.

type VC

type VC interface {
	SetLogger(logger logrus.FieldLogger)

	CreatePod(podConfig PodConfig) (VCPod, error)
	DeletePod(podID string) (VCPod, error)
	ListPod() ([]PodStatus, error)
	PausePod(podID string) (VCPod, error)
	ResumePod(podID string) (VCPod, error)
	RunPod(podConfig PodConfig) (VCPod, error)
	StartPod(podID string) (VCPod, error)
	StatusPod(podID string) (PodStatus, error)
	StopPod(podID string) (VCPod, error)

	CreateContainer(podID string, containerConfig ContainerConfig) (VCPod, VCContainer, error)
	DeleteContainer(podID, containerID string) (VCContainer, error)
	EnterContainer(podID, containerID string, cmd Cmd) (VCPod, VCContainer, *Process, error)
	KillContainer(podID, containerID string, signal syscall.Signal, all bool) error
	StartContainer(podID, containerID string) (VCContainer, error)
	StatusContainer(podID, containerID string) (ContainerStatus, error)
	StopContainer(podID, containerID string) (VCContainer, error)
	ProcessListContainer(podID, containerID string, options ProcessListOptions) (ProcessList, error)
}

VC is the Virtcontainers interface

type VCContainer

type VCContainer interface {
	GetAnnotations() map[string]string
	GetPid() int
	GetToken() string
	ID() string
	Pod() VCPod
	Process() Process
	SetPid(pid int) error
}

VCContainer is the Container interface (required since virtcontainers.Container only contains private fields)

func DeleteContainer

func DeleteContainer(podID, containerID string) (VCContainer, error)

DeleteContainer is the virtcontainers container deletion entry point. DeleteContainer deletes a Container from a Pod. If the container is running, it needs to be stopped first.

func StartContainer

func StartContainer(podID, containerID string) (VCContainer, error)

StartContainer is the virtcontainers container starting entry point. StartContainer starts an already created container.

func StopContainer

func StopContainer(podID, containerID string) (VCContainer, error)

StopContainer is the virtcontainers container stopping entry point. StopContainer stops an already running container.

type VCImpl

type VCImpl struct {
}

VCImpl is the official virtcontainers function of the same name.

func (*VCImpl) CreateContainer

func (impl *VCImpl) CreateContainer(podID string, containerConfig ContainerConfig) (VCPod, VCContainer, error)

CreateContainer implements the VC function of the same name.

func (*VCImpl) CreatePod

func (impl *VCImpl) CreatePod(podConfig PodConfig) (VCPod, error)

CreatePod implements the VC function of the same name.

func (*VCImpl) DeleteContainer

func (impl *VCImpl) DeleteContainer(podID, containerID string) (VCContainer, error)

DeleteContainer implements the VC function of the same name.

func (*VCImpl) DeletePod

func (impl *VCImpl) DeletePod(podID string) (VCPod, error)

DeletePod implements the VC function of the same name.

func (*VCImpl) EnterContainer

func (impl *VCImpl) EnterContainer(podID, containerID string, cmd Cmd) (VCPod, VCContainer, *Process, error)

EnterContainer implements the VC function of the same name.

func (*VCImpl) KillContainer

func (impl *VCImpl) KillContainer(podID, containerID string, signal syscall.Signal, all bool) error

KillContainer implements the VC function of the same name.

func (*VCImpl) ListPod

func (impl *VCImpl) ListPod() ([]PodStatus, error)

ListPod implements the VC function of the same name.

func (*VCImpl) PausePod

func (impl *VCImpl) PausePod(podID string) (VCPod, error)

PausePod implements the VC function of the same name.

func (*VCImpl) ProcessListContainer

func (impl *VCImpl) ProcessListContainer(podID, containerID string, options ProcessListOptions) (ProcessList, error)

ProcessListContainer implements the VC function of the same name.

func (*VCImpl) ResumePod

func (impl *VCImpl) ResumePod(podID string) (VCPod, error)

ResumePod implements the VC function of the same name.

func (*VCImpl) RunPod

func (impl *VCImpl) RunPod(podConfig PodConfig) (VCPod, error)

RunPod implements the VC function of the same name.

func (*VCImpl) SetLogger

func (impl *VCImpl) SetLogger(logger logrus.FieldLogger)

SetLogger implements the VC function of the same name.

func (*VCImpl) StartContainer

func (impl *VCImpl) StartContainer(podID, containerID string) (VCContainer, error)

StartContainer implements the VC function of the same name.

func (*VCImpl) StartPod

func (impl *VCImpl) StartPod(podID string) (VCPod, error)

StartPod implements the VC function of the same name.

func (*VCImpl) StatusContainer

func (impl *VCImpl) StatusContainer(podID, containerID string) (ContainerStatus, error)

StatusContainer implements the VC function of the same name.

func (*VCImpl) StatusPod

func (impl *VCImpl) StatusPod(podID string) (PodStatus, error)

StatusPod implements the VC function of the same name.

func (*VCImpl) StopContainer

func (impl *VCImpl) StopContainer(podID, containerID string) (VCContainer, error)

StopContainer implements the VC function of the same name.

func (*VCImpl) StopPod

func (impl *VCImpl) StopPod(podID string) (VCPod, error)

StopPod implements the VC function of the same name.

type VCPod

type VCPod interface {
	Annotations(key string) (string, error)
	GetAllContainers() []VCContainer
	GetAnnotations() map[string]string
	GetContainer(containerID string) VCContainer
	ID() string
	SetAnnotations(annotations map[string]string) error
}

VCPod is the Pod interface (required since virtcontainers.Pod only contains private fields)

func CreatePod

func CreatePod(podConfig PodConfig) (VCPod, error)

CreatePod is the virtcontainers pod creation entry point. CreatePod creates a pod and its containers. It does not start them.

func DeletePod

func DeletePod(podID string) (VCPod, error)

DeletePod is the virtcontainers pod deletion entry point. DeletePod will stop an already running container and then delete it.

func PausePod

func PausePod(podID string) (VCPod, error)

PausePod is the virtcontainers pausing entry point which pauses an already running pod.

func ResumePod

func ResumePod(podID string) (VCPod, error)

ResumePod is the virtcontainers resuming entry point which resumes (or unpauses) and already paused pod.

func RunPod

func RunPod(podConfig PodConfig) (VCPod, error)

RunPod is the virtcontainers pod running entry point. RunPod creates a pod and its containers and then it starts them.

func StartPod

func StartPod(podID string) (VCPod, error)

StartPod is the virtcontainers pod starting entry point. StartPod will talk to the given hypervisor to start an existing pod and all its containers. It returns the pod ID.

func StopPod

func StopPod(podID string) (VCPod, error)

StopPod is the virtcontainers pod stopping entry point. StopPod will talk to the given agent to stop an existing pod and destroy all containers within that pod.

type VFIODevice

type VFIODevice struct {
	DeviceType string
	DeviceInfo DeviceInfo
	BDF        string
}

VFIODevice is a vfio device meant to be passed to the hypervisor to be used by the Virtual Machine.

type VhostUserBlkDevice

type VhostUserBlkDevice struct {
	VhostUserDeviceAttrs
}

VhostUserBlkDevice is a block vhost-user based device

func (*VhostUserBlkDevice) Attrs

func (vhostUserBlkDevice *VhostUserBlkDevice) Attrs() *VhostUserDeviceAttrs

Attrs returns the VhostUserDeviceAttrs associated with the vhost-user device

func (*VhostUserBlkDevice) Type

func (vhostUserBlkDevice *VhostUserBlkDevice) Type() string

Type returns the type associated with the vhost-user device

type VhostUserDevice

type VhostUserDevice interface {
	Attrs() *VhostUserDeviceAttrs
	Type() string
}

VhostUserDevice represents a vhost-user device. Shared attributes of a vhost-user device can be retrieved using the Attrs() method. Unique data can be obtained by casting the object to the proper type.

type VhostUserDeviceAttrs

type VhostUserDeviceAttrs struct {
	DeviceType string
	DeviceInfo DeviceInfo
	SocketPath string
	ID         string
}

VhostUserDeviceAttrs represents data shared by most vhost-user devices

type VhostUserDeviceType

type VhostUserDeviceType string

VhostUserDeviceType - represents a vhost-user device type Currently support just VhostUserNet

type VhostUserEndpoint

type VhostUserEndpoint struct {
	// Path to the vhost-user socket on the host system
	SocketPath string
	// MAC address of the interface
	HardAddr           string
	IfaceName          string
	EndpointProperties NetworkInfo
	EndpointType       EndpointType
}

VhostUserEndpoint represents a vhost-user socket based network interface

func (*VhostUserEndpoint) Attach

func (endpoint *VhostUserEndpoint) Attach(h hypervisor) error

Attach for vhostuser endpoint

func (*VhostUserEndpoint) Detach

func (endpoint *VhostUserEndpoint) Detach() error

Detach for vhostuser endpoint

func (*VhostUserEndpoint) HardwareAddr

func (endpoint *VhostUserEndpoint) HardwareAddr() string

HardwareAddr returns the mac address of the vhostuser network interface

func (*VhostUserEndpoint) Name

func (endpoint *VhostUserEndpoint) Name() string

Name returns name of the interface.

func (*VhostUserEndpoint) Properties

func (endpoint *VhostUserEndpoint) Properties() NetworkInfo

Properties returns the properties of the interface.

func (*VhostUserEndpoint) SetProperties

func (endpoint *VhostUserEndpoint) SetProperties(properties NetworkInfo)

SetProperties sets the properties of the endpoint.

func (*VhostUserEndpoint) Type

func (endpoint *VhostUserEndpoint) Type() EndpointType

Type indentifies the endpoint as a vhostuser endpoint.

type VhostUserNetDevice

type VhostUserNetDevice struct {
	VhostUserDeviceAttrs
	MacAddress string
}

VhostUserNetDevice is a network vhost-user based device

func (*VhostUserNetDevice) Attrs

func (vhostUserNetDevice *VhostUserNetDevice) Attrs() *VhostUserDeviceAttrs

Attrs returns the VhostUserDeviceAttrs associated with the vhost-user device

func (*VhostUserNetDevice) Type

func (vhostUserNetDevice *VhostUserNetDevice) Type() string

Type returns the type associated with the vhost-user device

type VhostUserSCSIDevice

type VhostUserSCSIDevice struct {
	VhostUserDeviceAttrs
}

VhostUserSCSIDevice is a SCSI vhost-user based device

func (*VhostUserSCSIDevice) Attrs

func (vhostUserSCSIDevice *VhostUserSCSIDevice) Attrs() *VhostUserDeviceAttrs

Attrs returns the VhostUserDeviceAttrs associated with the vhost-user device

func (*VhostUserSCSIDevice) Type

func (vhostUserSCSIDevice *VhostUserSCSIDevice) Type() string

Type returns the type associated with the vhost-user device

type VirtualEndpoint

type VirtualEndpoint struct {
	NetPair            NetworkInterfacePair
	EndpointProperties NetworkInfo
	Physical           bool
	EndpointType       EndpointType
}

VirtualEndpoint gathers a network pair and its properties.

func (*VirtualEndpoint) Attach

func (endpoint *VirtualEndpoint) Attach(h hypervisor) error

Attach for virtual endpoint bridges the network pair and adds the tap interface of the network pair to the hypervisor.

func (*VirtualEndpoint) Detach

func (endpoint *VirtualEndpoint) Detach() error

Detach for the virtual endpoint tears down the tap and bridge created for the veth interface.

func (*VirtualEndpoint) HardwareAddr

func (endpoint *VirtualEndpoint) HardwareAddr() string

HardwareAddr returns the mac address that is assigned to the tap interface in th network pair.

func (*VirtualEndpoint) Name

func (endpoint *VirtualEndpoint) Name() string

Name returns name of the veth interface in the network pair.

func (*VirtualEndpoint) Properties

func (endpoint *VirtualEndpoint) Properties() NetworkInfo

Properties returns properties for the veth interface in the network pair.

func (*VirtualEndpoint) SetProperties

func (endpoint *VirtualEndpoint) SetProperties(properties NetworkInfo)

SetProperties sets the properties for the endpoint.

func (*VirtualEndpoint) Type

func (endpoint *VirtualEndpoint) Type() EndpointType

Type identifies the endpoint as a virtual endpoint.

type Volume

type Volume struct {
	// MountTag is a label used as a hint to the guest.
	MountTag string

	// HostPath is the host filesystem path for this volume.
	HostPath string
}

Volume is a shared volume between the host and the VM, defined by its mount tag and its host path.

type Volumes

type Volumes []Volume

Volumes is a Volume list.

func (*Volumes) Set

func (v *Volumes) Set(volStr string) error

Set assigns volume values from string to a Volume.

func (*Volumes) String

func (v *Volumes) String() string

String converts a Volume to a string.

Directories

Path Synopsis
hack
virtc command
hook
mock command
pkg
cni
oci
uuid
Package uuid can be used to generate 128 bit UUIDs compatible with rfc4122.
Package uuid can be used to generate 128 bit UUIDs compatible with rfc4122.
shim
mock/cc-shim command
mock/kata-shim command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL