Documentation ¶
Overview ¶
Package vmm provides helpers for configuring and running a KVM virtual machine.
Index ¶
Constants ¶
View Source
const ( MemSizeMin = 1 << 20 // 1M MemSizeDefault = 1 << 30 // 1G MemSizeMax = 1 << 40 // 1T )
Variables ¶
View Source
var ( ErrOpenKVM = errors.New("vmm: KVM is not available") ErrCompat = errors.New("vmm: incompatible KVM") ErrConfig = errors.New("vmm: invalid config") ErrGetVCPUMmapSize = errors.New("vmm: get VCPU mmap size failed") ErrCreate = errors.New("vmm: create failed") ErrSetup = errors.New("vmm: setup failed") ErrAllocMemory = errors.New("vmm: memory allocation failed") ErrSetupMemory = errors.New("vmm: memory setup failed") ErrLoadMemory = errors.New("vmm: memory load failed") ErrSetUserMemoryRegion = errors.New("vmm: set user memory region failed") ErrCreateVCPU = errors.New("vmm: VCPU create failed") ErrMmapVCPU = errors.New("vmm: VCPU mmap failed") ErrSetupVCPU = errors.New("vmm: VCPU setup failed") ErrLoadVCPU = errors.New("vmm: VCPU load failed") ErrVMClosed = errors.New("vmm: VM closed") )
Functions ¶
This section is empty.
Types ¶
type Arch ¶
type Arch interface { // SetupVM is called after the VM is created. // It sets up arch-specific "hardware" like the PIC. SetupVM(vm *kvm.VM) error // SetupMemory is called after the VM's memory is allocated. // It partitions the memory into regions. It can also write // arch-specific data to the memory if necessary. SetupMemory(mem []byte) ([]kvm.UserspaceMemoryRegion, error) // SetupVCPU is called after the VCPU is created and mmaped. // It sets up arch-specific features like MSRs and cpuid. SetupVCPU(slot int, vcpu *kvm.VCPU, state *kvm.VCPUState) error }
type Config ¶
type Config struct { // MemSize is the size of the VM's memory in bytes. // It must be a multiple of the host's page size. // If MemSize is 0, the VM will have 1G of memory. MemSize int // Devices configures the VM's virtio-mmio devices. Devices []virtio.DeviceConfig // Loader configures the VM's memory and registers. Loader Loader // Arch, if set, is called to do arch-specific setup during VM creation. // If Arch is nil, a default implementation is used. Setting Arch is // probably only useful for testing, debugging, and development. Arch Arch }
Config describes a new VM.
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
func (*VM) Close ¶
Close stops the VM and releases its resources. It returns ErrVMClosed if the VM is already closed. Close closes the VCPUs and waits for them to stop. Then it closes the MMIO bus, which closes each of its devices in turn. Then the underlying VM fd is closed and the VM's memory is munmaped.
type VMInfo ¶
type VMInfo struct { // MemSize is the size of the VM's memory in bytes. // It is a multiple of the host's page size. MemSize int // NumCPU is the number of VCPUs attached to the VM. // Right now it's always 1. NumCPU int // Devices enumerates the VM's virtio-mmio devices. Devices []mmio.DeviceInfo }
VMInfo describes a configured VM in a form useful to the Loader. It is passed to the Loader's LoadMemory and LoadVCPU methods.
Click to show internal directories.
Click to hide internal directories.