From nobody Mon Feb 9 14:33:11 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=1610359018; cv=none; d=zohomail.com; s=zohoarc; b=lXmIdUS3sXmYcEmovTXVek7olHvhc36fo7U+2Z3rfFNsqC0JB9qOJSNpEnlx2S3Gunq4OE7ITCKNjAd5Vtux3002sSgSvJmzo9UJKjGrn3K+tOG5pLeh+bdLHbi+rlJyT3YqEq3r8v0J72JCLmzbD+wE9ovf0iEqC4KcynAhwnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610359018; 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=fMHv8OX1Q5YtrW3TCjwGvWPIcceFxj3gRI721iQyF68=; b=ZOWjtbiAhpmtJ9Dmr7OustUP29AMW7jR/bZB/14FizfWY7q0A9e308MZ6JPrMIYGnNWExUjS/7v7sAMjFtiy6oU04y9XJB4DqviIdQL8cEQpOVaKkmapLTc+jKjQghkR6AA427Ca8OlOzm8xcQir/hmZWWSamq2uxZxJ11p/XY8= 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 161035901877813.359868209946399; Mon, 11 Jan 2021 01:56:58 -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-429-LD73IvKqPgCMh1HE6BHqQg-1; Mon, 11 Jan 2021 04:56:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10FE2612A5; Mon, 11 Jan 2021 09:56:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9F642C315; Mon, 11 Jan 2021 09:56:47 +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 21EF04BB7B; Mon, 11 Jan 2021 09:56:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10B9ujPK014773 for ; Mon, 11 Jan 2021 04:56:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id B264F9D46D; Mon, 11 Jan 2021 09:56:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD25B1C5BB for ; Mon, 11 Jan 2021 09:56:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 89ADB811E76 for ; Mon, 11 Jan 2021 09:56:43 +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-23-ZNQt-gApOwG-aULHnWG98g-1; Mon, 11 Jan 2021 04:56:41 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kytvA-00GBOE-T7 for libvir-list@redhat.com; Mon, 11 Jan 2021 12:55:32 +0300 X-MC-Unique: LD73IvKqPgCMh1HE6BHqQg-1 X-MC-Unique: ZNQt-gApOwG-aULHnWG98g-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 05/23] conf: factor out virDomainBlockIoTuneValidate Date: Mon, 11 Jan 2021 12:49:58 +0300 Message-Id: <1610358616-567804-6-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.79 on 10.11.54.5 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.15 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" virDomainBlockIoTuneValidate can be reused in virDomainSetBlockIoTune implementations. And also simplify if conditions. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 78 +++++++++++++++++++++++++-------------------= ---- src/conf/domain_conf.h | 3 ++ src/libvirt_private.syms | 1 + 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 349fc28..173424a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8627,6 +8627,45 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ct= xt, return 0; } =20 + +int +virDomainBlockIoTuneValidate(virDomainBlockIoTuneInfoPtr iotune) +{ + if (iotune->total_bytes_sec && + (iotune->read_bytes_sec || iotune->write_bytes_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec " + "cannot be set at the same time")); + return -1; + } + + if (iotune->total_iops_sec && + (iotune->read_iops_sec || iotune->write_iops_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec " + "cannot be set at the same time")); + return -1; + } + + if (iotune->total_bytes_sec_max && + (iotune->read_bytes_sec_max || iotune->write_bytes_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec_max " + "cannot be set at the same time")); + return -1; + } + + if (iotune->total_iops_sec_max && + (iotune->read_iops_sec_max || iotune->write_iops_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec_max " + "cannot be set at the same time")); + return -1; + } + + return 0; +} + #define PARSE_IOTUNE(val) \ if (virXPathULongLong("string(./iotune/" #val ")", \ ctxt, &def->blkdeviotune.val) =3D=3D -2) { \ @@ -8665,45 +8704,8 @@ virDomainDiskDefIotuneParse(virDomainDiskDefPtr def, def->blkdeviotune.group_name =3D virXPathString("string(./iotune/group_name)", ctxt); =20 - if ((def->blkdeviotune.total_bytes_sec && - def->blkdeviotune.read_bytes_sec) || - (def->blkdeviotune.total_bytes_sec && - def->blkdeviotune.write_bytes_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec " - "cannot be set at the same time")); - return -1; - } - - if ((def->blkdeviotune.total_iops_sec && - def->blkdeviotune.read_iops_sec) || - (def->blkdeviotune.total_iops_sec && - def->blkdeviotune.write_iops_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec " - "cannot be set at the same time")); - return -1; - } - - if ((def->blkdeviotune.total_bytes_sec_max && - def->blkdeviotune.read_bytes_sec_max) || - (def->blkdeviotune.total_bytes_sec_max && - def->blkdeviotune.write_bytes_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec_max " - "cannot be set at the same time")); + if (virDomainBlockIoTuneValidate(&def->blkdeviotune) < 0) return -1; - } - - if ((def->blkdeviotune.total_iops_sec_max && - def->blkdeviotune.read_iops_sec_max) || - (def->blkdeviotune.total_iops_sec_max && - def->blkdeviotune.write_iops_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec_max " - "cannot be set at the same time")); - return -1; - } =20 return 0; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ec43bbe..3c42313 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3963,3 +3963,6 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hos= tdev) bool virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); + +int +virDomainBlockIoTuneValidate(virDomainBlockIoTuneInfoPtr iotune); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c325040..bfe3ee7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -236,6 +236,7 @@ virDomainBlockIoTuneInfoHasAny; virDomainBlockIoTuneInfoHasBasic; virDomainBlockIoTuneInfoHasMax; virDomainBlockIoTuneInfoHasMaxLength; +virDomainBlockIoTuneValidate; virDomainBootTypeFromString; virDomainBootTypeToString; virDomainCapabilitiesPolicyTypeToString; --=20 1.8.3.1