From nobody Mon Feb 9 12:09:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1610358840; cv=none; d=zohomail.com; s=zohoarc; b=FgeH/w+1hhX2s1/ufwGmEj4A/krIyBUD03gOOK0lEuy1x2Rl8DjH7Gy/8AHrvkc/ZZ4K8r+S2BLVf9Fn65plHwVV+4ydrGz/4LzbvvO40TzoPKJtreSiyxOnLRxLegSZ31O/TZ7gd1q47l902he1d6H/xKh2c2EdPGsHx2l8ND4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610358840; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ILn5/LlgXa+IDtmqm4BT5eO3kBoNlYd2x1TJHD+0Q/c=; b=W/+GuNrmRLFKfsPledg9dCXFLBJCbdzQKAyyLQ1JVfdCxGvDmY6KeffrzEmuW07juMSJqiPKYsc2+XlK/gJwoOXEliREh5ycfBbOmLpjD04KNch+vPa4gxfJ0tued0D5Y1sCNPe+pMslO8FzbWvpZCq7tFdPCQzLWh+YYUO+Xlg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1610358840294546.4788698991365; Mon, 11 Jan 2021 01:54:00 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-gh0m1D9-PPOuiVYi7LCdPA-1; Mon, 11 Jan 2021 04:53:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 828FA1015C81; Mon, 11 Jan 2021 09:53:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 616E760C87; Mon, 11 Jan 2021 09:53:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2A4A6180954D; Mon, 11 Jan 2021 09:53:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10B9rnlF014529 for ; Mon, 11 Jan 2021 04:53:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 16B0B112D439; Mon, 11 Jan 2021 09:53:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12FAE112D435 for ; Mon, 11 Jan 2021 09:53:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA540803DCE for ; Mon, 11 Jan 2021 09:53:46 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-dpxkPC6TNcO144tUF7Cgqw-1; Mon, 11 Jan 2021 04:53:43 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kytsI-00GBOE-TF for libvir-list@redhat.com; Mon, 11 Jan 2021 12:52:34 +0300 X-MC-Unique: gh0m1D9-PPOuiVYi7LCdPA-1 X-MC-Unique: dpxkPC6TNcO144tUF7Cgqw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 02/23] qemu: factor out qemuValidateDomainBlkdeviotune Date: Mon, 11 Jan 2021 12:49:55 +0300 Message-Id: <1610358616-567804-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1610358616-567804-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1610358616-567804-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It can also be used for validation of input in qemuDomainSetBlockIoTune. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Peter Krempa --- 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 virDom= ainDiskDef *disk, } =20 =20 +int +qemuValidateDomainBlkdeviotune(const virDomainBlockIoTuneInfo *iotune, + virQEMUCapsPtr qemuCaps) +{ + 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; + } + + /* block I/O throttling 1.7 */ + if (virDomainBlockIoTuneInfoHasMax(iotune) && + !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 (iotune->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(iotune) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("there are some block I/O throttling length param= eters " + "that are not supported with this QEMU binary")); + return -1; + } + + return 0; +} + + /** * qemuValidateDomainDeviceDefDiskBlkdeviotune: * @disk: disk configuration @@ -2740,51 +2795,8 @@ qemuValidateDomainDeviceDefDiskBlkdeviotune(const vi= rDomainDiskDef *disk, } } =20 - if (disk->blkdeviotune.total_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_bytes_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_iops_sec > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.total_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.read_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.write_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX || - disk->blkdeviotune.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_IOT= UNE_MAX); - 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")); + if (qemuValidateDomainBlkdeviotune(&disk->blkdeviotune, qemuCaps) < 0) 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 param= eters " - "that are not supported with this QEMU binary")); - return -1; - } =20 return 0; } diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h index b6c5441..21e7986 100644 --- a/src/qemu/qemu_validate.h +++ b/src/qemu/qemu_validate.h @@ -26,6 +26,10 @@ #include "qemu_capabilities.h" #include "qemu_conf.h" =20 +int +qemuValidateDomainBlkdeviotune(const virDomainBlockIoTuneInfo *iotune, + virQEMUCapsPtr qemuCaps); + int qemuValidateDomainDef(const virDomainDef *def, void *opaque, void *parseOpaque); --=20 1.8.3.1