]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Always assume that qemu supports drive throttling
authorPeter Krempa <pkrempa@redhat.com>
Tue, 10 Aug 2021 12:56:31 +0000 (14:56 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 18 Aug 2021 07:56:17 +0000 (09:56 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_validate.c

index ed3af5a619c108af8d17779772af3b809c3d9c63..7b7639c51a43f941d7085409526f5c78f6483e26 100644 (file)
@@ -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;
index a964c8593d7d622ff8c49c903ba021ff3d9f6fe6..e5c4e3af2691a92d7c3eb2cc7d2967765b0ea99d 100644 (file)
@@ -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)