From nobody Mon Feb 9 06:29:10 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=1654154357; cv=none; d=zohomail.com; s=zohoarc; b=Ld9tu4WUnDfaxjV6yY27jpwyhV8EtDXBrL//MRlhcNAIRt5d+Ou/SPlgoRHrJCIvx72BP+PZYXzjfKt9LiiG7waZDC7grUHX8/Q/IhmSbSj5nWFr5FEjYPpYZmLho7KTjoC21Z8NtZGmO9l85g0GL5UtmRchvUUoxIAgrj6u5ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154357; 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=EmLdOgDGyeSW8MS7smRUpU6LAuWMCACgnhueA4+u0a8=; b=GtFcURQbbC4xj72PY5MJXxhP0O3m08lWFzf9SV1SnCAghJEcbe8NDdcuE7OsLplXw/ZicG2FrHmCo2N6I6i7oeYDaEbA4eglLCUT1Xj3QyabeVvyD6t4Ln5N4SxUw/v8i7CcmxH+lkhdOIksDXHXcq59JzWBe6lkvvkbnnZ9/bs= 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 1654154357195793.8058132149421; Thu, 2 Jun 2022 00:19:17 -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-34-VfAboSlINwy_Q7onlI_rTg-1; Thu, 02 Jun 2022 03:18:23 -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 2A18E185A7B2; Thu, 2 Jun 2022 07:18:15 +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 17620492C3B; Thu, 2 Jun 2022 07:18:15 +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 D60531947B87; Thu, 2 Jun 2022 07:18:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A04451947B87 for ; Thu, 2 Jun 2022 07:18:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8D68F2166B2C; Thu, 2 Jun 2022 07:18:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3360A2166B26 for ; Thu, 2 Jun 2022 07:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154356; 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=EmLdOgDGyeSW8MS7smRUpU6LAuWMCACgnhueA4+u0a8=; b=MKW1FwohRlzy1Ug+gpcqfasozOQfTPv7//oFjRmBthSmdgr3zNfq9z8MaXpbvLhEv5ZNdb qg0j78otPx3XaAMG4RjJb30B0/1kDDZaY98wfFr+R0u6AXpDSmVLocmenjkIDI/BS0oCHn HFEgD05qxpkU9at6iDyiEKhKVIipi0g= X-MC-Unique: VfAboSlINwy_Q7onlI_rTg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/16] virml: Introduce VIR_XML_PROP_NONNEGATIVE flag Date: Thu, 2 Jun 2022 09:17:51 +0200 Message-Id: <2c84145b8caa70e666181252ec80628a74a672e2.1654154053.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154358931100001 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 Mon Feb 9 06:29:10 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=1654154345; cv=none; d=zohomail.com; s=zohoarc; b=b9od66mOAGT6LfNjeIUFvrUP1k/t/v8UGldSDKmP+SkR8fgD2MVrtWDA8oP4ZwzXQyit6xgj3YgDXpyLnXqsMlseAJSEr2/HVjpq9yZvcSZbMYyMkbtSAm9ky7dJ4MgSpBgMPJczVUcFtJpZ5LaEceuz2aVptw7aN2bz5uaXhco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154345; 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=SVRR+zMC502yix9wizI7OE09TVjoz1bqLDIbVOr7PtA=; b=FCbXABENQzyhVdishZJ28HNHU0uzo6w4vrhwPt4Sx1JqOZBMAByPYDosaceqZTa5KtLsYgCHKOFfEKfdqetUayEn8U4jTOyuw9MDya6mR73pK3ioGYdiNEuNffBSsW+6rVVmhWEniRAmX6hHPb310Xc+R+ZQ+g/9FXdit74encI= 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 1654154345561541.520593862341; Thu, 2 Jun 2022 00:19:05 -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-266-DYRmkco9OMqHCIZD6khaDA-1; Thu, 02 Jun 2022 03:18:17 -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 73F6D3C0ED5A; Thu, 2 Jun 2022 07:18:15 +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 5CCEC1415101; Thu, 2 Jun 2022 07:18:15 +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 3F5A21954F5F; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 35A8C1947B83 for ; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2844E2166B2C; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id C45AB2166B26 for ; Thu, 2 Jun 2022 07:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154344; 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=SVRR+zMC502yix9wizI7OE09TVjoz1bqLDIbVOr7PtA=; b=HbeXKb8Ecyd1pyLDnSqSxokALqsqawUCdB2XCQs9Y8DQu5s7Lm2iJn7GAxcE5FkRsh0nsR S+JoGpd4Y3c8MjXhz+Svuqr2IGIXp7DBrN3nyZLWDoKgQX+oFj8BBiSmqJJsiz4PuW8Sv8 1ov/vtz69tCOWVJ6znHyTto1sAqUaxU= X-MC-Unique: DYRmkco9OMqHCIZD6khaDA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/16] virxml: Introduce virXMLPropLongLong() Date: Thu, 2 Jun 2022 09:17:52 +0200 Message-Id: <33c5277667e3f593fe767dbd1b7ce4cd6968a902.1654154053.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154345915100004 Content-Type: text/plain; charset="utf-8"; x-default="true" So far, we have functions that parse an enum, int, tristate bool, and what not but we have none for long long. Heavily inspired by virXMLPropInt(), introduce virXMLPropLongLong() for parsing long long attributes. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/virxml.c | 62 ++++++++++++++++++++++++++++++++++++++++ src/util/virxml.h | 9 ++++++ 3 files changed, 72 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bfedd85326..1e247878e3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3652,6 +3652,7 @@ virXMLPickShellSafeComment; virXMLPropEnum; virXMLPropEnumDefault; virXMLPropInt; +virXMLPropLongLong; virXMLPropString; virXMLPropTristateBool; virXMLPropTristateBoolAllowDefault; diff --git a/src/util/virxml.c b/src/util/virxml.c index d6e2e5dd91..22caf58131 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -721,6 +721,68 @@ virXMLPropUInt(xmlNodePtr node, } =20 =20 +/** + * virXMLPropLongLong: + * @node: XML dom node pointer + * @name: Name of the property (attribute) to get + * @base: Number base, see strtol + * @flags: Bitwise or of virXMLPropFlags + * @result: The returned value + * @defaultResult: default value of @result in case the property is not fo= und + * + * Convenience function to return value of an long long attribute. + * + * Returns 1 in case of success in which case @result is set, + * or 0 if the attribute is not present, + * or -1 and reports an error on failure. + */ +int +virXMLPropLongLong(xmlNodePtr node, + const char* name, + int base, + virXMLPropFlags flags, + long long *result, + long long defaultResult) +{ + g_autofree char *tmp =3D NULL; + long long val; + + *result =3D defaultResult; + + if (!(tmp =3D virXMLPropString(node, name))) { + if (!(flags & VIR_XML_PROP_REQUIRED)) + return 0; + + virReportError(VIR_ERR_XML_ERROR, + _("Missing required attribute '%s' in element '%s'"= ), + name, node->name); + return -1; + } + + if (virStrToLong_ll(tmp, NULL, base, &val) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : '%s'. Expected integer value"), + name, node->name, tmp); + return -1; + } + + 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"), + name, node->name); + return -1; + } + + *result =3D val; + return 1; +} /** * virXMLPropULongLong: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index 539228a9ba..94f3b9760c 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -137,6 +137,15 @@ virXMLPropUInt(xmlNodePtr node, unsigned int *result) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); =20 +int +virXMLPropLongLong(xmlNodePtr node, + const char* name, + int base, + virXMLPropFlags flags, + long long *result, + long long defaultResult) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); + int virXMLPropULongLong(xmlNodePtr node, const char* name, --=20 2.35.1 From nobody Mon Feb 9 06:29:10 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=1654154352; cv=none; d=zohomail.com; s=zohoarc; b=KXYmSh00bsNWEw1MnZYoDuHjoPlz9SuRiLCSQ7gCSbufkdA482Cjc/FohYkzxZXWksElBRx+OgMXPgX6Q3ndBUBWpYJ5KaTxPZHj1Tq3W3avdvHCvRFQ6JyAuQyfpC9xV8eRb3E8nQppEubdlxP5bXzb6/9Gl5Lw3QNYy760rUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154352; 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=3BUsKLD5UMzscaf2aEzE6ePE49k92roUpP1+AYrTwjk=; b=nklCRwbMHxdp+0iMPKKlh2NupRlKbtDv2xCjlLfgN/ZNU2RSrYpvo8abKrubVxF+HQ4LwTjUauzch0bqIG7J5YOfbQRUOD1RAAAT1vqH3WH5feyC0eC1z8QGlvJE+aHWP3O1n9Y71kWMysQ316WojTGDHqL44iXH6vG2YR2cmU8= 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 1654154352723416.80097223836754; Thu, 2 Jun 2022 00:19: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-543-p_PKa6VnMviKrQpsmiT6Ww-1; Thu, 02 Jun 2022 03:18:19 -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 28C23100BAB7; Thu, 2 Jun 2022 07:18:16 +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 14269492C3B; Thu, 2 Jun 2022 07:18:16 +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 AEF631954F67; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EE4EC1954F5A for ; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B87232166B2D; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60D8F2166B26 for ; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154351; 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=3BUsKLD5UMzscaf2aEzE6ePE49k92roUpP1+AYrTwjk=; b=Gd1LBbqjjr+4G2gNMRqGZHchdq/Ji/QPRmyDPkHoVom6T61zuAQxz2Y0sw3+b7MeHlh43p joNEQm1gkpTEUi+qHmiV1p+WxDWM8CQhQEd6ZoFoqS96AbefCHTsatP5mt6xN6IZWUounL S0KtOwKW+L40gIUmmZz5G6jCeUunHAI= X-MC-Unique: p_PKa6VnMviKrQpsmiT6Ww-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/16] virDomainDefParseIOThreads: Use g_autoptr() for @iothrid Date: Thu, 2 Jun 2022 09:17:53 +0200 Message-Id: <3eb76f2f003c72ce26c1929de93bb211cdad4bd6.1654154053.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154353912100017 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 Mon Feb 9 06:29:10 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=1654154344; cv=none; d=zohomail.com; s=zohoarc; b=I7kIl9AvrD8gG0wHxNJpKGpHjbJCjNrD7QuAkosB4KwD911/FJ+dmqUvfcQMYaOn4CDRH/PU51OiKvz71RCKfIt9+klWcV8XoSB3oITZqg1HOAgh3QrWexRBedzCR/6hbewelkGAoHV4hC+fBc4zBACarRwZLuCkKJFE0BEBmx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154344; 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=P0Y03oeHXm7u1Pf4gzjnHvkKV7P1os6r/4CDSUQrEe4=; b=cIUPqyNtzFZohBn0ppE8o/YnebeQIRLT8exJNnOh8D6Bzkk15knPQ2g0PfuVYk9A6ydx0WflJ0OKasrhpwsM57n1hmQS+QnoQD0raZHGREkXP8TSOQrCzS/K+J5rOJzj8e6Be1noIl6VHMSNnrDkjuHcrrnroLBC1EQidhjWYeA= 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 1654154344669727.9897972600535; Thu, 2 Jun 2022 00:19:04 -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-448-oLGR3kEjOhGbVk_44LfFcg-1; Thu, 02 Jun 2022 03:18:19 -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 95C4E3C1017F; Thu, 2 Jun 2022 07:18:16 +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 7D39641047EC; Thu, 2 Jun 2022 07:18:16 +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 171FE1954F69; Thu, 2 Jun 2022 07:18:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 865D61947B87 for ; Thu, 2 Jun 2022 07:18:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 56A9A2166B33; Thu, 2 Jun 2022 07:18:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id F139A2166B26 for ; Thu, 2 Jun 2022 07:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154342; 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=P0Y03oeHXm7u1Pf4gzjnHvkKV7P1os6r/4CDSUQrEe4=; b=J0kF+eNAEKFprhyENFlK6lhvkLs+YDY1kMsF2M858eajjzHAQom40jkMQbWwv6kLKgHV1R pv0JejoUj0Ox2zmonLNc7s6qWFt8rUGS0GLjwT1ZnfFFLtbSxp6Gh7tCd8GQDLnZ/PUPqP WDTSDvtkmzgHPrEi0CQrP/X5fgSM/LQ= X-MC-Unique: oLGR3kEjOhGbVk_44LfFcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/16] virDomainIOThreadIDDefArrayInit: Decrease scope of @iothrid Date: Thu, 2 Jun 2022 09:17:54 +0200 Message-Id: <529e2092754ca7b9f2fe8bdd985a19035314c2bc.1654154053.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154345814100001 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 Mon Feb 9 06:29:10 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=1654154351; cv=none; d=zohomail.com; s=zohoarc; b=aH2h3dX2yGD7KbmS1784t6bSEH7m6djoovYDA/l2qiv9j277xM6L6+W5gNfd2ANdfJLPUM6rjX1ZsldaDGEN5RNbMjR+CZXrrRwHTgnAguvQYPHaorEbWIzYyUlJor+dwgP9JeIJ3/IR/+4HevvC/mOWWwvKN+f5GeDZBTBmSC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154351; 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=5DUHto2bTO5zpevJPJae/cOxk85Lbg5Lnxk9dRHP1Js=; b=YqYDjKCbGWGpqDT0+gDuoB7m2MPLhRspaXbVb4AdL3ADbn2x4dlPzkl6Gna9uRJXqG4mfKmmM48+uP8q93a6VfUoeyRDO12MwpMtQe0AHFPXagh4OBgkaWPlwUcfCx4Bs6AaK/YnKMxyZnWRdq58AXgxyvJ7ZV1BZojWlXcRTSg= 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 1654154351477330.9059103677963; Thu, 2 Jun 2022 00:19:11 -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-207-CE1ud1RpP8CrAx9iVlo65g-1; Thu, 02 Jun 2022 03:18:21 -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 184911066559; Thu, 2 Jun 2022 07:18:17 +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 C6E4A8288A; Thu, 2 Jun 2022 07:18:16 +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 6E6F11954F6F; Thu, 2 Jun 2022 07:18:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0B9201954F5F for ; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E73F02166B26; Thu, 2 Jun 2022 07:18:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F81C2166B2D for ; Thu, 2 Jun 2022 07:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154350; 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=5DUHto2bTO5zpevJPJae/cOxk85Lbg5Lnxk9dRHP1Js=; b=SRsBli8zxdLZMBnatS8xC3D51zY/mJ0cvwjrxisxg1m7Tp7p6L3Eegl2N8V+eN2KiYq0PQ 4WGSgjLPuB3fRi9N7eIkXWkKc0M3Esj+Y+V00VHDgWIGleqZV4C/50AikQSPpS+cbYI4Kb XcCZvx66YCZ2KVBypfNA0gm3feoSj1Y= X-MC-Unique: CE1ud1RpP8CrAx9iVlo65g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/16] conf: Move iothread formatter into a separate function Date: Thu, 2 Jun 2022 09:17:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154351815100013 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 Mon Feb 9 06:29:10 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=1654154303; cv=none; d=zohomail.com; s=zohoarc; b=R+PzP6k7Qofs3HtgLiK7a23YtmykWs+nBQgukK+Yh/F4OZRa1bZ9ohkYtgRdXL9WgERh742pRNhTcipZV8QSNHAdG2TT/24yjUKMJVlzkzRxggFLrENjW4BiN2HERBvVo9kWbV9cUG8oB0M6YqYfVmA/EHOl89bEZm622oSOX5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154303; 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=vpel6P3+6VBnexb8vjBxIKL2BQkwLPYufomeXN+nA/U=; b=XwjXdOdv4kH0nIoXwp+45m5Gxea1VaRyprdLAdqp07Y8icSqeFNB6f+DpdJJ+DOGZ4JNFPuMyDJeo6FYVikDBIE9fgY0zeG+2TWndCJjlo5U1DHSqddzSaSJ1fWLAH86GjDoOWljdbaV9a5ie5bxTkUPZqxrtPLLz6j8+EJFEg8= 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 1654154303311841.4601706111033; Thu, 2 Jun 2022 00:18:23 -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-557-YKEFitXTMXyTByIJk7Xo6Q-1; Thu, 02 Jun 2022 03:18:20 -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 317E2181E07C; Thu, 2 Jun 2022 07:18:17 +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 15BD82026985; Thu, 2 Jun 2022 07:18:17 +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 BAE1E1954F66; Thu, 2 Jun 2022 07:18:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 91839194975B for ; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8477C2166B26; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C0642166B2D for ; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154302; 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=vpel6P3+6VBnexb8vjBxIKL2BQkwLPYufomeXN+nA/U=; b=ZQtQ/TRrj11exvP+3G7e/qKhp2WCMj5h0pqkqL0x3XoKo+fLxvbkt3JBXjUralljuFUANC w6gDQEyA3eeGa8SXb/gHyL1pPUO7fmTVWhwP/SAVEyvkco8aH66QPa2Q25EaKsPHRxtFxT synF7U8gwjd7A0VaqWgCky3rWMCvl7w= X-MC-Unique: YKEFitXTMXyTByIJk7Xo6Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/16] conf: Introduce allocator for virDomainIOThreadIDDef Date: Thu, 2 Jun 2022 09:17:56 +0200 Message-Id: <71097166401fa94e9965d67667f07c65672c9aa7.1654154053.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1654154303708100001 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 Mon Feb 9 06:29:10 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=1654154305; cv=none; d=zohomail.com; s=zohoarc; b=cLIYSYdjKpeUxgo4BZ5wf+kThC2536r+CbOXHZEajNMz11MFU34UwSINNTKPejIgELYvCCwSLHkTNyOqn8CH3WSa18howPDmkcXtdaJFRZScNegs3rKK7hzOSc0SJ8Yb1SWUzVV58EL9cV7L1qM6m8ujffzTZQsRnNPGoMeWxx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654154305; 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=uBXAaR75LIv76/UDBHhZgSnkMgYdbe8IwSeZ36b1hyw=; b=efbxR3IRJIeuC1Ry3pL/dvcSjbnZt+ePefgVQWeSX0VNoeitAvJVmkBnPBn1QypPJ3nab/wte6OK0UNEJUX28X0+Wts/FYYt+WKL2JvK5YcDu/2QHztWOKBa9Uyc6JOJPN+fR6j4ezYiXL4EtWbj4ZccaeAfFTlMhXqZDl+4LGw= 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 165415430545094.01534517542473; Thu, 2 Jun 2022 00:18:25 -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-470-X-sZK21fNVCcAUtsjOe69g-1; Thu, 02 Jun 2022 03:18:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9B668041B3; Thu, 2 Jun 2022 07:18:17 +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 A179D2166B2F; Thu, 2 Jun 2022 07:18:17 +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 3A2B41954F60; Thu, 2 Jun 2022 07:18:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 329FF1949759 for ; Thu, 2 Jun 2022 07:18:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 26FFF2166B2F; Thu, 2 Jun 2022 07:18:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0DAB2166B26 for ; Thu, 2 Jun 2022 07:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654154304; 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=uBXAaR75LIv76/UDBHhZgSnkMgYdbe8IwSeZ36b1hyw=; b=ZcrKR2mEF1kJm0Nii/kvqYOedwsZ1pLADZW/d9XqxO7kWCaC1McdRKYnbageJMbjbKFy1X dLvc4N/7XKZk0gOUZKzRNYFFPcWKqvy/6nP84MbX0AdEwikJ6+J+pBqF36yCUFworzuZZg ZJYX+RPSmhWNQRZoUmNWeuw1nzgnlTM= X-MC-Unique: X-sZK21fNVCcAUtsjOe69g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/16] conf: Introduce pool_min and pool_max attributes to IOThread Date: Thu, 2 Jun 2022 09:17:57 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.6 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: 1654154305828100001 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 | 32 +++++++++- 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, 110 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..de085f616a 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 ``pool_min`` and ``pool_max`` w= hich + allow setting lower and upper boundary for number of worker threads for + given IOThread. :since:`Since 8.4.0` + =20 =20 CPU Tuning diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8d4b27dbc0..7572e62db1 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->pool_min =3D -1; + def->pool_max =3D -1; + return def; } =20 @@ -17008,7 +17011,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, * * 4 * - * + * * * * @@ -17024,6 +17027,14 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) &iothrid->iothread_id) < 0) return NULL; =20 + if (virXMLPropLongLong(node, "pool_min", 10, + VIR_XML_PROP_NONNEGATIVE, &iothrid->pool_min, -= 1) < 0) + return NULL; + + if (virXMLPropLongLong(node, "pool_max", 10, + VIR_XML_PROP_NONNEGATIVE, &iothrid->pool_max, -= 1) < 0) + return NULL; + return g_steal_pointer(&iothrid); } =20 @@ -27607,8 +27618,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->pool_min >=3D 0) { + virBufferAsprintf(&attrBuf, " pool_min=3D'%lld'", + iothread->pool_min); + } + + if (iothread->pool_max >=3D 0) { + virBufferAsprintf(&attrBuf, " pool_max=3D'%lld'", + iothread->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..c502100d45 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2646,6 +2646,9 @@ struct _virDomainIOThreadIDDef { virBitmap *cpumask; =20 virDomainThreadSchedParam sched; + + long long pool_min; + long long pool_max; }; =20 void virDomainIOThreadIDDefFree(virDomainIOThreadIDDef *def); diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index cc598212a8..94035c38e7 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..5ff3b4b18e --- /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 + + + + +
+ + + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + +