libvirtc

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DomainAll                    = libvirt.CONNECT_LIST_DOMAINS_ACTIVE | libvirt.CONNECT_LIST_DOMAINS_INACTIVE
	DomainDeviceModifyConfig     = libvirt.DOMAIN_DEVICE_MODIFY_CONFIG
	DomainDeviceModifyPersistent = libvirt.DOMAIN_DEVICE_MODIFY_LIVE | libvirt.DOMAIN_DEVICE_MODIFY_CONFIG
	DomainDestroyGraceful        = libvirt.DOMAIN_DESTROY_GRACEFUL
	DomainShutdownAcpi           = libvirt.DOMAIN_SHUTDOWN_ACPI_POWER_BTN
	DomainCpuMaximum             = libvirt.DOMAIN_VCPU_MAXIMUM | libvirt.DOMAIN_VCPU_CONFIG
	DomainCpuConfig              = libvirt.DOMAIN_VCPU_CONFIG
	DomainMemMaximum             = libvirt.DOMAIN_MEM_MAXIMUM | libvirt.DOMAIN_MEM_CONFIG
	DomainMemConfig              = libvirt.DOMAIN_MEM_CONFIG
)
View Source
var (
	PciDomain       = "0x00"
	PciDiskBus      = "0x01"
	PciInterfaceBus = "0x02"
	PciFunc         = "0x00"
)
View Source
var DISK = &Disk{}
View Source
var INTERFACE = &Interface{}

Functions

func AddHyperListener

func AddHyperListener(listen HyperListener)

func DomainState2Str

func DomainState2Str(state libvirt.DomainState) string

Types

type ACPIXML

type ACPIXML struct {
	XMLName xml.Name `xml:"acpi" json:"-"`
	Value   string   `xml:",chardata" json:"value"`
}

type APICXML

type APICXML struct {
	XMLName xml.Name `xml:"apic" json:"-"`
	Value   string   `xml:",chardata" json:"value"`
}

type AddressXML

type AddressXML struct {
	XMLName    xml.Name `xml:"address" json:"-"`
	Type       string   `xml:"type,attr,omitempty" json:"type"` // pci and drive.
	Domain     string   `xml:"domain,attr,omitempty" json:"domain"`
	Bus        string   `xml:"bus,attr,omitempty" json:"bus"`
	Slot       string   `xml:"slot,attr,omitempty" json:"slot"`
	Function   string   `xml:"function,attr,omitempty" json:"function"`
	Target     string   `xml:"target,attr,omitempty" json:"target"`
	Unit       string   `xml:"unit,attr,omitempty" json:"unit"`
	Controller string   `xml:"controller,attr,omitempty" json:"controller"`
}

type CPUXML

type CPUXML struct {
	XMLName xml.Name `xml:"cpu" json:"-"`
	Mode    string   `xml:"mode,attr,omitempty" json:"mode"`   // host-model, host-passthrough
	Check   string   `xml:"check,attr,omitempty" json:"check"` // partial, full
	Match   string   `xml:"match,attr,omitempty" json:"match"` // exact
}

type ChannelDeviceXML

type ChannelDeviceXML struct {
	XMLName xml.Name         `xml:"channel" json:"-"`
	Type    string           `xml:"type,attr" json:"type"`
	Source  ChannelSourceXML `xml:"source" json:"source"`
	Target  ChannelTargetXML `xml:"target" json:"target"`
}

type ChannelSourceXML

type ChannelSourceXML struct {
	XMLName xml.Name `xml:"source" json:"-"`
	Channel string   `xml:"channel,attr" json:"channel"`
}

type ChannelTargetXML

type ChannelTargetXML struct {
	XMLName xml.Name `xml:"target" json:"-"`
	Type    string   `xml:"type,attr" json:"type"`
	Name    string   `xml:"name,attr" json:"name"`
}

type ControllerXML

type ControllerXML struct {
	XMLName xml.Name    `xml:"controller" json:"-"`
	Type    string      `xml:"type,attr" json:"type"`
	Index   string      `xml:"index,attr" json:"port"`
	Model   string      `xml:"model,attr,omitempty" json:"model"` // pci-root, pci-bridge.
	Address *AddressXML `xml:"address,omitempty" json:"address"`
}

Bus 0: root Bus 1: disk, ide Bus 2: interface Bus 3: reverse

type CurMemXML

type CurMemXML struct {
	XMLName xml.Name `xml:"currentMemory" json:"-"`
	Type    string   `xml:"unit,attr" json:"unit"`
	Value   string   `xml:",chardata" json:"value"`
}

type DevicesXML

type DevicesXML struct {
	XMLName     xml.Name           `xml:"devices" json:"-"`
	Graphics    []GraphicsXML      `xml:"graphics" json:"graphics"`
	Disks       []DiskXML          `xml:"disk" json:"disk"`
	Interfaces  []InterfaceXML     `xml:"interface" json:"interface"`
	Controllers []ControllerXML    `xml:"controller" json:"controller"`
	Inputs      []InputDeviceXML   `xml:"input" json:"input"`
	Sound       SoundDeviceXML     `xml:"sound" json:"sound"`
	Video       VideoDeviceXML     `xml:"video" json:"video"`
	Channels    []ChannelDeviceXML `xml:"channel" json:"channel"`
}

type Disk

type Disk struct {
}

func (*Disk) Slot2Dev

func (d *Disk) Slot2Dev(bus string, slot uint8) string

func (*Disk) Slot2Name

func (d *Disk) Slot2Name(slot uint8) string

type DiskDriverXML

type DiskDriverXML struct {
	XMLName xml.Name `xml:"driver" json:"-"`
	Type    string   `xml:"type,attr" json:"type"`
	Name    string   `xml:"name,attr" json:"name"`
}

type DiskSourceXML

type DiskSourceXML struct {
	XMLName xml.Name `xml:"source" json:"-"`
	File    string   `xml:"file,attr,omitempty" json:"file"`
	Device  string   `xml:"dev,attr,omitempty" json:"device"`
}

type DiskTargetXML

type DiskTargetXML struct {
	XMLName xml.Name `xml:"target" json:"-"`
	Bus     string   `xml:"bus,attr,omitempty" json:"bus"`
	Dev     string   `xml:"dev,attr,omitempty" json:"dev"`
}

type DiskXML

type DiskXML struct {
	XMLName xml.Name      `xml:"disk" json:"-"`
	Type    string        `xml:"type,attr" json:"type"`
	Device  string        `xml:"device,attr" json:"device"`
	Driver  DiskDriverXML `xml:"driver" json:"driver"`
	Source  DiskSourceXML `xml:"source" json:"source"`
	Target  DiskTargetXML `xml:"target" json:"target"`
	Address *AddressXML   `xml:"address,omitempty" json:"address"`
}

type Domain

type Domain struct {
	libvirt.Domain
	// contains filtered or unexported fields
}

func ListDomains

func ListDomains() ([]Domain, error)

func LookupDomainByUUIDName

func LookupDomainByUUIDName(uuid string) (*Domain, error)

func LookupDomainByUUIDString

func LookupDomainByUUIDString(uuid string) (*Domain, error)

func NewDomainFromVir

func NewDomainFromVir(dom *libvirt.Domain, hyper *HyperVisor) *Domain

func (*Domain) GetMetadataTitle

func (d *Domain) GetMetadataTitle(title bool) (string, error)

func (*Domain) GetXMLDesc

func (d *Domain) GetXMLDesc(secure bool) (string, error)

func (*Domain) SetCpu

func (d *Domain) SetCpu(max, mode string) error

func (*Domain) SetMemory

func (d *Domain) SetMemory(size, unit string) error

func (*Domain) SetMetadataTitle

func (d *Domain) SetMetadataTitle(value string, title bool) error

virsh desc 3 --config --live --title your_title

type DomainXML

type DomainXML struct {
	XMLName  xml.Name    `xml:"domain" json:"-"`
	Id       string      `xml:"id,attr" json:"id"`
	Type     string      `xml:"type,attr" json:"type"` // kvm
	Name     string      `xml:"name" json:"name"`
	UUID     string      `xml:"uuid" json:"uuid"`
	OS       OSXML       `xml:"os" json:"os"`
	Features FeaturesXML `xml:"features" json:"features"`
	CPU      CPUXML      `xml:"cpu" json:"cpu"`
	VCPU     VCPUXML     `xml:"vcpu" json:"vcpu"`
	Memory   MemXML      `xml:"memory" json:"memory"`
	CurMem   CurMemXML   `xml:"currentMemory" json:"currentMemory"`
	Devices  DevicesXML  `xml:"devices" json:"devices"`
}

func NewDomainXMLFromDom

func NewDomainXMLFromDom(dom *Domain, secure bool) *DomainXML

func (*DomainXML) GraphicsAddr

func (domain *DomainXML) GraphicsAddr(format string) (string, string)

type FeaturesXML

type FeaturesXML struct {
	XMLName xml.Name `xml:"features" json:"-"`
	Acpi    *ACPIXML `xml:"acpi,omitempty" json:"acpi"`
	Apic    *APICXML `xml:"apic,omitempty" json:"apic"`
	Pae     *PaeXML  `xml:"pae,omitempty" json:"pae"`
}

type GraphicsXML

type GraphicsXML struct {
	XMLName  xml.Name `xml:"graphics" json:"-"`
	Type     string   `xml:"type,attr" json:"type"` // vnc, spice
	Port     string   `xml:"port,attr" json:"port"`
	AutoPort string   `xml:"autoport,attr,omitempty" json:"autoport"`
	Listen   string   `xml:"listen,attr" json:"listen"`
	Password string   `xml:"passwd,attr,omitempty" json:"password"`
}

type HyperListener

type HyperListener struct {
	Opened func(Conn *libvirt.Connect) error
	Closed func(Conn *libvirt.Connect) error
}

type HyperVisor

type HyperVisor struct {
	Url        string
	Schema     string
	Address    string
	Path       string
	Host       string
	Conn       *libvirt.Connect
	Listener   []HyperListener
	ConnedTime int64
	Lock       sync.RWMutex
	Ticker     *time.Ticker
	CpuSts     *libvirt.NodeCPUStats
	Done       chan bool
	IdleUtil   uint64
	DomUtil    map[string]uint64
}

func GetHyper

func GetHyper() (*HyperVisor, error)

func SetHyper

func SetHyper(name string) (*HyperVisor, error)

func (*HyperVisor) AddListener

func (h *HyperVisor) AddListener(listen HyperListener)

func (*HyperVisor) Close

func (h *HyperVisor) Close()

func (*HyperVisor) DomainDefineXML

func (h *HyperVisor) DomainDefineXML(xmlConfig string) (*Domain, error)

func (*HyperVisor) FigureCPU

func (h *HyperVisor) FigureCPU() (err error)

func (*HyperVisor) GetCPU

func (h *HyperVisor) GetCPU() (uint, string, uint64)

func (*HyperVisor) GetMem

func (h *HyperVisor) GetMem() (t uint64, f uint64, c uint64)

func (*HyperVisor) GetRootfs

func (h *HyperVisor) GetRootfs() string

func (*HyperVisor) ListAllDomains

func (h *HyperVisor) ListAllDomains() ([]Domain, error)

func (*HyperVisor) LookupDomainByName

func (h *HyperVisor) LookupDomainByName(id string) (*Domain, error)

func (*HyperVisor) LookupDomainByUUIDName

func (h *HyperVisor) LookupDomainByUUIDName(id string) (*Domain, error)

func (*HyperVisor) LookupDomainByUUIDString

func (h *HyperVisor) LookupDomainByUUIDString(id string) (*Domain, error)

func (*HyperVisor) LoopForever

func (h *HyperVisor) LoopForever()

func (*HyperVisor) Open

func (h *HyperVisor) Open() error

func (*HyperVisor) SetUrl

func (h *HyperVisor) SetUrl(name string)

func (*HyperVisor) UpTime

func (h *HyperVisor) UpTime() int64

type InputDeviceXML

type InputDeviceXML struct {
	XMLName xml.Name `xml:"input" json:"-"`
	Type    string   `xml:"type,attr" json:"type"`
	Bus     string   `xml:"bus,attr" json:"bus"`
}

type Interface

type Interface struct {
}

func (*Interface) Slot2Dev

func (int *Interface) Slot2Dev(slot uint8) string

type InterfaceDriverXML

type InterfaceDriverXML struct {
	XMLName xml.Name `xml:"driver" json:"-"`
	Name    string   `xml:"name,attr,omitempty" json:"name"` //vfio or vhost
	Queues  string   `xml:"queues,attr,omitempty" json:"queues"`
}

type InterfaceMacXML

type InterfaceMacXML struct {
	XMLName xml.Name `xml:"mac" json:"-"`
	Address string   `xml:"address,attr,omitempty" json:"address"`
}

type InterfaceModelXML

type InterfaceModelXML struct {
	XMLName xml.Name `xml:"model" json:"-"`
	Type    string   `xml:"type,attr" json:"type"` //rtl8139, virtio, e1000
}

type InterfaceSourceXML

type InterfaceSourceXML struct {
	XMLName xml.Name    `xml:"source" json:"-"`
	Bridge  string      `xml:"bridge,attr,omitempty" json:"bridge"`
	Network string      `xml:"network,attr,omitempty" json:"network"`
	Address *AddressXML `xml:"address,omitempty" json:"address"`
}

type InterfaceTargetXML

type InterfaceTargetXML struct {
	XMLName xml.Name `xml:"target" json:"-"`
	Bus     string   `xml:"bus,attr,omitempty" json:"bus"`
	Dev     string   `xml:"dev,attr,omitempty" json:"dev"`
}

type InterfaceVirPortXML

type InterfaceVirPortXML struct {
	XMLName xml.Name `xml:"virtualport" json:"-"`
	Type    string   `xml:"type,attr,omitempty" json:"type"` //openvswitch
}

type InterfaceXML

type InterfaceXML struct {
	XMLName     xml.Name             `xml:"interface" json:"-"`
	Type        string               `xml:"type,attr" json:"type"`
	Mac         InterfaceMacXML      `xml:"mac" json:"mac"`
	Source      InterfaceSourceXML   `xml:"source" json:"source"`
	Model       InterfaceModelXML    `xml:"model" json:"model"`
	Driver      *InterfaceDriverXML  `xml:"driver" json:"driver"`
	Target      InterfaceTargetXML   `xml:"target" json:"target"`
	VirtualPort *InterfaceVirPortXML `xml:"virtualport,omitempty" json:"virtualport"`
	Address     *AddressXML          `xml:"address,omitempty" json:"address"`
}

type MemXML

type MemXML struct {
	XMLName xml.Name `xml:"memory" json:"-"`
	Type    string   `xml:"unit,attr" json:"unit"`
	Value   string   `xml:",chardata" json:"value"`
}

type OSBootMenuXML

type OSBootMenuXML struct {
	XMLName xml.Name `xml:"bootmenu" json:"-"`
	Enable  string   `xml:"enable,attr" json:"enable"` // yes
}

type OSBootXML

type OSBootXML struct {
	XMLName xml.Name `xml:"boot" json:"-"`
	Dev     string   `xml:"dev,attr" json:"dev"` // hd, cdrom, network
}

type OSTypeXML

type OSTypeXML struct {
	XMLName xml.Name `xml:"type" json:"-"`
	Arch    string   `xml:"arch,attr" json:"arch"` // x86_64
	Machine string   `xml:"machine,attr" json:"machine"`
	Value   string   `xml:",chardata" json:"value"` // hvm
}

type OSXML

type OSXML struct {
	XMLName  xml.Name      `xml:"os" json:"-"`
	Type     OSTypeXML     `xml:"type" json:"type"`
	Boot     []OSBootXML   `xml:"boot" json:"boot"` //<bootmenu enable='yes'/>
	BootMenu OSBootMenuXML `xml:"bootmenu" json:"bootmenu"`
}

type PaeXML

type PaeXML struct {
	XMLName xml.Name `xml:"pae" json:"-"`
	Value   string   `xml:",chardata" json:"value"`
}

type SnapshotXML

type SnapshotXML struct {
	XMLName   xml.Name `xml:"domainsnapshot" json:"-"`
	Name      string   `xml:"name,omitempty" json:"name"`
	State     string   `xml:"state,omitempty" json:"state"`
	CreateAt  int64    `xml:"creationTime,omitempty" json:"creationTime"`
	IsCurrent bool     `xml:"-" json:"-"`
}

func NewSnapshotXMLFromDom

func NewSnapshotXMLFromDom(ds *libvirt.DomainSnapshot) *SnapshotXML

type SoundDeviceXML

type SoundDeviceXML struct {
	XMLName xml.Name `xml:"sound" json:"-"`
	Model   string   `xml:"model,attr" json:"model"` // ac97, ich6
}

type VCPUXML

type VCPUXML struct {
	XMLName   xml.Name `xml:"vcpu" json:"-"`
	Placement string   `xml:"placement,attr" json:"placement"` // static
	Value     string   `xml:",chardata" json:"Value"`
}

type VideoDeviceXML

type VideoDeviceXML struct {
	XMLName xml.Name      `xml:"video" json:"-"`
	Model   VideoModelXML `xml:"model" json:"model"`
}

type VideoModelXML

type VideoModelXML struct {
	XMLName xml.Name `xml:"model" json:"-"`
	Type    string   `xml:"type,attr" json:"type"` // qxl, cirrus
}

Jump to

Keyboard shortcuts

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