@@ -778,6 +778,7 @@ type SCreateVMParam struct {
778
778
Nics []jsonutils.JSONObject
779
779
ResourcePool string
780
780
InstanceSnapshotInfo SEsxiInstanceSnapshotInfo
781
+ EnableEsxiSwap bool
781
782
}
782
783
783
784
type SEsxiInstanceSnapshotInfo struct {
@@ -1080,7 +1081,17 @@ func (host *SHost) DoCreateVM(ctx context.Context, ds *SDatastore, params SCreat
1080
1081
CpuHotAddEnabled : & True ,
1081
1082
CpuHotRemoveEnabled : & True ,
1082
1083
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
+ })
1083
1093
}
1094
+
1084
1095
spec .Files = & types.VirtualMachineFileInfo {
1085
1096
VmPathName : datastorePath ,
1086
1097
}
@@ -1319,6 +1330,14 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
1319
1330
CpuHotAddEnabled : & True ,
1320
1331
CpuHotRemoveEnabled : & True ,
1321
1332
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
+ })
1322
1341
}
1323
1342
cloneSpec .Config = & spec
1324
1343
task , err := ovm .Clone (ctx , folders .VmFolder , name , * cloneSpec )
0 commit comments