From nobody Fri May 17 03:00:39 2024 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660832471; cv=none; d=zohomail.com; s=zohoarc; b=EhwMV/7IGBbNM+zEtoCgrxFKF/3+frMPCc98+Te1Rv73rDyhKZdctrwbYCaCYTulsD7KxEYqulIzqnlvP+om57Ah/MjNHl+l1oRWLSAbaTs/qc1NUyi4G6v3XnK1llp4lgCwFaP6HW3e2Ivff9Z0m+WBxkfOAI9+jwyUC4ALegI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660832471; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1sy+5wNaLrKP99gUY03EAkUWTbqb3MYvytBdJAv2wU8=; b=P2JjLw4a5dl0K2HyM/0J9JX6XOuk8fB5GqkOtBsHYndTKj8BsomYtqaJBszGz3xFFLaIhbASmQ7c5RwFJXv+8Z1hcl7HTT67FS3uNxQv/Ds9z/h/iMtnWGJFuYgIjLmKaOhcTWOXeLCh5RdL+vNfSEVzJZHDdA5sX9UhSgIYzzM= 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=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.129.124]) by mx.zohomail.com with SMTPS id 1660832471334852.7408126481151; Thu, 18 Aug 2022 07:21:11 -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-73-xEmJHq-APvyb3i48WSIUMw-1; Thu, 18 Aug 2022 10:21:06 -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 384CE85A59C; Thu, 18 Aug 2022 14:21:04 +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 9A1401121315; Thu, 18 Aug 2022 14:21:03 +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 5B8001946A42; Thu, 18 Aug 2022 14:21:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D57001946A41 for ; Thu, 18 Aug 2022 14:21:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C1E1C400F36; Thu, 18 Aug 2022 14:21:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE212492C3B for ; Thu, 18 Aug 2022 14:21:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 A47558032F1 for ; Thu, 18 Aug 2022 14:21:02 +0000 (UTC) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-145-6HeZnp9-Obips06iZARGkw-1; Thu, 18 Aug 2022 10:21:01 -0400 Received: by mail-ej1-f71.google.com with SMTP id ne41-20020a1709077ba900b00730cde40757so738404ejc.23 for ; Thu, 18 Aug 2022 07:21:01 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id p2-20020a170906604200b0072b1cb2818csm896230ejj.158.2022.08.18.07.20.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 07:20:59 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 208488F4221C for ; Thu, 18 Aug 2022 16:20:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660832469; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1sy+5wNaLrKP99gUY03EAkUWTbqb3MYvytBdJAv2wU8=; b=CytLmXAq33fp7c8Qj7UCOG/r/H2ZApM4+yt3dv6XDDbsUrLxqX8xQ/jaf0IAd6MSJ/UJEF jwpsaZp0UUIEWwx/LP6rbwg82qIwTIzf6dPPchzQqrijVnXFkme1JDRTTYRT9uRr2rjPcl vAuJsB4p4BkWJZNiP2uxvtW71d30TY8= X-MC-Unique: xEmJHq-APvyb3i48WSIUMw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 6HeZnp9-Obips06iZARGkw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=1sy+5wNaLrKP99gUY03EAkUWTbqb3MYvytBdJAv2wU8=; b=UvafTAM37lMxmkoGjdpCT9NygyBCZz4OeH13r7WJ7wfkvdWh612yhvtggCstxO2T3o gkUsDRbjBnD38fC3FFzBxXjgaAHqG96x/r1J0HGOftaBA0HyHuGiQRwuq7VWmGJnsPZd z+mE6oS5JVlgg7a0hT2emoH0XAOZOibQL8aeey/EkUSP/iEpeKiEE053Lp8BU2m4Fd7d tQ60V8lbUqoYEsP3JdOwOdpFacuEty8ygTu8tQhLJV31osJjiliewKF93/gMi+yMZOJw beFYmMQeHAcnwYcBzVhjIeF+K0Ok4n6zC8eqT8569GxWtCQzOV5n3wWz9cCnf2pOBd1Z 1WUA== X-Gm-Message-State: ACgBeo2CHHvN07cT05cr2Y7K+S305DJ/gvhkm9YQy3qBrwgxBeGFz2pw RYEngoqkq3FZ5If9wrNbXOn1rN3zRyVrTygKvL64Rkcd3ZY8oFkKbUGdo1hDhgJx7U8/nulKqIw 5jfYz+4xq0Ka7edQH23qYp/kQK/+98TUtFtvUyzUkKnZ0maYFTeEuT9JtQ02veKtPyPmrj+c= X-Received: by 2002:a17:907:7fac:b0:732:989b:6bd6 with SMTP id qk44-20020a1709077fac00b00732989b6bd6mr2059553ejc.39.1660832460312; Thu, 18 Aug 2022 07:21:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qRzYayab4d7FFRXJqflxvGsTuEDg41xmOdlb39TW9KFcq9RkqcVN1U05psaM9jszuRsqQCQ== X-Received: by 2002:a17:907:7fac:b0:732:989b:6bd6 with SMTP id qk44-20020a1709077fac00b00732989b6bd6mr2059537ejc.39.1660832460050; Thu, 18 Aug 2022 07:21:00 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH] qemu: Do not keep swtmp pidfile around after stopping Date: Thu, 18 Aug 2022 16:20:56 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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 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: 1660832472320100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Just like the socket, remove the pidfile when TPM emulator is being stopped= . In order to make this a bit cleaner, try to remove it even if swtpm_ioctl does= not exist. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 584c787b700b..50e8c19f3a0b 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -795,28 +795,25 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, g_autofree char *pathname =3D NULL; g_autofree char *errbuf =3D NULL; g_autofree char *swtpm_ioctl =3D virTPMGetSwtpmIoctl(); + g_autofree char *pidfile =3D qemuTPMEmulatorPidFileBuildPath(swtpmStat= eDir, + shortName); + if (swtpm_ioctl && + (pathname =3D qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortN= ame)) && + virFileExists(pathname) && + (cmd =3D virCommandNew(swtpm_ioctl))) { =20 - if (!swtpm_ioctl) - return; - - if (!(pathname =3D qemuTPMEmulatorSocketBuildPath(swtpmStateDir, short= Name))) - return; - - if (!virFileExists(pathname)) - return; - - cmd =3D virCommandNew(swtpm_ioctl); - if (!cmd) - return; + virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL); =20 - virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL); + virCommandSetErrorBuffer(cmd, &errbuf); =20 - virCommandSetErrorBuffer(cmd, &errbuf); + ignore_value(virCommandRun(cmd, NULL)); =20 - ignore_value(virCommandRun(cmd, NULL)); + /* clean up the socket */ + unlink(pathname); + } =20 - /* clean up the socket */ - unlink(pathname); + if (pidfile) + virPidFileDeletePath(pidfile); } =20 =20 --=20 2.37.2