From nobody Sat Feb 7 08:04:00 2026 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=1654606393; cv=none; d=zohomail.com; s=zohoarc; b=lvw0S4hV+aZhr5bB7qlgBX+JgZNpI0N0MH8Lumn3JGdRjROYD7JY/oztdpGalbrjUVJKCbN6BoIDelpXgepouaPWiGHrinXlR8POLcHu/RdAhcGFThaKmKPbE/nU+rMAoXEy11spkvJDUfth5OwoHJrAizIUq9TF504RKibdGhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606393; 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=EsKTT0td+0g0QhngBz8dnAJbX0jLUF6dYWtpGHtSatlhQeWIta/wCCbyDm1q3bkyVdDdU94zlwJy3lCdRVCWRhS14BmwLlhYJs1DFT8eW/pGa0v6NE6aaTp5NgO/iCu/ibsvRkIUhitZ5VRUM7NLSuQeWMHHQBgw91RzNv+eFCo= 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 1654606393470526.3343940294949; Tue, 7 Jun 2022 05:53:13 -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-628-i-57jL_gNomGZR2eNfm2DA-1; Tue, 07 Jun 2022 08:53:06 -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 E685418013AE; Tue, 7 Jun 2022 12:53:03 +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 A12FF492CA4; Tue, 7 Jun 2022 12:53:03 +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 50AD519451F0; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2900519452D2 for ; Tue, 7 Jun 2022 12:53:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EFDAC4050C41; Tue, 7 Jun 2022 12:53:01 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848D14050C40 for ; Tue, 7 Jun 2022 12:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606392; 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=V7yvOzBynlVM3XsReQCda/JRI/NJ5X2GT6o0jzGrOwHe1n1pwgcHIZES2f8itlpZvkrNS/ JNANvHtqeFCInA7JlxcNAON073SJDMaEeSD4ddRH7E2bzhDksSg6Sn7N4gQDpaXV4Nd5mB sdcgN1jsC/Mjoq4EFug4yR6DBOzymJw= X-MC-Unique: i-57jL_gNomGZR2eNfm2DA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 01/15] virml: Introduce VIR_XML_PROP_NONNEGATIVE flag Date: Tue, 7 Jun 2022 14:52:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1654606394329100003 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 Sat Feb 7 08:04:00 2026 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=1654606442; cv=none; d=zohomail.com; s=zohoarc; b=LheMghw+0VmwK8fFyta1Egpe0n8ZmlFTTqBee9lSqU/EST8hiGHPEARxQAoX5ppYwmUNr/lVbn8XoFVZC7nSGkaU8gymc1ICkUsVzIPiLcnID1KzZSZl7WgBRdVkcRHiqbF52WqBvFoP/b++FpebfWbPCOlCV7JIaaC/3PCQnKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606442; 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=L2PK0KIA2ONPDObveeNDR7+tJzvExQz5/5CZhndARik=; b=ffVcjZUUdupzS6l0XkAszjeZgI2SWzrlgG3D3u7u8pMjycewObJb2lGUAI8xBSCxV9UxvyDnpotXzsJzREmIA9lyD7I5wFucw0EpnaKLDW/3gw4nWAx54xx8/fJkahanqv3W9nskBKLM9DUDrBA8R9Jrjc5mR3Z2aFTX0npp7Rc= 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 1654606442858266.56875227366686; Tue, 7 Jun 2022 05:54:02 -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-618-8BelUiD-O4a9Kja4DNJpVA-1; Tue, 07 Jun 2022 08:53:06 -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 3D42B395AFE4; Tue, 7 Jun 2022 12:53:04 +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 257C61121314; Tue, 7 Jun 2022 12:53:04 +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 B90551947B82; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DFA4119452D2 for ; Tue, 7 Jun 2022 12:53:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C33DB4050C41; Tue, 7 Jun 2022 12:53:02 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5274B4050C40 for ; Tue, 7 Jun 2022 12:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606441; 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=L2PK0KIA2ONPDObveeNDR7+tJzvExQz5/5CZhndARik=; b=e7sVgQg3NdTz4znG/puMLH5VK2rAkDaGeQF9b8CGZDWys22rZX8Muarbh0Aq6lIfvBMWr3 9vxt2IB20RNqZapvVnufSVjevF2Ql+iqjdPATCK5WRWk0j1mEQnHJAK6u8AJoHFvHX0CCu h0a355IZIRAo8TexNexVdJxxOrIOiG8= X-MC-Unique: 8BelUiD-O4a9Kja4DNJpVA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 02/15] virDomainDefParseIOThreads: Use g_autoptr() for @iothrid Date: Tue, 7 Jun 2022 14:52:46 +0200 Message-Id: <4ff48f8e39eebf363b563bab76ee0ef533bbb7f8.1654606121.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1654606444808100001 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 5d0d436a40..3b4274e037 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17046,7 +17046,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 @@ -17054,10 +17055,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 Sat Feb 7 08:04:00 2026 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=1654606448; cv=none; d=zohomail.com; s=zohoarc; b=OROF9Dpf+mOK1StztbG4DCHKYY/Nd8tYuCgvnIAZa0rfOgGkmSi9B2UpxVY6FCNULWqKPqImpqO9TADPX6ox/v9o66qmefMp6P+ZJXSmAyM2rowNP5TZKXCS0fIcPhOksC7jJ9nSwjcyVzTiGoSwcAZNic/kwDZdWaHcBpozrUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606448; 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=0ClgMzXhnoc3EPyXG3y8V4auiBVMCioqXVhfrcXzOFw=; b=dytY3RsFG4+HYdtnMpofy1gntPfwSZquUTtaB2KelbfLI6pf0xInqov7WeSchAW4rKEu/lWcJXArzPDwKasSTvK3L/GZaXz0z9z7jCftzY7k8CpoeZl0OUkQFoE2Mq/qCdnw9BQuSy6TGI7V3Ab40OKzxF1+Yon6VpMSlKWgYbI= 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 1654606448070347.4519542770903; Tue, 7 Jun 2022 05:54:08 -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-650-vxinm44rPK61lTTqDHCBJQ-1; Tue, 07 Jun 2022 08:53:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F6F3395B01C; Tue, 7 Jun 2022 12:53:04 +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 4C124C27E92; Tue, 7 Jun 2022 12:53:04 +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 20B371947B94; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9F15C1947B8D for ; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 820BA4050C41; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DF184050C40 for ; Tue, 7 Jun 2022 12:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606446; 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=0ClgMzXhnoc3EPyXG3y8V4auiBVMCioqXVhfrcXzOFw=; b=b2NhY/HwIE5m172bHhortYGcHvOr9vSSeVAZWsw/2woz89nyOZ08MNXcePNrulOGSslkct HZyKXOqn22rm+hkKZDglnMAcn/pI4PGTgycmK+j4m9C0n+TWoNWn14X4PIppsnbtlgXO5K 27oorYIuN1AIWAkkH7xDivdQE5KPvds= X-MC-Unique: vxinm44rPK61lTTqDHCBJQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 03/15] virDomainIOThreadIDDefArrayInit: Decrease scope of @iothrid Date: Tue, 7 Jun 2022 14:52:47 +0200 Message-Id: <0928c0fba500fa8deeb8c3194fb500907c7546aa.1654606121.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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.8 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: 1654606448752100005 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 3b4274e037..eec5941089 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3508,7 +3508,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 @@ -3533,6 +3532,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")); @@ -3541,7 +3542,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 Sat Feb 7 08:04:00 2026 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=1654606392; cv=none; d=zohomail.com; s=zohoarc; b=eWYTjpsJmdMs7KLS92gnLDEUPQVPYdoBLXBLNAjJqn6oQKkR81kAl7bKpT/kE5DTMcPNxuumCKa5EbebKDZshs9pES4nLm17EN6xZw7yo3RXcTsBUeWVddCFTXZtyTeqhdUumkY+vX2MB33HlQI6kLDv7fESBsN8hFcAlI6koOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606392; 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=HDVwVgB2+jd7UDiEVhSvsZo8xTyQZr1hLV1gbTsU4bs=; b=QZF/Aa8W1Re0Q7FhAiWZbq8xQPS9VjlcXY2NrHht03nu45TxosOfWCHrA6r1BvfDSFHTq0lNfM95lVjsjWEbPMZ6yuX/Lx6I2l6MYNFVMV+w9zE72sRyTh2xnRGxr6CP+G5YDwgkmSpN6lqi4X6jdCIyiL2+wesoWq/Poeofn18= 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 1654606392003160.2982250260833; Tue, 7 Jun 2022 05:53:12 -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-38-uL7kccfyPRW0hg7Hv_50VQ-1; Tue, 07 Jun 2022 08:53:08 -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 D95D72A59547; Tue, 7 Jun 2022 12:53:05 +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 C21E840336A; Tue, 7 Jun 2022 12:53:05 +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 7EF9A19451F0; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7065C1947B87 for ; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5513C4050C41; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id C16764050C40 for ; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606390; 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=HDVwVgB2+jd7UDiEVhSvsZo8xTyQZr1hLV1gbTsU4bs=; b=EU/gs/sddHjhrq096a/nuR9b0PzDogvjf1EPGQ/6fwQ8fjgLr+OaZHp/qNpAhOwkx/Wsx/ 0l56+bT+i+298f1r/xd06iZMzmsg9X7mkisCNXwcVdKDMeaC64cLV+dMgYI0CkHP/wBEZh 3cEaZZ/xzCB26bBy7YzDhcRgmypBJeQ= X-MC-Unique: uL7kccfyPRW0hg7Hv_50VQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 04/15] conf: Move iothread formatter into a separate function Date: Tue, 7 Jun 2022 14:52:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1654606392367100001 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 eec5941089..c60ab4e064 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27569,7 +27569,7 @@ virDomainCpuDefFormat(virBuffer *buf, =20 =20 static bool -virDomainDefIothreadShouldFormat(virDomainDef *def) +virDomainDefIothreadShouldFormat(const virDomainDef *def) { size_t i; =20 @@ -27582,6 +27582,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) @@ -28227,20 +28252,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 Sat Feb 7 08:04:00 2026 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=1654606392; cv=none; d=zohomail.com; s=zohoarc; b=Sf/4CaYwDgrD/VHsXtt0JZJrAEF+4Bn44tfwvOJhq9wLKdANucIICNLwap85eotA51AYlG0doxhN4wOPUwZZOLzOF9dd/+/gIJSTHxql02UpFej1HoCeabvjn3i2jm0FrV4ImPTqHdXkYYYEq+A1/T+/UHZdk+3v+hLMw/fqFMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606392; 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=aT+MJUvgsg6kntoPzMhnb0S09gCQ5QXJZ67r/m/7cXQ=; b=P+4+sjZ5kM3HV4dUAy3TL63mm5GTvX8DQ5Wy6UZ/pue59NmW6SminIclJ6NKVZxR44giXZGxtwdCGOL3VQ+bBONzFhpUXbouBqPwQq28CF8rPiu1z3MTdlRKq8W9ag3z86JmnCt5tARw02frVsD0vhyzzRjL8QQpxA3DahKqwrM= 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 1654606392845148.6280499926521; Tue, 7 Jun 2022 05:53:12 -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-88-WR2Iiqm5Pk-mJJJmM3hbag-1; Tue, 07 Jun 2022 08:53:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30E36833AEE; Tue, 7 Jun 2022 12:53:06 +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 188A38288A; Tue, 7 Jun 2022 12:53:06 +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 D6A051947B95; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2A8E819452D2 for ; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 182014050C40; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 922964050C43 for ; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606391; 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=aT+MJUvgsg6kntoPzMhnb0S09gCQ5QXJZ67r/m/7cXQ=; b=e6OKMgN3TJzc864/xjfGIRZKHzYGnEKef5UPIkiflRs5fz5nRUB9ABaI9ZOOE2D+CYUaY2 9OIKOKALZuNh+HJmniE3ZScQeno/8hGtG15CuTLgVHhqubvN/lp7Z4Kz4vXexnBsFnn/fp NP7d6KWszKMvLhJbYbzDBQOQeUZheGQ= X-MC-Unique: WR2Iiqm5Pk-mJJJmM3hbag-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 05/15] conf: Introduce allocator for virDomainIOThreadIDDef Date: Tue, 7 Jun 2022 14:52:49 +0200 Message-Id: <6e205efe680c6393bd7e8ecaa0ad1a6e4d3e9f80.1654606121.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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.79 on 10.11.54.5 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: 1654606394335100005 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 c60ab4e064..8d4b27dbc0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3476,6 +3476,15 @@ virDomainIOThreadIDArrayHasPin(virDomainDef *def) } =20 =20 +static virDomainIOThreadIDDef * +virDomainIOThreadIDDefNew(void) +{ + virDomainIOThreadIDDef *def =3D g_new0(virDomainIOThreadIDDef, 1); + + return def; +} + + void virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def) { @@ -3539,7 +3548,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= ); @@ -17008,7 +17017,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, @@ -22931,8 +22940,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 Sat Feb 7 08:04:00 2026 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=1654606455; cv=none; d=zohomail.com; s=zohoarc; b=GottJXPgmSkNzCzAUNnf5tYvNH+zZuJG+/7c7WeUSJYtOqtz2O3CpJQrLj5rcbu7/62tIImwnD99v59TIDRNdv0qat+OmfiVQnbPV4GAeQNK8ja2/p5+J2/izgNIDHmH+HCyCQfYZOHIpWKb6eSd4ykgquo9vsfMxeKxi0WjsQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606455; 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=d5vG1bfe3xl1TY9MhwyXfY0o94KD6PwQZKc7mWSd91Q=; b=cWwjLNAh2zbIcrcsD70kKflpCUnjTBEdiy32LfxdZ3zJbE9oN3lxSUHdVIpYvJ6NVUA8G1eUlCeeslKL23glmBh2/wetmcLN3s+AfTMjoQlknoFzI4iEhsiimWTMMniLBYcMFYbOYkGMTdRt0/stOJHFYWquEZkIi6PpgOm1qTY= 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 1654606455602180.07047241496718; Tue, 7 Jun 2022 05:54:15 -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-590-PgiyA9QTOCCoOolM7gJiIA-1; Tue, 07 Jun 2022 08:53:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 846B2824078; Tue, 7 Jun 2022 12:53: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 6E8674050C41; Tue, 7 Jun 2022 12:53: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 4D22C19451F0; Tue, 7 Jun 2022 12:53:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 01DDD19451F1 for ; Tue, 7 Jun 2022 12:53:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E84544050C40; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C9CD4050C41 for ; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606454; 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=d5vG1bfe3xl1TY9MhwyXfY0o94KD6PwQZKc7mWSd91Q=; b=iHn3LXYt5hQWQpLtdLh7JK/YV6fajO3QIh/zQ1y7XSCc6O1mRpiIGlCxU0V5TVQzNOEef7 xEoBa9JJGWnwxbFR1r5k2AMX3adEJm5MC0S/M8E0zT2AqE09N0I5s2EpaH9G6DkTcpPVXi V6GM896X5KJkMOTZZpC7BLCp9wmlNnU= X-MC-Unique: PgiyA9QTOCCoOolM7gJiIA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 06/15] conf: Introduce pool_min and pool_max attributes to IOThread Date: Tue, 7 Jun 2022 14:52:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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.84 on 10.11.54.2 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: 1654606456836100001 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 | 5 +- src/conf/domain_conf.c | 34 ++++++++++- src/conf/domain_conf.h | 3 + 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 + 7 files changed, 111 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..2aa39b2f63 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,9 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU on= ly)` 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 + ``hread_pool_max`` which allow setting lower and upper boundary for num= ber + of worker threads for given IOThread. :since:`Since 8.5.0` =20 =20 CPU Tuning diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8d4b27dbc0..8891289866 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3481,6 +3481,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 @@ -17008,7 +17011,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, * * 4 * - * + * * * * @@ -17024,6 +17027,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 @@ -27607,8 +27620,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]; + 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 e7e0f24443..2a5001f15c 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/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index cc598212a8..7e6310832b 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 + + + + +
+ + + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + +