Martin Sivák has uploaded a new change for review. Change subject: Add API.VM.setIoTune ......................................................................
Add API.VM.setIoTune Change-Id: I0bd48f13311ad2efc4241117a777ca3400c259ea Signed-off-by: Martin Sivak <[email protected]> --- M lib/vdsm/define.py M vdsm/API.py M vdsm/rpc/vdsmapi-schema.json M vdsm/virt/vm.py 4 files changed, 64 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/28714/1 diff --git a/lib/vdsm/define.py b/lib/vdsm/define.py index 4b25f89..34f423a 100644 --- a/lib/vdsm/define.py +++ b/lib/vdsm/define.py @@ -144,6 +144,9 @@ 'updateVmPolicyErr': {'status': { 'code': 63, 'message': 'Failed to update VM SLA policy'}}, + 'updateIoTuneErr': {'status': { + 'code': 64, + 'message': 'Failed to update ioTune values'}}, 'recovery': {'status': { 'code': 99, 'message': 'Recovering from crash or Initializing'}}, diff --git a/vdsm/API.py b/vdsm/API.py index cb8ec06..dcd1fc0 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -708,6 +708,12 @@ return errCode['noVM'] return v.setCpuTuneQuota(quota) + def setIoTune(self, tunables): + v = self._cif.vmContainer.get(self._UUID) + if not v: + return errCode['noVM'] + return v.setIoTune(tunables) + def setCpuTunePeriod(self, period): v = self._cif.vmContainer.get(self._UUID) if not v: diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json index 341b6c6..1dbb5f7 100644 --- a/vdsm/rpc/vdsmapi-schema.json +++ b/vdsm/rpc/vdsmapi-schema.json @@ -7470,6 +7470,22 @@ 'returns': 'VmDefinition'} ## +# @VM.setIoTune: +# +# Sets the ioTune parameters for block devices +# +# @tunables: list of VmDiskDeviceTuneParams objects +# describing the new settings +# Returns: +# Status code +# +# Since: 4.15.0 +## +{'command': {'class': 'VM', 'name': 'setIoTune'}, + 'data': {'tunables': ['VmDiskDeviceTuneParams']}, + 'returns': 'TasksStatus'} + +## # @VM.setCpuTuneQuota: # # Set the vCpu quota tune parameter to the VM diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index b4d142e..a4e5c2a 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -3723,6 +3723,45 @@ return {'status': doneCode} + def setIoTune(self, tunables): + for io_tune_change in tunables: + device_name = io_tune_change.get('name', None) + device_path = io_tune_change.get('path', None) + io_tune = io_tune_change['ioTune'] + + # Find the proper device object + for device in self._devices: + if ((device.name == device_name + or device.get("path") == device_path) + and isVdsmImage(device)): + found_device = device + break + else: + return self._reportError( + key='updateIoTuneErr', + msg="Device {} not found".format(device_name)) + + # Verify the ioTune params + try: + found_device._validateIoTuneParams(io_tune) + except ValueError: + return self._reportException(key='updateIoTuneErr', + msg='Invalid ioTune value') + + # Set the ioTune arguments + try: + self._dom.setBlockIoTune(device_name, io_tune, + libvirt.VIR_DOMAIN_AFFECT_CURRENT) + except libvirt.libvirtError as e: + self.log.exception("setVmIoTune failed") + if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN: + return errCode['noVM'] + else: + return self._reportError(key='updateIoTuneErr', + msg=e.message) + + return {'status': doneCode} + def _createTransientDisk(self, diskParams): if diskParams.get('shared', None) != DRIVE_SHARED_TYPE.TRANSIENT: return -- To view, visit http://gerrit.ovirt.org/28714 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0bd48f13311ad2efc4241117a777ca3400c259ea Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
