From nobody Mon Feb 2 07:29:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1769421087; cv=none; d=zohomail.com; s=zohoarc; b=BT3EPtcl+2tLi61bdJd7FKhzcZsVAAQG3bwtGWyfKeGZJ8oMqxYorCTzoKlS/lQrd+1TL/6dgYWocez4WoVtWukw/LdlsQkviQ0o3YxTinwK0ddoB20NvoMiRktCggGxkmdQ74GThD+1mi5WtOqkw2BNvK1lWxdU88px6rOjMGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769421087; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=vHHmtCpjCweYWpWzH7n8xP3fw855WcaJD4/7S9jAdiU=; b=JTrIsKQPrYIxv+yoGP6u+CvFSyfzEYFAeqzOzBgWXu0nRH0SyaUtKMLzjCgBWLmnRWG/6IKebrhHaBvEzZv8fPz0RDSfJArJXAh7Eu8QAjsnb6KOeDobmGYJjSbBbfPS5yiBQgomtDW9JsPx9SriWQD7zarMFCJdxl+lOYV3h1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1769421087281154.6602698180352; Mon, 26 Jan 2026 01:51:27 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 07EC141A25; Mon, 26 Jan 2026 04:51:26 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 791724194C; Mon, 26 Jan 2026 04:50:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id CCC3F418DF; Mon, 26 Jan 2026 04:50:28 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E713341904 for ; Mon, 26 Jan 2026 04:50:27 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-5qvb8XR2OpGsOygX8qgWZw-1; Mon, 26 Jan 2026 04:50:25 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF158180047F for ; Mon, 26 Jan 2026 09:50:24 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5770D1956095 for ; Mon, 26 Jan 2026 09:50:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769421027; h=from:from: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; bh=vHHmtCpjCweYWpWzH7n8xP3fw855WcaJD4/7S9jAdiU=; b=OY4ruAvoQ3qoDAQ+wMqU+p2arNhPG5Lzte2pI1VpgrG9oRRYzoD5BCUNG5HP7pI6cmyUGD NGdGTeTON9OHsuBQPniRO0H1EZXha6WNQ/RH8gHFlkUXxwyJgtbYxBmCopkA6f2hi0euXq ZA4ahApsXyoAHlxspdg8U29vUw6d1fM= X-MC-Unique: 5qvb8XR2OpGsOygX8qgWZw-1 X-Mimecast-MFC-AGG-ID: 5qvb8XR2OpGsOygX8qgWZw_1769421025 To: devel@lists.libvirt.org Subject: [PATCH v2 1/7] conf: Teach virDomainParseMemory() new retval Date: Mon, 26 Jan 2026 10:50:15 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: G6jFhoUoilAMqnJq03kfDm5Quji9Skgc4AOv5GE70X4_1769421025 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6EBU363OAKG2U7BYEYODCP5PWEYTUQTV X-Message-ID-Hash: 6EBU363OAKG2U7BYEYODCP5PWEYTUQTV X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1769421091176158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik So far, virDomainParseMemory() returns either 0 or -1. While this allows callers to distinguish a success case from an error it doesn't allow them to differentiate the case when no value was provided in the XML, thus nothing was parsed and nothing was required. Therefore, make virDomainParseMemory() return 1 on success, 0 in case nothing was parsed and nothing was required, and -1 on failure. Arguably, no caller needs this distinction currently, but that is about to change. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9672168df9..1b2a439ca4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8719,7 +8719,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, * if @capped is true, the value must fit within an unsigned long * (only matters on 32-bit platforms). * - * Return 0 on success, -1 on failure after issuing error. + * Returns: 1 if value was parsed successfully, + * 0 if value wasn't present and @required is false, + * -1 on failure after issuing error. */ int virDomainParseMemory(const char *xpath, @@ -8730,21 +8732,27 @@ virDomainParseMemory(const char *xpath, bool capped) { unsigned long long bytes, max; + int rc; =20 max =3D virMemoryMaxValue(capped); =20 - if (virParseScaledValue(xpath, units_xpath, ctxt, - &bytes, 1024, max, required) < 0) + rc =3D virParseScaledValue(xpath, units_xpath, ctxt, + &bytes, 1024, max, required); + if (rc < 0) { return -1; + } else if (rc =3D=3D 0) { + *mem =3D 0; + return 0; + } =20 - /* Yes, we really do use kibibytes for our internal sizing. */ + /* Yes, we really do use kibibytes for our internal sizing. */ *mem =3D VIR_DIV_UP(bytes, 1024); =20 if (*mem >=3D VIR_DIV_UP(max, 1024)) { virReportError(VIR_ERR_OVERFLOW, "%s", _("size value too large")); return -1; } - return 0; + return 1; } =20 =20 --=20 2.52.0