From nobody Sun Dec 22 01:42:02 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1733839319139824.9034032628873; Tue, 10 Dec 2024 06:01:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D620B11A6; Tue, 10 Dec 2024 09:01:57 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4E647E89; Tue, 10 Dec 2024 09:01:40 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CDCF2E66; Tue, 10 Dec 2024 09:01:36 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 51DA1E67 for ; Tue, 10 Dec 2024 09:01:36 -0500 (EST) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-vYETgXhPMKCARNqc-wvCLQ-1; Tue, 10 Dec 2024 09:01:33 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 48CCC1956067; Tue, 10 Dec 2024 14:01:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.85]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1294C19560A2; Tue, 10 Dec 2024 14:01:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733839296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sQIWqA/5c0jkM2bNaKc4us9oG+aav42m1u/J10OR1aY=; b=IWzEt55tkmqigBhpPIHNTbel7nwR3f18N+ybUHYnPh9A4gKdlGRzVpsG9Z3NEfQyjqVxfq 4zCrNyBqLmU996iMt6R6HN+rjlszMU7KuyHxDOu7wEumLBhRf9652k9r3rYaOCdOdGHVqc w4rTwtvOjaazSZMRUbaGhZEBLYcmfEs= X-MC-Unique: vYETgXhPMKCARNqc-wvCLQ-1 X-Mimecast-MFC-AGG-ID: vYETgXhPMKCARNqc-wvCLQ From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH v2] qemu: tpm: do not update profile name for transient domains Date: Tue, 10 Dec 2024 15:01:16 +0100 Message-ID: <4ccf4e8162b8c2def668ed710f450d3d7fb44fbe.1733839276.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 912nQMF5nq4ILNnMI9wktlj8-ddmTmRSyAWzJpwaorg_1733839292 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VKO6KGI4Q7YCRQQYVC7UA5XVNEJZ73AB X-Message-ID-Hash: VKO6KGI4Q7YCRQQYVC7UA5XVNEJZ73AB X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: stefanb@linux.ibm.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1733839324159116600 Content-Type: text/plain; charset="utf-8" If we do not have a persistent definition, there's no point in looking for it since we cannot store it. Also skip the update if the tpm device(s) in the persistent definition are different. This fixes the crash when starting a transient domain. https://issues.redhat.com/browse/RHEL-69774 Fixes: d79542eec669eb9c449bb8228179e7a87e768017 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Stefan Berger --- src/qemu/qemu_extdevice.c | 12 +++++++++++- src/qemu/qemu_tpm.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index a6f31f9773..21db01a361 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -190,7 +190,17 @@ qemuExtDevicesStart(virQEMUDriver *driver, =20 for (i =3D 0; i < def->ntpms; i++) { virDomainTPMDef *tpm =3D def->tpms[i]; - virDomainTPMDef *persistentTPMDef =3D persistentDef->tpms[i]; + virDomainTPMDef *persistentTPMDef =3D NULL; + + if (persistentDef) { + /* do not try to update the profile in the persistent definiti= on + * if the device does not match */ + if (persistentDef->ntpms =3D=3D def->ntpms) + persistentTPMDef =3D persistentDef->tpms[i]; + if (persistentTPMDef->type !=3D tpm->type || + persistentTPMDef->model !=3D tpm->model) + persistentTPMDef =3D NULL; + } =20 if (tpm->type =3D=3D VIR_DOMAIN_TPM_TYPE_EMULATOR && qemuExtTPMStart(driver, vm, tpm, persistentTPMDef, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index f223dcb9ae..f5e0184e54 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -773,7 +773,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, incomingMigration) < 0) goto error; =20 - if (run_setup && !incomingMigration && + if (run_setup && !incomingMigration && persistentTPMDef && qemuTPMEmulatorUpdateProfileName(&tpm->data.emulator, persistentTP= MDef, cfg, saveDef) < 0) goto error; --=20 2.47.0