diff --git a/internal/schema2/vm_processor_limits.go b/internal/schema2/vm_processor_limits.go new file mode 100644 index 0000000000..de1b9cf1ae --- /dev/null +++ b/internal/schema2/vm_processor_limits.go @@ -0,0 +1,22 @@ +/* + * HCS API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 2.4 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package hcsschema + +// ProcessorLimits is used when modifying processor scheduling limits of a virtual machine. +type ProcessorLimits struct { + // Maximum amount of host CPU resources that the virtual machine can use. + Limit uint64 `json:"Limit,omitempty"` + // Value describing the relative priority of this virtual machine compared to other virtual machines. + Weight uint64 `json:"Weight,omitempty"` + // Minimum amount of host CPU resources that the virtual machine is guaranteed. + Reservation uint64 `json:"Reservation,omitempty"` + // Provides the target maximum CPU frequency, in MHz, for a virtual machine. + MaximumFrequencyMHz uint32 `json:"MaximumFrequencyMHz,omitempty"` +} diff --git a/internal/uvm/cpulimits_update.go b/internal/uvm/cpulimits_update.go new file mode 100644 index 0000000000..4ea66178f9 --- /dev/null +++ b/internal/uvm/cpulimits_update.go @@ -0,0 +1,17 @@ +package uvm + +import ( + "context" + + hcsschema "github.com/Microsoft/hcsshim/internal/schema2" +) + +// UpdateCPULimits updates the CPU limits of the utility vm +func (uvm *UtilityVM) UpdateCPULimits(ctx context.Context, limits *hcsschema.ProcessorLimits) error { + req := &hcsschema.ModifySettingRequest{ + ResourcePath: cpuLimitsResourcePath, + Settings: limits, + } + + return uvm.modify(ctx, req) +} diff --git a/internal/uvm/resourcepaths.go b/internal/uvm/resourcepaths.go index 93a5af5596..395e5ea412 100644 --- a/internal/uvm/resourcepaths.go +++ b/internal/uvm/resourcepaths.go @@ -3,9 +3,10 @@ package uvm const ( gpuResourcePath string = "VirtualMachine/ComputeTopology/Gpu" memoryResourcePath string = "VirtualMachine/ComputeTopology/Memory/SizeInMB" - cpuGroupResourceFormat string = "VirtualMachine/ComputeTopology/Processor/CpuGroup/%s" + cpuGroupResourcePath string = "VirtualMachine/ComputeTopology/Processor/CpuGroup" idledResourcePath string = "VirtualMachine/ComputeTopology/Processor/IdledProcessors" cpuFrequencyPowerCapResourcePath string = "VirtualMachine/ComputeTopology/Processor/CpuFrequencyPowerCap" + cpuLimitsResourcePath string = "VirtualMachine/ComputeTopology/Processor/Limits" serialResourceFormat string = "VirtualMachine/Devices/ComPorts/%d" flexibleIovResourceFormat string = "VirtualMachine/Devices/FlexibleIov/%s" licensingResourcePath string = "VirtualMachine/Devices/Licensing"