Documentation ¶
Overview ¶
+build linux
+build linux
+build linux
+build linux
+build linux
+build linux
+build linux
+build linux
+build linux
+build linux i386 amd64
+build i386 amd64
Index ¶
- Constants
- Variables
- func Align(addr uint64, alignment uint, up bool) uint64
- func AlignBytes(data []byte) []byte
- type BoundEventFd
- type Clock
- type ControlRegister
- type ControlRegisterValue
- type Cpuid
- type Descriptor
- type DescriptorValue
- type EventFd
- type Events
- type ExceptionEvent
- type ExitDebug
- type ExitException
- type ExitInternalError
- type ExitMmio
- type ExitPio
- type ExitShutdown
- type ExitUnknown
- type Fpu
- type InterruptEvent
- type Irq
- type IrqChip
- type LApicState
- type MpState
- type Msr
- type Paddr
- type PitState
- type Register
- type RegisterValue
- type Registers
- type RunInfo
- type Segment
- type SegmentValue
- type Vaddr
- type Vcpu
- func (vcpu *Vcpu) Dispose() error
- func (vcpu *Vcpu) GetControlRegister(reg ControlRegister) (ControlRegisterValue, error)
- func (vcpu *Vcpu) GetCpuid() ([]Cpuid, error)
- func (vcpu *Vcpu) GetDescriptor(desc Descriptor) (DescriptorValue, error)
- func (vcpu *Vcpu) GetEvents() (Events, error)
- func (vcpu *Vcpu) GetExitError() error
- func (vcpu *Vcpu) GetFpuState() (Fpu, error)
- func (vcpu *Vcpu) GetLApic() (LApicState, error)
- func (vcpu *Vcpu) GetMpState() (MpState, error)
- func (vcpu *Vcpu) GetMsr(index uint32) (uint64, error)
- func (vcpu *Vcpu) GetMsrs() ([]Msr, error)
- func (vcpu *Vcpu) GetRegister(reg Register) (RegisterValue, error)
- func (vcpu *Vcpu) GetRegisters() (Registers, error)
- func (vcpu *Vcpu) GetSegment(seg Segment) (SegmentValue, error)
- func (vcpu *Vcpu) GetXSave() (XSave, error)
- func (vcpu *Vcpu) GetXcrs() ([]Xcr, error)
- func (vcpu *Vcpu) IsStepping() bool
- func (vcpu *Vcpu) Load(info VcpuInfo) error
- func (vcpu *Vcpu) Pause(manual bool) error
- func (vcpu *Vcpu) Run() error
- func (vcpu *Vcpu) SetControlRegister(reg ControlRegister, val ControlRegisterValue, sync bool) error
- func (vcpu *Vcpu) SetCpuid(cpuids []Cpuid) error
- func (vcpu *Vcpu) SetDescriptor(desc Descriptor, val DescriptorValue, sync bool) error
- func (vcpu *Vcpu) SetEvents(events Events) error
- func (vcpu *Vcpu) SetFpuState(state Fpu) error
- func (vcpu *Vcpu) SetLApic(state LApicState) error
- func (vcpu *Vcpu) SetMpState(state MpState) error
- func (vcpu *Vcpu) SetMsr(index uint32, value uint64) error
- func (vcpu *Vcpu) SetMsrs(msrs []Msr) error
- func (vcpu *Vcpu) SetRegister(reg Register, val RegisterValue) error
- func (vcpu *Vcpu) SetRegisters(regs Registers) error
- func (vcpu *Vcpu) SetSegment(seg Segment, val SegmentValue, sync bool) error
- func (vcpu *Vcpu) SetStepping(step bool) error
- func (vcpu *Vcpu) SetXSave(state XSave) error
- func (vcpu *Vcpu) SetXcrs(xcrs []Xcr) error
- func (vcpu *Vcpu) Translate(vaddr Vaddr) (Paddr, bool, bool, bool, error)
- func (vcpu *Vcpu) Unpause(manual bool) error
- type VcpuInfo
- type Vm
- func (vm *Vm) CreateIrqChip() error
- func (vm *Vm) CreatePit() error
- func (vm *Vm) CreateVcpus(spec []VcpuInfo) ([]*Vcpu, error)
- func (vm *Vm) Dispose() error
- func (vm *Vm) GetClock() (Clock, error)
- func (vm *Vm) GetIrqChip() (IrqChip, error)
- func (vm *Vm) GetPit() (PitState, error)
- func (vm *Vm) Interrupt(irq Irq, level bool) error
- func (vm *Vm) MapReservedMemory(start Paddr, size uint64) error
- func (vm *Vm) MapSpecialMemory(addr Paddr) error
- func (vm *Vm) MapUserMemory(start Paddr, size uint64, mmap []byte) error
- func (vm *Vm) NewBoundEventFd(paddr Paddr, size uint, is_pio bool, has_value bool, value uint64) (*BoundEventFd, error)
- func (vm *Vm) NewVcpu(id uint) (*Vcpu, error)
- func (vm *Vm) Pause(manual bool) error
- func (vm *Vm) SetClock(clock Clock) error
- func (vm *Vm) SetEventFd(eventfd *EventFd, paddr Paddr, size uint, is_pio bool, unbind bool, ...) error
- func (vm *Vm) SetIrqChip(state IrqChip) error
- func (vm *Vm) SetPit(state PitState) error
- func (vm *Vm) SignalMSI(addr Paddr, data uint32, flags uint32) error
- func (vm *Vm) SizeSpecialMemory() uint64
- func (vm *Vm) Unpause(manual bool) error
- func (vm *Vm) VcpuInfo() ([]VcpuInfo, error)
- func (vm *Vm) Vcpus() []*Vcpu
- type XSave
- type Xcr
Constants ¶
const (
PageSize = 4096
)
x86 platform constants.
Variables ¶
var AlreadyPaused = errors.New("Vcpu is already paused.")
var IrqChipIncompatible = errors.New("Incompatible IRQ chip state?")
var LApicIncompatible = errors.New("Incompatible LApic state?")
var MpStateHalted = MpState(C.MpStateHalted)
var MpStateInitReceived = MpState(C.MpStateInitReceived)
var MpStateRunnable = MpState(C.MpStateRunnable)
var MpStateSipiReceived = MpState(C.MpStateSipiReceived)
var MpStateUninitialized = MpState(C.MpStateUninitialized)
var NotPaused = errors.New("Vcpu is not paused?")
Vcpu state errors.
var PitIncompatible = errors.New("Incompatible PIT state?")
var UnknownRegister = errors.New("Unknown Register")
Register errors.
var UnknownState = errors.New("Unknown vcpu state?")
var VcpuIncompatible = errors.New("Incompatible VCPU data?")
Serialization.
Functions ¶
func AlignBytes ¶
Types ¶
type BoundEventFd ¶
type BoundEventFd struct { // Our system eventfd. *EventFd // Our VM reference. *Vm // contains filtered or unexported fields }
func (*BoundEventFd) Close ¶
func (fd *BoundEventFd) Close() error
type ControlRegister ¶
type ControlRegister int
Special control registers.
const ( CR0 ControlRegister = iota CR2 CR3 CR4 CR8 EFER APIC_BASE )
type ControlRegisterValue ¶
type ControlRegisterValue uint64
type Descriptor ¶
type Descriptor int
Segment descriptor registers.
const ( GDT Descriptor = iota IDT )
type DescriptorValue ¶
type Events ¶
type Events struct { Exception *ExceptionEvent `json:"exception"` Interrupt *InterruptEvent `json:"interrupt"` NmiPending bool `json:"nmi-pending"` NmiMasked bool `json:"nmi-masked"` SipiVector uint32 `json:"sipi-vector"` Flags uint32 `json:"flags"` }
type ExceptionEvent ¶
Our event state.
type ExitException ¶
type ExitException struct {
// contains filtered or unexported fields
}
func (*ExitException) Error ¶
func (exit *ExitException) Error() string
type ExitInternalError ¶
type ExitInternalError struct {
// contains filtered or unexported fields
}
func (*ExitInternalError) Error ¶
func (exit *ExitInternalError) Error() string
type ExitShutdown ¶
type ExitShutdown struct { }
func (*ExitShutdown) Error ¶
func (exit *ExitShutdown) Error() string
type ExitUnknown ¶
type ExitUnknown struct {
// contains filtered or unexported fields
}
Exit events. When running the vcpu (i.e. vcpu.Run()), you should check the return value to see if it matches these types. They should be handled appropriate and Run() can be called again to resume.
func (*ExitUnknown) Error ¶
func (exit *ExitUnknown) Error() string
type Fpu ¶
type Fpu struct { FPR [8][16]uint8 FCW uint16 FSW uint16 FTWX uint8 LastOpcode uint16 `json:"last-opcode"` LastIp uint64 `json:"last-ip"` LastDp uint64 `json:"last-dp"` XMM [16][16]uint8 MXCSR uint32 }
Our FPU state.
type InterruptEvent ¶
type IrqChip ¶
type IrqChip struct { Pic1 []byte `json:"pic1"` Pic2 []byte `json:"pic2"` IOApic []byte `json:"ioapic"` }
IrqChip --
The IrqChip state requires three different devices: pic1, pic2 and the I/O apic. Each of these devices can be represented with a simple blob of data (compatibility will be the responsibility of KVM internally).
type LApicState ¶
type LApicState struct {
Data []byte `json:"data"`
}
LApicState --
Just a blob of data. KVM will be ensure forward-compatibility.
type PitState ¶
type PitState struct {
Data []byte `json:"data"`
}
PitState --
We represent the PitState as a blob. This representation should be relatively safe from a forward-compatibility perspective, as KVM internally will take care of reserving bits and ensuring compatibility, etc.
type RegisterValue ¶
type RegisterValue uint64
type Registers ¶
type Registers struct { RAX *RegisterValue RBX *RegisterValue RCX *RegisterValue RDX *RegisterValue RSI *RegisterValue RDI *RegisterValue RSP *RegisterValue RBP *RegisterValue R8 *RegisterValue R9 *RegisterValue R10 *RegisterValue R11 *RegisterValue R12 *RegisterValue R13 *RegisterValue R14 *RegisterValue R15 *RegisterValue RIP *RegisterValue RFLAGS *RegisterValue CR0 *ControlRegisterValue CR2 *ControlRegisterValue CR3 *ControlRegisterValue CR4 *ControlRegisterValue CR8 *ControlRegisterValue EFER *ControlRegisterValue APIC_BASE *ControlRegisterValue `json:"APIC"` IDT *DescriptorValue GDT *DescriptorValue CS *SegmentValue DS *SegmentValue ES *SegmentValue FS *SegmentValue GS *SegmentValue SS *SegmentValue TR *SegmentValue LDT *SegmentValue }
Utility structure containing all registers.
type SegmentValue ¶
type Vcpu ¶
type Vcpu struct { // The VCPU id. Id uint // Our run information. RunInfo // contains filtered or unexported fields }
func (*Vcpu) GetControlRegister ¶
func (vcpu *Vcpu) GetControlRegister(reg ControlRegister) (ControlRegisterValue, error)
func (*Vcpu) GetDescriptor ¶
func (vcpu *Vcpu) GetDescriptor(desc Descriptor) (DescriptorValue, error)
func (*Vcpu) GetExitError ¶
func (*Vcpu) GetFpuState ¶
func (*Vcpu) GetLApic ¶
func (vcpu *Vcpu) GetLApic() (LApicState, error)
func (*Vcpu) GetMpState ¶
func (*Vcpu) GetRegister ¶
func (vcpu *Vcpu) GetRegister(reg Register) (RegisterValue, error)
func (*Vcpu) GetRegisters ¶
func (*Vcpu) GetSegment ¶
func (vcpu *Vcpu) GetSegment(seg Segment) (SegmentValue, error)
func (*Vcpu) IsStepping ¶
func (*Vcpu) SetControlRegister ¶
func (vcpu *Vcpu) SetControlRegister( reg ControlRegister, val ControlRegisterValue, sync bool) error
func (*Vcpu) SetDescriptor ¶
func (vcpu *Vcpu) SetDescriptor( desc Descriptor, val DescriptorValue, sync bool) error
func (*Vcpu) SetFpuState ¶
func (*Vcpu) SetLApic ¶
func (vcpu *Vcpu) SetLApic(state LApicState) error
func (*Vcpu) SetMpState ¶
func (*Vcpu) SetRegister ¶
func (vcpu *Vcpu) SetRegister(reg Register, val RegisterValue) error
func (*Vcpu) SetRegisters ¶
func (*Vcpu) SetSegment ¶
func (vcpu *Vcpu) SetSegment( seg Segment, val SegmentValue, sync bool) error
func (*Vcpu) SetStepping ¶
type VcpuInfo ¶
type VcpuInfo struct { // Our optional id. // If this is not provided, we // assume that it is in order. Id *uint `json:"id"` // Full register state. Registers Registers `json:"registers"` // Optional multiprocessor state. MpState *MpState `json:"state"` // Our cpuid (not optional). Cpuid []Cpuid `json:"cpuid"` // Our LApic state. // This is optional, but is handled // within kvm_apic.go and not here. LApic LApicState `json:"lapic"` // Our msrs (not optional). Msrs []Msr `json:"msrs"` // Our pending vcpu events. Events Events `json:"events"` // Optional FRU state. Fpu *Fpu `json:"fpu"` // Extended control registers. Xcrs []Xcr `json:"xcrs"` // Optional xsave state. XSave *XSave `json:"xsave"` }
func NewVcpuInfo ¶
type Vm ¶
type Vm struct {
// contains filtered or unexported fields
}