Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uvm call for updating cpu limits #906

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://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"`
}
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