diff --git a/src/api/vm.coffee b/src/api/vm.coffee index 06ef0bafe..5d73c6a17 100644 --- a/src/api/vm.coffee +++ b/src/api/vm.coffee @@ -325,6 +325,9 @@ set = $coroutine (params) -> else yield xapi.call 'VM.remove_from_other_config', ref, 'auto_poweron' + if 'cpuWeight' of params + yield xapi.setVcpuWeight(vm._xapiId, params.cpuWeight) + # Other fields. for param, fields of { 'name_label' @@ -362,6 +365,8 @@ set.params = { # Kernel arguments for PV VM. PV_args: { type: 'string', optional: true } + + cpuWeight: { type: 'integer', optional: true} } set.resolve = { diff --git a/src/xapi-object-to-xo.js b/src/xapi-object-to-xo.js index ae175818a..55f3ba6a7 100644 --- a/src/xapi-object-to-xo.js +++ b/src/xapi-object-to-xo.js @@ -308,6 +308,10 @@ const TRANSFORMS = { } } + if (obj.VCPUs_params && obj.VCPUs_params.weight) { + vm.cpuWeight = obj.VCPUs_params.weight + } + if (!isHvm) { vm.PV_args = obj.PV_args } diff --git a/src/xapi.js b/src/xapi.js index cab14e4f8..bd36abc24 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -1657,6 +1657,11 @@ export default class Xapi extends XapiBase { ) } + async setVcpuWeight (vmId, weight) { + const vm = this.getObject(vmId) + await this._updateObjectMapProperty(vm, 'VCPUs_params', {weight}) + } + _startVm (vm) { debug(`Starting VM ${vm.name_label}`)