Skip to content

Commit

Permalink
Merge pull request #906 from katiewasnothere/uvm_update_cpu_limits
Browse files Browse the repository at this point in the history
Add uvm call for updating cpu limits
  • Loading branch information
katiewasnothere authored Dec 15, 2020
2 parents e8a2e45 + e0f4daf commit ae33b43
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
22 changes: 22 additions & 0 deletions internal/schema2/vm_processor_limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* HCS API
*
* No description provided (generated by Swagger Codegen https:/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https:/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"`
}
17 changes: 17 additions & 0 deletions internal/uvm/cpulimits_update.go
Original file line number Diff line number Diff line change
@@ -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)
}
3 changes: 2 additions & 1 deletion internal/uvm/resourcepaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ae33b43

Please sign in to comment.