package client

import "github.com/Microsoft/opengcs/client"

Index

Constants

const (

	// ModeActualError means an error has occurred during validation
	ModeActualError = iota
	// ModeActualVhdx means that we are going to use VHDX boot after validation
	ModeActualVhdx
	// ModeActualKernelInitrd means that we are going to use kernel+initrd for boot after validation
	ModeActualKernelInitrd

	// ModeRequestAuto means auto-select the boot mode for a utility VM
	ModeRequestAuto = iota // VHDX will be priority over kernel+initrd
	// ModeRequestVhdx means request VHDX boot if possible
	ModeRequestVhdx
	// ModeRequestKernelInitrd means request Kernel+initrd boot if possible
	ModeRequestKernelInitrd

	// DefaultVhdxSizeGB is the size of the default sandbox & scratch in GB
	DefaultVhdxSizeGB = 20
)

Functions

func CopyFile

func CopyFile(srcFile, destFile string, overwrite bool) error

CopyFile is a utility for copying a file - used for the sandbox cache. Uses CopyFileW win32 API for performance

func LayerVhdDetails

func LayerVhdDetails(folder string) (string, int64, bool, error)

LayerVhdDetails is a utility for getting a file name, size and indication of sandbox for a VHD(x) in a folder. A read-only layer will be layer.vhd. A read-write layer will be sandbox.vhdx.

Types

type Config

type Config struct {
	Options                                        // Configuration options
	Name               string                      // Name of the utility VM
	RequestedMode      Mode                        // What mode is preferred when validating
	ActualMode         Mode                        // What mode was obtained during validation
	UvmTimeoutSeconds  int                         // How long to wait for the utility VM to respond in seconds
	Uvm                hcsshim.Container           // The actual container
	MappedVirtualDisks []hcsshim.MappedVirtualDisk // Data-disks to be attached
}

Config is the structure used to configuring a utility VM. There are two ways of starting. Either supply a VHD, or a Kernel+Initrd. For the latter, both must be supplied, and both must be in the same directory.

VHD is the priority.

func (*Config) CreateExt4Vhdx

func (config *Config) CreateExt4Vhdx(destFile string, sizeGB uint32, cacheFile string) error

CreateExt4Vhdx does what it says on the tin. It is the responsibility of the caller to synchronise simultaneous attempts to create the cache file.

func (*Config) DebugGCS

func (config *Config) DebugGCS()

DebugGCS extracts logs from the GCS. It's a useful hack for debugging, but not necessarily optimal, but all that is available to us in RS3.

func (*Config) GenerateDefault

func (config *Config) GenerateDefault(options []string) error

GenerateDefault generates a default config from a set of options If baseDir is not supplied, defaults to $env:ProgramFiles\Linux Containers

func (*Config) HotAddVhd

func (config *Config) HotAddVhd(hostPath string, containerPath string, readOnly bool, mount bool) error

HotAddVhd hot-adds a VHD to a utility VM. This is used in the global one-utility-VM- service-VM per host scenario. In order to do a graphdriver `Diff`, we hot-add the sandbox to /mnt/<id> so that we can run `exportSandbox` inside the utility VM to get a tar-stream of the sandboxes contents back to the daemon.

func (*Config) HotRemoveVhd

func (config *Config) HotRemoveVhd(hostPath string) error

HotRemoveVhd hot-removes a VHD from a utility VM. This is used in the global one-utility-VM- service-VM per host scenario.

func (*Config) RunProcess

func (config *Config) RunProcess(commandLine string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (hcsshim.Process, error)

RunProcess runs the given command line program in the utilityVM. It takes in an input to the reader to feed into stdin and returns stdout to output. IMPORTANT: It is the responsibility of the caller to call Close() on the returned process.

func (*Config) StartUtilityVM

func (config *Config) StartUtilityVM() error

StartUtilityVM creates and starts a utility VM from a configuration.

func (*Config) TarToVhd

func (config *Config) TarToVhd(targetVHDFile string, reader io.Reader) (int64, error)

TarToVhd streams a tarstream contained in an io.Reader to a fixed vhd file

func (*Config) Validate

func (config *Config) Validate() error

Validate validates a Config structure for starting a utility VM.

func (*Config) VhdToTar

func (config *Config) VhdToTar(vhdFile string, uvmMountPath string, isSandbox bool, vhdSize int64) (io.ReadCloser, error)

VhdToTar does what is says - it exports a VHD in a specified folder (either a read-only layer.vhd, or a read-write sandbox.vhd) to a ReadCloser containing a tar-stream of the layers contents.

type Mode

type Mode uint

Mode is the operational mode, both requested, and actual after verification

type Options

type Options struct {
	KirdPath       string // Path to where kernel/initrd are found (defaults to %PROGRAMFILES%\Linux Containers)
	KernelFile     string // Kernel for Utility VM (embedded in a UEFI bootloader) - does NOT include full path, just filename
	InitrdFile     string // Initrd image for Utility VM - does NOT include full path, just filename
	Vhdx           string // VHD for booting the utility VM - is a full path
	TimeoutSeconds int    // Requested time for the utility VM to respond in seconds (may be over-ridden by environment)
	BootParameters string // Additional boot parameters for initrd booting (not VHDx)
}

Options is the structure used by a client to define configurable options for a utility VM.

func ParseOptions

func ParseOptions(options []string) (Options, error)

ParseOptions parses a set of K-V pairs into options used by opengcs. Note for consistency with the LCOW graphdriver in docker, we keep the same convention of an `lcow.` prefix.

Source Files

config.go createext4vhdx.go hotaddvhd.go hotremovevhd.go init.go layervhddetails.go process.go tartovhd.go utilities.go vhdtotar.go

Version
v0.3.5
Published
Jan 18, 2018
Platform
windows/amd64
Imports
15 packages
Last checked
11 minutes ago

Tools for package owners.