Documentation
¶
Index ¶
- Constants
- func CreateContainer(userPod *pod.UserPod, sharedDir string, hub chan VmEvent) (string, error)
- func CreateInterface(index int, pciAddr int, name string, isDefault bool, addrOnly bool, ...)
- func DiskId2Name(id int) string
- func EventString(ev int) string
- func ReleaseInterface(index int, ipAddr string, file *os.File, maps []pod.UserContainerPort, ...)
- func TtyLiner(conn io.Reader, output chan string)
- func UmountAufsContainer(shareDir, image string, index int, hub chan VmEvent)
- func UmountDMDevice(deviceFullPath, name string, hub chan VmEvent)
- func UmountOverlayContainer(shareDir, image string, index int, hub chan VmEvent)
- func UmountVolume(shareDir, volPath string, name string, hub chan VmEvent)
- func UnixSocketConnect(name string) (conn net.Conn, err error)
- func VmAssociate(driver HypervisorDriver, vmId string, hub chan VmEvent, ...)
- func VmLoop(driver HypervisorDriver, vmId string, hub chan VmEvent, ...)
- type AttachCommand
- type BlockdevInsertedEvent
- type BlockdevRemovedEvent
- type BootConfig
- type CommandAck
- type CommandError
- type ContainerCreatedEvent
- type ContainerInfo
- type ContainerUnmounted
- type DecodedMessage
- type DeviceFailed
- type DriverContext
- type EmptyContext
- func (ec *EmptyContext) AddDisk(ctx *VmContext, name, sourceType, filename, format string, id int)
- func (ec *EmptyContext) AddNic(ctx *VmContext, host *HostNicInfo, guest *GuestNicInfo)
- func (ec *EmptyContext) Associate(ctx *VmContext)
- func (ec *EmptyContext) BuildinNetwork() bool
- func (ec *EmptyContext) Close()
- func (ec *EmptyContext) Dump() (map[string]interface{}, error)
- func (ec *EmptyContext) Kill(ctx *VmContext)
- func (ec *EmptyContext) Launch(ctx *VmContext)
- func (ec *EmptyContext) RemoveDisk(ctx *VmContext, filename, format string, id int, callback VmEvent)
- func (ec *EmptyContext) RemoveNic(ctx *VmContext, device, mac string, callback VmEvent)
- func (ec *EmptyContext) Shutdown(ctx *VmContext)
- type EmptyDriver
- type ExecCommand
- type FinishCmd
- type GuestNicInfo
- type HostNicInfo
- type HypervisorDriver
- type InitConnectedEvent
- type InitFailedEvent
- type InterfaceCreated
- type InterfaceReleased
- type Interrupted
- type NetDevInsertedEvent
- type NetDevRemovedEvent
- type PersistInfo
- type PersistNetworkInfo
- type PersistVolumeInfo
- type PodFinished
- type PreparingItem
- type ReleaseVMCommand
- type ReplacePodCommand
- type RouteRule
- type RunPodCommand
- type RunningContainer
- type ShutdownCommand
- type StopPodCommand
- type TtyIO
- type VmContainer
- type VmContext
- type VmEnvironmentVar
- type VmEvent
- type VmExit
- type VmFsmapDescriptor
- type VmHwStatus
- type VmKilledEvent
- type VmNetworkInf
- type VmOnDiskInfo
- type VmPod
- type VmRoute
- type VmStartFailEvent
- type VmTimeout
- type VmVolumeDescriptor
- type VolumeInfo
- type VolumeReadyEvent
- type VolumeUnmounted
- type WindowSize
- type WindowSizeCommand
Constants ¶
View Source
const ( BaseDir = "/var/run/hyper" HyperSockName = "hyper.sock" TtySockName = "tty.sock" ConsoleSockName = "console.sock" DefaultKernel = "/var/lib/hyper/kernel" DefaultInitrd = "/var/lib/hyper/hyper-initrd.img" PciAddrFrom = 0x05 ExitChar = 4 InterfaceCount = 1 )
View Source
const ( EVENT_VM_START_FAILED = iota EVENT_VM_EXIT EVENT_VM_KILL EVENT_VM_TIMEOUT EVENT_POD_FINISH EVENT_INIT_CONNECTED EVENT_CONTAINER_ADD EVENT_CONTAINER_DELETE EVENT_VOLUME_ADD EVENT_VOLUME_DELETE EVENT_BLOCK_INSERTED EVENT_BLOCK_EJECTED EVENT_INTERFACE_ADD EVENT_INTERFACE_DELETE EVENT_INTERFACE_INSERTED EVENT_INTERFACE_EJECTED EVENT_SERIAL_ADD EVENT_SERIAL_DELETE EVENT_TTY_OPEN EVENT_TTY_CLOSE COMMAND_RUN_POD COMMAND_REPLACE_POD COMMAND_STOP_POD COMMAND_SHUTDOWN COMMAND_RELEASE COMMAND_EXEC COMMAND_ATTACH COMMAND_DETACH COMMAND_WINDOWSIZE COMMAND_ACK ERROR_INIT_FAIL ERROR_QMP_FAIL ERROR_INTERRUPTED ERROR_CMD_FAIL )
View Source
const ( INIT_RESERVED = iota INIT_STARTPOD INIT_GETPOD INIT_STOPPOD INIT_DESTROYPOD INIT_NEWCONTAINER INIT_EXECCMD INIT_FINISHCMD INIT_READY INIT_ACK INIT_ERROR INIT_WINSIZE INIT_PING INIT_FINISHPOD )
View Source
const ( PREPARING_CONTAINER = iota PREPARING_VOLUME PREPARING_BLOCK PREPARING_BIND_DIR )
Variables ¶
This section is empty.
Functions ¶
func CreateContainer ¶
func CreateInterface ¶
func DiskId2Name ¶
func EventString ¶
func ReleaseInterface ¶
func UmountAufsContainer ¶
func UmountDMDevice ¶
func UmountOverlayContainer ¶
func UmountVolume ¶
func VmAssociate ¶
func VmAssociate(driver HypervisorDriver, vmId string, hub chan VmEvent, client chan *types.QemuResponse, wg *sync.WaitGroup, pack []byte)
func VmLoop ¶
func VmLoop(driver HypervisorDriver, vmId string, hub chan VmEvent, client chan *types.QemuResponse, boot *BootConfig)
Types ¶
type AttachCommand ¶
type AttachCommand struct { Container string Streams *TtyIO Size *WindowSize }
func (*AttachCommand) Event ¶
func (qe *AttachCommand) Event() int
type BlockdevInsertedEvent ¶
type BlockdevInsertedEvent struct { Name string SourceType string //image or volume DeviceName string ScsiId int }
func (*BlockdevInsertedEvent) Event ¶
func (qe *BlockdevInsertedEvent) Event() int
type BlockdevRemovedEvent ¶
func (*BlockdevRemovedEvent) Event ¶
func (qe *BlockdevRemovedEvent) Event() int
type BootConfig ¶
type CommandAck ¶
type CommandAck struct {
// contains filtered or unexported fields
}
func (*CommandAck) Event ¶
func (qe *CommandAck) Event() int
type CommandError ¶
type CommandError struct {
// contains filtered or unexported fields
}
func (*CommandError) Event ¶
func (qe *CommandError) Event() int
type ContainerCreatedEvent ¶
type ContainerCreatedEvent struct { Index int Id string Rootfs string Image string // if fstype is `dir`, this should be a path relative to share_dir // which described the mounted aufs or overlayfs dir. Fstype string Workdir string Entrypoint []string Cmd []string Envs map[string]string }
func (*ContainerCreatedEvent) Event ¶
func (qe *ContainerCreatedEvent) Event() int
type ContainerInfo ¶
type ContainerUnmounted ¶
func (*ContainerUnmounted) Event ¶
func (qe *ContainerUnmounted) Event() int
type DecodedMessage ¶
type DecodedMessage struct {
// contains filtered or unexported fields
}
Message
type DeviceFailed ¶
type DeviceFailed struct {
Session VmEvent
}
func (*DeviceFailed) Event ¶
func (qe *DeviceFailed) Event() int
type DriverContext ¶
type DriverContext interface { Launch(ctx *VmContext) Associate(ctx *VmContext) Dump() (map[string]interface{}, error) AddDisk(ctx *VmContext, name, sourceType, filename, format string, id int) RemoveDisk(ctx *VmContext, filename, format string, id int, callback VmEvent) AddNic(ctx *VmContext, host *HostNicInfo, guest *GuestNicInfo) RemoveNic(ctx *VmContext, device, mac string, callback VmEvent) Shutdown(ctx *VmContext) Kill(ctx *VmContext) BuildinNetwork() bool Close() }
type EmptyContext ¶
type EmptyContext struct{}
func (*EmptyContext) AddDisk ¶
func (ec *EmptyContext) AddDisk(ctx *VmContext, name, sourceType, filename, format string, id int)
func (*EmptyContext) AddNic ¶
func (ec *EmptyContext) AddNic(ctx *VmContext, host *HostNicInfo, guest *GuestNicInfo)
func (*EmptyContext) Associate ¶
func (ec *EmptyContext) Associate(ctx *VmContext)
func (*EmptyContext) BuildinNetwork ¶
func (ec *EmptyContext) BuildinNetwork() bool
func (*EmptyContext) Close ¶
func (ec *EmptyContext) Close()
func (*EmptyContext) Dump ¶
func (ec *EmptyContext) Dump() (map[string]interface{}, error)
func (*EmptyContext) Kill ¶
func (ec *EmptyContext) Kill(ctx *VmContext)
func (*EmptyContext) Launch ¶
func (ec *EmptyContext) Launch(ctx *VmContext)
func (*EmptyContext) RemoveDisk ¶
func (ec *EmptyContext) RemoveDisk(ctx *VmContext, filename, format string, id int, callback VmEvent)
func (*EmptyContext) RemoveNic ¶
func (ec *EmptyContext) RemoveNic(ctx *VmContext, device, mac string, callback VmEvent)
func (*EmptyContext) Shutdown ¶
func (ec *EmptyContext) Shutdown(ctx *VmContext)
type EmptyDriver ¶
type EmptyDriver struct{}
func (*EmptyDriver) InitContext ¶
func (ed *EmptyDriver) InitContext(homeDir string) DriverContext
func (*EmptyDriver) Initialize ¶
func (ed *EmptyDriver) Initialize() error
func (*EmptyDriver) LoadContext ¶
func (ed *EmptyDriver) LoadContext(persisted map[string]interface{}) (DriverContext, error)
type ExecCommand ¶
type ExecCommand struct { Container string `json:"container,omitempty"` Sequence uint64 `json:"seq"` Command []string `json:"cmd"` Streams *TtyIO `json:"-"` }
func (*ExecCommand) Event ¶
func (qe *ExecCommand) Event() int
type HostNicInfo ¶
type HypervisorDriver ¶
type HypervisorDriver interface { Initialize() error InitContext(homeDir string) DriverContext LoadContext(persisted map[string]interface{}) (DriverContext, error) }
type InitConnectedEvent ¶
type InitConnectedEvent struct {
// contains filtered or unexported fields
}
func (*InitConnectedEvent) Event ¶
func (qe *InitConnectedEvent) Event() int
type InitFailedEvent ¶
type InitFailedEvent struct {
Reason string
}
func (*InitFailedEvent) Event ¶
func (qe *InitFailedEvent) Event() int
type InterfaceCreated ¶
type InterfaceCreated struct { Index int PCIAddr int Fd *os.File Bridge string HostDevice string DeviceName string MacAddr string IpAddr string NetMask string RouteTable []*RouteRule }
func (*InterfaceCreated) Event ¶
func (qe *InterfaceCreated) Event() int
type InterfaceReleased ¶
func (*InterfaceReleased) Event ¶
func (qe *InterfaceReleased) Event() int
type Interrupted ¶
type Interrupted struct {
Reason string
}
func (*Interrupted) Event ¶
func (qe *Interrupted) Event() int
type NetDevInsertedEvent ¶
func (*NetDevInsertedEvent) Event ¶
func (qe *NetDevInsertedEvent) Event() int
type NetDevRemovedEvent ¶
type NetDevRemovedEvent struct {
Index int
}
func (*NetDevRemovedEvent) Event ¶
func (qe *NetDevRemovedEvent) Event() int
type PersistInfo ¶
type PersistInfo struct { Id string DriverInfo map[string]interface{} UserSpec *pod.UserPod VmSpec *VmPod HwStat *VmHwStatus VolumeList []*PersistVolumeInfo NetworkList []*PersistNetworkInfo }
type PersistNetworkInfo ¶
type PersistVolumeInfo ¶
type PodFinished ¶
type PodFinished struct {
// contains filtered or unexported fields
}
func (*PodFinished) Event ¶
func (qe *PodFinished) Event() int
type PreparingItem ¶
type PreparingItem interface {
ItemType() string
}
type ReleaseVMCommand ¶
type ReleaseVMCommand struct{}
func (*ReleaseVMCommand) Event ¶
func (qe *ReleaseVMCommand) Event() int
type ReplacePodCommand ¶
type ReplacePodCommand RunPodCommand
func (*ReplacePodCommand) Event ¶
func (qe *ReplacePodCommand) Event() int
type RunPodCommand ¶
type RunPodCommand struct { Spec *pod.UserPod Containers []*ContainerInfo Volumes []*VolumeInfo Wg *sync.WaitGroup }
func (*RunPodCommand) Event ¶
func (qe *RunPodCommand) Event() int
type RunningContainer ¶
type RunningContainer struct {
Id string `json:"id"`
}
type ShutdownCommand ¶
type ShutdownCommand struct {
Wait bool
}
func (*ShutdownCommand) Event ¶
func (qe *ShutdownCommand) Event() int
type StopPodCommand ¶
type StopPodCommand struct{}
func (*StopPodCommand) Event ¶
func (qe *StopPodCommand) Event() int
type TtyIO ¶
type TtyIO struct { Stdin io.ReadCloser Stdout io.WriteCloser ClientTag string Callback chan *types.QemuResponse }
type VmContainer ¶
type VmContainer struct { Id string `json:"id"` Rootfs string `json:"rootfs"` Fstype string `json:"fstype,omitempty"` Image string `json:"image"` Volumes []VmVolumeDescriptor `json:"volumes,omitempty"` Fsmap []VmFsmapDescriptor `json:"fsmap,omitempty"` Tty uint64 `json:"tty,omitempty"` Workdir string `json:"workdir"` Entrypoint []string `json:"-"` Cmd []string `json:"cmd"` Envs []VmEnvironmentVar `json:"envs,omitempty"` RestartPolicy string `json:"restartPolicy"` }
type VmContext ¶
type VmContext struct { Id string Boot *BootConfig // Communication Context Hub chan VmEvent DCtx DriverContext HomeDir string HyperSockName string TtySockName string ConsoleSockName string // contains filtered or unexported fields }
func InitContext ¶
func InitContext(dr HypervisorDriver, id string, hub chan VmEvent, client chan *types.QemuResponse, dc DriverContext, boot *BootConfig) (*VmContext, error)
func (*VmContext) InitDeviceContext ¶
func (ctx *VmContext) InitDeviceContext(spec *pod.UserPod, wg *sync.WaitGroup, cInfo []*ContainerInfo, vInfo []*VolumeInfo)
InitDeviceContext will init device info in context
type VmEnvironmentVar ¶
type VmFsmapDescriptor ¶
type VmHwStatus ¶
type VmKilledEvent ¶
type VmKilledEvent struct {
Success bool
}
func (*VmKilledEvent) Event ¶
func (qe *VmKilledEvent) Event() int
type VmNetworkInf ¶
type VmOnDiskInfo ¶
type VmPod ¶
type VmPod struct { Hostname string `json:"hostname"` Containers []VmContainer `json:"containers"` Interfaces []VmNetworkInf `json:"interfaces"` Routes []VmRoute `json:"routes"` }
type VmStartFailEvent ¶
type VmStartFailEvent struct {
Message string
}
func (*VmStartFailEvent) Event ¶
func (qe *VmStartFailEvent) Event() int
type VmVolumeDescriptor ¶
type VmVolumeDescriptor struct { Device string `json:"device"` Mount string `json:"mount"` Fstype string `json:"fstype,omitempty"` ReadOnly bool `json:"readOnly"` }
Vm DataStructure
type VolumeInfo ¶
type VolumeReadyEvent ¶
type VolumeReadyEvent struct { Name string //volumen name in spec Filepath string //block dev absolute path, or dir path relative to share dir Fstype string //"xfs", "ext4" etc. for block dev, or "dir" for dir path Format string //"raw" (or "qcow2") for volume, no meaning for dir path }
func (*VolumeReadyEvent) Event ¶
func (qe *VolumeReadyEvent) Event() int
type VolumeUnmounted ¶
func (*VolumeUnmounted) Event ¶
func (qe *VolumeUnmounted) Event() int
type WindowSize ¶
type WindowSizeCommand ¶
type WindowSizeCommand struct { ClientTag string Size *WindowSize }
func (*WindowSizeCommand) Event ¶
func (qe *WindowSizeCommand) Event() int
Source Files
¶
Click to show internal directories.
Click to hide internal directories.