From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654696034; cv=none; d=zohomail.com; s=zohoarc; b=ODnq4R4Dm5q/or5E8qxZzsxNGiCgnxsYVj9D0vDCxX9SqEFPDS6PTWQk1uz+wqLCq4O6GXVOwJwcFsuWmLcjzdUCWHSoF9Hu2MW3HRGCK966RJVPwNu9iC7DpAZ5iILANRfS8tiXpakWnrLzq6oZMUStOdQw5w4HdNEtvv1OkKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654696034; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cqpzclSCWbb6ihm48TtQXDr/wA3t4ZUX+BFMa3J1EHA=; b=BU+hCAu4/gb9Btn9RooOY0dTcLi18NF8nyrhser19s/a+J18cKsh8IkMv0tqOaA3MCVO6UC1JklI9N1EE8i0vNLOnrwz3y+CLQcSK3Jiy7AAPbO1Fmp76dtwkAT+uvSucCkMrFW+nPLzxWPcJ5Iz73rz4WakwyRikr+TWK6SyWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654696034462138.75530545266383; Wed, 8 Jun 2022 06:47:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-93-qEeu1FczO2ue9NwWsl4wyg-1; Wed, 08 Jun 2022 09:47:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8334101E986; Wed, 8 Jun 2022 13:47:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D4AC1415100; Wed, 8 Jun 2022 13:47:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 583491947041; Wed, 8 Jun 2022 13:47:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BF66D1947040 for ; Wed, 8 Jun 2022 13:43:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A0F2D492CA3; Wed, 8 Jun 2022 13:43:11 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48D6A492C3B for ; Wed, 8 Jun 2022 13:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654696033; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cqpzclSCWbb6ihm48TtQXDr/wA3t4ZUX+BFMa3J1EHA=; b=VwbdahkJXg1onX/RtWa4rjXCfzsIRBlSR+mHuTOD36PLU+CkYkMTrvJtZXpOUpoqqjXmMt YQlVk3nT4A7QpYamIXXHoo6kifZIGEjSfC+GecMh0+iKxmnuexqE7EeATpk3vE+KaF2kCq qCUcqhyrlMyarsD9I5EJaTpzFSxtZSc= X-MC-Unique: qEeu1FczO2ue9NwWsl4wyg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 01/15] virml: Introduce VIR_XML_PROP_NONNEGATIVE flag Date: Wed, 8 Jun 2022 15:42:55 +0200 Message-Id: <9ee48bb0cdf404f682bdf13fc843b90cc74acb98.1654695585.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654696035031100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For easier attribute parsing we have virXMLProp*() family of functions. These accept flags through which a caller can pose some conditions onto the attribute value, for instance: VIR_XML_PROP_NONZERO when the attribute may not be zero, etc. What we are missing is VIR_XML_PROP_NONNEGATIVE when the attribute value may be non-negative. Obviously, this flag makes sense only for some members of the virXMLProp*() family. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virxml.c | 7 +++++++ src/util/virxml.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/util/virxml.c b/src/util/virxml.c index 12b2ef635a..d6e2e5dd91 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -643,6 +643,13 @@ virXMLPropInt(xmlNodePtr node, return -1; } =20 + if ((flags & VIR_XML_PROP_NONNEGATIVE) && (val < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : '%s'. Expected non-negative value"), + name, node->name, tmp); + return -1; + } + if ((flags & VIR_XML_PROP_NONZERO) && (val =3D=3D 0)) { virReportError(VIR_ERR_XML_ERROR, _("Invalid value for attribute '%s' in element '%s'= : Zero is not permitted"), diff --git a/src/util/virxml.h b/src/util/virxml.h index 5d49056bc7..539228a9ba 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -38,6 +38,9 @@ typedef enum { VIR_XML_PROP_NONE =3D 0, VIR_XML_PROP_REQUIRED =3D 1 << 0, /* Attribute may not be absent */ VIR_XML_PROP_NONZERO =3D 1 << 1, /* Attribute may not be zero */ + VIR_XML_PROP_NONNEGATIVE =3D 1 << 2, /* Attribute may not be negative,= makes + sense only for some virXMLProp*() + functions. */ } virXMLPropFlags; =20 =20 --=20 2.35.1 From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654697330; cv=none; d=zohomail.com; s=zohoarc; b=XeVNMNeoOnPatAsHyYc5m+zTqWuvyvgBn6UmYten/WmezK9oY3pbW3/dNonGXIUOmkzwDYbqmACB214QDldwHcyyhheW7R7FimFRyRPEBOgmYXp3ZU0jZpayKYYrm2BfjpBO0y6WKeR84707rNZvWMHK6DIMH4lWjYMimXvXlWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654697330; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+g5MmJ1F16BjzkfKong4Z/bEMDqgx2H/JBht7A6sUfo=; b=Nk9BDin9uFEXrv4vwXWRfVsODsJFOA5clOYquUklfwwDjeW92eZLHcE+NcggOT9NY1bau8BDfb3nYU/gahYVhWp7+Mgw5x8/L048Ir6w7vVlV+EtRcrarzX/FBmsICZkXuMAmyNswBi8UE/U46Cek9IZrGEF843pcKT6W59dQw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654697330399835.777385009539; Wed, 8 Jun 2022 07:08:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-5QqM63Y0OAG6WezPbLvIyg-1; Wed, 08 Jun 2022 10:08:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 755E4196F5BA; Wed, 8 Jun 2022 14:08:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3513D1121314; Wed, 8 Jun 2022 14:08:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E24901947055; Wed, 8 Jun 2022 14:08:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5BC661947040 for ; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3E3EC492C3B; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9EBA492CA3 for ; Wed, 8 Jun 2022 13:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654697329; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+g5MmJ1F16BjzkfKong4Z/bEMDqgx2H/JBht7A6sUfo=; b=ScmN34Fopb5gTMEOvFmjFkm4h1nuiHS+FqfDh5E10H3m7dblQJ1WeerZoblKORpXEAq5eB q9NBTufn06PNilzN72FZMhfODHwSDN4o8r/zOdJYT+CgqNpUWmX7lZtbcbMsJD4pT2tU0M 7WpB5q2hXWs6mNcUXHFQxhKlrCC7lAE= X-MC-Unique: 5QqM63Y0OAG6WezPbLvIyg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 02/15] virDomainDefParseIOThreads: Use g_autoptr() for @iothrid Date: Wed, 8 Jun 2022 15:42:56 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654697330679100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Using g_autoptr() for @iothrid variable inside virDomainDefParseIOThreads() allows us to drop explicit call to virDomainIOThreadIDDefFree() in one case. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f75012f1f..cc1f765ca9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17047,7 +17047,8 @@ virDomainDefParseIOThreads(virDomainDef *def, def->iothreadids =3D g_new0(virDomainIOThreadIDDef *, n); =20 for (i =3D 0; i < n; i++) { - virDomainIOThreadIDDef *iothrid =3D NULL; + g_autoptr(virDomainIOThreadIDDef) iothrid =3D NULL; + if (!(iothrid =3D virDomainIOThreadIDDefParseXML(nodes[i]))) return -1; =20 @@ -17055,10 +17056,9 @@ virDomainDefParseIOThreads(virDomainDef *def, virReportError(VIR_ERR_XML_ERROR, _("duplicate iothread id '%u' found"), iothrid->iothread_id); - virDomainIOThreadIDDefFree(iothrid); return -1; } - def->iothreadids[def->niothreadids++] =3D iothrid; + def->iothreadids[def->niothreadids++] =3D g_steal_pointer(&iothrid= ); } =20 return virDomainIOThreadIDDefArrayInit(def, iothreads); --=20 2.35.1 From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654695832; cv=none; d=zohomail.com; s=zohoarc; b=F86UV9IUDm3GPXuANmjexAiD0LzOa5BddTN9GrTYNWidS627v0Ri5P3SE8gh+/XpEcyx1Y1NXD3Xcd7YSWtqJ6iZaTg0rJAg+A/gWrTNXzf55hvN6Ihm3koXp5Q4PmcTADelM9Dhwp0JJ+/RVM3YbF7JsLG8xTsieUF5M26MLX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654695832; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8LZ06g3wUiS5r+nJYfk4FnFWqTjlRT9eRgFTzhpEhP8=; b=jJAiXfT5nq1QJ3cjavRwPurDj720wHMAw1s+T2RYRVJfa8wdsuPtAKBiL/8Dxejc1l4xzwxuamFYIcVhaoxoOBZ/n0/inDXUQFdTiloo3Li9j+0pfNMjzvuMbRPakKlAeaUv6OxS1lp6MAgPmnYh/SQ29nmH3Q0nmUVNjt4qRuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654695832618406.6743529986354; Wed, 8 Jun 2022 06:43:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-qy03tcJJMkqYTWJRi2-3jw-1; Wed, 08 Jun 2022 09:43:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5FD9185A7BA; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1EB02026D64; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 46C3D1947041; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DED8F1947070 for ; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CFE70492CA3; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 784A7492C3B for ; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654695831; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8LZ06g3wUiS5r+nJYfk4FnFWqTjlRT9eRgFTzhpEhP8=; b=is6jGOSqA+hF1tM/UuQCdNwuKF1MxXxfCvXv3tGjj5axo1x4cqJ1w82VbwV4xnTsYFvTtj a7aCLrrIvH6s+s1NcSg5r0l0HL0PudkaBgmwvV2CO0avteqBX0+Bg1apMFahekneXNZ8Uc tdHMGkell2n0k+xM5fVKWZ1EnP8fnzM= X-MC-Unique: qy03tcJJMkqYTWJRi2-3jw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 03/15] virDomainIOThreadIDDefArrayInit: Decrease scope of @iothrid Date: Wed, 8 Jun 2022 15:42:57 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654695834232100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In virDomainIOThreadIDDefArrayInit() the variable @iothrid is used only inside a loop but is declared for whole function. Bring the variable into the loop so that it's obvious that the variable is not used elsewhere. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cc1f765ca9..22b58e3212 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3509,7 +3509,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDef *def, { size_t i; ssize_t nxt =3D -1; - virDomainIOThreadIDDef *iothrid =3D NULL; g_autoptr(virBitmap) thrmap =3D NULL; =20 /* Same value (either 0 or some number), then we have none to fill in = or @@ -3534,6 +3533,8 @@ virDomainIOThreadIDDefArrayInit(virDomainDef *def, =20 /* Populate iothreadids[] using the set bit number from thrmap */ while (def->niothreadids < iothreads) { + g_autoptr(virDomainIOThreadIDDef) iothrid =3D NULL; + if ((nxt =3D virBitmapNextSetBit(thrmap, nxt)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to populate iothreadids")); @@ -3542,7 +3543,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDef *def, iothrid =3D g_new0(virDomainIOThreadIDDef, 1); iothrid->iothread_id =3D nxt; iothrid->autofill =3D true; - def->iothreadids[def->niothreadids++] =3D iothrid; + def->iothreadids[def->niothreadids++] =3D g_steal_pointer(&iothrid= ); } =20 return 0; --=20 2.35.1 From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654695832; cv=none; d=zohomail.com; s=zohoarc; b=WX1aqgOStZm/i3DKCKOBHWgj5di3fmMYT1hB2pCErJOo8GWLzFJkOcsHk3iO1eiNE6QbWRwJrRIrj9NJIQwU07f/BkEWu8mY8D6+ZRG52pVACc0TtdxbC9YscgjSHmsGm2KBtVecja4x7mlvUZi81AWwkycp8F8eGOd6yMh21UA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654695832; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A+C3OGATP6eB1+wJflCsJ++Khio/g2xB5NgfTUP3HCE=; b=EgdolqUL3d6idRbID0blNBemM7FzD3b7bML+uynX2SKdACe7gLCMsBP2nZbcHCOwr2zgp4XWBDctiymzrkvZW27P8XH2vMi5MrZXd1ziTYAnJXy8JoWFUJ4vsUYazFgKzXByVHhjSc8L7wKlaIwof1k2zPb1Vwke21vKHuvlgXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654695831742432.09701144129815; Wed, 8 Jun 2022 06:43:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-U4UO7c1cN8est9lOXRGvFA-1; Wed, 08 Jun 2022 09:43:47 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E584F185A79C; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D235A492C3B; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 749FA194705D; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8BCDA1947041 for ; Wed, 8 Jun 2022 13:43:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6CBEC492CA4; Wed, 8 Jun 2022 13:43:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14BFA492C3B for ; Wed, 8 Jun 2022 13:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654695830; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=A+C3OGATP6eB1+wJflCsJ++Khio/g2xB5NgfTUP3HCE=; b=eVLlZfwVvzyn1wezVQWqxb8fti5JUR096b1aNa9bhuFIdfMHsBms2EvheqDIlW00N1Crzw XCkbaG4v6i2M0mIltjUXJjY2x2J77RxDzhPNvEk5WUTKKe8Z3/JoRBANt8Ykfm4qZI+V2P Tr9PN5/16Tb+nE/AVWnJJw6UXTkXmjA= X-MC-Unique: U4UO7c1cN8est9lOXRGvFA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 04/15] conf: Move iothread formatter into a separate function Date: Wed, 8 Jun 2022 15:42:58 +0200 Message-Id: <7fdca93a34b2e124232e850b3104e80aa0ec4ce1.1654695585.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654695834235100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Formatting iothreads is currently open coded inside of virDomainDefFormatInternalSetRootName(). While this works, it makes the function needlessly long, especially if the formatting code will expand in near future. Therefore, move it into a separate function. At the same time, make virDomainDefIothreadShouldFormat() accept const domain definition so that the new function can also accept const domain definition. Formatters shouldn't need to change definition. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22b58e3212..f7b86be5fc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27570,7 +27570,7 @@ virDomainCpuDefFormat(virBuffer *buf, =20 =20 static bool -virDomainDefIothreadShouldFormat(virDomainDef *def) +virDomainDefIothreadShouldFormat(const virDomainDef *def) { size_t i; =20 @@ -27583,6 +27583,31 @@ virDomainDefIothreadShouldFormat(virDomainDef *def) } =20 =20 +static void +virDomainDefIOThreadsFormat(virBuffer *buf, + const virDomainDef *def) +{ + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; + + if (def->niothreadids =3D=3D 0) + return; + + virBufferAsprintf(buf, "%zu\n", + def->niothreadids); + + if (!virDomainDefIothreadShouldFormat(def)) + return; + + for (i =3D 0; i < def->niothreadids; i++) { + virBufferAsprintf(&childrenBuf, "\n", + def->iothreadids[i]->iothread_id); + } + + virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf); +} + + static void virDomainIOMMUDefFormat(virBuffer *buf, const virDomainIOMMUDef *iommu) @@ -28228,20 +28253,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, if (virDomainCpuDefFormat(buf, def) < 0) return -1; =20 - if (def->niothreadids > 0) { - virBufferAsprintf(buf, "%zu\n", - def->niothreadids); - if (virDomainDefIothreadShouldFormat(def)) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < def->niothreadids; i++) { - virBufferAsprintf(buf, "\n", - def->iothreadids[i]->iothread_id); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } + virDomainDefIOThreadsFormat(buf, def); =20 if (virDomainCputuneDefFormat(buf, def, flags) < 0) return -1; --=20 2.35.1 From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654696647; cv=none; d=zohomail.com; s=zohoarc; b=czXtLK7mWaw3CQ7m1fcHT4pRP1SInQbBHgF3yXEdFxB7aQQ0Lyq2S7QMGKg12RNIjNbO6gkW8gewSG74bF0FGzNjmgQu2kNm78SZd2zmwO0iP+7/QLOvmEEzXEmBFnoH+MrNS6O2cZr13cyBpn7/TA5VF2P7C7A2GUBegt5apIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654696647; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Aq5merrOCZ9S3RBMyhPPwU4gdwid1xtDiEH/sLmkfCo=; b=YWSbCrq/VtVx97et7sxScSz1TeXo9xeP6sx4ZDkB+yzWFzUAJd5DXZlsMGzSyhFGyzQRRBvDJtbjiJd/ATuYFy+Ca4t4BKo1plLT92zgYeSABBYvAgti7wk5MNc2KueIKn6zvl3MCdDjdDemfQ8nYvB6ZbuZmsEfa/F6C6Ub4H4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654696647725333.7819179033105; Wed, 8 Jun 2022 06:57:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-RRTh-s60OBeX30qT6hQ_gw-1; Wed, 08 Jun 2022 09:57:25 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E72E83C01D82; Wed, 8 Jun 2022 13:57:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8FDB492C3B; Wed, 8 Jun 2022 13:57:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 945DA1947051; Wed, 8 Jun 2022 13:57:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 17EBC1947040 for ; Wed, 8 Jun 2022 13:43:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0B8D6492CA5; Wed, 8 Jun 2022 13:43:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A68C0492C3B for ; Wed, 8 Jun 2022 13:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654696646; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Aq5merrOCZ9S3RBMyhPPwU4gdwid1xtDiEH/sLmkfCo=; b=FYqMttkusFU10oK4gKwQFhIcN/tWJvBHv5MweJ6TPAtNetmQZQ3M0ujx2uuq+cd8vUPNLX Nv/pSLCNjDWLl6YYuw98pJoFnNOmxEZnxFu0KYtcZHlAMOAt8j5QmCfBsN22vZcP3D4q4u 9ceKIZs0xiXfuIlCsbmHm9v6ThwPjzY= X-MC-Unique: RRTh-s60OBeX30qT6hQ_gw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 05/15] conf: Introduce allocator for virDomainIOThreadIDDef Date: Wed, 8 Jun 2022 15:42:59 +0200 Message-Id: <0f2ff3dfabce68e9f3218bc770aa3717e7c0a86e.1654695585.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654696649417100001 Content-Type: text/plain; charset="utf-8"; x-default="true" So far, iothread configuration structure (virDomainIOThreadIDDef) is allocated by plain g_new0(). This is perfectly okay because all members of the struct default to value 0 anyway. But soon this is going to change. Therefore, replace those g_new0() with a function so that the default value can be set consistently in one place. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f7b86be5fc..f3923cf2ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3477,6 +3477,15 @@ virDomainIOThreadIDArrayHasPin(virDomainDef *def) } =20 =20 +static virDomainIOThreadIDDef * +virDomainIOThreadIDDefNew(void) +{ + virDomainIOThreadIDDef *def =3D g_new0(virDomainIOThreadIDDef, 1); + + return def; +} + + void virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def) { @@ -3540,7 +3549,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDef *def, _("failed to populate iothreadids")); return -1; } - iothrid =3D g_new0(virDomainIOThreadIDDef, 1); + iothrid =3D virDomainIOThreadIDDefNew(); iothrid->iothread_id =3D nxt; iothrid->autofill =3D true; def->iothreadids[def->niothreadids++] =3D g_steal_pointer(&iothrid= ); @@ -17009,7 +17018,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, static virDomainIOThreadIDDef * virDomainIOThreadIDDefParseXML(xmlNodePtr node) { - g_autoptr(virDomainIOThreadIDDef) iothrid =3D g_new0(virDomainIOThread= IDDef, 1); + g_autoptr(virDomainIOThreadIDDef) iothrid =3D virDomainIOThreadIDDefNe= w(); =20 if (virXMLPropUInt(node, "id", 10, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, @@ -22932,8 +22941,7 @@ virDomainIOThreadIDAdd(virDomainDef *def, { virDomainIOThreadIDDef *iothrid =3D NULL; =20 - iothrid =3D g_new0(virDomainIOThreadIDDef, 1); - + iothrid =3D virDomainIOThreadIDDefNew(); iothrid->iothread_id =3D iothread_id; =20 VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, iothrid); --=20 2.35.1 From nobody Tue May 14 21:40:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654695844; cv=none; d=zohomail.com; s=zohoarc; b=E2j4VvPTesn389jMTl/MwksDvGOn6Oap6GmoolfB+gVE20c+ndgBCzD+58M5EyiQgTkDNpGqtAhuAgKjQdDPUKjjpTj1PlTtzKJsc55JK4eNeuaN6RB05X+E8A90acYYcPqoMGpIjIbAj9OHWSG4u9P71PVHw8uUqvbcz7O8DpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654695844; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qxRU695Cc8EV4N+sOH5W8Dc50iopVgdgI1RKxmWox9c=; b=NyiZ3lJgP4+S1MlGFJIFI84svEwgHXl4FNCil+VdHiCoYrgMXMdajcm8SejHuHv9NouLc+k56y/AFNw7K0RhvwPZyFGx9XBAcQUHWBdBmMux8KoaiEpqQoCbwxI+IH4LOoA77CsJmM8CZix5x5wNcir72ydQwFV+UiaZkqM6D48= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654695843830276.1512693204313; Wed, 8 Jun 2022 06:44:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-II_05YmsP8Cw6sgJ8UXsIg-1; Wed, 08 Jun 2022 09:43:48 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBB5538107A8; Wed, 8 Jun 2022 13:43:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F118401E5C; Wed, 8 Jun 2022 13:43:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C6A211947B9C; Wed, 8 Jun 2022 13:43:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA35A1947040 for ; Wed, 8 Jun 2022 13:43:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9C573492CA3; Wed, 8 Jun 2022 13:43:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44775492C3B for ; Wed, 8 Jun 2022 13:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654695842; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qxRU695Cc8EV4N+sOH5W8Dc50iopVgdgI1RKxmWox9c=; b=ZRUJchN/3bz0+KdTDiSOvyeQEpVl74tVNN2vYMeJSqOVvI+J0aI4aVNv65+FxyrXLqUPQB phiXCnpON8fvL26c9qy1CxXsC16p2j76DiWHGy6dsnBeMojPPGBnBeImfEVtMMi1pa3zdF /b/urwEVj56dYejAb4R2y9mLMbq2ic0= X-MC-Unique: II_05YmsP8Cw6sgJ8UXsIg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 06/15] conf: Introduce thread_pool_min and thread_pool_max attributes to IOThread Date: Wed, 8 Jun 2022 15:43:00 +0200 Message-Id: <8328d151eb43cadbf7e6871c09ce931652a1f9c1.1654695585.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654695846328100003 Content-Type: text/plain; charset="utf-8"; x-default="true" At least in case of QEMU an IOThread is actually a pool of threads (see iothread_set_aio_context_params() in QEMU's code base). As such, it can have minimal and maximal number of worker threads. Allow setting them in domain XML. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- docs/formatdomain.rst | 6 +- src/conf/domain_conf.c | 34 ++++++++++- src/conf/domain_conf.h | 3 + src/conf/domain_validate.c | 28 +++++++++ src/conf/schemas/domaincommon.rng | 10 +++ .../iothreads-ids-pool-sizes.xml | 61 +++++++++++++++++++ ...iothreads-ids-pool-sizes.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml create mode 120000 tests/qemuxml2xmloutdata/iothreads-ids-pool-sizes.x86_6= 4-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 312b605a8b..07837220ed 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -675,7 +675,7 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU on= ly)` - + ... @@ -696,6 +696,10 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU o= nly)` any predefined ``id``. If there are more ``iothreadids`` defined than ``iothreads`` defined for the domain, then the ``iothreads`` value will= be adjusted accordingly. :since:`Since 1.2.15` + The element has two optional attributes ``thread_pool_min`` and + ``thread_pool_max`` which allow setting lower and upper boundary for nu= mber + of worker threads for given IOThread. While the former can be value of = zero, + the latter can't. :since:`Since 8.5.0` =20 =20 CPU Tuning diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f3923cf2ba..ea8061dc3d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3482,6 +3482,9 @@ virDomainIOThreadIDDefNew(void) { virDomainIOThreadIDDef *def =3D g_new0(virDomainIOThreadIDDef, 1); =20 + def->thread_pool_min =3D -1; + def->thread_pool_max =3D -1; + return def; } =20 @@ -17009,7 +17012,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, * * 4 * - * + * * * * @@ -17025,6 +17028,16 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) &iothrid->iothread_id) < 0) return NULL; =20 + if (virXMLPropInt(node, "thread_pool_min", 10, + VIR_XML_PROP_NONNEGATIVE, + &iothrid->thread_pool_min, -1) < 0) + return NULL; + + if (virXMLPropInt(node, "thread_pool_max", 10, + VIR_XML_PROP_NONNEGATIVE, + &iothrid->thread_pool_max, -1) < 0) + return NULL; + return g_steal_pointer(&iothrid); } =20 @@ -27608,8 +27621,23 @@ virDomainDefIOThreadsFormat(virBuffer *buf, return; =20 for (i =3D 0; i < def->niothreadids; i++) { - virBufferAsprintf(&childrenBuf, "\n", - def->iothreadids[i]->iothread_id); + virDomainIOThreadIDDef *iothread =3D def->iothreadids[i]; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&attrBuf, " id=3D'%u'", + iothread->iothread_id); + + if (iothread->thread_pool_min >=3D 0) { + virBufferAsprintf(&attrBuf, " thread_pool_min=3D'%d'", + iothread->thread_pool_min); + } + + if (iothread->thread_pool_max >=3D 0) { + virBufferAsprintf(&attrBuf, " thread_pool_max=3D'%d'", + iothread->thread_pool_max); + } + + virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, NULL); } =20 virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1efdb439ac..035edc0710 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2646,6 +2646,9 @@ struct _virDomainIOThreadIDDef { virBitmap *cpumask; =20 virDomainThreadSchedParam sched; + + int thread_pool_min; + int thread_pool_max; }; =20 void virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def); diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f3910f08a4..3ada739ea7 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1716,6 +1716,31 @@ virDomainDefFSValidate(const virDomainDef *def) } =20 =20 +static int +virDomainDefValidateIOThreads(const virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->niothreadids; i++) { + virDomainIOThreadIDDef *iothread =3D def->iothreadids[i]; + + if (iothread->thread_pool_max =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("thread_pool_max must be a positive integer")= ); + return -1; + } + + if (iothread->thread_pool_min > iothread->thread_pool_max) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("thread_pool_min must be smaller or equal to = thread_pool_max")); + return -1; + } + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOption *xmlopt) @@ -1771,6 +1796,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefFSValidate(def) < 0) return -1; =20 + if (virDomainDefValidateIOThreads(def) < 0) + return -1; + return 0; } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index cc598212a8..fad70d3857 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -829,6 +829,16 @@ + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml b/tests/qe= muxml2argvdata/iothreads-ids-pool-sizes.xml new file mode 100644 index 0000000000..0f93d14f12 --- /dev/null +++ b/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml @@ -0,0 +1,61 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 6 + 5 + + + + + + + + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + +