hypervisor

package
v0.0.0-...-a6598b8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IORESOURCE_BITS      = 0x000000ff
	IORESOURCE_TYPE_BITS = 0x00001f00
	IORESOURCE_IO        = 0x00000100
	IORESOURCE_MEM       = 0x00000200
	IORESOURCE_REG       = 0x00000300
	IORESOURCE_IRQ       = 0x00000400
	IORESOURCE_DMA       = 0x00000800
	IORESOURCE_BUS       = 0x00001000
	IORESOURCE_MEM_64    = 0x00100000
)

define go constants for the flags as defined in include/linux/pci_ids.h

View Source
const ACRNHypervisorName = "acrn"

ACRNHypervisorName is a name of acrn hypervisor

View Source
const (

	//ContainerdHypervisorName is a name of containerd hypervisor
	ContainerdHypervisorName = "containerd"
)
View Source
const KVMHypervisorName = "kvm"

KVMHypervisorName is a name of kvm hypervisor

View Source
const (
	// KubevirtHypervisorName : Name of the kubevirt hypervisor
	KubevirtHypervisorName = "kubevirt"
)
View Source
const NullHypervisorName = "null"

NullHypervisorName is a name of null hypervisor

View Source
const (
	PCI_BASE_CLASS_BRIDGE = "0x06"
)

https://elixir.bootlin.com/linux/latest/source/include/linux/pci_ids.h#L57

View Source
const (

	//XenHypervisorName is a name of xen hypervisor
	XenHypervisorName = "xen"
)

Variables

This section is empty.

Functions

func GetAvailableHypervisors

func GetAvailableHypervisors() (all []string, enabled []string)

GetAvailableHypervisors returns a list of all available hypervisors plus the one that is enabled on the system. Note that you don't have to follow the advice of this function and always ask for the enabled one.

func GetQmpExecutorSocket

func GetQmpExecutorSocket(domainName string) string

GetQmpExecutorSocket returns the path to the qmp socket of a domain

func PCIReleaseGeneric

func PCIReleaseGeneric(long string) error

PCIReleaseGeneric : Common function used by kvm and kubevirt

func PCIReserveGeneric

func PCIReserveGeneric(long string) error

PCIReserveGeneric : Common Reserve function used by both kvm and kubevirt

func PCISameControllerGeneric

func PCISameControllerGeneric(id1 string, id2 string) bool

PCISameControllerGeneric : Common function for kvm and kubevirt

func QmpExecDeviceAdd

func QmpExecDeviceAdd(socket, id string, busnum, devnum uint16) error

QmpExecDeviceAdd adds a usb device via busnum/devnum

func QmpExecDeviceDelete

func QmpExecDeviceDelete(socket, id string) error

QmpExecDeviceDelete removes a device

Types

type Hypervisor

type Hypervisor interface {
	Name() string
	Task(*types.DomainStatus) types.Task

	PCIReserve(string) error
	PCIRelease(string) error
	PCISameController(string, string) bool

	GetHostCPUMem() (types.HostMemory, error)
	GetDomsCPUMem() (map[string]types.DomainMetric, error)

	GetCapabilities() (*types.Capabilities, error)

	CountMemOverhead(domainName string, domainUUID uuid.UUID, domainRAMSize int64, vmmMaxMem int64,
		domainMaxCpus int64, domainVCpus int64, domainIoAdapterList []types.IoAdapter, aa *types.AssignableAdapters,
		globalConfig *types.ConfigItemValueMap) (uint64, error)
}

Hypervisor provides methods for manipulating domains on the host

func BootTimeHypervisor

func BootTimeHypervisor() Hypervisor

BootTimeHypervisor returns the hypervisor according to /run/eve-hv-type

func GetHypervisor

func GetHypervisor(hint string) (Hypervisor, error)

GetHypervisor returns a particular hypervisor implementation

type KvmContext

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

KvmContext is a KVM domains map 0-1 to anchor device model UNIX processes (qemu or firecracker) For every anchor process we maintain the following entry points in the /run/hypervisor/kvm/DOMAIN_NAME:

 pid - contains PID of the anchor process
 qmp - UNIX domain socket that allows us to talk to anchor process
cons - symlink to /dev/pts/X that allows us to talk to the serial console of the domain

In addition to that, we also maintain DOMAIN_NAME -> PID mapping in KvmContext, so we don't have to look things up in the filesystem all the time (this also allows us to filter domains that may be created by others)

func (KvmContext) Annotations

func (ctx KvmContext) Annotations(domainName string) (map[string]string, error)

func (KvmContext) Cleanup

func (ctx KvmContext) Cleanup(domainName string) error

Cleanup cleans up a domain

func (KvmContext) CountMemOverhead

func (ctx KvmContext) CountMemOverhead(domainName string, domainUUID uuid.UUID, domainRAMSize int64, vmmMaxMem int64,
	domainMaxCpus int64, domainVCpus int64, domainIoAdapterList []types.IoAdapter, aa *types.AssignableAdapters,
	globalConfig *types.ConfigItemValueMap) (uint64, error)

CountMemOverhead - returns the memory overhead estimation for a domain.

func (KvmContext) Create

func (ctx KvmContext) Create(domainName string, cfgFilename string, config *types.DomainConfig) (int, error)

func (KvmContext) CreateDomConfig

func (ctx KvmContext) CreateDomConfig(domainName string, config types.DomainConfig, status types.DomainStatus,
	diskStatusList []types.DiskStatus, aa *types.AssignableAdapters, file *os.File) error

CreateDomConfig creates a domain config (a qemu config file, typically named something like xen-%d.cfg)

func (KvmContext) Delete

func (ctx KvmContext) Delete(domainName string) (result error)

Delete deletes a domain

func (KvmContext) GetCapabilities

func (ctx KvmContext) GetCapabilities() (*types.Capabilities, error)

GetCapabilities returns capabilities of the kvm hypervisor

func (KvmContext) GetDomsCPUMem

func (ctx KvmContext) GetDomsCPUMem() (map[string]types.DomainMetric, error)

func (KvmContext) GetHostCPUMem

func (ctx KvmContext) GetHostCPUMem() (types.HostMemory, error)

func (KvmContext) Info

func (ctx KvmContext) Info(domainName string) (int, types.SwState, error)

Info returns information of a domain

func (KvmContext) Name

func (ctx KvmContext) Name() string

Name returns the name of the kvm hypervisor

func (KvmContext) PCIRelease

func (ctx KvmContext) PCIRelease(long string) error

PCIRelease releases the PCI device reservation

func (KvmContext) PCIReserve

func (ctx KvmContext) PCIReserve(long string) error

PCIReserve reserves a PCI device

func (KvmContext) PCISameController

func (ctx KvmContext) PCISameController(id1 string, id2 string) bool

PCISameController checks if two PCI controllers are the same

func (KvmContext) Setup

func (ctx KvmContext) Setup(status types.DomainStatus, config types.DomainConfig,
	aa *types.AssignableAdapters, globalConfig *types.ConfigItemValueMap, file *os.File) error

Setup sets up kvm

func (KvmContext) Start

func (ctx KvmContext) Start(domainName string) error

Start starts a domain

func (KvmContext) Stop

func (ctx KvmContext) Stop(domainName string, _ bool) error

Stop stops a domain

func (KvmContext) Task

func (ctx KvmContext) Task(status *types.DomainStatus) types.Task

Task returns either the kvm context or the containerd context depending on the domain status

Jump to

Keyboard shortcuts

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