uvm

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxVPMEMCount is the maximum number of VPMem devices that may be added to an LCOW
	// utility VM
	MaxVPMEMCount = 128

	// DefaultVPMEMCount is the default number of VPMem devices that may be added to an LCOW
	// utility VM if the create request doesn't specify how many.
	DefaultVPMEMCount = 64

	// DefaultVPMemSizeBytes is the default size of a VPMem device if the create request
	// doesn't specify.
	DefaultVPMemSizeBytes = 4 * 1024 * 1024 * 1024 // 4GB
)
View Source
const (
	// InitrdFile is the default file name for an initrd.img used to boot LCOW.
	InitrdFile = "initrd.img"
	// VhdFile is the default file name for a rootfs.vhd used to boot LCOW.
	VhdFile = "rootfs.vhd"
	// KernelFile is the default file name for a kernel used to boot LCOW.
	KernelFile = "kernel"
	// UncompressedKernelFile is the default file name for an uncompressed
	// kernel used to boot LCOW with KernelDirect.
	UncompressedKernelFile = "vmlinux"
)

Variables

View Source
var (
	ErrNoAvailableLocation      = fmt.Errorf("no available location")
	ErrNotAttached              = fmt.Errorf("not attached")
	ErrAlreadyAttached          = fmt.Errorf("already attached")
	ErrNoSCSIControllers        = fmt.Errorf("no SCSI controllers configured for this utility VM")
	ErrTooManyAttachments       = fmt.Errorf("too many SCSI attachments")
	ErrSCSILayerWCOWUnsupported = fmt.Errorf("SCSI attached layers are not supported for WCOW")
)

Functions

This section is empty.

Types

type Options added in v0.8.4

type Options struct {
	ID                      string // Identifier for the uvm. Defaults to generated GUID.
	Owner                   string // Specifies the owner. Defaults to executable name.
	AdditionHCSDocumentJSON string // Optional additional JSON to merge into the HCS document prior

	// MemorySizeInMB sets the UVM memory. If `0` will default to platform
	// default.
	MemorySizeInMB int32

	// Memory for UVM. Defaults to true. For physical backed memory, set to
	// false.
	AllowOvercommit bool

	// Memory for UVM. Defaults to false. For virtual memory with deferred
	// commit, set to true.
	EnableDeferredCommit bool

	// ProcessorCount sets the number of vCPU's. If `0` will default to platform
	// default.
	ProcessorCount int32
}

Options are the set of options passed to Create() to create a utility vm.

type OptionsLCOW added in v0.8.4

type OptionsLCOW struct {
	*Options

	BootFilesPath         string              // Folder in which kernel and root file system reside. Defaults to \Program Files\Linux Containers
	KernelFile            string              // Filename under `BootFilesPath` for the kernel. Defaults to `kernel`
	KernelDirect          bool                // Skip UEFI and boot directly to `kernel`
	RootFSFile            string              // Filename under `BootFilesPath` for the UVMs root file system. Defaults to `InitrdFile`
	KernelBootOptions     string              // Additional boot options for the kernel
	EnableGraphicsConsole bool                // If true, enable a graphics console for the utility VM
	ConsolePipe           string              // The named pipe path to use for the serial console.  eg \\.\pipe\vmpipe
	SCSIControllerCount   uint32              // The number of SCSI controllers. Defaults to 1. Currently we only support 0 or 1.
	UseGuestConnection    bool                // Whether the HCS should connect to the UVM's GCS. Defaults to true
	ExecCommandLine       string              // The command line to exec from init. Defaults to GCS
	ForwardStdout         bool                // Whether stdout will be forwarded from the executed program. Defaults to false
	ForwardStderr         bool                // Whether stderr will be forwarded from the executed program. Defaults to true
	OutputHandler         OutputHandler       `json:"-"` // Controls how output received over HVSocket from the UVM is handled. Defaults to parsing output as logrus messages
	VPMemDeviceCount      uint32              // Number of VPMem devices. Defaults to `DefaultVPMEMCount`. Limit at 128. If booting UVM from VHD, device 0 is taken.
	VPMemSizeBytes        uint64              // Size of the VPMem devices. Defaults to `DefaultVPMemSizeBytes`.
	PreferredRootFSType   PreferredRootFSType // If `KernelFile` is `InitrdFile` use `PreferredRootFSTypeInitRd`. If `KernelFile` is `VhdFile` use `PreferredRootFSTypeVHD`
}

OptionsLCOW are the set of options passed to CreateLCOW() to create a utility vm.

func NewDefaultOptionsLCOW added in v0.8.4

func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW

NewDefaultOptionsLCOW creates the default options for a bootable version of LCOW.

`id` the ID of the compute system. If not passed will generate a new GUID.

`owner` the owner of the compute system. If not passed will use the executable files name.

type OptionsWCOW added in v0.8.4

type OptionsWCOW struct {
	*Options

	LayerFolders []string // Set of folders for base layers and scratch. Ordered from top most read-only through base read-only layer, followed by scratch
}

OptionsWCOW are the set of options passed to CreateWCOW() to create a utility vm.

func NewDefaultOptionsWCOW added in v0.8.4

func NewDefaultOptionsWCOW(id, owner string) *OptionsWCOW

NewDefaultOptionsWCOW creates the default options for a bootable version of WCOW. The caller `MUST` set the `LayerFolders` path on the returned value.

`id` the ID of the compute system. If not passed will generate a new GUID.

`owner` the owner of the compute system. If not passed will use the executable files name.

type OutputHandler added in v0.8.4

type OutputHandler func(io.Reader)

OutputHandler is used to process the output from the program run in the UVM.

type PreferredRootFSType

type PreferredRootFSType int
const (
	PreferredRootFSTypeInitRd PreferredRootFSType = iota
	PreferredRootFSTypeVHD
)

type UtilityVM

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

UtilityVM is the object used by clients representing a utility VM

func CreateLCOW added in v0.8.4

func CreateLCOW(opts *OptionsLCOW) (_ *UtilityVM, err error)

CreateLCOW creates an HCS compute system representing a utility VM.

func CreateWCOW added in v0.8.4

func CreateWCOW(opts *OptionsWCOW) (_ *UtilityVM, err error)

CreateWCOW creates an HCS compute system representing a utility VM.

WCOW Notes:

  • The scratch is always attached to SCSI 0:0

func (*UtilityVM) AddNetNS

func (uvm *UtilityVM) AddNetNS(id string, endpoints []*hns.HNSEndpoint) (err error)

AddNetNS adds network namespace inside the guest & adds endpoints to the guest on that namepace

func (*UtilityVM) AddPlan9

func (uvm *UtilityVM) AddPlan9(hostPath string, uvmPath string, readOnly bool) error

AddPlan9 adds a Plan9 share to a utility VM. Each Plan9 share is ref-counted and only added if it isn't already.

func (*UtilityVM) AddSCSI

func (uvm *UtilityVM) AddSCSI(hostPath string, uvmPath string, readOnly bool) (int, int32, error)

AddSCSI adds a SCSI disk to a utility VM at the next available location. This function should be called for a RW/scratch layer or a passthrough vhd/vhdx. For read-only layers on LCOW as an alternate to PMEM for large layers, use AddSCSILayer instead.

`hostPath` is required and must point to a vhd/vhdx path.

`uvmPath` is optional.

`readOnly` set to `true` if the vhd/vhdx should be attached read only.

func (*UtilityVM) AddSCSILayer added in v0.7.13

func (uvm *UtilityVM) AddSCSILayer(hostPath string) (int, int32, error)

AddSCSILayer adds a read-only layer disk to a utility VM at the next available location. This function is used by LCOW as an alternate to PMEM for large layers. The UVMPath will always be /tmp/S<controller>/<lun>.

func (*UtilityVM) AddSCSIPhysicalDisk added in v0.8.4

func (uvm *UtilityVM) AddSCSIPhysicalDisk(hostPath, uvmPath string, readOnly bool) (int, int32, error)

AddSCSIPhysicalDisk attaches a physical disk from the host directly to the Utility VM at the next available location.

`hostPath` is required and `likely` start's with `\\.\PHYSICALDRIVE`.

`uvmPath` is optional if a guest mount is not requested.

`readOnly` set to `true` if the physical disk should be attached read only.

func (*UtilityVM) AddVPMEM

func (uvm *UtilityVM) AddVPMEM(hostPath string, expose bool) (uint32, string, error)

AddVPMEM adds a VPMEM disk to a utility VM at the next available location.

Returns the location(0..MaxVPMEM-1) where the device is attached, and if exposed, the utility VM path which will be /tmp/p<location>//

func (*UtilityVM) AddVSMB

func (uvm *UtilityVM) AddVSMB(hostPath string, guestRequest interface{}, options *hcsschema.VirtualSmbShareOptions) error

AddVSMB adds a VSMB share to a Windows utility VM. Each VSMB share is ref-counted and only added if it isn't already. This is used for read-only layers, mapped directories to a container, and for mapped pipes.

func (*UtilityVM) Close

func (uvm *UtilityVM) Close() error

Close terminates and releases resources associated with the utility VM.

func (*UtilityVM) ComputeSystem

func (uvm *UtilityVM) ComputeSystem() *hcs.System

func (*UtilityVM) ContainerCounter

func (uvm *UtilityVM) ContainerCounter() uint64

ContainerCounter is used for where we layout things for a container in a utility VM. For WCOW it'll be C:\c\N\. For LCOW it'll be /run/gcs/c/N/.

func (*UtilityVM) GetScsiUvmPath added in v0.8.4

func (uvm *UtilityVM) GetScsiUvmPath(hostPath string) (string, error)

GetScsiUvmPath returns the guest mounted path of a SCSI drive.

If `hostPath` is not mounted returns `ErrNotAttached`.

func (*UtilityVM) GetVSMBUvmPath

func (uvm *UtilityVM) GetVSMBUvmPath(hostPath string) (string, error)

GetVSMBUvmPath returns the guest path of a VSMB mount.

func (*UtilityVM) ID

func (uvm *UtilityVM) ID() string

ID returns the ID of the VM's compute system.

func (*UtilityVM) Modify

func (uvm *UtilityVM) Modify(hcsModificationDocument interface{}) error

Modifies the compute system by sending a request to HCS

func (*UtilityVM) OS

func (uvm *UtilityVM) OS() string

OS returns the operating system of the utility VM.

func (*UtilityVM) PMemMaxSizeBytes added in v0.8.0

func (uvm *UtilityVM) PMemMaxSizeBytes() uint64

PMemMaxSizeBytes returns the maximum size of a PMEM layer (LCOW)

func (*UtilityVM) RemoveNetNS

func (uvm *UtilityVM) RemoveNetNS(id string) error

RemoveNetNS removes the namespace information

func (*UtilityVM) RemovePlan9

func (uvm *UtilityVM) RemovePlan9(hostPath string) error

RemovePlan9 removes a Plan9 share from a utility VM. Each Plan9 share is ref-counted and only actually removed when the ref-count drops to zero.

func (*UtilityVM) RemoveSCSI

func (uvm *UtilityVM) RemoveSCSI(hostPath string) error

RemoveSCSI removes a SCSI disk from a utility VM. As an external API, it is "safe". Internal use can call removeSCSI.

func (*UtilityVM) RemoveVPMEM

func (uvm *UtilityVM) RemoveVPMEM(hostPath string) error

RemoveVPMEM removes a VPMEM disk from a utility VM. As an external API, it is "safe". Internal use can call removeVPMEM.

func (*UtilityVM) RemoveVSMB

func (uvm *UtilityVM) RemoveVSMB(hostPath string) error

RemoveVSMB removes a VSMB share from a utility VM. Each VSMB share is ref-counted and only actually removed when the ref-count drops to zero.

func (*UtilityVM) Start

func (uvm *UtilityVM) Start() error

Start synchronously starts the utility VM.

func (*UtilityVM) Terminate

func (uvm *UtilityVM) Terminate() error

Terminate requests a utility VM terminate. If IsPending() on the error returned is true, it may not actually be shut down until Wait() succeeds.

func (*UtilityVM) Wait

func (uvm *UtilityVM) Wait() error

Waits synchronously waits for a utility VM to terminate.

func (*UtilityVM) WaitExpectedError added in v0.8.4

func (uvm *UtilityVM) WaitExpectedError(expected error) error

WaitExpectedError synchronously waits for a utility VM to terminate. If the UVM terminates successfully, or if the given error is encountered internally during the wait, this function returns nil.

Jump to

Keyboard shortcuts

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