kvm

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

README

Example

Supported image urls

  • nbd[+tcp]://host[:port][/name]
    • default port is 10809
  • nbd+unix://[/name]?socket=/path/to/unix.socket

Documentation

Index

Constants

View Source
const (
	DomainTypeKVM = "kvm"

	OSTypeTypeHVM OSTypeType = "hvm"

	ArchI686   = "i686"
	ArchX86_64 = "x86_64"
)
View Source
const (
	DiskTypeFile    DiskType = "file"
	DiskTypeDir     DiskType = "dir"
	DiskTypeVolume  DiskType = "volume"
	DiskTypeNetwork DiskType = "network"

	DiskDeviceTypeDisk  DiskDeviceType = "disk"
	DiskDeviceTypeCDROM DiskDeviceType = "cdrom"
)
View Source
const (
	BaseMACAddress = "00:28:06:82:%02x:%02x"

	BaseIPAddr = "172.19.%d.%d"

	//for flist vms
	VmNamespaceFmt = "vms/%s"
	VmBaseRoot     = "/mnt/vms"
)
View Source
const (
	OVSTag       = "ovs"
	OVSBackPlane = "backplane"
	OVSVXBackend = "vxbackend"
)
View Source
const (
	DefaultBridgeName = "kvm0"
)

Variables

View Source
var (
	ReservedSequences = []uint16{0x0, 0x1, 0xffff}
	BridgeIP          = []byte{172, 19, 0, 1}
	IPRangeStart      = fmt.Sprintf("%d.%d.%d.%d", BridgeIP[0], BridgeIP[1], 0, 2)
	IPRangeEnd        = fmt.Sprintf("%d.%d.%d.%d", BridgeIP[0], BridgeIP[1], 255, 254)
	DefaultBridgeIP   = fmt.Sprintf("%d.%d.%d.%d", BridgeIP[0], BridgeIP[1], BridgeIP[2], BridgeIP[3])
	DefaultBridgeCIDR = fmt.Sprintf("%s/16", DefaultBridgeIP)
)
View Source
var (
	SyncTimeout = fmt.Errorf("timeout")
)

Functions

func KVMSubsystem

func KVMSubsystem(conmgr containers.ContainerManager, cell *screen.RowCell) error

func StateToString

func StateToString(state libvirt.DomainState) string

Types

type Alias added in v1.3.0

type Alias struct {
	Name string `xml:"name,attr"`
}

type Bool

type Bool struct{}

type ConsoleDevice

type ConsoleDevice struct {
	XMLName xml.Name         `xml:"console"`
	Type    SerialDeviceType `xml:"type,attr"`
	TTY     string           `xml:"tty,attr"`
	Source  SerialSource     `xml:"source"`
	Target  ConsoleTarget    `xml:"target"`
	Alias   SerialAlias      `xml:"alias"`
}

type ConsoleTarget

type ConsoleTarget struct {
	XMLName xml.Name `xml:"target"`
	Port    int      `xml:"port,attr"`
	Type    string   `xml:"type,attr"`
}

type CreateParams

type CreateParams struct {
	NicParams
	Name   string            `json:"name"`
	CPU    int               `json:"cpu"`
	Memory int               `json:"memory"`
	FList  string            `json:"flist"`
	Mount  []Mount           `json:"mount"`
	Media  []Media           `json:"media"`
	Config map[string]string `json:"config"` //overrides vm config (from flist)
	Tags   pm.Tags           `json:"tags"`
}

func (*CreateParams) Valid

func (c *CreateParams) Valid() error

type Device

type Device interface{}

type Devices

type Devices struct {
	Emulator    string            `xml:"emulator"`
	Graphics    []GraphicsDevice  `xml:"graphics"`
	Disks       []DiskDevice      `xml:"disk"`
	Interfaces  []InterfaceDevice `xml:"interface"`
	Devices     []Device          `xml:"device"`
	Filesystems []Filesystem      `xml:"filesystem"`
}

type DiskDevice

type DiskDevice struct {
	XMLName xml.Name       `xml:"disk"`
	Type    DiskType       `xml:"type,attr"`
	Device  DiskDeviceType `xml:"device,attr"`
	Source  DiskSource     `xml:"source"`
	Target  DiskTarget     `xml:"target"`
	Driver  DiskDriver     `xml:"driver"`
	IOTune  IOTune         `xml:"iotune,omitempty"`
	Alias   Alias          `xml:"alias"`
}

type DiskDeviceType

type DiskDeviceType string

type DiskDriver

type DiskDriver struct {
	Type  DiskDriverType `xml:"type,attr,omitempty"`
	Cache string         `xml:"cache,attr,omitempty"`
	IO    string         `xml:"io,attr,omitempty"`
}

type DiskDriverType

type DiskDriverType string

type DiskSource

type DiskSource struct {
	// File
	File string `xml:"file,attr,omitempty"`
	// Block
	Dev string `xml:"dev,attr.,omitempty"`
	// Network
	Protocol string                `xml:"protocol,attr,omitempty"`
	Host     DiskSourceNetworkHost `xml:"host,omitempty"`
	Name     string                `xml:"name,attr,omitempty,omitempty"`
}

type DiskSourceNetworkHost

type DiskSourceNetworkHost struct {
	Transport string `xml:"transport,attr,omitempty"`
	Socket    string `xml:"socket,attr,omitempty"`
	Port      string `xml:"port,attr,omitempty"`
	Name      string `xml:"name,attr,omitempty"`
}

type DiskTarget

type DiskTarget struct {
	Dev string `xml:"dev,attr"`
	Bus string `xml:"bus,attr"`
}

type DiskType

type DiskType string

type Domain

type Domain struct {
	XMLName  xml.Name     `xml:"domain"`
	QemuNS   string       `xml:"xmlns:qemu,attr"`
	Type     DomainType   `xml:"type,attr"`
	Name     string       `xml:"name"`
	UUID     string       `xml:"uuid"`
	Memory   Memory       `xml:"memory"`
	VCPU     int          `xml:"vcpu"`
	OS       OS           `xml:"os"`
	Features FeaturesType `xml:"features"`
	Devices  Devices      `xml:"devices"`
	Qemu     Qemu         `xml:"qemu:commandline"`
}

type DomainInfo added in v1.2.2

type DomainInfo struct {
	CreateParams
	Sequence uint16 `json:"seq"`
}

type DomainStats

type DomainStats struct {
	Vcpu  []DomainStatsVcpu  `json"vcpu"`
	Net   []DomainStatsNet   `json"net"`
	Block []DomainStatsBlock `json"block"`
}

type DomainStatsBlock

type DomainStatsBlock struct {
	Name    string `json"name"`
	RdBytes uint64 `json"rdbytes"`
	RdTimes uint64 `json"rdtimes"`
	WrBytes uint64 `json"wrbytes"`
	WrTimes uint64 `json"wrtimes"`
}

type DomainStatsNet

type DomainStatsNet struct {
	Name    string `json"name"`
	RxBytes uint64 `json"rxbytes"`
	RxPkts  uint64 `json"rxpkts"`
	RxErrs  uint64 `json"rxerrs"`
	RxDrop  uint64 `json"rxdrop"`
	TxBytes uint64 `json"txbytes"`
	TxPkts  uint64 `json"txpkts"`
	TxErrs  uint64 `json"txerrs"`
	TxDrop  uint64 `json"txdrop"`
}

type DomainStatsVcpu

type DomainStatsVcpu struct {
	State int    `json"state"`
	Time  uint64 `json"time"`
}

type DomainType

type DomainType string

type DomainUUID

type DomainUUID struct {
	UUID string `json:"uuid"`
}

type FListBootConfig

type FListBootConfig struct {
	Root      string
	Kernel    string
	InitRD    string
	Cmdline   string
	NoDefault bool
}

type FeaturesType

type FeaturesType struct {
	Acpi string `xml:"acpi"`
	Apic string `xml:"apic"`
	Pae  string `xml:"pae"`
}

type Filesystem

type Filesystem struct {
	Source   FilesystemDir `xml:"source"`
	Target   FilesystemDir `xml:"target"`
	Readonly *Bool         `xml:"readonly"`
}

type FilesystemDir

type FilesystemDir struct {
	Dir string `xml:"dir,attr"`
}

type GraphicsDevice

type GraphicsDevice struct {
	XMLName xml.Name           `xml:"graphics"`
	Type    GraphicsDeviceType `xml:"type,attr"`
	Port    int                `xml:"port,attr"`
	KeyMap  string             `xml:"keymap,attr"`
	Listen  Listen             `xml:"listen"`
}

type GraphicsDeviceType

type GraphicsDeviceType string
const (
	GraphicsDeviceTypeVNC GraphicsDeviceType = "vnc"
)

type IOTune

type IOTune struct {
	TotalBytesSec          *uint64 `xml:"total_bytes_sec,omitempty"`
	ReadBytesSec           *uint64 `xml:"read_bytes_sec,omitempty"`
	WriteBytesSec          *uint64 `xml:"write_bytes_sec,omitempty"`
	TotalIopsSec           *uint64 `xml:"total_iops_sec,omitempty"`
	ReadIopsSec            *uint64 `xml:"read_iops_sec,omitempty"`
	WriteIopsSec           *uint64 `xml:"write_iops_sec,omitempty"`
	TotalBytesSecMax       *uint64 `xml:"total_bytes_sec_max,omitempty"`
	ReadBytesSecMax        *uint64 `xml:"read_bytes_sec_max,omitempty"`
	WriteBytesSecMax       *uint64 `xml:"write_bytes_sec_max,omitempty"`
	TotalIopsSecMax        *uint64 `xml:"total_iops_sec_max,omitempty"`
	ReadIopsSecMax         *uint64 `xml:"read_iops_sec_max,omitempty"`
	WriteIopsSecMax        *uint64 `xml:"write_iops_sec_max,omitempty"`
	TotalBytesSecMaxLength *uint64 `xml:"total_bytes_sec_max_length,omitempty"`
	ReadBytesSecMaxLength  *uint64 `xml:"read_bytes_sec_max_length,omitempty"`
	WriteBytesSecMaxLength *uint64 `xml:"write_bytes_sec_max_length,omitempty"`
	TotalIopsSecMaxLength  *uint64 `xml:"total_iops_sec_max_length,omitempty"`
	ReadIopsSecMaxLength   *uint64 `xml:"read_iops_sec_max_length,omitempty"`
	WriteIopsSecMaxLength  *uint64 `xml:"write_iops_sec_max_length,omitempty"`
	SizeIopsSec            *uint64 `xml:"size_iops_sec,omitempty"`
	GroupName              *string `xml:"group_name,omitempty"`
}

func IOTuneParamsToIOTune

func IOTuneParamsToIOTune(inp IOTuneParams) IOTune

type IOTuneParams

type IOTuneParams struct {
	TotalBytesSecSet          bool   `json:"totalbytessecset"`
	TotalBytesSec             uint64 `json:"totalbytessec"`
	ReadBytesSecSet           bool   `json:"readbytessecset"`
	ReadBytesSec              uint64 `json:"readbytessec"`
	WriteBytesSecSet          bool   `json:"writebytessecset"`
	WriteBytesSec             uint64 `json:"writebytessec"`
	TotalIopsSecSet           bool   `json:"totaliopssecset"`
	TotalIopsSec              uint64 `json:"totaliopssec"`
	ReadIopsSecSet            bool   `json:"readiopssecset"`
	ReadIopsSec               uint64 `json:"readiopssec"`
	WriteIopsSecSet           bool   `json:"writeiopssecset"`
	WriteIopsSec              uint64 `json:"writeiopssec"`
	TotalBytesSecMaxSet       bool   `json:"totalbytessecmaxset"`
	TotalBytesSecMax          uint64 `json:"totalbytessecmax"`
	ReadBytesSecMaxSet        bool   `json:"readbytessecmaxset"`
	ReadBytesSecMax           uint64 `json:"readbytessecmax"`
	WriteBytesSecMaxSet       bool   `json:"writebytessecmaxset"`
	WriteBytesSecMax          uint64 `json:"writebytessecmax"`
	TotalIopsSecMaxSet        bool   `json:"totaliopssecmaxset"`
	TotalIopsSecMax           uint64 `json:"totaliopssecmax"`
	ReadIopsSecMaxSet         bool   `json:"readiopssecmaxset"`
	ReadIopsSecMax            uint64 `json:"readiopssecmax"`
	WriteIopsSecMaxSet        bool   `json:"writeiopssecmaxset"`
	WriteIopsSecMax           uint64 `json:"writeiopssecmax"`
	TotalBytesSecMaxLengthSet bool   `json:"totalbytessecmaxlengthset"`
	TotalBytesSecMaxLength    uint64 `json:"totalbytessecmaxlength"`
	ReadBytesSecMaxLengthSet  bool   `json:"readbytessecmaxlengthset"`
	ReadBytesSecMaxLength     uint64 `json:"readbytessecmaxlength"`
	WriteBytesSecMaxLengthSet bool   `json:"writebytessecmaxlengthset"`
	WriteBytesSecMaxLength    uint64 `json:"writebytessecmaxlength"`
	TotalIopsSecMaxLengthSet  bool   `json:"totaliopssecmaxlengthset"`
	TotalIopsSecMaxLength     uint64 `json:"totaliopssecmaxlength"`
	ReadIopsSecMaxLengthSet   bool   `json:"readiopssecmaxlengthset"`
	ReadIopsSecMaxLength      uint64 `json:"readiopssecmaxlength"`
	WriteIopsSecMaxLengthSet  bool   `json:"writeiopssecmaxlengthset"`
	WriteIopsSecMaxLength     uint64 `json:"writeiopssecmaxlength"`
	SizeIopsSecSet            bool   `json:"sizeiopssecset"`
	SizeIopsSec               uint64 `json:"sizeiopssec"`
	GroupNameSet              bool   `json:"groupnameset"`
	GroupName                 string `json:"groupname"`
}

type InterfaceDevice

type InterfaceDevice struct {
	XMLName xml.Name              `xml:"interface"`
	Type    InterfaceDeviceType   `xml:"type,attr"`
	Source  InterfaceDeviceSource `xml:"source"`
	Target  InterfaceDeviceTarget `xml:"target,omitempty"`
	Model   InterfaceDeviceModel  `xml:"model"`
	Alias   Alias                 `xml:"alias"`
	Mac     *InterfaceDeviceMac   `xml:"mac,omitempty"`
}

type InterfaceDeviceMac

type InterfaceDeviceMac struct {
	Address string `xml:"address,attr"`
}

type InterfaceDeviceModel

type InterfaceDeviceModel struct {
	Type string `xml:"type,attr"`
}

type InterfaceDeviceSource

type InterfaceDeviceSource struct {
	Bridge  string `xml:"bridge,attr,omitempty"`
	Network string `xml:"network,attr,omitempty"`
}

type InterfaceDeviceTarget

type InterfaceDeviceTarget struct {
	Dev string `xml:"dev,attr"`
}

type InterfaceDeviceType

type InterfaceDeviceType string
const (
	InterfaceDeviceTypeBridge  InterfaceDeviceType = "bridge"
	InterfaceDeviceTypeNetwork InterfaceDeviceType = "network"
)

type LastStatistics

type LastStatistics struct {
	Last  float64 `json:"last_value"`
	Epoch int64   `json:"last_time"`
}

type LibvirtConnection

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

type LimitDiskIOParams

type LimitDiskIOParams struct {
	IOTuneParams
	UUID  string `json:"uuid"`
	Media Media  `json:"media"`
}

type Listen

type Listen struct {
	Type    string `xml:"type,attr"`
	Address string `xml:"address,attr"`
}

type Machine

type Machine struct {
	ID         int          `json:"id"`
	UUID       string       `json:"uuid"`
	Name       string       `json:"name"`
	State      string       `json:"state"`
	Vnc        int          `json:"vnc"`
	Tags       pm.Tags      `json:"tags"`
	IfcTargets []string     `json:"ifctargets"`
	DefaultIP  string       `json:"default_ip"`
	Params     CreateParams `json:"params"`
}

type ManDiskParams

type ManDiskParams struct {
	UUID  string `json:"uuid"`
	Media Media  `json:"media"`
}

type ManNicParams

type ManNicParams struct {
	Nic
	UUID string `json:"uuid"`
}

type Media

type Media struct {
	URL    string         `json:"url"`
	Type   DiskDeviceType `json:"type"`
	Bus    string         `json:"bus"`
	IOTune *IOTuneParams  `json:"iotune,omitempty"`
}

type Memory

type Memory struct {
	Capacity int    `xml:",chardata"`
	Unit     string `xml:"unit,attr,omitempty"`
}

type MigrateParams

type MigrateParams struct {
	UUID    string `json:"uuid"`
	DestURI string `json:"desturi"`
}

type Mount

type Mount struct {
	Source   string `json:"source"`
	Target   string `json:"target"`
	Readonly bool   `json:"readonly"`
}

type Network

type Network struct {
	XMLName xml.Name `xml:"network"`
	Name    string   `xml:"name"`
	Forward struct {
		Mode string `xml:"mode,attr"`
	} `xml:"forward"`
	Bridge struct {
		Name string `xml:"name,attr"`
	} `xml:"bridge"`
	VirtualPort struct {
		Type string `xml:"type,attr"`
	} `xml:"virtualport"`
}

type Nic

type Nic struct {
	Type      string `json:"type"`
	ID        string `json:"id"`
	HWAddress string `json:"hwaddr"`
}

type NicParams

type NicParams struct {
	Nics []Nic          `json:"nics"`
	Port map[string]int `json:"port"`
}

func (*NicParams) Valid

func (c *NicParams) Valid() error

type OS

type OS struct {
	Type    OSType `xml:"type"`
	Kernel  string `xml:"kernel,omitempty"`
	InitRD  string `xml:"initrd,omitempty"`
	Cmdline string `xml:"cmdline,omitempty"`
}

type OSType

type OSType struct {
	Type OSTypeType `xml:",chardata"`
	Arch string     `xml:"arch,attr"`
}

type OSTypeType

type OSTypeType string

type Qemu

type Qemu struct {
	Args []QemuArg
}

type QemuArg

type QemuArg struct {
	XMLName xml.Name `xml:"qemu:arg"`
	Value   string   `xml:"value,attr"`
}

type QemuImgInfoResult

type QemuImgInfoResult struct {
	Format string `json:"format"`
}

type SerialAlias

type SerialAlias struct {
	XMLName xml.Name `xml:"alias"`
	Name    string   `xml:"name,attr"`
}

type SerialDevice

type SerialDevice struct {
	XMLName xml.Name         `xml:"serial"`
	Type    SerialDeviceType `xml:"type,attr"`
	Source  SerialSource     `xml:"source"`
	Target  SerialTarget     `xml:"target"`
	Alias   SerialAlias      `xml:"alias"`
}

type SerialDeviceType

type SerialDeviceType string
const (
	SerialDeviceTypePTY SerialDeviceType = "pty"
)

type SerialSource

type SerialSource struct {
	XMLName xml.Name `xml:"source"`
	Path    string   `xml:"path,attr"`
}

type SerialTarget

type SerialTarget struct {
	XMLName xml.Name `xml:"target"`
	Port    int      `xml:"port,attr"`
}

type Sync added in v1.3.0

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

Sync helper type to process device remove events.

func NewSync added in v1.3.0

func NewSync() *Sync

NewSync create a new sync type

func (*Sync) Expect added in v1.3.0

func (s *Sync) Expect(uuid string, alias string)

Expect notify the sync type that we expect an event for deleting this device

func (*Sync) Release added in v1.3.0

func (s *Sync) Release(uuid, alias string)

Release a waiting routine if exists

func (*Sync) Unexpect added in v1.3.0

func (s *Sync) Unexpect(uuid, alias string)

Unexpect forgets about those keys

func (*Sync) Wait added in v1.3.0

func (s *Sync) Wait(uuid, alias string, timeout time.Duration) error

Wait waits for the event to arrive

Jump to

Keyboard shortcuts

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