juju: github.com/wallyworld/juju/container/kvm/libvirt Index | Files

package libvirt

import "github.com/wallyworld/juju/container/kvm/libvirt"


Package Files

doc.go domainxml.go

type Address Uses

type Address struct {
    Type     string `xml:"type,attr,omitepmty"`
    Domain   string `xml:"domain,attr,omitempty"`
    Bus      string `xml:"bus,attr,omitempty"`
    Slot     string `xml:"slot,attr,omitempty"`
    Function string `xml:"function,attr,omitempty"`

Address is static. We generate a default value for it. See: Controller, Video

type CPU Uses

type CPU struct {
    Mode  string `xml:"mode,attr,omitempty"`
    Match string `xml:"match,attr,omitempty"`
    Model Model  `xml:"model,omitempty"`

CPU defines CPU topology and model requirements. See: https://libvirt.org/formatdomain.html#elementsCPU

type Console Uses

type Console struct {
    Type   string        `xml:"type,attr"`
    TTY    string        `xml:"tty,attr,omitempty"`
    Source ConsoleSource `xml:"source,omitempty"`
    Target ConsoleTarget `xml:"target,omitempty"`

Console is static. We generate a default value for it. See: https://libvirt.org/formatdomain.html#elementsConsole

type ConsoleSource Uses

type ConsoleSource struct {
    Path string `xml:"path,attr,omitempty"`

ConsoleSource is static. We generate a default value for it. See: Console

type ConsoleTarget Uses

type ConsoleTarget struct {
    Type string `xml:"type,attr,omitempty"`
    Port int    `xml:"port,attr"`
    Path string `xml:"path,attr,omitempty"`

ConsoleTarget is static. We generate a default value for it. See: Console

type CurrentMemory Uses

type CurrentMemory struct {
    Unit string `xml:"unit,attr"`
    Text uint64 `xml:",chardata"`

CurrentMemory is the actual allocation of memory for the guest. It appears we historically set this the same as Memory, which is also the default behavior of libvirt. Constraints.Value.Mem documents this as "megabytes". Interpreting that here as MiB. See: Memory, github.com/juju/juju/core/constraints/constraints.Value.Mem

type Disk Uses

type Disk struct {
    Device string     `xml:"device,attr"`
    Type   string     `xml:"type,attr"`
    Driver DiskDriver `xml:"driver"`
    Source DiskSource `xml:"source"`
    Target DiskTarget `xml:"target"`

Disk is dynamic. We create it with paths to the user data source and disk. See: https://libvirt.org/formatdomain.html#elementsDisks

type DiskDriver Uses

type DiskDriver struct {
    Type string `xml:"type,attr"`
    Name string `xml:"name,attr"`

DiskDriver is the type of virtual disk. We generate it dynamically. See: Disk

type DiskInfo Uses

type DiskInfo interface {
    // Source is the path to the disk image.
    Source() string
    // Driver is the type of disk, qcow, vkmd, raw, etc...
    Driver() string

DiskInfo represents the type and location of a libvirt pool image.

type DiskSource Uses

type DiskSource struct {
    File string `xml:"file,attr"`

DiskSource is the location of the disk image. In our case the path to the necessary images. See: Disk

type DiskTarget Uses

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

DiskTarget is the target device on the guest. We generate these.

type Domain Uses

type Domain struct {
    XMLName       xml.Name    `xml:"domain"`
    Type          string      `xml:"type,attr"`
    Name          string      `xml:"name"`
    VCPU          uint64      `xml:"vcpu"`
    CurrentMemory Memory      `xml:"currentMemory"`
    Memory        Memory      `xml:"memory"`
    OS            OS          `xml:"os"`
    Features      *Features   `xml:"features,omitempty"`
    CPU           *CPU        `xml:"cpu,omitempty"`
    Disk          []Disk      `xml:"devices>disk"`
    Interface     []Interface `xml:"devices>interface"`
    Serial        Serial      `xml:"devices>serial,omitempty"`
    Console       []Console   `xml:"devices>console"`

Domain describes a libvirt domain. A domain is an instance of an operating system running on a virtualized machine. See: https://libvirt.org/formatdomain.html where we only care about kvm specific details.

func NewDomain Uses

func NewDomain(p domainParams) (Domain, error)

NewDomain returns a guest domain suitable for unmarshaling (as XML) onto the target host.

type Features Uses

type Features struct {
    GIC  *GIC   `xml:"gic,omitempty"`
    ACPI string `xml:"acpi"`

Features allows us to request one or more hypervisor features to be toggled on/off. See: https://libvirt.org/formatdomain.html#elementsFeatures

type GIC Uses

type GIC struct {
    Version string `xml:"version,attr,omitempty"`

GIC is the Generic Interrupt Controller and is required to UEFI boot on ARM64.

NB: Dann Frazier (irc:dannf) reports: To deploy trusty, we'll either need to use a GICv2 host, or use the HWE kernel in your guest. There are no official cloud images w/ HWE kernel preinstalled AFAIK. The systems we have in our #hyperscale lab are GICv3 (requiring an HWE kernel) - but the system Juju QA has had for a while (McDivitt) is GICv2, so it should be able to boot a standard trusty EFI cloud image. Either way, you'll need a xenial *host*, at least to have a new enough version of qemu-efi and so libvirt can parse the gic_version=host xml.

TODO(ro) 2017-01-20 Determine if we can provide details to reliably boot trusty, or if we should exit on error if we are trying to boot trusty on arm64.

See: https://libvirt.org/formatdomain.html#elementsFeatures

type Interface Uses

type Interface struct {
    Type            string                `xml:"type,attr"`
    MAC             InterfaceMAC          `xml:"mac"`
    Model           Model                 `xml:"model"`
    Source          InterfaceSource       `xml:"source"`
    Guest           InterfaceGuest        `xml:"guest"`
    VirtualPortType *InterfaceVirtualPort `xml:"virtualport,omitempty"`

Interface is dynamic. It represents a network interface. We generate it from an incoming argument. See: https://libvirt.org/formatdomain.html#elementsNICSBridge

type InterfaceGuest Uses

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

InterfaceGuest is the guests network device. See: Interface

type InterfaceInfo Uses

type InterfaceInfo interface {
    // MAC returns the interfaces MAC address.
    MACAddress() string
    // ParentInterfaceName returns the interface's parent device name.
    ParentInterfaceName() string
    // ParentVirtualPortType returns the type of the virtual port for this
    // interface's parent (e.g. for bridging to an OVS-managed device) or
    // an empty value if no virtual port is used.
    ParentVirtualPortType() string
    // InterfaceName returns the interface's device name.
    InterfaceName() string

InterfaceInfo represents network interface parameters for a kvm domain.

type InterfaceMAC Uses

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

InterfaceMAC is the MAC address for an Interface. See: Interface

type InterfaceSource Uses

type InterfaceSource struct {
    Bridge string `xml:"bridge,attr"`

InterfaceSource it the host bridge to the network. See: Interface

type InterfaceVirtualPort Uses

type InterfaceVirtualPort struct {
    Type string `xml:"type,attr"`

InterfaceVirtualPort provides additional configuration data to be forwarded to a vepa (802.1Qbg) or 802.1Qbh compliant switch, or to an Open vSwitch virtual switch.

type Memory Uses

type Memory struct {
    Unit string `xml:"unit,attr,omitempty"`
    Text uint64 `xml:",chardata"`

Memory is dynamic. We take an argument to set it. Unit is magnitude of memory: b, k or KiB, KB, M or MiB, MB, etc... The libvirt default is KiB. We want to set MiB so we default to that. See: https://libvirt.org/formatdomain.html#elementsMemoryAllocation

type Model Uses

type Model struct {
    Fallback string `xml:"fallback,attr,omitempty"`
    Text     string `xml:",chardata"`
    Type     string `xml:"type,attr,omitempty"`

Model is used as an element in CPU and Interface. See: CPU, Interface

type NVRAMCode Uses

type NVRAMCode struct {
    Text     string `xml:",chardata"`
    ReadOnly string `xml:"readonly,attr,omitempty"`
    Type     string `xml:"type,attr,omitempty"`

NVRAMCode represents the "firmware blob". In our case that is the UEFI code which is of type pflash. See: https://libvirt.org/formatdomain.html#elementsOS

type OS Uses

type OS struct {
    Type OSType `xml:"type"`
    // Loader is a pointer so it is omitted if empty.
    Loader *NVRAMCode `xml:"loader,omitempty"`

OS is static. We generate a default value (kvm) for it. See: https://libvirt.org/formatdomain.html#elementsOSBIOS See also: https://libvirt.org/formatcaps.html#elementGuest

type OSType Uses

type OSType struct {
    Text    string `xml:",chardata"`
    Arch    string `xml:"arch,attr,omitempty"`
    Machine string `xml:"machine,attr,omitempty"`

OSType provides details that are required on certain architectures, e.g. ARM64. See: https://libvirt.org/formatdomain.html#elementsOS

type Serial Uses

type Serial struct {
    Type   string       `xml:"type,attr"`
    Source SerialSource `xml:"source"`
    Target SerialTarget `xml:"target"`

Serial is static. This was added specifically to create a functional console for troubleshooting vms as they boot. You can attach to this console with `virsh console <domainName>`. See: https://libvirt.org/formatdomain.html#elementsConsole

type SerialSource Uses

type SerialSource struct {
    Path string `xml:"path,attr"`

SerialSource is static. We generate a default value for it. See: Serial

type SerialTarget Uses

type SerialTarget struct {
    Port int `xml:"port,attr"`

SerialTarget is static. We generate a default value for it. See: Serial

Package libvirt imports 4 packages (graph). Updated 2020-08-06. Refresh now. Tools for package owners.