From nobody Fri Dec 19 16:04:47 2025 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=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1661169986; cv=none; d=zohomail.com; s=zohoarc; b=bRezlmysrRkxplVaZCLglNgDPqFbkfgkDOrspwy+Kdr4umOAhMshv1E2Wur9EOCZ8ZnmG+JJP6PUQSNDtZH93bBqMrB6GszSejfWlLYXl3fVJ7ckxqJnfYVwXwVj1hwAHuHHQFfutcYyg4as8mZv1Nu+cEl9eBrQJlMfL0PSza8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661169986; h=Content-Type:Content-Transfer-Encoding:Cc: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=cgTWcsEGnfmdT/r9jxWVFRDBHQYTUpIsyOZEwHh/dVI=; b=XMQ9CAQ6L20C881OoFbkPBsvP/DORii142cznsZ7RheFumwQs7dSV6J+tXI0QiWfZnICHBdyGbHFMkpKfkg64I1LT3OMk/4IeYruO0bTD5s/TAN8+xLjEnAVPpSZMLciSG26RRDDz/B7mPR5EH9sc0/e6ed4UKKjWf4vZyPjd7I= 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=fail 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 1661169986139727.8793979826555; Mon, 22 Aug 2022 05:06:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-vyF6sPQTP7uAeHfe7033xg-1; Mon, 22 Aug 2022 08:06:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18E703C11E66; Mon, 22 Aug 2022 12:06:15 +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 7D0844010D2A; Mon, 22 Aug 2022 12:06:12 +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 499601946A47; Mon, 22 Aug 2022 12:06:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 37BBA1946A44 for ; Mon, 22 Aug 2022 12:06:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 26883C15BBA; Mon, 22 Aug 2022 12:06:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22777C15BB3 for ; Mon, 22 Aug 2022 12:06:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 082B9299E74D for ; Mon, 22 Aug 2022 12:06:11 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-108-OdXAaZo1PTmHuPp4WzEAFQ-1; Mon, 22 Aug 2022 08:06:09 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27MBxsLT012061 for ; Mon, 22 Aug 2022 12:06:08 GMT Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3j49dr05ft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Aug 2022 12:06:08 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27MC5Hlc016715 for ; Mon, 22 Aug 2022 12:06:07 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma03wdc.us.ibm.com with ESMTP id 3j2q894han-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Aug 2022 12:06:07 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27MC67MZ65012222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Aug 2022 12:06:07 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1201DAC05E; Mon, 22 Aug 2022 12:06:07 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F52CAC059; Mon, 22 Aug 2022 12:06:07 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 22 Aug 2022 12:06:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661169985; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cgTWcsEGnfmdT/r9jxWVFRDBHQYTUpIsyOZEwHh/dVI=; b=GOtXWkA1Q/okad/v9H/qpWnM7/GhEbcaYAjbl0UJZiEYofwXiRmwZqRisIqTBtAsW7yNUR JDYR5/bhEcxnGByhI+EQjZfWaOqXLG9jrkWLNYmghn2jACr+iUtdyiLeWFEmDgtA1lovC4 acBKHxdsvV4NIWXC8U1I2i6Unz/eS+w= X-MC-Unique: vyF6sPQTP7uAeHfe7033xg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: OdXAaZo1PTmHuPp4WzEAFQ-1 From: Stefan Berger To: libvir-list@redhat.com Subject: [PATCH 6/7] qemu: tpm: Remove TPM state files and directory only when undefining a VM Date: Mon, 22 Aug 2022 08:05:53 -0400 Message-Id: <20220822120554.3529999-7-stefanb@linux.ibm.com> In-Reply-To: <20220822120554.3529999-1-stefanb@linux.ibm.com> References: <20220822120554.3529999-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: s8oqrxfu6v2swHi2D-z9cs99QL0hqs5w X-Proofpoint-ORIG-GUID: s8oqrxfu6v2swHi2D-z9cs99QL0hqs5w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-22_06,2022-08-22_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=896 impostorscore=0 clxscore=1011 suspectscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208220051 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: , Cc: Stefan Berger Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1661169986578100003 Content-Type: text/plain; charset="utf-8"; x-default="true" When share storage for the TPM state files has been setup betwen hosts then remove the TPM state files and directory only when undefining a VM and only if the attribute persistent_state is not set. Avoid removing the TPM state files and directory structure when a VM is migrated and shared storage is used since this would also remove those files and directory structure on the destination side. Signed-off-by: Stefan Berger --- src/qemu/qemu_tpm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 20c7e92766..d1639318e7 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -728,10 +728,20 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, */ static void qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm, - qemuDomainUndefineReason undefReason G_GNUC_UNU= SED) + qemuDomainUndefineReason undefReason) { - if (!tpm->data.emulator.persistent_state) + if (tpm->data.emulator.shared_storage) { + /* When using shared storage remove the domain only if this is due= to + * a 'virsh undefine' type of command and only if persistent_state= =3D=3D + * false. Avoid removal of the state files/directory during migrat= ion. + */ + if (undefReason =3D=3D QEMU_DOMAIN_UNDEFINE_DOMAIN && + !tpm->data.emulator.persistent_state) { + qemuTPMEmulatorDeleteStorage(tpm); + } + } else if (!tpm->data.emulator.persistent_state) { qemuTPMEmulatorDeleteStorage(tpm); + } } =20 =20 --=20 2.37.1