Skip to content

Commit

Permalink
Merge pull request #1106 from ioito/hotfix/qx-esxi-disable-swap
Browse files Browse the repository at this point in the history
fix(esxi): disable swap
  • Loading branch information
ioito authored Nov 4, 2024
2 parents c92ac41 + 6eaad27 commit 863ef87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/multicloud/esxi/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ type SCreateVMParam struct {
Nics []jsonutils.JSONObject
ResourcePool string
InstanceSnapshotInfo SEsxiInstanceSnapshotInfo
EnableEsxiSwap bool
}

type SEsxiInstanceSnapshotInfo struct {
Expand Down Expand Up @@ -1080,7 +1081,17 @@ func (host *SHost) DoCreateVM(ctx context.Context, ds *SDatastore, params SCreat
CpuHotAddEnabled: &True,
CpuHotRemoveEnabled: &True,
MemoryHotAddEnabled: &True,

ExtraConfig: []types.BaseOptionValue{},
}

if !params.EnableEsxiSwap {
spec.ExtraConfig = append(spec.ExtraConfig, &types.OptionValue{
Key: "sched.swap.vmxSwapEnabled",
Value: "FALSE",
})
}

spec.Files = &types.VirtualMachineFileInfo{
VmPathName: datastorePath,
}
Expand Down Expand Up @@ -1319,6 +1330,14 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
CpuHotAddEnabled: &True,
CpuHotRemoveEnabled: &True,
MemoryHotAddEnabled: &True,

ExtraConfig: []types.BaseOptionValue{},
}
if !params.EnableEsxiSwap {
spec.ExtraConfig = append(spec.ExtraConfig, &types.OptionValue{
Key: "sched.swap.vmxSwapEnabled",
Value: "FALSE",
})
}
cloneSpec.Config = &spec
task, err := ovm.Clone(ctx, folders.VmFolder, name, *cloneSpec)
Expand Down
1 change: 1 addition & 0 deletions pkg/multicloud/esxi/storagecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type SDatastoreImageCache struct {
type EsxiOptions struct {
ReasonableCIDREsxi string `help:"Reasonable CIDR in esxi, such as '10.0.0.0/8'" defautl:""`
TemplateNameRegex string `help:"Regex of template name"`
EnableEsxiSwap bool `help:"Enable esxi vm swap" default:"false"`
}

var tempalteNameRegex *regexp.Regexp
Expand Down

0 comments on commit 863ef87

Please sign in to comment.