@@ -19,6 +19,7 @@ import (
1919 "github.com/Microsoft/hcsshim/internal/uvmfolder"
2020 "github.com/Microsoft/hcsshim/internal/wclayer"
2121 "github.com/Microsoft/hcsshim/internal/wcow"
22+ "github.com/Microsoft/hcsshim/osversion"
2223 "github.com/containerd/ttrpc"
2324 "github.com/pkg/errors"
2425 "go.opencensus.io/trace"
@@ -122,6 +123,19 @@ func prepareConfigDoc(ctx context.Context, uvm *UtilityVM, opts *OptionsWCOW, uv
122123 }
123124 }
124125
126+ processor := & hcsschema.Processor2 {
127+ Count : uvm .processorCount ,
128+ Limit : opts .ProcessorLimit ,
129+ Weight : opts .ProcessorWeight ,
130+ }
131+ // We can set a cpu group for the VM at creation time in recent builds.
132+ if opts .CPUGroupID != "" {
133+ if osversion .Build () < cpuGroupCreateBuild {
134+ return nil , errCPUGroupCreateNotSupported
135+ }
136+ processor .CpuGroup = & hcsschema.CpuGroup {Id : opts .CPUGroupID }
137+ }
138+
125139 doc := & hcsschema.ComputeSystem {
126140 Owner : uvm .owner ,
127141 SchemaVersion : schemaversion .SchemaV21 (),
@@ -148,11 +162,7 @@ func prepareConfigDoc(ctx context.Context, uvm *UtilityVM, opts *OptionsWCOW, uv
148162 HighMMIOBaseInMB : opts .HighMMIOBaseInMB ,
149163 HighMMIOGapInMB : opts .HighMMIOGapInMB ,
150164 },
151- Processor : & hcsschema.Processor2 {
152- Count : uvm .processorCount ,
153- Limit : opts .ProcessorLimit ,
154- Weight : opts .ProcessorWeight ,
155- },
165+ Processor : processor ,
156166 },
157167 Devices : & hcsschema.Devices {
158168 HvSocket : & hcsschema.HvSocket2 {
@@ -215,7 +225,6 @@ func CreateWCOW(ctx context.Context, opts *OptionsWCOW) (_ *UtilityVM, err error
215225 vpciDevices : make (map [string ]* VPCIDevice ),
216226 physicallyBacked : ! opts .AllowOvercommit ,
217227 devicesPhysicallyBacked : opts .FullyPhysicallyBacked ,
218- cpuGroupID : opts .CPUGroupID ,
219228 createOpts : * opts ,
220229 }
221230
0 commit comments