From nobody Wed Feb 11 06:32:24 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=1648225689; cv=none; d=zohomail.com; s=zohoarc; b=JXGnO4lmV/AAad8lGqZnFqi3b3GjW5qwZz6yoGWi+Brziyj709tsR/gxgB/LNUPBrGb0fIO5fL8a+I2bPPgGzXuVdnRo69RFyZEJaN2oaF+EJ6CMMEGmLOpRQdAw8Q31FXBOnNuotekgGG4LzlrEIngyPE/xyMNnyhqIPMljFTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648225689; 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=n4b1+KaUruR+QBlRz1r1eiO8PTNBXY74P5ho3orsLGg=; b=k7et5SjYEC7mu1fUZylZjvxuMNGsftIYV+m2k/4XSjoEcuU4iNn6QKdfAxFC//B69m2QOybz0ofrordDnOSJC3aOYmnzB+YTPw9PC9zZC6tSxYWkOq7iP/HShFDYd+eJEZ7cXFQ2/Rfl+iZzvxUXECSiqycxH1My91SXw7ZCt8s= 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 1648225689766737.5044529901944; Fri, 25 Mar 2022 09:28:09 -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-mYJM8W7nO6mWr1TLr6-uWA-1; Fri, 25 Mar 2022 12:27:06 -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 D832B8F3DC7; Fri, 25 Mar 2022 16:27:02 +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 C287C2026D4C; Fri, 25 Mar 2022 16:27:02 +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 52287193F50C; Fri, 25 Mar 2022 16:26:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9D92C1940377 for ; Fri, 25 Mar 2022 16:26:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 82CBB5E8A4C; Fri, 25 Mar 2022 16:26:57 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.192.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 118D45E8A42 for ; Fri, 25 Mar 2022 16:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648225687; 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=n4b1+KaUruR+QBlRz1r1eiO8PTNBXY74P5ho3orsLGg=; b=H8o5xrOiC5Vzf8AED12flhVeOlORFCyJwDjahtC0nSrdeTr4QT/RwE85J0aBeaVW36X/4G afpTMM3s9pgNdptFd/nvSUa8Vm7CAEJLB2NFMFowEvMrCzloimZise6Oc/afjK8yjAMI6t BHYsxkWZwpQZ0GF1ystUfIpU6tGDoDQ= X-MC-Unique: mYJM8W7nO6mWr1TLr6-uWA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [PATCH 4/9] util: Introduce virXMLPropTristateBoolAllowDefault() Date: Fri, 25 Mar 2022 17:26:47 +0100 Message-Id: <20220325162652.328686-5-abologna@redhat.com> In-Reply-To: <20220325162652.328686-1-abologna@redhat.com> References: <20220325162652.328686-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648225690038100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We need it for a single scenario in which prop=3D'default' has to be treated as valid input. Signed-off-by: Andrea Bolognani --- src/libvirt_private.syms | 1 + src/util/virxml.c | 18 ++++++++++++++++++ src/util/virxml.h | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8a3e5f7f7c..a9d7ed972f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3647,6 +3647,7 @@ virXMLPropEnumDefault; virXMLPropInt; virXMLPropString; virXMLPropTristateBool; +virXMLPropTristateBoolAllowDefault; virXMLPropTristateSwitch; virXMLPropUInt; virXMLPropULongLong; diff --git a/src/util/virxml.c b/src/util/virxml.c index 8ff59e7cda..e9ccb54c41 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -552,6 +552,24 @@ virXMLPropTristateBool(xmlNodePtr node, } =20 =20 +/* Same as virXMLPropTristateBoolAllowDefault, but will accept the + * value 'default' and convert it to VIR_TRISTATE_BOOL_ABSENT instead + * of rejecting it with an error. Should only be used for backwards + * compatibility reasons, and specifically to parse XML files where a + * property having value VIR_TRISTATE_BOOL_ABSENT has historically + * resulted in it being formatted with value 'default' instead of + * being omitted entirely */ +int +virXMLPropTristateBoolAllowDefault(xmlNodePtr node, + const char* name, + virXMLPropFlags flags, + virTristateBool *result) +{ + return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromStrin= g, + flags, result, VIR_TRISTATE_BOOL_ABSENT); +} + + /** * virXMLPropTristateSwitch: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index c39eae6282..05016db577 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -103,6 +103,13 @@ virXMLPropTristateBool(xmlNodePtr node, virTristateBool *result) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); =20 +int +virXMLPropTristateBoolAllowDefault(xmlNodePtr node, + const char *name, + virXMLPropFlags flags, + virTristateBool *result) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); + int virXMLPropTristateSwitch(xmlNodePtr node, const char *name, --=20 2.35.1