From nobody Sun Feb 8 23:59:03 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=1658136855; cv=none; d=zohomail.com; s=zohoarc; b=dRFRMvyICuw1a3y0oWx3+YNh0+hAQcDRQx318Dxpd8tiWpIwR+Pu4NkaSvY+xdzjDGqgGCQq1r17slQAXUDJLFkng3paDbHCdfqnkLgV7oHd3d+8y8A44kzG+be32h0HUneym3T28Q/ufIGpB2aaN8wM+R3N3kNq3nrJIOhPvuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658136855; 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=2Vpmzt8qUar+ZbkrmRW6w3OxrjTzQV3/kVn94fvsiWk=; b=QWaLz0hE+qFr9Tc8Q6vkvIvHxNcH8EE+nKTXWPLvfw4x9Pm0c9qTyLKgUZ/Csw0iIUwuAlAp6bOAYthAFzrIqgXx4k4g9Bh7puYn4ZmTg7AOisyQ4YjBuPoos1n8LjL/Ehb+GEBhrqqu9DuvgQSODce37nuSkrbfh4xusWI+RCc= 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 16581368551351014.5333100769631; Mon, 18 Jul 2022 02:34: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-133-lfiM6qEyN5Kas28VRhhv9g-1; Mon, 18 Jul 2022 05:31:00 -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 3C3DE811E75; Mon, 18 Jul 2022 09:30:56 +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 22BC21121314; Mon, 18 Jul 2022 09:30:55 +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 E776C1947056; Mon, 18 Jul 2022 09:30:54 +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 AB7A2194704C for ; Mon, 18 Jul 2022 09:30:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 875CB2166B2A; Mon, 18 Jul 2022 09:30:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 334692166B26 for ; Mon, 18 Jul 2022 09:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658136854; 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=2Vpmzt8qUar+ZbkrmRW6w3OxrjTzQV3/kVn94fvsiWk=; b=czvQusLH4BNO5OC7LPLfyQAj8Q3BPIqoampEYEbBFLghNMS3m2DiHEossf6Y3U3hHI/H57 gdFAqpTojUcNoJ9foUJEq+ZsOueiNr3LJ5Lkl+MAkjC4i71bZgW0NMMztCmLSSLJCao2wa QOCNo1PpOEcC/gp4lXSBlK+aFC/wL48= X-MC-Unique: lfiM6qEyN5Kas28VRhhv9g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/8] conf: Report error when default TPM version is provided Date: Mon, 18 Jul 2022 11:30:44 +0200 Message-Id: <838c8127f28cdf75364d8e5e16b25c0b3c46cca0.1658136603.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.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: 1658136855401100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When "default" version of TPM was provided, our parses accepts it happily even though the value is forbidden by our RNG and not documented as accepted value. This is because of < 0 vs <=3D 0 comparison of virDomainTPMModelTypeFromString() retval. Make the parser error out explicitly in this case. Users can always chose to not specify the attribute in which case we pick a sane default (in qemuDomainDefTPMsPostParse()). Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b7147945da..6c178783af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10400,7 +10400,7 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, if (!version) { def->version =3D VIR_DOMAIN_TPM_VERSION_DEFAULT; } else { - if ((def->version =3D virDomainTPMVersionTypeFromString(version)) = < 0) { + if ((def->version =3D virDomainTPMVersionTypeFromString(version)) = <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported TPM version '%s'"), version); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5a057c36b8..7139b91aca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1417,7 +1417,7 @@ typedef enum { } virDomainTPMBackendType; =20 typedef enum { - VIR_DOMAIN_TPM_VERSION_DEFAULT, + VIR_DOMAIN_TPM_VERSION_DEFAULT =3D 0, VIR_DOMAIN_TPM_VERSION_1_2, VIR_DOMAIN_TPM_VERSION_2_0, =20 --=20 2.35.1