From nobody Sun Dec 22 03:28:15 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 17339068804183.5518916219007224; Wed, 11 Dec 2024 00:48:00 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 75EE092F; Wed, 11 Dec 2024 03:47:59 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A87E3CEC; Wed, 11 Dec 2024 03:47:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1019FCDC; Wed, 11 Dec 2024 03:47:39 -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 8D0F0CD1 for ; Wed, 11 Dec 2024 03:47:38 -0500 (EST) Received: from mx-prod-mc-01.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-614-Z77R2p-LMQmotdM9NZe9ag-1; Wed, 11 Dec 2024 03:47:32 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E5D34195609D; Wed, 11 Dec 2024 08:47:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.164]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9F6571956048; Wed, 11 Dec 2024 08:47: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=1733906858; 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=KZ3hzen/RzsP1wvkLqOtXZ/ZNElOvrtjbNCC50j2yQ0=; b=M7zLZjQJRpVNqzuICAr3fgIrc66g4P/6jiACh0CNiRgFkJoYASMmsTRg1fLVBXZ0rrBFAX H76g14xE04nirQVbPpfoyNxQAhEwnhkVfE/FTC4nH0PsAAE6A40sTTYZ1Zw7zmHswcySuW jGKeH2xAzs9YJCwIgxN7dkKyP9AnZdY= X-MC-Unique: Z77R2p-LMQmotdM9NZe9ag-1 X-Mimecast-MFC-AGG-ID: Z77R2p-LMQmotdM9NZe9ag From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH v3] qemu: tpm: do not update profile name for transient domains Date: Wed, 11 Dec 2024 09:46:49 +0100 Message-ID: <3256728a3cbdbe89aef226b2a491d7f2fca26d34.1733906809.git.jtomko@redhat.com> 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: 0JxXxDK-nYKRYCzFCD_Kc8s0Gu7m4CNcdrPXqfUprEI_1733906852 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 57SVVMMXUYB3JVJZG5QD47HUZRO7YD7S X-Message-ID-Hash: 57SVVMMXUYB3JVJZG5QD47HUZRO7YD7S 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: 1733906881599116600 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: Jiri Denemark Reviewed-by: Stefan Berger --- src/qemu/qemu_extdevice.c | 13 ++++++++++++- src/qemu/qemu_tpm.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index a6f31f9773..954cb323a4 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -190,7 +190,18 @@ 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 && + (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