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

Automated cherry pick of #1106: fix(esxi): disable swap #1107

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
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
Loading