From nobody Mon Feb 9 19:05:47 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=1610359671; cv=none; d=zohomail.com; s=zohoarc; b=jOtYV7/aeAVkPNpn8V8spocLdU+rYfpWkrd0+Zg2ZbPSxa8wsEAe4QIe8XxzMqSpybjv8Je/JGSEeaoDC07SwxCLZeLhSiAvbHYkE25wHTeTp28j1SGMEqkgabafpGBhmWq0oBwGMcUxMLctErq5RdI9ndn8C9xXPvlQaFIMXHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610359671; 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=G3JsZ+6CZH0fkYLCSGn+uSePzkhlfAcIp1QHm5CUjqA=; b=WK3maaIlc9zFb7mXUBkc3AlWFmgCbYx3Te/S/SsTybtHtPq87sITJp13UkYhfYsSnjJe+LQ3uXkWwikAC7eYq3ogH7IvQg/pLq5vMpRUpo7jS2XWj+UkTCN7tkh0NtoSSSHlvxuOHw3VYfGQ+2oTM04yu11KgqoHhRTEW0LFSn0= 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 1610359671469505.9833452462258; Mon, 11 Jan 2021 02:07:51 -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-293-4MXrPHsuO9at3qKkjJeR-w-1; Mon, 11 Jan 2021 05:07:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43F2C10151EF; Mon, 11 Jan 2021 10:07:42 +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 21E586EF65; Mon, 11 Jan 2021 10:07:42 +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 E10EE180954D; Mon, 11 Jan 2021 10:07:41 +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 10BA7eMd016442 for ; Mon, 11 Jan 2021 05:07:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id A5EBC112D43F; Mon, 11 Jan 2021 10:07:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A26B3112D439 for ; Mon, 11 Jan 2021 10:07:37 +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 E6ED1186E122 for ; Mon, 11 Jan 2021 10:07:36 +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-373-fYhN-AKcOge3ykbSI_xR7g-1; Mon, 11 Jan 2021 05:07:34 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kyu5i-00GBOE-Hb for libvir-list@redhat.com; Mon, 11 Jan 2021 13:06:26 +0300 X-MC-Unique: 4MXrPHsuO9at3qKkjJeR-w-1 X-MC-Unique: fYhN-AKcOge3ykbSI_xR7g-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 16/23] conf: get rid of macros in virDomainDiskDefIotuneParse Date: Mon, 11 Jan 2021 12:50:09 +0300 Message-Id: <1610358616-567804-17-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.13 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" At first glance we don't get much win because of introduction of virDomainBlockIoTuneFieldNames and virDomainBlockIoTuneFields. But we are g= oing to use these two in other places to remove usage of macros too. Signed-off-by: Nikolay Shirokovskiy --- src/conf/domain_conf.c | 99 +++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 800bca5..024d0e3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8695,40 +8695,80 @@ virDomainBlockIoTuneValidate(virDomainBlockIoTuneIn= foPtr iotune) return 0; } =20 -#define PARSE_IOTUNE(val) \ - if (virXPathULongLong("string(./iotune/" #val ")", \ - ctxt, &def->blkdeviotune.val) =3D=3D -2) { \ - virReportError(VIR_ERR_XML_ERROR, \ - _("disk iotune field '%s' must be an integer"), #va= l); \ - return -1; \ - } + +static const char* virDomainBlockIoTuneFieldNames[] =3D { + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX, + VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX_LENGTH, + VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX_LENGTH, + VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX_LENGTH, +}; + + +static unsigned long long** +virDomainBlockIoTuneFields(virDomainBlockIoTuneInfoPtr iotune) +{ + unsigned long long **ret =3D g_new0(unsigned long long*, + G_N_ELEMENTS(virDomainBlockIoTuneFie= ldNames)); + size_t i =3D 0; + + ret[i++] =3D &iotune->total_bytes_sec; + ret[i++] =3D &iotune->read_bytes_sec; + ret[i++] =3D &iotune->write_bytes_sec; + ret[i++] =3D &iotune->total_iops_sec; + ret[i++] =3D &iotune->read_iops_sec; + ret[i++] =3D &iotune->write_iops_sec; + ret[i++] =3D &iotune->total_bytes_sec_max; + ret[i++] =3D &iotune->read_bytes_sec_max; + ret[i++] =3D &iotune->write_bytes_sec_max; + ret[i++] =3D &iotune->total_iops_sec_max; + ret[i++] =3D &iotune->read_iops_sec_max; + ret[i++] =3D &iotune->write_iops_sec_max; + ret[i++] =3D &iotune->size_iops_sec; + ret[i++] =3D &iotune->total_bytes_sec_max_length; + ret[i++] =3D &iotune->read_bytes_sec_max_length; + ret[i++] =3D &iotune->write_bytes_sec_max_length; + ret[i++] =3D &iotune->total_iops_sec_max_length; + ret[i++] =3D &iotune->read_iops_sec_max_length; + ret[i++] =3D &iotune->write_iops_sec_max_length; + + return ret; +} + =20 static int virDomainDiskDefIotuneParse(virDomainDiskDefPtr def, xmlXPathContextPtr ctxt) { - PARSE_IOTUNE(total_bytes_sec); - PARSE_IOTUNE(read_bytes_sec); - PARSE_IOTUNE(write_bytes_sec); - PARSE_IOTUNE(total_iops_sec); - PARSE_IOTUNE(read_iops_sec); - PARSE_IOTUNE(write_iops_sec); - - PARSE_IOTUNE(total_bytes_sec_max); - PARSE_IOTUNE(read_bytes_sec_max); - PARSE_IOTUNE(write_bytes_sec_max); - PARSE_IOTUNE(total_iops_sec_max); - PARSE_IOTUNE(read_iops_sec_max); - PARSE_IOTUNE(write_iops_sec_max); - - PARSE_IOTUNE(size_iops_sec); - - PARSE_IOTUNE(total_bytes_sec_max_length); - PARSE_IOTUNE(read_bytes_sec_max_length); - PARSE_IOTUNE(write_bytes_sec_max_length); - PARSE_IOTUNE(total_iops_sec_max_length); - PARSE_IOTUNE(read_iops_sec_max_length); - PARSE_IOTUNE(write_iops_sec_max_length); + g_autofree unsigned long long **fields =3D + virDomainBlockIoTuneFields(&def->blkdeviotune); + size_t i; + + for (i =3D 0; i < G_N_ELEMENTS(virDomainBlockIoTuneFieldNames); i++) { + const char *name =3D virDomainBlockIoTuneFieldNames[i]; + g_autofree char *sel =3D g_strdup_printf("string(./iotune/%s)", na= me); + + if (virXPathULongLong(sel, ctxt, fields[i]) =3D=3D -2) { + virReportError(VIR_ERR_XML_ERROR, + _("disk iotune field '%s' must be an integer"), + name); + return -1; + } + } =20 def->blkdeviotune.group_name =3D virXPathString("string(./iotune/group_name)", ctxt); @@ -8738,7 +8778,6 @@ virDomainDiskDefIotuneParse(virDomainDiskDefPtr def, =20 return 0; } -#undef PARSE_IOTUNE =20 =20 static int --=20 1.8.3.1