package layers

import "github.com/Microsoft/hcsshim/internal/layers"

Package layers deals with container layer mounting/unmounting for LCOW and WCOW

Index

Functions

func GetWCOWUVMBootFilesFromLayers

func GetWCOWUVMBootFilesFromLayers(ctx context.Context, rootfs []*types.Mount, layerFolders []string) (*uvm.WCOWBootFiles, error)

GetWCOWUVMBootFilesFromLayers prepares the UVM boot files from the rootfs or layerFolders.

func MountLCOWLayers

func MountLCOWLayers(ctx context.Context, containerID string, layers *LCOWLayers, guestRoot string, vm *uvm.UtilityVM) (_, _ string, _ resources.ResourceCloser, err error)

MountLCOWLayers is a helper for clients to hide all the complexity of layer mounting for LCOW Layer folder are in order: base, [rolayer1..rolayern,] scratch Returns the path at which the `rootfs` of the container can be accessed. Also, returns the path inside the UVM at which container scratch directory is located. Usually, this path is the path at which the container scratch VHD is mounted. However, in case of scratch sharing this is a directory under the UVM scratch.

func MountSandboxVolume

func MountSandboxVolume(ctx context.Context, hostPath, volumeName string) (err error)

Mount the sandbox vhd to a user friendly path.

func RemoveSandboxMountPoint

func RemoveSandboxMountPoint(ctx context.Context, hostPath string) error

Remove volume mount point. And remove folder afterwards.

Types

type LCOWLayer

type LCOWLayer struct {
	VHDPath   string
	Partition uint64
}

type LCOWLayers

type LCOWLayers struct {
	// Should be in order from top-most layer to bottom-most layer.
	Layers         []*LCOWLayer
	ScratchVHDPath string
}

LCOWLayers defines a set of LCOW layers. For future extensibility, the LCOWLayer type could be swapped for an interface, and we could either call some method on the interface to "apply" it directly to the UVM, or type cast it to the various types that we support, and use the one it matches. This would allow us to support different "types" of mounts, such as raw VHD, VHD+partition, etc.

func ParseLCOWLayers

func ParseLCOWLayers(rootfs []*types.Mount, layerFolders []string) (*LCOWLayers, error)

ParseLCOWLayers returns a layers.LCOWLayers describing the rootfs that should be set up for an LCOW container. It takes as input the set of rootfs mounts and the layer folders from the OCI spec.

type MountedWCOWLayer

type MountedWCOWLayer struct {
	// A unique layer GUID is expected by HCS for every layer
	LayerID string
	// The path at which this layer is mounted. Could be a path on the host or a path
	// inside the guest.
	MountedPath string
}

Represents a single layer that is mounted and ready to use. Depending on the type of layers each individual layer may or may not be mounted. However, HCS still needs paths of individual layers and a unique ID for each layer.

type MountedWCOWLayers

type MountedWCOWLayers struct {
	// path at which rootfs is setup - this could be a path on the host or a path
	// inside the guest
	RootFS string
	// mounted read-only layer paths are required in the container doc that we send to HCS.
	// In case of WCIFS based layers these would be layer directory paths, however, in case
	// of CimFS layers this would a single volume path at which the CIM is mounted.
	MountedLayerPaths []MountedWCOWLayer
}

func MountWCOWLayers

func MountWCOWLayers(ctx context.Context, containerID string, vm *uvm.UtilityVM, wl WCOWLayers) (_ *MountedWCOWLayers, _ resources.ResourceCloser, err error)

type WCOWLayers

type WCOWLayers interface {
	IsWCOWLayers()
}

WCOW image layers is a tagging interface that all WCOW layers MUST implement. This is only used so that any random struct cannot be passed as a WCOWLayers type.

func ParseWCOWLayers

func ParseWCOWLayers(rootfs []*types.Mount, layerFolders []string) (WCOWLayers, error)

ParseWCOWLayers parses the layers provided by containerd into the format understood by hcsshim and prepares them for mounting.

Source Files

doc.go helpers.go lcow.go wcow_mount.go wcow_parse.go

Version
v0.13.0 (latest)
Published
Apr 21, 2025
Platform
windows/amd64
Imports
28 packages
Last checked
11 hours ago

Tools for package owners.