From: Peter Krempa Date: Tue, 10 Aug 2021 12:56:31 +0000 (+0200) Subject: qemu: Always assume that qemu supports drive throttling X-Git-Tag: v7.7.0-rc1~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96ecc3e20855f3b61c7b7b64b5ad01b43050ec1b;p=thirdparty%2Flibvirt.git qemu: Always assume that qemu supports drive throttling All currently supported qemu versions support all throttling capabilities. It is unlikely that any of the fields will be removed in the future and if it will we will need to do specific probing which is possible via the 'throttle' object which is the replacement for the legacy way to configure throttling. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ed3af5a619..7b7639c51a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15928,9 +15928,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, virDomainDiskDef *conf_disk = NULL; virDomainDiskDef *disk; qemuBlockIoTuneSetFlags set_fields = 0; - bool supportMaxOptions = true; - bool supportGroupNameOption = true; - bool supportMaxLengthOptions = true; g_autoptr(virQEMUDriverConfig) cfg = NULL; virObjectEvent *event = NULL; virTypedParameterPtr eventParams = NULL; @@ -16115,40 +16112,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, virDomainBlockIoTuneInfoCopy(&info, &conf_info); if (def) { - supportMaxOptions = virQEMUCapsGet(priv->qemuCaps, - QEMU_CAPS_DRIVE_IOTUNE_MAX); - supportGroupNameOption = virQEMUCapsGet(priv->qemuCaps, - QEMU_CAPS_DRIVE_IOTUNE_GROUP); - supportMaxLengthOptions = - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH); - - if (!supportMaxOptions && - (set_fields & (QEMU_BLOCK_IOTUNE_SET_BYTES_MAX | - QEMU_BLOCK_IOTUNE_SET_IOPS_MAX | - QEMU_BLOCK_IOTUNE_SET_SIZE_IOPS))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("a block I/O throttling parameter is not " - "supported with this QEMU binary")); - goto endjob; - } - - if (!supportGroupNameOption && - (set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the block I/O throttling group parameter is not " - "supported with this QEMU binary")); - goto endjob; - } - - if (!supportMaxLengthOptions && - (set_fields & (QEMU_BLOCK_IOTUNE_SET_BYTES_MAX_LENGTH | - QEMU_BLOCK_IOTUNE_SET_IOPS_MAX_LENGTH))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("a block I/O throttling length parameter is not " - "supported with this QEMU binary")); - goto endjob; - } - if (!(disk = qemuDomainDiskByName(def, path))) goto endjob; @@ -16216,9 +16179,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid, - &info, supportMaxOptions, + &info, true, set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME, - supportMaxLengthOptions); + true); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret = -1; if (ret < 0) @@ -16323,19 +16286,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; - if (def) { - /* If the VM is running, we can check if the current VM can use - * optional parameters or not. */ - maxparams = QEMU_NB_BLOCK_IO_TUNE_BASE_PARAMS; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) - maxparams += QEMU_NB_BLOCK_IO_TUNE_MAX_PARAMS; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_GROUP)) - maxparams += QEMU_NB_BLOCK_IO_TUNE_GROUP_PARAMS; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) - maxparams += QEMU_NB_BLOCK_IO_TUNE_LENGTH_PARAMS; - } else { - maxparams = QEMU_NB_BLOCK_IO_TUNE_ALL_PARAMS; - } + maxparams = QEMU_NB_BLOCK_IO_TUNE_ALL_PARAMS; if (*nparams == 0) { *nparams = maxparams; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a964c8593d..e5c4e3af26 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2876,15 +2876,13 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, /** * qemuValidateDomainDeviceDefDiskBlkdeviotune: * @disk: disk configuration - * @qemuCaps: qemu capabilities, NULL if checking cold-configuration * * Checks whether block io tuning settings make sense. Returns -1 on error and * reports a proper libvirt error. */ static int qemuValidateDomainDeviceDefDiskBlkdeviotune(const virDomainDiskDef *disk, - const virDomainDef *def, - virQEMUCaps *qemuCaps) + const virDomainDef *def) { /* group_name by itself is ignored by qemu */ if (disk->blkdeviotune.group_name && @@ -2936,33 +2934,6 @@ qemuValidateDomainDeviceDefDiskBlkdeviotune(const virDomainDiskDef *disk, return -1; } - /* block I/O throttling 1.7 */ - if (virDomainBlockIoTuneInfoHasMax(&disk->blkdeviotune) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("there are some block I/O throttling parameters " - "that are not supported with this QEMU binary")); - return -1; - } - - /* block I/O group 2.4 */ - if (disk->blkdeviotune.group_name && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_GROUP)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the block I/O throttling group parameter is " - "not supported with this QEMU binary")); - return -1; - } - - /* block I/O throttling length 2.6 */ - if (virDomainBlockIoTuneInfoHasMaxLength(&disk->blkdeviotune) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("there are some block I/O throttling length parameters " - "that are not supported with this QEMU binary")); - return -1; - } - return 0; } @@ -3052,7 +3023,7 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, if (qemuValidateDomainDeviceDefDiskFrontend(disk, def, qemuCaps) < 0) return -1; - if (qemuValidateDomainDeviceDefDiskBlkdeviotune(disk, def, qemuCaps) < 0) + if (qemuValidateDomainDeviceDefDiskBlkdeviotune(disk, def) < 0) return -1; if (qemuValidateDomainDeviceDefDiskTransient(disk, qemuCaps) < 0)