package hcsoci
import "github.com/Microsoft/hcsshim/internal/hcsoci"
Index ¶
- func ConvertCPULimits(ctx context.Context, cid string, spec *specs.Spec, maxCPUCount int32) (int32, int32, int32, error)
- func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Container, _ *resources.Resources, err error)
- func NormalizeMemorySize(ctx context.Context, cid string, requestedSizeMB uint64) uint64
- func NormalizeProcessorCount(ctx context.Context, cid string, requestedCount, hostCount int32) int32
- type CreateOptions
- type MountType
Functions ¶
func ConvertCPULimits ¶
func ConvertCPULimits(ctx context.Context, cid string, spec *specs.Spec, maxCPUCount int32) (int32, int32, int32, error)
ConvertCPULimits handles the logic of converting and validating the containers CPU limits specified in the OCI spec to what HCS expects.
`cid` is the container's ID.
`vmid` is the Utility VM's ID if the container we're constructing is going to belong to one.
`spec` is the OCI spec for the container.
`maxCPUCount` is the maximum cpu count allowed for the container. This value should be the number of processors on the host, or in the case of a hypervisor isolated container the number of processors assigned to the guest/Utility VM.
Returns the cpu count, cpu limit, and cpu weight in this order. Returns an error if more than one of cpu count, cpu limit, or cpu weight was specified in the OCI spec as they are mutually exclusive.
func CreateContainer ¶
func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Container, _ *resources.Resources, err error)
CreateContainer creates a container. It can cope with a wide variety of scenarios, including v1 HCS schema calls, as well as more complex v2 HCS schema calls. Note we always return the resources that have been allocated, even in the case of an error. This provides support for the debugging option not to release the resources on failure, so that the client can make the necessary call to release resources that have been allocated as part of calling this function.
func NormalizeMemorySize ¶
NormalizeMemorySize returns the requested memory size in MB aligned up to an even number
func NormalizeProcessorCount ¶
func NormalizeProcessorCount(ctx context.Context, cid string, requestedCount, hostCount int32) int32
NormalizeProcessorCount returns the `Min(requested, logical CPU count)`.
Types ¶
type CreateOptions ¶
type CreateOptions struct { // Common parameters ID string // Identifier for the container Owner string // Specifies the owner. Defaults to executable name. Spec *specs.Spec // Definition of the container or utility VM being created SchemaVersion *hcsschema.Version // Requested Schema Version. Defaults to v2 for RS5, v1 for RS1..RS4 HostingSystem *uvm.UtilityVM // Utility or service VM in which the container is to be created. NetworkNamespace string // Host network namespace to use (overrides anything in the spec) LCOWLayers *layers.LCOWLayers WCOWLayers layers.WCOWLayers // This is an advanced debugging parameter. It allows for diagnosability by leaving a containers // resources allocated in case of a failure. Thus you would be able to use tools such as hcsdiag // to look at the state of a utility VM to see what resources were allocated. Obviously the caller // must a) not tear down the utility VM on failure (or pause in some way) and b) is responsible for // performing the ReleaseResources() call themselves. DoNotReleaseResourcesOnFailure bool // ScaleCPULimitsToSandbox indicates that the container CPU limits should be adjusted to account // for the difference in CPU count between the host and the UVM. ScaleCPULimitsToSandbox bool }
CreateOptions are the set of fields used to call CreateContainer(). Note: In the spec, the LayerFolders must be arranged in the same way in which moby configures them: layern, layern-1,...,layer2,layer1,scratch where layer1 is the base read-only layer, layern is the top-most read-only layer, and scratch is the RW layer. This is for historical reasons only.
type MountType ¶
type MountType = string
MountType represents the type of mount being added
const ( // supported internal mount types MountTypeBind MountType = "bind" MountTypePhysicalDisk MountType = "physical-disk" MountTypeVirtualDisk MountType = "virtual-disk" MountTypeExtensibleVirtualDisk MountType = "extensible-virtual-disk" )
MountType const
Source Files ¶
create.go devices.go doc.go hcsdoc_lcow.go hcsdoc_wcow.go network.go resources.go resources_lcow.go resources_wcow.go
- Version
- v0.13.0 (latest)
- Published
- Apr 21, 2025
- Platform
- windows/amd64
- Imports
- 39 packages
- Last checked
- 2 hours ago –
Tools for package owners.