...
1 package hcsoci
2
3 import (
4 "context"
5
6 "github.com/Microsoft/hcsshim/internal/log"
7 "github.com/sirupsen/logrus"
8 )
9
10
11 type MountType = string
12
13
14 const (
15
16 MountTypeBind MountType = "bind"
17 MountTypePhysicalDisk MountType = "physical-disk"
18 MountTypeVirtualDisk MountType = "virtual-disk"
19 MountTypeExtensibleVirtualDisk MountType = "extensible-virtual-disk"
20 )
21
22
23 func NormalizeProcessorCount(ctx context.Context, cid string, requestedCount, hostCount int32) int32 {
24 if requestedCount > hostCount {
25 log.G(ctx).WithFields(logrus.Fields{
26 "id": cid,
27 "requested count": requestedCount,
28 "assigned count": hostCount,
29 }).Warn("Changing user requested cpu count to current number of processors on the host")
30 return hostCount
31 } else {
32 return requestedCount
33 }
34 }
35
36
37 func NormalizeMemorySize(ctx context.Context, cid string, requestedSizeMB uint64) uint64 {
38 actualMB := (requestedSizeMB + 1) &^ 1
39 if requestedSizeMB != actualMB {
40 log.G(ctx).WithFields(logrus.Fields{
41 "id": cid,
42 "requestedMB": requestedSizeMB,
43 "actualMB": actualMB,
44 }).Warn("Changing user requested MemorySizeInMB to align to 2MB")
45 }
46 return actualMB
47 }
48
View as plain text