Skip to content

Commit 8789c0c

Browse files
committed
fix(esxi): disable swap
1 parent 77d2f73 commit 8789c0c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/multicloud/esxi/host.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ type SCreateVMParam struct {
778778
Nics []jsonutils.JSONObject
779779
ResourcePool string
780780
InstanceSnapshotInfo SEsxiInstanceSnapshotInfo
781+
EnableEsxiSwap bool
781782
}
782783

783784
type SEsxiInstanceSnapshotInfo struct {
@@ -1080,7 +1081,17 @@ func (host *SHost) DoCreateVM(ctx context.Context, ds *SDatastore, params SCreat
10801081
CpuHotAddEnabled: &True,
10811082
CpuHotRemoveEnabled: &True,
10821083
MemoryHotAddEnabled: &True,
1084+
1085+
ExtraConfig: []types.BaseOptionValue{},
1086+
}
1087+
1088+
if !params.EnableEsxiSwap {
1089+
spec.ExtraConfig = append(spec.ExtraConfig, &types.OptionValue{
1090+
Key: "sched.swap.vmxSwapEnabled",
1091+
Value: "FALSE",
1092+
})
10831093
}
1094+
10841095
spec.Files = &types.VirtualMachineFileInfo{
10851096
VmPathName: datastorePath,
10861097
}
@@ -1319,6 +1330,14 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
13191330
CpuHotAddEnabled: &True,
13201331
CpuHotRemoveEnabled: &True,
13211332
MemoryHotAddEnabled: &True,
1333+
1334+
ExtraConfig: []types.BaseOptionValue{},
1335+
}
1336+
if !params.EnableEsxiSwap {
1337+
spec.ExtraConfig = append(spec.ExtraConfig, &types.OptionValue{
1338+
Key: "sched.swap.vmxSwapEnabled",
1339+
Value: "FALSE",
1340+
})
13221341
}
13231342
cloneSpec.Config = &spec
13241343
task, err := ovm.Clone(ctx, folders.VmFolder, name, *cloneSpec)

pkg/multicloud/esxi/storagecache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type SDatastoreImageCache struct {
4242
type EsxiOptions struct {
4343
ReasonableCIDREsxi string `help:"Reasonable CIDR in esxi, such as '10.0.0.0/8'" defautl:""`
4444
TemplateNameRegex string `help:"Regex of template name"`
45+
EnableEsxiSwap bool `help:"Enable esxi vm swap" default:"false"`
4546
}
4647

4748
var tempalteNameRegex *regexp.Regexp

0 commit comments

Comments
 (0)