Skip to content

Commit

Permalink
Add cpu_pinning option and isolate_emulator_thread to vm resource
Browse files Browse the repository at this point in the history
Signed-off-by: Cooper Tseng <[email protected]>

test
  • Loading branch information
brandboat committed Nov 25, 2024
1 parent a7a0ae4 commit 307f8bc
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"errors"
"fmt"

"github.com/harvester/harvester/pkg/builder"
harvesterutil "github.com/harvester/harvester/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
kubevirtv1 "kubevirt.io/api/core/v1"

"github.com/harvester/harvester/pkg/builder"
harvesterutil "github.com/harvester/harvester/pkg/util"

"github.com/harvester/terraform-provider-harvester/internal/util"
"github.com/harvester/terraform-provider-harvester/pkg/client"
"github.com/harvester/terraform-provider-harvester/pkg/constants"
Expand Down Expand Up @@ -306,6 +307,20 @@ func (c *Constructor) Setup() util.Processors {
return nil
},
},
{
Field: constants.FieldVirtualMachineCPUPinning,
Parser: func(i interface{}) error {
vmBuilder.VirtualMachine.Spec.Template.Spec.Domain.CPU.DedicatedCPUPlacement = i.(bool)
return nil
},
},
{
Field: constants.FieldVirtualMachineIsolateEmulatorThread,
Parser: func(i interface{}) error {
vmBuilder.VirtualMachine.Spec.Template.Spec.Domain.CPU.IsolateEmulatorThread = i.(bool)
return nil
},
},
}
return append(processors, customProcessors...)
}
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/virtualmachine/schema_virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ please use %s instead of this deprecated field:
Optional: true,
Default: false,
},
constants.FieldVirtualMachineCPUPinning: {
Type: schema.TypeBool,
Description: "To enable VM CPU pinning, ensure that at least one node has the CPU manager enabled",
Optional: true,
Default: false,
},
constants.FieldVirtualMachineIsolateEmulatorThread: {
Type: schema.TypeBool,
Description: "To enable isolate emulator thread, ensure that at least one node has the CPU manager enabled, also VM CPU pinning must be enabled. Note that enable option will allocate an additional dedicated CPU.",
Optional: true,
Default: false,
},
}
util.NamespacedSchemaWrap(s, false)
return s
Expand Down
Loading

0 comments on commit 307f8bc

Please sign in to comment.