libvirt

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default maximum memory limitation for VM
	DefaultMaxMem = 32768 // size in MiB
	// Default maximum cpu cores limitation for VM
	DefaultMaxCPUs = 8
)

Variables

View Source
var ErrDomainNotFound = errors.New("domain not found")

ErrDomainNotFound err means can't find specified domain returned by domain loop up methods

Functions

This section is empty.

Types

type DomainState

type DomainState int

DomainState represents a state of a libvirt domain

const (
	// DOMAIN_NOSTATE represents the domain is in no state
	DOMAIN_NOSTATE DomainState = iota
	// DOMAIN_RUNNING represents that the domain is running
	DOMAIN_RUNNING
	// DOMAIN_BLOCKED represents that the domain is blocked
	DOMAIN_BLOCKED
	// DOMAIN_PAUSED represents that the domain is paused
	DOMAIN_PAUSED
	// DOMAIN_SHUTDOWN represents that the domain is being shut down
	DOMAIN_SHUTDOWN
	// DOMAIN_CRASHED represents that the domain is crashed
	DOMAIN_CRASHED
	// DOMAIN_PMSUSPENDED represents that the domain is suspended
	DOMAIN_PMSUSPENDED
	// DOMAIN_SHUTOFF represents that the domain is shut off
	DOMAIN_SHUTOFF
)

NOTE: Keep same with github.com/libvirt/libvirt-go/domain.go

type LibvirtConnect

type LibvirtConnect struct {
}

LibvirtConnect is a wrapper for libvirt connection

func NewLibvirtConnect

func NewLibvirtConnect(uri string) (*LibvirtConnect, error)

NewLibvirtConnect create LibvirtConnect by libvirt uri

func (*LibvirtConnect) DefineDomain

func (lc *LibvirtConnect) DefineDomain(dxml *libvirtxml.Domain) (*LibvirtDomain, error)

DefineDomain define domain with domain setting xml

func (*LibvirtConnect) GetDomainByName

func (lc *LibvirtConnect) GetDomainByName(name string) (*LibvirtDomain, error)

GetDomainByName get domain from libvirt by domian name

func (*LibvirtConnect) GetDomainByUUIDString

func (lc *LibvirtConnect) GetDomainByUUIDString(uuid string) (*LibvirtDomain, error)

GetDomainByUUIDString get domain from libvirt by domain UUID

func (*LibvirtConnect) ListDomains

func (lc *LibvirtConnect) ListDomains() ([]*LibvirtDomain, error)

ListDomains get all domains managed by libvirt, including those not managed by unikernel runtime.

type LibvirtDomain

type LibvirtDomain struct {
}

LibvirtDomain is a wrapper for libvirt-go Domain

func (*LibvirtDomain) Create

func (ld *LibvirtDomain) Create() error

Create creates libvirt domain

func (*LibvirtDomain) Destroy

func (ld *LibvirtDomain) Destroy() error

Destroy destroy libvirt domain

func (*LibvirtDomain) GetName

func (ld *LibvirtDomain) GetName() (string, error)

GetName gets name of libvirt domain

func (*LibvirtDomain) GetState

func (ld *LibvirtDomain) GetState() (DomainState, error)

GetState get domain state

func (*LibvirtDomain) GetUUIDString

func (ld *LibvirtDomain) GetUUIDString() (string, error)

GetUUIDString return uuid of libvirt domain

func (*LibvirtDomain) Shutdown

func (ld *LibvirtDomain) Shutdown() error

Shutdown shutdown libvirt domain

func (*LibvirtDomain) Undefine

func (ld *LibvirtDomain) Undefine() error

Undefine undefines libvirt domain

type VMInfo

type VMInfo struct {
	UUID  string
	State DomainState
}

type VMSetting

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

type VMTool

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

func NewVMTool

func NewVMTool(conn *LibvirtConnect, enableLog bool) *VMTool

func (*VMTool) CreateContainer

func (vt *VMTool) CreateContainer(ctrMeta *metadata.ContainerMetadata, sbMeta *metadata.SandboxMetadata) error

NOTE(Crazykev): This method may be changed when support multiple container per Pod. CreateContainer creates VM which contains container defined in container spec

func (*VMTool) GetVMInfo

func (vt *VMTool) GetVMInfo(domainID string) (*VMInfo, error)

GetVMInfo get VM instance info by domain UUID

func (*VMTool) ListVMs

func (vt *VMTool) ListVMs() (map[string]*VMInfo, error)

ListVMs list all known VMs managed by libvirt

func (*VMTool) RemoveVM

func (vt *VMTool) RemoveVM(domainID string) error

RemoveVM stops VM by domain UUID

func (*VMTool) StartVM

func (vt *VMTool) StartVM(domainID string) error

StartVM starts VM by domain UUID

func (*VMTool) StopVM

func (vt *VMTool) StopVM(domainID string, timeout int64) error

StopVM stops VM by domain UUID

Jump to

Keyboard shortcuts

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