From 8c42d4ae06afd17d71d76749df1c7a637d3ca2f8 Mon Sep 17 00:00:00 2001 From: Cooper Tseng Date: Mon, 21 Oct 2024 17:46:37 +0800 Subject: [PATCH 1/2] Add cpu_pinning and isolate_emulator_thread option --- harvester/create.go | 4 ++++ harvester/flags.go | 14 ++++++++++++++ harvester/harvester.go | 3 +++ 3 files changed, 21 insertions(+) diff --git a/harvester/create.go b/harvester/create.go index da67ce4d..3eea7ab1 100644 --- a/harvester/create.go +++ b/harvester/create.go @@ -106,6 +106,10 @@ func (d *Driver) Create() error { vm.Spec.Template.Spec.Domain.Features.SMM = &kubevirtv1.FeatureState{Enabled: &v} vm.Spec.Template.Spec.Domain.Firmware = &kubevirtv1.Firmware{Bootloader: &kubevirtv1.Bootloader{EFI: &kubevirtv1.EFI{SecureBoot: &v}}} } + + vm.Spec.Template.Spec.Domain.CPU.DedicatedCPUPlacement = d.CPUPinning + vm.Spec.Template.Spec.Domain.CPU.IsolateEmulatorThread = d.IsolateEmulatorThread + createdVM, err := d.createVM(vm) if err != nil { return err diff --git a/harvester/flags.go b/harvester/flags.go index e9ae04f1..47a02a8e 100644 --- a/harvester/flags.go +++ b/harvester/flags.go @@ -158,6 +158,16 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Name: "harvester-vgpu-info", Usage: "harvester-vgpu-info", }, + mcnflag.BoolFlag{ + EnvVar: "HARVESTER_CPU_PINNING", + Name: "harvester-cpu-pinning", + Usage: "enable vm cpu pinning, make sure the the harvester cluster enable cpu manager in at least one node", + }, + mcnflag.BoolFlag{ + EnvVar: "HARVESTER_ISOLATE_EMULATOR_THREAD", + Name: "harvester-isolate-emulator-thread", + Usage: "enable vm isolatate emulator thread, note that enabling this feature will acquire one more cpu", + }, } } @@ -250,6 +260,10 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { } d.VGPUInfo = vGPUInfo } + + d.CPUPinning = flags.Bool("harvester-cpu-pinning") + d.IsolateEmulatorThread = flags.Bool("harvester-isolate-emulator-thread") + return d.checkConfig() } diff --git a/harvester/harvester.go b/harvester/harvester.go index d72e3fa3..94c742ec 100644 --- a/harvester/harvester.go +++ b/harvester/harvester.go @@ -73,6 +73,9 @@ type Driver struct { EnableEFI bool EnableSecureBoot bool VGPUInfo *VGPUInfo + + CPUPinning bool + IsolateEmulatorThread bool } func NewDriver(hostName, storePath string) *Driver { From f6156921a9a81d31914a20d6660766f880e7bb70 Mon Sep 17 00:00:00 2001 From: Cooper Tseng Date: Thu, 12 Dec 2024 12:07:43 +0800 Subject: [PATCH 2/2] Address comments --- harvester/flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/harvester/flags.go b/harvester/flags.go index 47a02a8e..5045bc13 100644 --- a/harvester/flags.go +++ b/harvester/flags.go @@ -161,12 +161,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { mcnflag.BoolFlag{ EnvVar: "HARVESTER_CPU_PINNING", Name: "harvester-cpu-pinning", - Usage: "enable vm cpu pinning, make sure the the harvester cluster enable cpu manager in at least one node", + Usage: "enable vm cpu pinning, please ensure the harvester cluster has cpu manager enabled in at least one node", }, mcnflag.BoolFlag{ EnvVar: "HARVESTER_ISOLATE_EMULATOR_THREAD", Name: "harvester-isolate-emulator-thread", - Usage: "enable vm isolatate emulator thread, note that enabling this feature will acquire one more cpu", + Usage: "enable vm isolatated emulator thread", }, } }