From nobody Sun Feb 8 19:24:22 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=1644000698; cv=none; d=zohomail.com; s=zohoarc; b=V2bdXk0z65fU7ZLZVcz/PlBR+Hpsli3CfVzRgZ8AdABr8xqJL3uWjPv0zsHAlNRlROlEhq536lSob1fyQ87nRxlFSYbyZFBBMUBjSOGwutZ8CTxII7O3aS5mdszDUodNhfIJJCfu+IHx7rNh4dRmiL9GHW9+NdiENYYexbGy4zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000698; 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=tkYq06wl72i88Ym6OdORathWtEEVxIecDGue7g6W+BI=; b=jtkARWe5lR2cTGVivwU2GlbglttPJvJ4jx1VJ3EP1Xfh2DSFJIJg2fF8KPEgvSN59caM39I1HBrXlJwf9dnNhPCAOcNJFifvVtf7hfSeTfbkWqFNcIXCbvcKhl7tz92kHKxbeGqft3BVGkCD0Aj8L3a9iHxQqKItURf1smfRqH0= 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 1644000698572312.9198861350967; Fri, 4 Feb 2022 10:51:38 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-8Vg2if2OOlmZ_B5KyM0ITA-1; Fri, 04 Feb 2022 13:51:36 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 758C2835B4E; Fri, 4 Feb 2022 18:51:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AB9B34D50; Fri, 4 Feb 2022 18:51:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 617074BB7C; Fri, 4 Feb 2022 18:51:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpM2v002111 for ; Fri, 4 Feb 2022 13:51:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id D095870F53; Fri, 4 Feb 2022 18:51:22 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CCD7703B5 for ; Fri, 4 Feb 2022 18:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000697; 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=tkYq06wl72i88Ym6OdORathWtEEVxIecDGue7g6W+BI=; b=JeovYoIKbkltyTeJmZWyXbd+kGsFvv9Czcow7B7ZQBTuUgXm5H4rddF74whIQizlb97rlC YgaxF40cQ5iFaO0tQYKihqooQkTTig2QsNLHEOFYovHcMJpr+1FidPO0vmEs45VtP4Q/eB KpufbG8s56kAutd+7Tg5LhR9qHDZ2xM= X-MC-Unique: 8Vg2if2OOlmZ_B5KyM0ITA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 01/14] qemu: Rename qemuExtTPMStartEmulator() Date: Fri, 4 Feb 2022 19:51:04 +0100 Message-Id: <20220204185117.61149-2-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000699782100001 Content-Type: text/plain; charset="utf-8" Its counterpart is qemuTPMEmulatorStop(). Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 9c5d1ffed4..c82e5921d7 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -875,9 +875,8 @@ qemuExtTPMCleanupHost(virDomainDef *def) } =20 =20 -/* - * qemuExtTPMStartEmulator: - * +/** + * qemuTPMEmulatorStart: * @driver: QEMU driver * @vm: the domain object * @incomingMigration: whether we have an incoming migration @@ -887,10 +886,10 @@ qemuExtTPMCleanupHost(virDomainDef *def) * - start the external TPM Emulator and sync with it before QEMU start */ static int -qemuExtTPMStartEmulator(virQEMUDriver *driver, - virDomainObj *vm, - virDomainTPMDef *tpm, - bool incomingMigration) +qemuTPMEmulatorStart(virQEMUDriver *driver, + virDomainObj *vm, + virDomainTPMDef *tpm, + bool incomingMigration) { g_autoptr(virCommand) cmd =3D NULL; VIR_AUTOCLOSE errfd =3D -1; @@ -994,8 +993,8 @@ qemuExtTPMStart(virQEMUDriver *driver, if (vm->def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - return qemuExtTPMStartEmulator(driver, vm, vm->def->tpms[i], - incomingMigration); + return qemuTPMEmulatorStart(driver, vm, vm->def->tpms[i], + incomingMigration); } =20 return 0; --=20 2.34.1 From nobody Sun Feb 8 19:24:22 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=1644000748; cv=none; d=zohomail.com; s=zohoarc; b=h3F/9v2Ps2v8PAUzjVEev3g7TGG8v0sCUXD50peEuMp6hcy+lB4iyRvB5qp/ng0fsYnBsiDcqNN/8n0Ns2ntcrvUKpShPEQ/dm8voM5tu6MWTFshJV95GsxZ7Xs5hvRP7shTEyo8rT2++moaHGinZH5dWgXhfJYj9ehtXbiBiNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000748; 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=LQN9KZ02yoGCCWd2FxJRPjx38BLCrSKVxVxCapt6Rn8=; b=Q8jUGNmQ4mlx7fYWN0Mqiwlwjb1QS2c5Yo/A42mXW9QujZYAurQgMg4CyioP/0leXbJQQqS2sSW8WGf4onKzHq/25ULlfBVs4mNgWUC9ETMSgahHC9Iem1rdnJqTjOK6Je7RTcE5QcwKeasWSrcpHwStaIUi7JQcUAqc44cozsw= 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 164400074815038.1387177000978; Fri, 4 Feb 2022 10:52:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-CooGzxZGPES0X9TyxvuTjg-1; Fri, 04 Feb 2022 13:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 352601091DA0; Fri, 4 Feb 2022 18:52:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12BA434D50; Fri, 4 Feb 2022 18:52:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D61044A7CB; Fri, 4 Feb 2022 18:52:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpOto002123 for ; Fri, 4 Feb 2022 13:51:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1300A72414; Fri, 4 Feb 2022 18:51:24 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5298C703B5 for ; Fri, 4 Feb 2022 18:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000746; 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=LQN9KZ02yoGCCWd2FxJRPjx38BLCrSKVxVxCapt6Rn8=; b=VB2D+ckTXRud0PQGg6fzCLxw/AKxGkC7aMev6ubeYYa/sGYNQWYTbqFHzVJEwrULO6ZxtN 0XC4GKqrsG8AwCqrhs+yJ1y/O6JnMwCcsvJ0/iVj4zDWt36NbH37w7I5zX8nZ8Y4TR7JCC hLMsKKYLi6Lyh/GWI7al2ytp/pzpjKU= X-MC-Unique: CooGzxZGPES0X9TyxvuTjg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 02/14] qemu: Fully document qemuTPMEmulatorStart() Date: Fri, 4 Feb 2022 19:51:05 +0100 Message-Id: <20220204185117.61149-3-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000749843100001 Content-Type: text/plain; charset="utf-8" The @tpm argument was not mentioned. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index c82e5921d7..627c7e631d 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -879,6 +879,7 @@ qemuExtTPMCleanupHost(virDomainDef *def) * qemuTPMEmulatorStart: * @driver: QEMU driver * @vm: the domain object + * @tpm: TPM definition * @incomingMigration: whether we have an incoming migration * * Start the external TPM Emulator: --=20 2.34.1 From nobody Sun Feb 8 19:24:22 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=1644000724; cv=none; d=zohomail.com; s=zohoarc; b=lxUly5/u4Gvt3cfGCK8bPdqi2CLIp0DMCOdx63id10ZlLlFI/hr8Fo+yVSMcVCnJYjl6KvxEpSaebSHZQcTAD1+PFkGO+42Ne1bQzAPWt4cBhIk6FQRRIEUu0BI+sdNcSJVbkxEsJ4ZmVHvqPweBlu+/on6RNz/nVygtcw9fNKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000724; 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=eAxndR+EeE84h8Af8qGjoeiBpfzn+A6azv4kPf02a3s=; b=Gu5XNm8cVFTVF1pAKrYHWVKbzq5VsKCnDo0dPEQ1NA+Su2ktl/FK6Y5lOisPYPsqHN7CrxTwzQVePukIwBonafzC52LtwVIuCq86Ehodtyf2frNe1w+8duQFbn/gMHE4s88zBQaZwPWiB6z1iiM4yx43HHnp7UuJfO8nX4M8dZo= 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 164400072416961.200262481628556; Fri, 4 Feb 2022 10:52:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-xGMWv2-1NfqDSK9RK0GmiA-1; Fri, 04 Feb 2022 13:51:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FB36869EDB; Fri, 4 Feb 2022 18:51:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6980A34D50; Fri, 4 Feb 2022 18:51:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 450434CA9B; Fri, 4 Feb 2022 18:51:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpPJx002134 for ; Fri, 4 Feb 2022 13:51:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 48920703B5; Fri, 4 Feb 2022 18:51:25 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8956574E87 for ; Fri, 4 Feb 2022 18:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000723; 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=eAxndR+EeE84h8Af8qGjoeiBpfzn+A6azv4kPf02a3s=; b=c+u2lANpn3QD5DtkFKps8FxX75Ge0bIuUGDxMyCctD8VfydNxypdivceROIX0RZ+OuEWtZ NPGom9Xp2dxJdzOwZ9g/yTgEaGUeYlqG2KkLhCC0X83MC1vEedrk9ll2pT/2Iy2ZzsX5FY COvEv/0+2Vc40TERWmN4Rq+/gkY1iE4= X-MC-Unique: xGMWv2-1NfqDSK9RK0GmiA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 03/14] qemu: Rename qemuTPM{Create, Delete}EmulatorStorage() Date: Fri, 4 Feb 2022 19:51:06 +0100 Message-Id: <20220204185117.61149-4-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000724727100001 Content-Type: text/plain; charset="utf-8" Other functions that operate on a single TPM emulator follow the qemuTPMEmulatorDoThing() naming convention. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 627c7e631d..8d66a2127e 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -123,9 +123,8 @@ qemuTPMEmulatorInitStorage(const char *swtpmStorageDir) } =20 =20 -/* - * qemuTPMCreateEmulatorStorage - * +/** + * qemuTPMEmulatorCreateStorage: * @storagepath: directory for swtpm's persistent state * @created: a pointer to a bool that will be set to true if the * storage was created because it did not exist yet @@ -137,7 +136,7 @@ qemuTPMEmulatorInitStorage(const char *swtpmStorageDir) * Adapt ownership of the directory and all swtpm's state files there. */ static int -qemuTPMCreateEmulatorStorage(const char *storagepath, +qemuTPMEmulatorCreateStorage(const char *storagepath, bool *created, uid_t swtpm_user, gid_t swtpm_group) @@ -168,7 +167,7 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, =20 =20 static void -qemuTPMDeleteEmulatorStorage(virDomainTPMDef *tpm) +qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) { g_autofree char *path =3D g_path_get_dirname(tpm->data.emulator.stora= gepath); =20 @@ -686,7 +685,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, if (!swtpm) return NULL; =20 - if (qemuTPMCreateEmulatorStorage(tpm->data.emulator.storagepath, + if (qemuTPMEmulatorCreateStorage(tpm->data.emulator.storagepath, &created, swtpm_user, swtpm_group) < = 0) return NULL; =20 @@ -765,7 +764,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, =20 error: if (created) - qemuTPMDeleteEmulatorStorage(tpm); + qemuTPMEmulatorDeleteStorage(tpm); =20 return NULL; } @@ -870,7 +869,7 @@ qemuExtTPMCleanupHost(virDomainDef *def) continue; =20 if (!def->tpms[i]->data.emulator.persistent_state) - qemuTPMDeleteEmulatorStorage(def->tpms[i]); + qemuTPMEmulatorDeleteStorage(def->tpms[i]); } } =20 --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000749; cv=none; d=zohomail.com; s=zohoarc; b=JTEoXwwTXAqTejk40Csy5WAHlUtr6PSzRoFuehhdSjMpPaNU3nR04C8GFvnW3tTr0wzI15Mg7FzaY+/iujU4en8y0Xc/0LAoj4GJOT9X1n1QkdEUQiEYx40jfWEVN6bCupqsoRs2XMO4vV6g2TyGG5+UKA87LXJJoyD3lxL9GEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000749; 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=2M6XHCZhJg/aSEw9GpgqU5su8GrBXrWKEAtWEs6K5tY=; b=BNHFsZMXzSUeBF96ks2oYiojS9RkCm+QQdDWVUh7HqnYeT1iAmu3EfBNE1nsOgZmK3BvljPjBipK3P0lJJIicGOD6Xbrj0jedJVHS37CLtkNDPmnhPVNZc+Wps1/FmNTIeZAnuFINiASAk5yUTFpV6xxkozX//v3tD/msNYIbKw= 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 1644000749190900.1769750518238; Fri, 4 Feb 2022 10:52:29 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-241-jTQOuOevPT6JAYAHjFM7CQ-1; Fri, 04 Feb 2022 13:52:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6E941091DA4; Fri, 4 Feb 2022 18:52:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7EC47243E; Fri, 4 Feb 2022 18:52:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 78E361809CB8; Fri, 4 Feb 2022 18:52:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpQ1q002150 for ; Fri, 4 Feb 2022 13:51:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C1DC70F53; Fri, 4 Feb 2022 18:51:26 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE39E703B5 for ; Fri, 4 Feb 2022 18:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000748; 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=2M6XHCZhJg/aSEw9GpgqU5su8GrBXrWKEAtWEs6K5tY=; b=Ry7/r1GhyEcn2l1ebN06EL6QI3+x0AcvS0Lt9WMzdaymlV6WaXns1ArAoMVJoaiajjpxAI A5CyN5qjuVkLu8LxxWIH5SAAx6z8nDddz1iC2PIscEb6l0aFXyPazY9xQc0qWqB/Fn7axX mZukADneAbSaN/rLGNYD0FTHpER/4U0= X-MC-Unique: jTQOuOevPT6JAYAHjFM7CQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 04/14] qemu: Document qemuTPMEmulatorDeleteStorage() Date: Fri, 4 Feb 2022 19:51:07 +0100 Message-Id: <20220204185117.61149-5-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1644000751710100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 8d66a2127e..182209bda6 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -166,6 +166,12 @@ qemuTPMEmulatorCreateStorage(const char *storagepath, } =20 =20 +/** + * qemuTPMEmulatorDeleteStorage: + * @tpm: TPM definition + * + * Delete all persistent storage associated with the swtpm. + */ static void qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) { --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000730; cv=none; d=zohomail.com; s=zohoarc; b=cji1/5qaW4dNIUYq26dlsEStMGnD+F124TLDx7r5jEStEa1XyfBiLs2XXF63qDto5Sp2qn2Ae6w7nQ93ryv8U+lsEQR7L9VXbLIQbZ4vJpMxHxn4QWZ6QlfKzL8unOrX7TPZzIyzuR/f7R0zHM+vanyJf9+YAc7ZFMlQSK6QZ+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000730; 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=yKiSNkR1R9dUyH9sLFb6gjpJ7ZTnuVZMdTOiJZyutl8=; b=bSMLOTbEpN5kkFzQSda3iOQLG25i21VDIpnRAnzDHQ/QNcuDtNKNu7gsh0dfGJXPQy/KzDzI7PV8ofBeblauyigNUCVbbNpEmmNr46eriCzYSLOSKFuAh7qoDN9hAVmEPH+LnQ2dDQLEZwezJUJdmG/P2y04t9b9bC8QCTzNYnQ= 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 1644000730069700.2458713536121; Fri, 4 Feb 2022 10:52:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-plmUH9k3Nia6kOFVDzq_pw-1; Fri, 04 Feb 2022 13:52:06 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5DA9B1018724; Fri, 4 Feb 2022 18:52:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39BEF838D8; Fri, 4 Feb 2022 18:52:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 04F501809CB8; Fri, 4 Feb 2022 18:52:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpR2T002158 for ; Fri, 4 Feb 2022 13:51:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id B1DE8703B5; Fri, 4 Feb 2022 18:51:27 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F19BA72416 for ; Fri, 4 Feb 2022 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000729; 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=yKiSNkR1R9dUyH9sLFb6gjpJ7ZTnuVZMdTOiJZyutl8=; b=OTJE9/2Bs2EEJRUpys42uzQ36k7j/F6H32T9X17gxW68EqV9CYOZAkgo+UGf1pNpJB6w2e Og2lAksoAj5hPeQDIm5kpbkKUnxRnaR2FaYadSqLmyomTqm1O62y/bZHH6Ei5Vw+XwoXF8 6yRP5iI4AXHStDaDwX2/8cS7TK9jS2Y= X-MC-Unique: plmUH9k3Nia6kOFVDzq_pw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 05/14] qemu: Drop qemuTPMEmulatorInitStorage() Date: Fri, 4 Feb 2022 19:51:08 +0100 Message-Id: <20220204185117.61149-6-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644000731689100001 Content-Type: text/plain; charset="utf-8" Absorb it into qemuTPMEmulatorCreateStorage(), its only caller. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 182209bda6..127a2c80be 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -99,30 +99,6 @@ qemuTPMCreateEmulatorLogPath(const char *logDir, } =20 =20 -/* - * qemuTPMEmulatorInitStorage - * - * Initialize the TPM Emulator storage by creating its root directory, - * which is typically found in /var/lib/libvirt/tpm. - * - */ -static int -qemuTPMEmulatorInitStorage(const char *swtpmStorageDir) -{ - int rc =3D 0; - - /* allow others to cd into this dir */ - if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) { - virReportSystemError(errno, - _("Could not create TPM directory %s"), - swtpmStorageDir); - rc =3D -1; - } - - return rc; -} - - /** * qemuTPMEmulatorCreateStorage: * @storagepath: directory for swtpm's persistent state @@ -143,8 +119,13 @@ qemuTPMEmulatorCreateStorage(const char *storagepath, { g_autofree char *swtpmStorageDir =3D g_path_get_dirname(storagepath); =20 - if (qemuTPMEmulatorInitStorage(swtpmStorageDir) < 0) + /* allow others to cd into this dir */ + if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) { + virReportSystemError(errno, + _("Could not create TPM directory %s"), + swtpmStorageDir); return -1; + } =20 *created =3D false; =20 --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000786; cv=none; d=zohomail.com; s=zohoarc; b=aZLjo07CqhZlv5NYjkel2cXELbJ2RbOUeU2cpPAWFJWPIUTfb6vnXl364yoJls8rWAHgjQ/TyIR5p3mI1ZoU+TC1AB5qryvD17PrgXrwgtySxL8/65MoPyozggIm3m4fyPIzYzWtJBffyJAtHrGB5QRdk9ByUpBD+Yzcgt4lero= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000786; 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=j1B4UXpUD//ftr2Hre1tsEQXA/y9X9w8K8VuSC96AD4=; b=aJt/pZT6PCB0EafDGGL8wzj6zyAv2859Ajx/iNMdH1Hb0ApBKyLbtMH80rJeXiyMTCAuiTkU8OHyBxprd51+WH+y73xviAulJGHC16RSysf0WD13tbaWp/NZRnQbKa9f9YQHLdxjrgcBIoiJOpukSet2qLejfBmWwJ6nZ/ls4dU= 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 1644000786339682.1577493844205; Fri, 4 Feb 2022 10:53:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-j2IEnJtnMk69GU6b9qe3Yg-1; Fri, 04 Feb 2022 13:53:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFCC434835; Fri, 4 Feb 2022 18:52:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C5C2838D6; Fri, 4 Feb 2022 18:52:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 702EE1809CB9; Fri, 4 Feb 2022 18:52:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpSv4002176 for ; Fri, 4 Feb 2022 13:51:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id E0840703B5; Fri, 4 Feb 2022 18:51:28 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30A1372416 for ; Fri, 4 Feb 2022 18:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000785; 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=j1B4UXpUD//ftr2Hre1tsEQXA/y9X9w8K8VuSC96AD4=; b=WA++3dSBOHtaZ+XhsKCzpwRnNHVWZyIq/sqWZ5YtV02QR8L8moCL08ut2VzquK/Z2CpMdY J9IcBNkE9uZ7t4P2c0LfFnJ2EOqtNk+HWfeQyNB/eUJD+M7XMoRveO6R6LKHc4KCdMQ/Xm mOPbEwuTx4HnZDOagc4k9GvlCJZAfw8= X-MC-Unique: j2IEnJtnMk69GU6b9qe3Yg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 06/14] qemu: Make qemuTPMEmulatorCreateStorage() take a virDomainTPMDef* Date: Fri, 4 Feb 2022 19:51:09 +0100 Message-Id: <20220204185117.61149-7-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644001688200100001 Content-Type: text/plain; charset="utf-8" This matches how qemuTPMEmulatorDeleteStorage() expects to be called. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 127a2c80be..2196b5c567 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -101,7 +101,7 @@ qemuTPMCreateEmulatorLogPath(const char *logDir, =20 /** * qemuTPMEmulatorCreateStorage: - * @storagepath: directory for swtpm's persistent state + * @tpm: TPM definition for an emulator type * @created: a pointer to a bool that will be set to true if the * storage was created because it did not exist yet * @swtpm_user: The uid that needs to be able to access the directory @@ -112,11 +112,12 @@ qemuTPMCreateEmulatorLogPath(const char *logDir, * Adapt ownership of the directory and all swtpm's state files there. */ static int -qemuTPMEmulatorCreateStorage(const char *storagepath, +qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm, bool *created, uid_t swtpm_user, gid_t swtpm_group) { + const char *storagepath =3D tpm->data.emulator.storagepath; g_autofree char *swtpmStorageDir =3D g_path_get_dirname(storagepath); =20 /* allow others to cd into this dir */ @@ -672,8 +673,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, if (!swtpm) return NULL; =20 - if (qemuTPMEmulatorCreateStorage(tpm->data.emulator.storagepath, - &created, swtpm_user, swtpm_group) < = 0) + if (qemuTPMEmulatorCreateStorage(tpm, &created, swtpm_user, swtpm_grou= p) < 0) return NULL; =20 if (tpm->data.emulator.hassecretuuid) --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000756; cv=none; d=zohomail.com; s=zohoarc; b=eobjyKn7Of5kJW595Q7Ojdvab3jz5oGJmN/JpQ1jgzmT1hQgDCbYxULZH/QnNSw6j/mg2Zj3GESPkoItX5ciOWAXsdFT4hsEYjhbbRrnMk2Fju909llRz69MZnNTNnDJYvugTNOIE6Un9nFizXtDIY1xcdlmJIScwfTMK/6h5/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000756; 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=4wGDinYyyh2heKJFOoXKQ11IwmQrkglIrSUPSck8XwQ=; b=eZrmABk8R+J/zD6HL7LNH4S2itOQ0T5YTo8c3UGSfFPqHZuKIT7a7MeaoU2LtEfj3csdm9z2YPeoANGMDCRq2IQF4hBvlQsvcYSNoOFhcRNOu1VxD3HSN2uXa6t7cIduXZ+6DVlvN7EQbHmi/0ZDDOGr1wU1Vy7ZZi82usSrRwY= 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 1644000756001285.84265692263614; Fri, 4 Feb 2022 10:52:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-Br-KZLqBMW2Kjz_i8pMf1A-1; Fri, 04 Feb 2022 13:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A5C5344B8; Fri, 4 Feb 2022 18:52:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EB58838E3; Fri, 4 Feb 2022 18:52:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E14051809CBA; Fri, 4 Feb 2022 18:52:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpUE3002190 for ; Fri, 4 Feb 2022 13:51:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 224B0703B5; Fri, 4 Feb 2022 18:51:30 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61E9772416 for ; Fri, 4 Feb 2022 18:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000754; 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=4wGDinYyyh2heKJFOoXKQ11IwmQrkglIrSUPSck8XwQ=; b=JHikaRt9PwwTT/+y3O1o97ffyNYKMcWPTbOU80V8zWtoy423d1Vf0VsIiznUk1Ojuolcjm dOFr8VOvTPFt+Dy/hgu2xw2TpO6ADyW5nji8mwhzRorbeMB68mgl61yps4tjBK0Tuy1wYq nsrIYug+RDu+WsSdxzZLOKs8mK+03s4= X-MC-Unique: Br-KZLqBMW2Kjz_i8pMf1A-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 07/14] qemu: Introduce qemuExtTPMEmulatorSetupCgroup() Date: Fri, 4 Feb 2022 19:51:10 +0100 Message-Id: <20220204185117.61149-8-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644000756949100003 Content-Type: text/plain; charset="utf-8" This leaves qemuExtTPMSetupCgroup() to only deal with looping over TPM devices, same as other qemuExtTPMDoThing() functions. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 2196b5c567..2a2e585080 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -797,6 +797,36 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, } =20 =20 +/** + * qemuExtTPMEmulatorSetupCgroup: + * @swtpmStateDir: directory for swtpm's persistent state + * @shortName: short and unique name of the domain + * @cgroup: cgroup to add the swtpm process to + * + * Add the swtpm process to the appropriate cgroup. + */ +static int +qemuExtTPMEmulatorSetupCgroup(const char *swtpmStateDir, + const char *shortName, + virCgroup *cgroup) +{ + int rc; + pid_t pid; + + rc =3D qemuTPMEmulatorGetPid(swtpmStateDir, shortName, &pid); + if (rc < 0 || (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get process id of swtpm")); + return -1; + } + + if (virCgroupAddProcess(cgroup, pid) < 0) + return -1; + + return 0; +} + + int qemuExtTPMInitPaths(virQEMUDriver *driver, virDomainDef *def) @@ -1019,8 +1049,6 @@ qemuExtTPMSetupCgroup(virQEMUDriver *driver, virCgroup *cgroup) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int rc; - pid_t pid; size_t i; =20 for (i =3D 0; i < def->ntpms; i++) { @@ -1032,13 +1060,8 @@ qemuExtTPMSetupCgroup(virQEMUDriver *driver, shortName =3D virDomainDefGetShortName(def); if (!shortName) return -1; - rc =3D qemuTPMEmulatorGetPid(cfg->swtpmStateDir, shortName, &pid); - if (rc < 0 || (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not get process id of swtpm")); - return -1; - } - if (virCgroupAddProcess(cgroup, pid) < 0) + + if (qemuExtTPMEmulatorSetupCgroup(cfg->swtpmStateDir, shortName, c= group) < 0) return -1; } =20 --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000754; cv=none; d=zohomail.com; s=zohoarc; b=e7N/qXguDSiGtco5c3AvY8AMYzQ1WmJRDOIkCKeZ0ViSs7b3h2EjHX0loqzC5Cv+vebXMOLrp5WXVqe4lkWkQNu7H8pVlTdX2hC8FvrTKaoSFmCpFkQ0gL51ByOhYouTAm/xs+eNsYnlQ6Cc79lqh3kCVNKhobHOiSMn/UjciZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000754; 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=vPwafqRJDCpsa0/l3woyWMYdKkbVGgrY4L2HiWiztZ4=; b=FiZA15zdLEyu9GUr1UFPAYzBU3KscysAQlhb0IImasAtle4qK7PFUkJCyOfOr2CkJ6wfM4VwddN9PuxKRrnbbrMXlRthfHu0gDL1gmeYTvy/eQgd7n8QZpno9do0vspRk3U278ar2+jSsdlfPLD9JpIaVktD04KQk5Mewo9eKec= 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 1644000754579821.2597481708609; Fri, 4 Feb 2022 10:52:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-qlGFP9BkNRyqffRJ8TY1Jw-1; Fri, 04 Feb 2022 13:52:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 330271018736; Fri, 4 Feb 2022 18:52:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 149E8703B5; Fri, 4 Feb 2022 18:52:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AA7124A7CD; Fri, 4 Feb 2022 18:52:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpVFV002212 for ; Fri, 4 Feb 2022 13:51:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 566A5703B5; Fri, 4 Feb 2022 18:51:31 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97C5074E88 for ; Fri, 4 Feb 2022 18:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000754; 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=vPwafqRJDCpsa0/l3woyWMYdKkbVGgrY4L2HiWiztZ4=; b=cRCoHZOHYXof61EStsliOm+ZFChjpIKhp4sV1w1ywgxZzggf+mZzDyAXbZL6gg9Z3Wzgnr SIAH5kyHIEi2TkMW61tXTYtVNjx3G8thZJRmn+mFml2wiMvZB6y2pvGeJa79ywtR8m3kh4 /InIr5skkPUnuAlVZJVDuuCtA86yXwU= X-MC-Unique: qlGFP9BkNRyqffRJ8TY1Jw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 08/14] qemu: Introduce qemuTPMEmulatorCleanupHost() Date: Fri, 4 Feb 2022 19:51:11 +0100 Message-Id: <20220204185117.61149-9-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1644000756743100001 Content-Type: text/plain; charset="utf-8" This leaves qemuExtTPMCleanupHost() to only deal with looping over TPM devices, same as other qemuExtTPMDoThing() functions. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 2a2e585080..754897bf93 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -259,6 +259,20 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, } =20 =20 +/** + * qemuTPMEmulatorCleanupHost: + * @tpm: TPM definition + * + * Clean up persistent storage for the swtpm. + */ +static void +qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm) +{ + if (!tpm->data.emulator.persistent_state) + qemuTPMEmulatorDeleteStorage(tpm); +} + + /* * qemuTPMEmulatorPrepareHost: * @@ -885,8 +899,7 @@ qemuExtTPMCleanupHost(virDomainDef *def) if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - if (!def->tpms[i]->data.emulator.persistent_state) - qemuTPMEmulatorDeleteStorage(def->tpms[i]); + qemuTPMEmulatorCleanupHost(def->tpms[i]); } } =20 --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000785; cv=none; d=zohomail.com; s=zohoarc; b=ioz8dbxXAbJW3Thexx5sNfpFNkbsaF135b5kfnmaVj50iElZ+/WxpFJx5TPT/sadACyXeUXj2Hq2BrCI7Fx00mesvRtk/UadCoOqa94GiB6B/OsSOKuwUJl5hG0TB9nZoU4c5OBtn7Ts9JLWeE4zNp1DZIAinmOUKhufOyPgrAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000785; 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=GuPK4LiGdv1yhbhF7zyaPenc0MN9Vdf9/0ioqqAbZoE=; b=BGszFrI0f+rpUKmML+oNhNAQPKwp8H619aQCFaikwNKtgQ99a0w4RVy5bTGxhuhKqezfXo1Dvzf7AY7hQGhGGyIi2yJ7XAmUOPmG0Pkdr3gDhcHXvNb5Sdbtp+2Cnkct9GxY0ftCrqyJI653oYUAWdjk9ZyOXk5piz8jJoTZYas= 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 1644000785810781.6790264437641; Fri, 4 Feb 2022 10:53:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-j7fXVfXKMPmSYoGwiutqjw-1; Fri, 04 Feb 2022 13:52:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CD5F1018744; Fri, 4 Feb 2022 18:52:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07BDD34D4F; Fri, 4 Feb 2022 18:52:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CBF9F4CA9B; Fri, 4 Feb 2022 18:52:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpWuH002220 for ; Fri, 4 Feb 2022 13:51:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E4E372414; Fri, 4 Feb 2022 18:51:32 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDD43703B5 for ; Fri, 4 Feb 2022 18:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000784; 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=GuPK4LiGdv1yhbhF7zyaPenc0MN9Vdf9/0ioqqAbZoE=; b=dTyOeBUatTts11GOk5KtjBxI5f/Xv4QkqQ4HUEMSpdSlBggCC6XPiK5/HErNHmyOtLoZKk s8PRTokkBdXSs7lC2CQRi1PRKW4bWA/j11ZqUrpVP8/Np7+KgX4xfUdgHLxL3WzBMwCS1w BN8IvRrRGiSP1NRspCCbZcSJDYeDfxA= X-MC-Unique: j7fXVfXKMPmSYoGwiutqjw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 09/14] qemu: Rename path-building functions Date: Fri, 4 Feb 2022 19:51:12 +0100 Message-Id: <20220204185117.61149-10-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000787268100002 Content-Type: text/plain; charset="utf-8" Using the word "create" can give users the impression that disk operations will be performed, when in reality all these functions do is string formatting. Follow the naming convention established by virBuildPath(), virFileBuildPath() and virPidFileBuildPath(). Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 69 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 754897bf93..d78acf8215 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -50,19 +50,18 @@ =20 VIR_LOG_INIT("qemu.tpm"); =20 -/* - * qemuTPMCreateEmulatorStoragePath - * +/** + * qemuTPMEmulatorStorageBuildPath: * @swtpmStorageDir: directory for swtpm persistent state - * @uuid: The UUID of the VM for which to create the storage + * @uuidstr: UUID of the VM * @tpmversion: version of the TPM * - * Create the swtpm's storage path + * Generate the swtpm's storage path. */ static char * -qemuTPMCreateEmulatorStoragePath(const char *swtpmStorageDir, - const char *uuidstr, - virDomainTPMVersion tpmversion) +qemuTPMEmulatorStorageBuildPath(const char *swtpmStorageDir, + const char *uuidstr, + virDomainTPMVersion tpmversion) { char *path =3D NULL; const char *dir =3D ""; @@ -85,15 +84,15 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStora= geDir, =20 =20 /** - * qemuTPMCreateEmulatorLogPath: - * @logDir: directory where swtpm writes its logs into + * qemuTPMEmulatorLogBuildPath: + * @logDir: directory for swtpm log files * @vmname: name of the VM * - * Create the swtpm's log path. + * Generate the swtpm's log path. */ static char* -qemuTPMCreateEmulatorLogPath(const char *logDir, - const char *vmname) +qemuTPMEmulatorLogBuildPath(const char *logDir, + const char *vmname) { return g_strdup_printf("%s/%s-swtpm.log", logDir, vmname); } @@ -163,17 +162,16 @@ qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) } =20 =20 -/* - * qemuTPMCreateEmulatorSocket: - * - * @swtpmStateDir: the directory where to create the socket in +/** + * qemuTPMEmulatorSocketBuildPath: + * @swtpmStateDir: directory for swtpm runtime state * @shortName: short and unique name of the domain * - * Create the Unix socket path from the given parameters + * Generate the swtpm's Unix socket path. */ static char * -qemuTPMCreateEmulatorSocket(const char *swtpmStateDir, - const char *shortName) +qemuTPMEmulatorSocketBuildPath(const char *swtpmStateDir, + const char *shortName) { return g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName); } @@ -202,25 +200,29 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, =20 if (!tpm->data.emulator.storagepath && !(tpm->data.emulator.storagepath =3D - qemuTPMCreateEmulatorStoragePath(swtpmStorageDir, uuidstr, - tpm->version))) + qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr, + tpm->version))) return -1; =20 if (!tpm->data.emulator.logfile) { - tpm->data.emulator.logfile =3D qemuTPMCreateEmulatorLogPath(logDir, - vmname); + tpm->data.emulator.logfile =3D qemuTPMEmulatorLogBuildPath(logDir, + vmname); } =20 return 0; } =20 =20 -/* - * qemuTPMCreatePidFilename +/** + * qemuTPMEmulatorPidFileBuildPath: + * @swtpmStateDir: directory for swtpm runtime state + * @shortName: short and unique name of the domain + * + * Generate the swtpm's pidfile path. */ static char * -qemuTPMEmulatorCreatePidFilename(const char *swtpmStateDir, - const char *shortName) +qemuTPMEmulatorPidFileBuildPath(const char *swtpmStateDir, + const char *shortName) { g_autofree char *devicename =3D NULL; =20 @@ -246,9 +248,8 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, const char *shortName, pid_t *pid) { - g_autofree char *pidfile =3D qemuTPMEmulatorCreatePidFilename(swtpmSta= teDir, - shortName); - + g_autofree char *pidfile =3D qemuTPMEmulatorPidFileBuildPath(swtpmStat= eDir, + shortName); if (!pidfile) return -1; =20 @@ -333,7 +334,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDef *tpm, /* create the socket filename */ if (!tpm->data.emulator.source->data.nix.path && !(tpm->data.emulator.source->data.nix.path =3D - qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName))) + qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName))) return -1; tpm->data.emulator.source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; =20 @@ -790,7 +791,7 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, if (!swtpm_ioctl) return; =20 - if (!(pathname =3D qemuTPMCreateEmulatorSocket(swtpmStateDir, shortNam= e))) + if (!(pathname =3D qemuTPMEmulatorSocketBuildPath(swtpmStateDir, short= Name))) return; =20 if (!virFileExists(pathname)) @@ -949,7 +950,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0) return -1; =20 - if (!(pidfile =3D qemuTPMEmulatorCreatePidFilename(cfg->swtpmStateDir,= shortName))) + if (!(pidfile =3D qemuTPMEmulatorPidFileBuildPath(cfg->swtpmStateDir, = shortName))) return -1; =20 virCommandDaemonize(cmd); --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000793; cv=none; d=zohomail.com; s=zohoarc; b=kpY9ExxjVHbp7NJS+viMGLEMVIMx0Z86cz7IN9MpoL7ZmZsx46wzx9GBzeylZQq8NmhYdP5/xl4ua34ZmCbKJ8XCBr1+4H+SJbI8I2xo6M2UjFjpv8/srA6ac1ECXb6w1J2KcFaqWWwH/ERT6HTLuu6fBEdpxeLVBksUVz5xViY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000793; 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=poR0fTBJ8hvkaHV23y1rh2EjBAfSjmt6Z83CUg07pwI=; b=PTFT+K/iU52j6QmrK5U6Qb0iUXPP6oAT6FV2tDGPFB9V5DF3cdfGH7rpHkdC3L4Z3D8QIqZNYRCJsDdToDu2zGTIT7yZz3PXYAujWNtSnIPJ3YpIzXpI8l9WNE8bXixy6gtyZCZev27chWhdi0Q1I7QYypg49bFLjQZDGVv5kLQ= 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 1644000793848330.4794843922691; Fri, 4 Feb 2022 10:53:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-2_VdSrixM6uNDZ8W1lTgHQ-1; Fri, 04 Feb 2022 13:53:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1589383DD20; Fri, 4 Feb 2022 18:53:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 904B01F471; Fri, 4 Feb 2022 18:53:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5B18A4A700; Fri, 4 Feb 2022 18:53:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpXSn002242 for ; Fri, 4 Feb 2022 13:51:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6EB4703B5; Fri, 4 Feb 2022 18:51:33 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 113A772416 for ; Fri, 4 Feb 2022 18:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000793; 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=poR0fTBJ8hvkaHV23y1rh2EjBAfSjmt6Z83CUg07pwI=; b=ieztyrDJGzksyweogFWPIOnyWWtjQBfJ7H/I1AXCT8/6c6C6PVHXonc4ZCdoCNL4P/B3Qi CinudYeX4nPtv2+A0l0TuJVrouxmY/Ficx6mr5pzhZHBZluJvfRan9ZhBEE0DVAbRDSjft mqV1mcYWncxsCRlr4KSdhZkD4i+y7lg= X-MC-Unique: 2_VdSrixM6uNDZ8W1lTgHQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 10/14] qemu: Call virDomainDefGetShortName() less frequently Date: Fri, 4 Feb 2022 19:51:13 +0100 Message-Id: <20220204185117.61149-11-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000812589100001 Content-Type: text/plain; charset="utf-8" When looping over TPM devices for a domain, we can avoid calling this function for each iteration and call it once per domain instead. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index d78acf8215..b38aa5e7ce 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -869,17 +869,16 @@ qemuExtTPMPrepareHost(virQEMUDriver *driver, virDomainDef *def) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - g_autofree char *shortName =3D NULL; + g_autofree char *shortName =3D virDomainDefGetShortName(def); size_t i; =20 + if (!shortName) + return -1; + for (i =3D 0; i < def->ntpms; i++) { if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - shortName =3D virDomainDefGetShortName(def); - if (!shortName) - return -1; - return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir, cfg->swtpm_user, cfg->swtpm_group, @@ -910,6 +909,7 @@ qemuExtTPMCleanupHost(virDomainDef *def) * @driver: QEMU driver * @vm: the domain object * @tpm: TPM definition + * @shortName: short and unique name of the domain * @incomingMigration: whether we have an incoming migration * * Start the external TPM Emulator: @@ -919,22 +919,19 @@ qemuExtTPMCleanupHost(virDomainDef *def) static int qemuTPMEmulatorStart(virQEMUDriver *driver, virDomainObj *vm, + const char *shortName, virDomainTPMDef *tpm, bool incomingMigration) { g_autoptr(virCommand) cmd =3D NULL; VIR_AUTOCLOSE errfd =3D -1; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autofree char *shortName =3D virDomainDefGetShortName(vm->def); g_autofree char *pidfile =3D NULL; virTimeBackOffVar timebackoff; const unsigned long long timeout =3D 1000; /* ms */ int cmdret =3D 0; pid_t pid =3D -1; =20 - if (!shortName) - return -1; - cfg =3D virQEMUDriverGetConfig(driver); =20 /* stop any left-over TPM emulator for this VM */ @@ -1018,13 +1015,17 @@ qemuExtTPMStart(virQEMUDriver *driver, virDomainObj *vm, bool incomingMigration) { + g_autofree char *shortName =3D virDomainDefGetShortName(vm->def); size_t i; =20 + if (!shortName) + return -1; + for (i =3D 0; i < vm->def->ntpms; i++) { if (vm->def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - return qemuTPMEmulatorStart(driver, vm, vm->def->tpms[i], + return qemuTPMEmulatorStart(driver, vm, shortName, vm->def->tpms[i= ], incomingMigration); } =20 @@ -1037,18 +1038,16 @@ qemuExtTPMStop(virQEMUDriver *driver, virDomainObj *vm) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autofree char *shortName =3D virDomainDefGetShortName(vm->def); size_t i; =20 - for (i =3D 0; i < vm->def->ntpms; i++) { - g_autofree char *shortName =3D NULL; + if (!shortName) + return; =20 + for (i =3D 0; i < vm->def->ntpms; i++) { if (vm->def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - shortName =3D virDomainDefGetShortName(vm->def); - if (!shortName) - return; - qemuTPMEmulatorStop(cfg->swtpmStateDir, shortName); qemuSecurityCleanupTPMEmulator(driver, vm); } @@ -1063,18 +1062,16 @@ qemuExtTPMSetupCgroup(virQEMUDriver *driver, virCgroup *cgroup) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autofree char *shortName =3D virDomainDefGetShortName(def); size_t i; =20 - for (i =3D 0; i < def->ntpms; i++) { - g_autofree char *shortName =3D NULL; + if (!shortName) + return -1; =20 + for (i =3D 0; i < def->ntpms; i++) { if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - shortName =3D virDomainDefGetShortName(def); - if (!shortName) - return -1; - if (qemuExtTPMEmulatorSetupCgroup(cfg->swtpmStateDir, shortName, c= group) < 0) return -1; } --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000733; cv=none; d=zohomail.com; s=zohoarc; b=aqubG/rxNhUxrm6wmRljHdHyCSWtWdIbChnvND0yrOBKcVq8zxGUVlQEg/sZrSdGlw1WejbkeP/qDjnKaAnEwt+ScsVRCopbhpssrAe4sBleG7aD7gnNqxUOVcJUahh/dCf4msHIkT7V6Nb+bF6yqMGa3gUCfEIrFyWerYGhoC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000733; 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=2jnG3hWKxyYB/nFFybmvWsZGD+i7CoHwQzNM393R0/M=; b=fuJLYgJrc/HVvJJnjOfhRF8netCuf/Vg1J4JwHjUqPxiICr9fG1vuUfXqeizQxyxuarBASWtOjcmMsVuMWjYRxoE/SM9lOOaoHqPDMMN69wKNHKo1duj3h9sdFegKG3KK7xngFWmzFUgphrNGtjlLv8KKVoS/xtVj/mXSVcl610= 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 1644000733203178.43571555619758; Fri, 4 Feb 2022 10:52:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-kUrEPiH_MpWHt1gT7GKkbQ-1; Fri, 04 Feb 2022 13:52:11 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D04FE86A095; Fri, 4 Feb 2022 18:52:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF42D10589A5; Fri, 4 Feb 2022 18:52:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7618D4A7CA; Fri, 4 Feb 2022 18:52:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpZqh002252 for ; Fri, 4 Feb 2022 13:51:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05AE6703B5; Fri, 4 Feb 2022 18:51:35 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 471257243E for ; Fri, 4 Feb 2022 18:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000732; 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=2jnG3hWKxyYB/nFFybmvWsZGD+i7CoHwQzNM393R0/M=; b=fy/RbLPQFZAEMfLGLkl0fPJDVWHUX1sTAwsDbH5NHrUT3HLNsxjCwl5nN0ypmMNggzgIIf hULaYyMbDE76+TLMwVSdQNt1LHfvtRk3GYUiX1grUbZl/QjWSx1hqnXJb7TezH30JDG/kR g2O7yIwZK6COD5ArbELo+oBOJB2Joi8= X-MC-Unique: kUrEPiH_MpWHt1gT7GKkbQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 11/14] qemu: Fix description of swtpmStateDir Date: Fri, 4 Feb 2022 19:51:14 +0100 Message-Id: <20220204185117.61149-12-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1644000751598100003 Content-Type: text/plain; charset="utf-8" This directory contains runtime state, not persistent state. The latter goes into swtpmStorageDir. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index b38aa5e7ce..c0e875627d 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -281,7 +281,7 @@ qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm) * @logDir: directory where swtpm writes its logs into * @swtpm_user: uid to run the swtpm with * @swtpm_group: gid to run the swtpm with - * @swtpmStateDir: directory for swtpm's persistent state + * @swtpmStateDir: directory for swtpm runtime state * @qemu_user: uid that qemu will run with; we share the socket file with = it * @shortName: short and unique name of the domain * @@ -814,7 +814,7 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, =20 /** * qemuExtTPMEmulatorSetupCgroup: - * @swtpmStateDir: directory for swtpm's persistent state + * @swtpmStateDir: directory for swtpm runtime state * @shortName: short and unique name of the domain * @cgroup: cgroup to add the swtpm process to * --=20 2.34.1 From nobody Sun Feb 8 19:24:22 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=1644000738; cv=none; d=zohomail.com; s=zohoarc; b=Mx7JJYr7DwH4JTa+lsKQwxdrBnsiIy1LHFBmlSTwLjQ6kl/xmV3DUH2KpR4gR9olHarMl/KR0K9OsdZjRxAwlw/eJCWFWsVlCGrsZVI5E+yBRZ0xV/s8kOEX25p7kHK/MfkRt/0nLQiS8dAYuSVjZ0piYWcpsYBz/n8zc3nFUL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000738; 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=KR6cwXVAB49lPrLz9O4+K1NI6tSCLNLkRMfNOtHL920=; b=VeM6HSKIkGk8YoJ1WhSagUFwbVdgvnQx4s5ve7DyR9D3FedEA3jGk4x3DRoQy114DuNufXyA26ZiMWYjOPq0/O9PEDlI1UFAMAp+jjF9/3GBpEaY8wEowkcqukUS9DXs/JkAyPsrX/1TIk2MbfoTZcyDTG53/JaGEIIUxxL3Fw8= 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 1644000738252967.7403780938296; Fri, 4 Feb 2022 10:52:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-398-L0Zv0Pq9Nj6hUzntR7x8Xw-1; Fri, 04 Feb 2022 13:52:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9425E871104; Fri, 4 Feb 2022 18:52:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 702BD45D87; Fri, 4 Feb 2022 18:52:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3F9AF1809CB8; Fri, 4 Feb 2022 18:52:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214IpaOA002269 for ; Fri, 4 Feb 2022 13:51:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 38D75703B5; Fri, 4 Feb 2022 18:51:36 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A5237243D for ; Fri, 4 Feb 2022 18:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000737; 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=KR6cwXVAB49lPrLz9O4+K1NI6tSCLNLkRMfNOtHL920=; b=afSjz/MfoygVIrtdL2BOeIS+QWMzy/JfIaycbiJlFd4st+CbBXeq4whv2KS7+qslkNWMKp G7DWP3O+l784swU/nsTg0kONcHifGYV+AwdoZ9MNj9a5IIiWKABwc3u/Syr7HO5Vw2HlY/ 46c4NUjJAZSSzt1Z5D7vC3SbkEf7OQY= X-MC-Unique: L0Zv0Pq9Nj6hUzntR7x8Xw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 12/14] qemu: Move utility functions close together Date: Fri, 4 Feb 2022 19:51:15 +0100 Message-Id: <20220204185117.61149-13-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1644000740418100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 124 ++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index c0e875627d..264b9b1d60 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -98,6 +98,68 @@ qemuTPMEmulatorLogBuildPath(const char *logDir, } =20 =20 +/** + * qemuTPMEmulatorSocketBuildPath: + * @swtpmStateDir: directory for swtpm runtime state + * @shortName: short and unique name of the domain + * + * Generate the swtpm's Unix socket path. + */ +static char * +qemuTPMEmulatorSocketBuildPath(const char *swtpmStateDir, + const char *shortName) +{ + return g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName); +} + + +/** + * qemuTPMEmulatorPidFileBuildPath: + * @swtpmStateDir: directory for swtpm runtime state + * @shortName: short and unique name of the domain + * + * Generate the swtpm's pidfile path. + */ +static char * +qemuTPMEmulatorPidFileBuildPath(const char *swtpmStateDir, + const char *shortName) +{ + g_autofree char *devicename =3D NULL; + + devicename =3D g_strdup_printf("%s-swtpm", shortName); + + return virPidFileBuildPath(swtpmStateDir, devicename); +} + + +/* + * qemuTPMEmulatorGetPid + * + * @swtpmStateDir: the directory where swtpm writes the pidfile into + * @shortName: short name of the domain + * @pid: pointer to pid + * + * Return -1 upon error, or zero on successful reading of the pidfile. + * If the PID was not still alive, zero will be returned, and @pid will be + * set to -1; + */ +static int +qemuTPMEmulatorGetPid(const char *swtpmStateDir, + const char *shortName, + pid_t *pid) +{ + g_autofree char *pidfile =3D qemuTPMEmulatorPidFileBuildPath(swtpmStat= eDir, + shortName); + if (!pidfile) + return -1; + + if (virPidFileReadPathIfLocked(pidfile, pid) < 0) + return -1; + + return 0; +} + + /** * qemuTPMEmulatorCreateStorage: * @tpm: TPM definition for an emulator type @@ -162,21 +224,6 @@ qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) } =20 =20 -/** - * qemuTPMEmulatorSocketBuildPath: - * @swtpmStateDir: directory for swtpm runtime state - * @shortName: short and unique name of the domain - * - * Generate the swtpm's Unix socket path. - */ -static char * -qemuTPMEmulatorSocketBuildPath(const char *swtpmStateDir, - const char *shortName) -{ - return g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName); -} - - /* * qemuTPMEmulatorInitPaths: * @@ -213,53 +260,6 @@ qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, } =20 =20 -/** - * qemuTPMEmulatorPidFileBuildPath: - * @swtpmStateDir: directory for swtpm runtime state - * @shortName: short and unique name of the domain - * - * Generate the swtpm's pidfile path. - */ -static char * -qemuTPMEmulatorPidFileBuildPath(const char *swtpmStateDir, - const char *shortName) -{ - g_autofree char *devicename =3D NULL; - - devicename =3D g_strdup_printf("%s-swtpm", shortName); - - return virPidFileBuildPath(swtpmStateDir, devicename); -} - - -/* - * qemuTPMEmulatorGetPid - * - * @swtpmStateDir: the directory where swtpm writes the pidfile into - * @shortName: short name of the domain - * @pid: pointer to pid - * - * Return -1 upon error, or zero on successful reading of the pidfile. - * If the PID was not still alive, zero will be returned, and @pid will be - * set to -1; - */ -static int -qemuTPMEmulatorGetPid(const char *swtpmStateDir, - const char *shortName, - pid_t *pid) -{ - g_autofree char *pidfile =3D qemuTPMEmulatorPidFileBuildPath(swtpmStat= eDir, - shortName); - if (!pidfile) - return -1; - - if (virPidFileReadPathIfLocked(pidfile, pid) < 0) - return -1; - - return 0; -} - - /** * qemuTPMEmulatorCleanupHost: * @tpm: TPM definition --=20 2.34.1 From nobody Sun Feb 8 19:24:22 2026 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=1644000793; cv=none; d=zohomail.com; s=zohoarc; b=dALGBhjL4VIRLAwG5ykdzePbL7RjCfYCQeBSudSoYFSXe2tFAsmwqT1WNwTiXYAlaWEYlvip7T9TRVRqiNXrRci5+t495/7k3Xx5P3NWk4gDN3jP/86iDmr+fTbobMkWytF2axwy0oJyx80rlDIEzJiKwLfdjTTcQRZ6pp9kCOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000793; 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=gv9iN6/Zh9UW1o0lfoXCXEr5+un7+8TfZwB6uC2zXq4=; b=WgIuqaAi+fkyftNcKdCFgFSDsmZjfaRvv8xlXvZTzChNwqjM8aUoSV6MH5HD82btKrW4kvFUk4qrfrQntkI7USImX9R/NrfyhuduJdQWLQ5+9mQ7Mjv0SBibiz0ElsTibMbUZOcffx4WztBkF7spCHC7P55HnorKdsy4aABm8fw= 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 1644000793920428.7040590094683; Fri, 4 Feb 2022 10:53:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-495-j3kZjStuOHma45D4siLuSg-1; Fri, 04 Feb 2022 13:53:11 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19DD534837; Fri, 4 Feb 2022 18:53:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECE8937FBD; Fri, 4 Feb 2022 18:53:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C0CC1180B654; Fri, 4 Feb 2022 18:53:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214Ipbrq002279 for ; Fri, 4 Feb 2022 13:51:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6FD1570F53; Fri, 4 Feb 2022 18:51:37 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF8CD703B5 for ; Fri, 4 Feb 2022 18:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000793; 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=gv9iN6/Zh9UW1o0lfoXCXEr5+un7+8TfZwB6uC2zXq4=; b=AWY2oOZhuvORGL5VfzL+uyFM2zMGulg0+THyHqflioSWrMqi346m93YxMOznzD9BDA5cRJ IlsXz8crTRvi2nhnKLnCrjnS4n32mHer6PwroL0YzTVWg1kZ48ZOLoACQjG653L2lS1Int yge1TqWEVuxVqQkD8gMY4dDISG/sklg= X-MC-Unique: j3kZjStuOHma45D4siLuSg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 13/14] qemu: Move entry points close together Date: Fri, 4 Feb 2022 19:51:16 +0100 Message-Id: <20220204185117.61149-14-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644000794688100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 133 +++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 264b9b1d60..4c0b42e7ff 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -842,68 +842,6 @@ qemuExtTPMEmulatorSetupCgroup(const char *swtpmStateDi= r, } =20 =20 -int -qemuExtTPMInitPaths(virQEMUDriver *driver, - virDomainDef *def) -{ - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - size_t i; - - for (i =3D 0; i < def->ntpms; i++) { - if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) - continue; - - return qemuTPMEmulatorInitPaths(def->tpms[i], - cfg->swtpmStorageDir, - cfg->swtpmLogDir, - def->name, - def->uuid); - } - - return 0; -} - - -int -qemuExtTPMPrepareHost(virQEMUDriver *driver, - virDomainDef *def) -{ - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - g_autofree char *shortName =3D virDomainDefGetShortName(def); - size_t i; - - if (!shortName) - return -1; - - for (i =3D 0; i < def->ntpms; i++) { - if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) - continue; - - return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir, - cfg->swtpm_user, - cfg->swtpm_group, - cfg->swtpmStateDir, cfg->user, - shortName); - } - - return 0; -} - - -void -qemuExtTPMCleanupHost(virDomainDef *def) -{ - size_t i; - - for (i =3D 0; i < def->ntpms; i++) { - if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) - continue; - - qemuTPMEmulatorCleanupHost(def->tpms[i]); - } -} - - /** * qemuTPMEmulatorStart: * @driver: QEMU driver @@ -1010,6 +948,77 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, } =20 =20 +/* --------------------- + * Module entry points + * --------------------- + * + * These are the public functions that will be called by other parts + * of the QEMU driver. + */ + + +int +qemuExtTPMInitPaths(virQEMUDriver *driver, + virDomainDef *def) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + size_t i; + + for (i =3D 0; i < def->ntpms; i++) { + if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) + continue; + + return qemuTPMEmulatorInitPaths(def->tpms[i], + cfg->swtpmStorageDir, + cfg->swtpmLogDir, + def->name, + def->uuid); + } + + return 0; +} + + +int +qemuExtTPMPrepareHost(virQEMUDriver *driver, + virDomainDef *def) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autofree char *shortName =3D virDomainDefGetShortName(def); + size_t i; + + if (!shortName) + return -1; + + for (i =3D 0; i < def->ntpms; i++) { + if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) + continue; + + return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir, + cfg->swtpm_user, + cfg->swtpm_group, + cfg->swtpmStateDir, cfg->user, + shortName); + } + + return 0; +} + + +void +qemuExtTPMCleanupHost(virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->ntpms; i++) { + if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) + continue; + + qemuTPMEmulatorCleanupHost(def->tpms[i]); + } +} + + int qemuExtTPMStart(virQEMUDriver *driver, virDomainObj *vm, --=20 2.34.1 From nobody Sun Feb 8 19:24:22 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=1644000798; cv=none; d=zohomail.com; s=zohoarc; b=CZ6AV3jI+Ag1RAa0UwzqtOc10erEEOZl63DYwxdUP+GQ2ghp9vouPPKdnRE6ujoFnvIfdvHnVPSw30/drfVVPTh9fGrnZaYBHBnkYn0EZhb1ke67BgHARxq+MJuRN6KxGxCCU0mFOksD2dA2Vx4CRUQ0vUqyWrfzZ7PJNl7XS2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644000798; 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=NOJmSJ+cc7DrRuXWsGcOgC66gA6NuADefBcm3oCYJ2k=; b=PM/xxinyLprexij93bKWjs/+TmXiER+whigrgjT581x2xN7pCms2Upq2obAuf71Xb6gEGSy1tnAE9i6WkW10pYVQ/grs2A1pLe845oRpd8F1qyh8vl/VvYlapEmB9VdGMlIrJdMS47HxnzzetdTw5LI3UfbGahL0uYG7qDuck7c= 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 1644000798665130.07671213585888; Fri, 4 Feb 2022 10:53:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-WQJmeWcJNKShT99dE48Z4Q-1; Fri, 04 Feb 2022 13:53:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 758F01091DBB; Fri, 4 Feb 2022 18:53:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 577A87A436; Fri, 4 Feb 2022 18:53:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2825C1806D1D; Fri, 4 Feb 2022 18:53:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 214Ipc7l002290 for ; Fri, 4 Feb 2022 13:51:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id D7F0F70F53; Fri, 4 Feb 2022 18:51:38 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4C54703B5 for ; Fri, 4 Feb 2022 18:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644000797; 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=NOJmSJ+cc7DrRuXWsGcOgC66gA6NuADefBcm3oCYJ2k=; b=NW+Z9Rp1IoB15b/W1EHgWTYsHB3NWuHBEt918Gh3xQeJFDTG8t9Z3xEr73egOuxdk+acwt 8bc1G6O9UKvqH3OM34yeru5DbqZsgdiXg0cs7CSDrPNDRFieyGsRl7iZqZWPaPZs8nLU0X NueTdTgsmdXNRfVA7BVCLo/GT9SfI2Q= X-MC-Unique: WQJmeWcJNKShT99dE48Z4Q-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 14/14] qemu: Move high-level actions close together Date: Fri, 4 Feb 2022 19:51:17 +0100 Message-Id: <20220204185117.61149-15-abologna@redhat.com> In-Reply-To: <20220204185117.61149-1-abologna@redhat.com> References: <20220204185117.61149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1644000812640100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 245 +++++++++++++++++++++++--------------------- 1 file changed, 128 insertions(+), 117 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 4c0b42e7ff..50f9caabf3 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -224,123 +224,6 @@ qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm) } =20 =20 -/* - * qemuTPMEmulatorInitPaths: - * - * @tpm: TPM definition for an emulator type - * @swtpmStorageDir: the general swtpm storage dir which is used as a base - * directory for creating VM specific directories - * @logDir: directory where swtpm writes its logs into - * @vmname: name of the VM - * @uuid: the UUID of the VM - */ -static int -qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, - const char *swtpmStorageDir, - const char *logDir, - const char *vmname, - const unsigned char *uuid) -{ - char uuidstr[VIR_UUID_STRING_BUFLEN]; - - virUUIDFormat(uuid, uuidstr); - - if (!tpm->data.emulator.storagepath && - !(tpm->data.emulator.storagepath =3D - qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr, - tpm->version))) - return -1; - - if (!tpm->data.emulator.logfile) { - tpm->data.emulator.logfile =3D qemuTPMEmulatorLogBuildPath(logDir, - vmname); - } - - return 0; -} - - -/** - * qemuTPMEmulatorCleanupHost: - * @tpm: TPM definition - * - * Clean up persistent storage for the swtpm. - */ -static void -qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm) -{ - if (!tpm->data.emulator.persistent_state) - qemuTPMEmulatorDeleteStorage(tpm); -} - - -/* - * qemuTPMEmulatorPrepareHost: - * - * @tpm: tpm definition - * @logDir: directory where swtpm writes its logs into - * @swtpm_user: uid to run the swtpm with - * @swtpm_group: gid to run the swtpm with - * @swtpmStateDir: directory for swtpm runtime state - * @qemu_user: uid that qemu will run with; we share the socket file with = it - * @shortName: short and unique name of the domain - * - * Prepare the log directory for the swtpm and adjust ownership of it and = the - * log file we will be using. Prepare the state directory where we will sh= are - * the socket between tss and qemu users. - */ -static int -qemuTPMEmulatorPrepareHost(virDomainTPMDef *tpm, - const char *logDir, - uid_t swtpm_user, - gid_t swtpm_group, - const char *swtpmStateDir, - uid_t qemu_user, - const char *shortName) -{ - /* create log dir ... allow 'tss' user to cd into it */ - if (g_mkdir_with_parents(logDir, 0711) < 0) - return -1; - - /* ... and adjust ownership */ - if (virDirCreate(logDir, 0730, swtpm_user, swtpm_group, - VIR_DIR_CREATE_ALLOW_EXIST) < 0) - return -1; - - if (!virFileExists(tpm->data.emulator.logfile) && - virFileTouch(tpm->data.emulator.logfile, 0644) < 0) { - return -1; - } - - /* ... and make sure it can be accessed by swtpm_user */ - if (chown(tpm->data.emulator.logfile, swtpm_user, swtpm_group) < 0) { - virReportSystemError(errno, - _("Could not chown on swtpm logfile %s"), - tpm->data.emulator.logfile); - return -1; - } - - /* - create our swtpm state dir ... - - QEMU user needs to be able to access the socket there - - swtpm group needs to be able to create files there - - in privileged mode 0570 would be enough, for non-privileged mode - we need 0770 - */ - if (virDirCreate(swtpmStateDir, 0770, qemu_user, swtpm_group, - VIR_DIR_CREATE_ALLOW_EXIST) < 0) - return -1; - - /* create the socket filename */ - if (!tpm->data.emulator.source->data.nix.path && - !(tpm->data.emulator.source->data.nix.path =3D - qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName))) - return -1; - tpm->data.emulator.source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - - return 0; -} - /* * qemuTPMSetupEncryption * @@ -772,6 +655,134 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, } =20 =20 +/* -------------------- + * High-level actions + * -------------------- + * + * Each of these corresponds to one of the public entry points + * defined below, but operates on a single TPM device instead of the + * entire VM. + */ + + +/* + * qemuTPMEmulatorInitPaths: + * + * @tpm: TPM definition for an emulator type + * @swtpmStorageDir: the general swtpm storage dir which is used as a base + * directory for creating VM specific directories + * @logDir: directory where swtpm writes its logs into + * @vmname: name of the VM + * @uuid: the UUID of the VM + */ +static int +qemuTPMEmulatorInitPaths(virDomainTPMDef *tpm, + const char *swtpmStorageDir, + const char *logDir, + const char *vmname, + const unsigned char *uuid) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(uuid, uuidstr); + + if (!tpm->data.emulator.storagepath && + !(tpm->data.emulator.storagepath =3D + qemuTPMEmulatorStorageBuildPath(swtpmStorageDir, uuidstr, + tpm->version))) + return -1; + + if (!tpm->data.emulator.logfile) { + tpm->data.emulator.logfile =3D qemuTPMEmulatorLogBuildPath(logDir, + vmname); + } + + return 0; +} + + +/** + * qemuTPMEmulatorCleanupHost: + * @tpm: TPM definition + * + * Clean up persistent storage for the swtpm. + */ +static void +qemuTPMEmulatorCleanupHost(virDomainTPMDef *tpm) +{ + if (!tpm->data.emulator.persistent_state) + qemuTPMEmulatorDeleteStorage(tpm); +} + + +/* + * qemuTPMEmulatorPrepareHost: + * + * @tpm: tpm definition + * @logDir: directory where swtpm writes its logs into + * @swtpm_user: uid to run the swtpm with + * @swtpm_group: gid to run the swtpm with + * @swtpmStateDir: directory for swtpm runtime state + * @qemu_user: uid that qemu will run with; we share the socket file with = it + * @shortName: short and unique name of the domain + * + * Prepare the log directory for the swtpm and adjust ownership of it and = the + * log file we will be using. Prepare the state directory where we will sh= are + * the socket between tss and qemu users. + */ +static int +qemuTPMEmulatorPrepareHost(virDomainTPMDef *tpm, + const char *logDir, + uid_t swtpm_user, + gid_t swtpm_group, + const char *swtpmStateDir, + uid_t qemu_user, + const char *shortName) +{ + /* create log dir ... allow 'tss' user to cd into it */ + if (g_mkdir_with_parents(logDir, 0711) < 0) + return -1; + + /* ... and adjust ownership */ + if (virDirCreate(logDir, 0730, swtpm_user, swtpm_group, + VIR_DIR_CREATE_ALLOW_EXIST) < 0) + return -1; + + if (!virFileExists(tpm->data.emulator.logfile) && + virFileTouch(tpm->data.emulator.logfile, 0644) < 0) { + return -1; + } + + /* ... and make sure it can be accessed by swtpm_user */ + if (chown(tpm->data.emulator.logfile, swtpm_user, swtpm_group) < 0) { + virReportSystemError(errno, + _("Could not chown on swtpm logfile %s"), + tpm->data.emulator.logfile); + return -1; + } + + /* + create our swtpm state dir ... + - QEMU user needs to be able to access the socket there + - swtpm group needs to be able to create files there + - in privileged mode 0570 would be enough, for non-privileged mode + we need 0770 + */ + if (virDirCreate(swtpmStateDir, 0770, qemu_user, swtpm_group, + VIR_DIR_CREATE_ALLOW_EXIST) < 0) + return -1; + + /* create the socket filename */ + if (!tpm->data.emulator.source->data.nix.path && + !(tpm->data.emulator.source->data.nix.path =3D + qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName))) + return -1; + tpm->data.emulator.source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + + return 0; +} + + /* * qemuTPMEmulatorStop * @swtpmStateDir: A directory where the socket is located --=20 2.34.1