From nobody Sun Feb 8 16:30:17 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=1658136669; cv=none; d=zohomail.com; s=zohoarc; b=I7j9ELYkLC9CR0HJu3gdOcv+KmtnixalU5HOFGq5NF/E6N5w8K+I5W0J+JQG21I+dyOAx9nlxj7WQC+jmhaecIyzrVRYPnXdNd6lb2aOkabuqEm8fcQ7z4snnBCc7fUYzCGi4P6ZNxV+IZgHMcJR3lf+zw/8dRgs/fUqermxh5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658136669; 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=N7ta73u3b6MyXPV3yLyI3U2r63ctswWTeNh1I2zWocY=; b=PYw+F9A8tA92YeUO605G4zn0ApVPLFWZsmEv3wdKZSjaa8XqrF5OuO0KeeJr16EBwRNiCTLIKgX6FXL3gkM9uvr8v0UwhAjTOo47gLNHcb/6iSM0DQ788HpAHYgxmklIfZgY2IBAvPfxQyTSjjM5OptAi4xjg1Hsf/fzaY8h1FQ= 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 16581366692271012.1649379678274; Mon, 18 Jul 2022 02:31: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-588-H3ijfjzbOAaRrGeoqPPVDA-1; Mon, 18 Jul 2022 05:30:56 -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 A94628039AD; Mon, 18 Jul 2022 09:30:54 +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 8F289C35979; Mon, 18 Jul 2022 09:30:54 +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 166A9194706F; 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 2DB4D1947054 for ; Mon, 18 Jul 2022 09:30:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F09F02166B2A; Mon, 18 Jul 2022 09:30:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C7F22166B26 for ; Mon, 18 Jul 2022 09:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658136668; 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=N7ta73u3b6MyXPV3yLyI3U2r63ctswWTeNh1I2zWocY=; b=H34p8SZCJgMdMe4ClnkNix21jqQOexv/TTNiJsp+xLLHEXMWQ4U/eZ5K4/HmZww77jlOh4 7jUX0++Ygk6YTUROYGiXMhfxJ7dP46rGrmPYPl5rxUwUV9Lm41qooqO9UD5Gnkrn/48YE6 QPsS17JuXkNKTHDqLIrG/yuyKP2V+4E= X-MC-Unique: H3ijfjzbOAaRrGeoqPPVDA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/8] conf: Report an error when default TPM model is provided Date: Mon, 18 Jul 2022 11:30:43 +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.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: 1658136670153100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When "default" model of a 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 qemuDomainTPMDefPostParse()). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- 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 4c7a5a044c..b7147945da 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10360,7 +10360,7 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, =20 model =3D virXMLPropString(node, "model"); if (model !=3D NULL && - (def->model =3D virDomainTPMModelTypeFromString(model)) < 0) { + (def->model =3D virDomainTPMModelTypeFromString(model)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown TPM frontend model '%s'"), model); goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 90de50c12f..5a057c36b8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1400,7 +1400,7 @@ struct _virDomainHubDef { }; =20 typedef enum { - VIR_DOMAIN_TPM_MODEL_DEFAULT, + VIR_DOMAIN_TPM_MODEL_DEFAULT =3D 0, VIR_DOMAIN_TPM_MODEL_TIS, VIR_DOMAIN_TPM_MODEL_CRB, VIR_DOMAIN_TPM_MODEL_SPAPR, --=20 2.35.1