fix(Xapi#editVm): XS 7.3 support for memory (#634)
Fixes vatesfr/xo-web#2540
This commit is contained in:
commit
5fe03f2934
@ -1,5 +1,5 @@
|
||||
import deferrable from 'golike-defer'
|
||||
import { ignoreErrors } from 'promise-toolbox'
|
||||
import { catchPlus as pCatch, ignoreErrors } from 'promise-toolbox'
|
||||
import {
|
||||
find,
|
||||
gte,
|
||||
@ -319,13 +319,40 @@ export default {
|
||||
memoryMax: {
|
||||
addToLimits: true,
|
||||
limitName: 'memory',
|
||||
constraints: {
|
||||
memoryMin: lte,
|
||||
memoryStaticMax: gte,
|
||||
},
|
||||
get: vm => +vm.memory_dynamic_max,
|
||||
preprocess: parseSize,
|
||||
set: 'memory_dynamic_max',
|
||||
set (dynamicMax, vm) {
|
||||
const { $ref } = vm
|
||||
const dynamicMin = Math.min(vm.memory_dynamic_min, dynamicMax)
|
||||
|
||||
if (isVmRunning(vm)) {
|
||||
return this.call(
|
||||
'VM.set_memory_dynamic_range',
|
||||
$ref,
|
||||
dynamicMin,
|
||||
dynamicMax
|
||||
)
|
||||
}
|
||||
|
||||
const staticMin = Math.min(vm.memory_static_min, dynamicMax)
|
||||
return this.call(
|
||||
'VM.set_memory_limits',
|
||||
$ref,
|
||||
staticMin,
|
||||
Math.max(dynamicMax, vm.memory_static_max),
|
||||
dynamicMin,
|
||||
dynamicMax
|
||||
)::pCatch({ code: 'MEMORY_CONSTRAINT_VIOLATION' }, () =>
|
||||
this.call(
|
||||
'VM.set_memory_limits',
|
||||
$ref,
|
||||
staticMin,
|
||||
dynamicMax,
|
||||
dynamicMax,
|
||||
dynamicMax
|
||||
)
|
||||
)
|
||||
},
|
||||
},
|
||||
|
||||
memoryStaticMax: {
|
||||
|
Loading…
Reference in New Issue
Block a user