[PATCH 02/23] qemu: factor out qemuValidateDomainBlkdeviotune

Peter Krempa pkrempa at redhat.com
Wed Mar 3 12:54:35 UTC 2021


On Mon, Jan 11, 2021 at 12:49:55 +0300, Nikolay Shirokovskiy wrote:
> It can also be used for validation of input in qemuDomainSetBlockIoTune.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
> ---
>  src/qemu/qemu_validate.c | 100 ++++++++++++++++++++++++++---------------------
>  src/qemu/qemu_validate.h |   4 ++
>  2 files changed, 60 insertions(+), 44 deletions(-)
> 
> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> index eadf3af..6a27565 100644
> --- a/src/qemu/qemu_validate.c
> +++ b/src/qemu/qemu_validate.c
> @@ -2696,6 +2696,61 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
>  }
>  
>  
> +int
> +qemuValidateDomainBlkdeviotune(const virDomainBlockIoTuneInfo *iotune,
> +                               virQEMUCapsPtr qemuCaps)
> +{

The check that group_name must be set along with other fields :

    /* group_name by itself is ignored by qemu */
    if (disk->blkdeviotune.group_name &&
        !virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune)) {
        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                       _("group_name can be configured only together with "
                         "settings"));
        return -1;
    }


also belongs here.


> +    if (iotune->total_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->read_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->write_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->total_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->read_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->write_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->total_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->read_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->write_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->total_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->read_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->write_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
> +        iotune->size_iops_sec > QEMU_BLOCK_IOTUNE_MAX) {
> +        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
> +                       _("block I/O throttle limit must "
> +                         "be no more than %llu using QEMU"),
> +                       QEMU_BLOCK_IOTUNE_MAX);
> +        return -1;
> +    }

We also nowadays prefer if the error detail strings are not broken up,
but that's not a required change.

With the group name check moved too:

Reviewed-by: Peter Krempa <pkrempa at redhat.com>




More information about the libvir-list mailing list