Documentation
¶
Overview ¶
Package hypervisor contains the Hypervisor interface and the implementation of the interface for different hypervisors.
Index ¶
- Constants
- func GetAvailableHypervisors() (all []string, enabled []string)
- func GetQmpExecutorSocket(domainName string) string
- func PCIReleaseGeneric(long string) error
- func PCIReserveGeneric(long string) error
- func PCISameControllerGeneric(id1 string, id2 string) bool
- func QmpExecDeviceAdd(socket, id string, busnum, devnum uint16) error
- func QmpExecDeviceDelete(socket, id string) error
- type Hypervisor
- type KvmContext
- func (ctx KvmContext) Annotations(domainName string) (map[string]string, error)
- func (ctx KvmContext) Cleanup(domainName string) error
- func (ctx KvmContext) CountMemOverhead(domainName string, domainUUID uuid.UUID, domainRAMSize int64, vmmMaxMem int64, ...) (uint64, error)
- func (ctx KvmContext) Create(domainName string, cfgFilename string, config *types.DomainConfig) (int, error)
- func (ctx KvmContext) CreateDomConfig(domainName string, config types.DomainConfig, status types.DomainStatus, ...) error
- func (ctx KvmContext) Delete(domainName string) (result error)
- func (ctx KvmContext) GetCapabilities() (*types.Capabilities, error)
- func (ctx KvmContext) GetDomsCPUMem() (map[string]types.DomainMetric, error)
- func (ctx KvmContext) GetHostCPUMem() (types.HostMemory, error)
- func (ctx KvmContext) Info(domainName string) (int, types.SwState, error)
- func (ctx KvmContext) Name() string
- func (ctx KvmContext) PCIRelease(long string) error
- func (ctx KvmContext) PCIReserve(long string) error
- func (ctx KvmContext) PCISameController(id1 string, id2 string) bool
- func (ctx KvmContext) Setup(status types.DomainStatus, config types.DomainConfig, ...) error
- func (ctx KvmContext) Start(domainName string) error
- func (ctx KvmContext) Stop(domainName string, _ bool) error
- func (ctx KvmContext) Task(status *types.DomainStatus) types.Task
- func (ctx KvmContext) VirtualTPMSetup(domainName string, wp *types.WatchdogParam) error
- func (ctx KvmContext) VirtualTPMTeardown(domainName string, wp *types.WatchdogParam) error
- func (ctx KvmContext) VirtualTPMTerminate(domainName string, wp *types.WatchdogParam) error
Constants ¶
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
const ACRNHypervisorName = "acrn"
ACRNHypervisorName is a name of acrn hypervisor
const (
//ContainerdHypervisorName is a name of containerd hypervisor
ContainerdHypervisorName = "containerd"
)
const (
// KVMHypervisorName is a name of kvm hypervisor
KVMHypervisorName = "kvm"
)
const (
// KubevirtHypervisorName : Name of the kubevirt hypervisor
KubevirtHypervisorName = "kubevirt"
)
const NullHypervisorName = "null"
NullHypervisorName is a name of null hypervisor
const (
PCI_BASE_CLASS_BRIDGE = "0x06"
)
https://elixir.bootlin.com/linux/latest/source/include/linux/pci_ids.h#L57
const (
//XenHypervisorName is a name of xen hypervisor
XenHypervisorName = "xen"
)
Variables ¶
This section is empty.
Functions ¶
func GetAvailableHypervisors ¶
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 ¶
GetQmpExecutorSocket returns the path to the qmp socket of a domain
func PCIReleaseGeneric ¶
PCIReleaseGeneric : Common function used by kvm and kubevirt
func PCIReserveGeneric ¶
PCIReserveGeneric : Common Reserve function used by both kvm and kubevirt
func PCISameControllerGeneric ¶
PCISameControllerGeneric : Common function for kvm and kubevirt
func QmpExecDeviceAdd ¶
QmpExecDeviceAdd adds a usb device via busnum/devnum
func QmpExecDeviceDelete ¶
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 (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) CreateDomConfig ¶
func (ctx KvmContext) CreateDomConfig(domainName string, config types.DomainConfig, status types.DomainStatus, diskStatusList []types.DiskStatus, aa *types.AssignableAdapters, globalConfig *types.ConfigItemValueMap, swtpmCtrlSock string, 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) 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
func (KvmContext) VirtualTPMSetup ¶
func (ctx KvmContext) VirtualTPMSetup(domainName string, wp *types.WatchdogParam) error
VirtualTPMSetup launches a vTPM instance for the domain
func (KvmContext) VirtualTPMTeardown ¶
func (ctx KvmContext) VirtualTPMTeardown(domainName string, wp *types.WatchdogParam) error
VirtualTPMTeardown purges the vTPM instance.
func (KvmContext) VirtualTPMTerminate ¶
func (ctx KvmContext) VirtualTPMTerminate(domainName string, wp *types.WatchdogParam) error
VirtualTPMTerminate terminates the vTPM instance