From nobody Fri May 3 16:28:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614619073; cv=none; d=zohomail.com; s=zohoarc; b=ayCmqqZod/8+rhmYAEshoDDRgOfaOaTlM6Bp1nJizN58bq4fqz2UaJwJIm4XHFu2pIVfXAlg6I21TbzxKoGcpBCyfp8IcLWFgpFrJ3xXbdjcrQ3a9TKyfYlmQ+fsVPMXACfnqjXNprjBt0BDsjjVIsp2QsmaCAv20n1j+2faUhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614619073; 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=2l+ZmTWyCdEuJ5+KnsxGrNgJqpmrZZvpGqSdofV0mcU=; b=C9oAsy72uqOU8vTCPeqcAkJJsTEGjiePwEnsRcW/JG7tf5cgYQIbrT6JK2LZblnj0OgVPV4ODmqpP9RWQhSPRiZvI2GX2l/cxmddd9rMvi9AgOtb6w7gsTJEpsBQ0QhS1Y2jdsFwi2FJ73n6Q/F9c+GYDUI0mL6x4BTnqmZayv4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614619073126236.11352863315005; Mon, 1 Mar 2021 09:17:53 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-eXxDrWyZMmOvMmRMeK6Jog-1; Mon, 01 Mar 2021 12:17:49 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54BA7801975; Mon, 1 Mar 2021 17:17:44 +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 4EDD560C04; Mon, 1 Mar 2021 17:17:43 +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 60FFC58074; Mon, 1 Mar 2021 17:17:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121HHfA7004852 for ; Mon, 1 Mar 2021 12:17:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id CADA610016DB; Mon, 1 Mar 2021 17:17:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BC5810013C1 for ; Mon, 1 Mar 2021 17:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614619072; 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=2l+ZmTWyCdEuJ5+KnsxGrNgJqpmrZZvpGqSdofV0mcU=; b=X/O30khrMgc4DDIWrZBKVbiwDmh4+WN4EM7HfMZm7uYjKUmszsNQsioREssbuZ42xf3ALL f4nMI/GQIs+wWwLtIP/pyljtc/VX8msqY+3JPk2LViKkTEh61GHaadzmIsNXHIgo4O/MHa 695DTVHgm31Ld/Rk4HzmOsLxNXwlURI= X-MC-Unique: eXxDrWyZMmOvMmRMeK6Jog-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] qemu_tpm: Move logfile path generation into a separate function Date: Mon, 1 Mar 2021 18:17:32 +0100 Message-Id: <913fb769cf484d6a5997a4a07e6229966a6324b7.1614617800.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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) Content-Type: text/plain; charset="utf-8" Strictly not needed, but the rest of paths is generated in separate functions. Helps with code readability. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index f94cad8230..71339b785a 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -82,6 +82,21 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStorag= eDir, } =20 =20 +/** + * qemuTPMCreateEmulatorLogPath: + * @logDir: directory where swtpm writes its logs into + * @vmname: name of the VM + * + * Create the swtpm's log path. + */ +static char* +qemuTPMCreateEmulatorLogPath(const char *logDir, + const char *vmname) +{ + return g_strdup_printf("%s/%s-swtpm.log", logDir, vmname); +} + + /* * qemuTPMEmulatorInitStorage * @@ -286,7 +301,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, =20 /* create logfile name ... */ if (!tpm->data.emulator.logfile) - tpm->data.emulator.logfile =3D g_strdup_printf("%s/%s-swtpm.log", = logDir, vmname); + tpm->data.emulator.logfile =3D qemuTPMCreateEmulatorLogPath(logDir= , vmname); =20 if (!virFileExists(tpm->data.emulator.logfile) && virFileTouch(tpm->data.emulator.logfile, 0644) < 0) { --=20 2.26.2 From nobody Fri May 3 16:28:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614619083; cv=none; d=zohomail.com; s=zohoarc; b=mADV55soCd3I0IoUfFPVxPjivxycSg/Jb3FJ1ULUB8H3zuxsLh2mFe4TrFGXM9m/fj8mlKdZhw3yfSL9sZvAU3cMZoEjRsvbc07FXjEF9degwDsZTlkqN+PR3cUJOxlzo5/9ykE2UXqgM8B5tW/p+FR+6ldGAS8VyD4HNbE9W0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614619083; 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=xobB7RhXmSURitg4HR+d0Fwgj+nTKGGMadR7ZaKNgHo=; b=i1AEsGdwBDeG7AfHkGWDNVLmMQ6wGTSOtwmFYxWz5fWj2ALYc659+3QA3xqGkubjeEGrruXPVqsQY3Z8onuNnk7CeL8EUjJSava1jNesskls8ddKvKsTqgiVEioE1znXWQjtJBx/tnuusXKmvA5kugbBErsdvRJRpOwwSrNt9Eo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614619083780643.0505173419066; Mon, 1 Mar 2021 09:18:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-iYODOiO-PWmO3EeTg4ivyA-1; Mon, 01 Mar 2021 12:17:58 -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 54AB910066FB; Mon, 1 Mar 2021 17:17:52 +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 2EC2F10023AB; Mon, 1 Mar 2021 17:17:52 +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 ED52A5807A; Mon, 1 Mar 2021 17:17:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121HHg4U004870 for ; Mon, 1 Mar 2021 12:17:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id A722610016DB; Mon, 1 Mar 2021 17:17:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 290BC10013C1 for ; Mon, 1 Mar 2021 17:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614619082; 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=xobB7RhXmSURitg4HR+d0Fwgj+nTKGGMadR7ZaKNgHo=; b=bW2LidV7jGvXtCMDFNu6/xcOjXl4vy3if3UTkPH0n4kXMI/E8m4K5mEkkxOW5CBxAbl6i8 XsG+eJxd8CQKkupT6Vc8UIGHyAh6sJg3tvs+A6uNycv13DaWkCGmWrZfeI8O4iu746Lm26 N1/rHJ+H7FmBDeNeUa6tHAYK3GgJ8q0= X-MC-Unique: iYODOiO-PWmO3EeTg4ivyA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu_tpm: Generate log file path among with storage path Date: Mon, 1 Mar 2021 18:17:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" When starting a guest with TPM of type=3D'emulator' an external process is started with it (swtmp) to emulat TPM. This external process is passed path to a log file via --logfile. The path to the log file is generated in qemuTPMEmulatorPrepareHost() which works, until the daemon is restarted. The problem is that the path is not stored in private data or anywhere inside live XML and thus later, when qemuExtTPMStop() is called (when shutting off the guest) the stored logpath is NULL and thus it's seclabel is not cleaned up (see virSecuritySELinuxRestoreTPMLabels()). Fortunately, qemuExtDevicesStop() (which calls qemuExtTPMStop() eventually) does call qemuExtDevicesInitPaths() where the log path can be generated again. Basically, tpm->data.emulator.storagepath is generated in qemuExtTPMInitPaths() and it's seclabels are restored properly, and this commit move logfile onto the same level. This means, that the log path doesn't have to be generated in qemuExtDevicesStart() because it was already done in qemuExtDevicesPrepareHost(). This change also renders @vmname argument of qemuTPMEmulatorPrepareHost() unused and thus is removed. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1769196 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_extdevice.c | 6 +++--- src/qemu/qemu_tpm.c | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 8fe7ceaa10..fdba22616c 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -132,6 +132,9 @@ qemuExtDevicesPrepareHost(virQEMUDriverPtr driver, virDomainDefPtr def =3D vm->def; size_t i; =20 + if (qemuExtDevicesInitPaths(driver, def) < 0) + return -1; + if (def->ntpms > 0 && qemuExtTPMPrepareHost(driver, def) < 0) return -1; @@ -169,9 +172,6 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, virDomainDefPtr def =3D vm->def; size_t i; =20 - if (qemuExtDevicesInitPaths(driver, def) < 0) - return -1; - for (i =3D 0; i < def->nvideos; i++) { virDomainVideoDefPtr video =3D def->videos[i]; =20 diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 71339b785a..b11c5474a5 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -196,11 +196,15 @@ qemuTPMCreateEmulatorSocket(const char *swtpmStateDir, * @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(virDomainTPMDefPtr tpm, const char *swtpmStorageDir, + const char *logDir, + const char *vmname, const unsigned char *uuid) { char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -213,6 +217,11 @@ qemuTPMEmulatorInitPaths(virDomainTPMDefPtr tpm, tpm->version))) return -1; =20 + if (!tpm->data.emulator.logfile && + !(tpm->data.emulator.logfile =3D + qemuTPMCreateEmulatorLogPath(logDir, vmname))) + return -1; + return 0; } =20 @@ -266,7 +275,6 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, * * @tpm: tpm definition * @logDir: directory where swtpm writes its logs into - * @vmname: name of the VM * @swtpm_user: uid to run the swtpm with * @swtpm_group: gid to run the swtpm with * @swtpmStateDir: directory for swtpm's persistent state @@ -280,7 +288,6 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, static int qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, const char *logDir, - const char *vmname, uid_t swtpm_user, gid_t swtpm_group, const char *swtpmStateDir, @@ -299,10 +306,6 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, VIR_DIR_CREATE_ALLOW_EXIST) < 0) return -1; =20 - /* create logfile name ... */ - if (!tpm->data.emulator.logfile) - tpm->data.emulator.logfile =3D qemuTPMCreateEmulatorLogPath(logDir= , vmname); - if (!virFileExists(tpm->data.emulator.logfile) && virFileTouch(tpm->data.emulator.logfile, 0644) < 0) { return -1; @@ -702,7 +705,10 @@ qemuExtTPMInitPaths(virQEMUDriverPtr driver, if (def->tpms[i]->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) continue; =20 - return qemuTPMEmulatorInitPaths(def->tpms[i], cfg->swtpmStorageDir, + return qemuTPMEmulatorInitPaths(def->tpms[i], + cfg->swtpmStorageDir, + cfg->swtpmLogDir, + def->name, def->uuid); } =20 @@ -727,7 +733,7 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, return -1; =20 return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir, - def->name, cfg->swtpm_user, + cfg->swtpm_user, cfg->swtpm_group, cfg->swtpmStateDir, cfg->user, shortName); --=20 2.26.2 From nobody Fri May 3 16:28:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1614619077; cv=none; d=zohomail.com; s=zohoarc; b=ir5ynYZh1yqwfwMJk4quPGptFFp4LP1JIXtYKyrDWMzaqnE9d2B+S+AWQaDPesXV6zfzSICuWxADflIzr1ILBbY3Mp9eya/f3E7FfZ6UxQepONKlYM6YF0cGvaS0yn7x0UyZI6VX5Sr+Y2Ixiz35tWZ285htqwDSOzGiPFskOIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614619077; 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=yhIA5wBHFjwJzXeSfRdlzjKh3sLs3FNObfES8ybvJZw=; b=cfRAgkKJxbSkFuSLYd7GeUK8aKplIPlsIzr8/EvWuQ8zNTjFOMC/FzPOYeHTt4FW3oyxeeCyWkV8MR4FC0WAVDOgVh4O8m3eiufvweXKtmVTwJGT8s+DDQbgsF2A3A4bipIxObQkCia7X/cSVDmekzkEiJMCw6mSFOZ9DZEK4Pw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161461907702273.31591469629961; Mon, 1 Mar 2021 09:17:57 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-UU2IY1NLM2eA9wSXAvMqdQ-1; Mon, 01 Mar 2021 12:17:50 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18993107ACE8; Mon, 1 Mar 2021 17:17:45 +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 E79C560C04; Mon, 1 Mar 2021 17:17:44 +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 B0F6418095CB; Mon, 1 Mar 2021 17:17:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121HHhmB004878 for ; Mon, 1 Mar 2021 12:17:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 837ED10016DB; Mon, 1 Mar 2021 17:17:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04F7C10013C1 for ; Mon, 1 Mar 2021 17:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614619074; 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=yhIA5wBHFjwJzXeSfRdlzjKh3sLs3FNObfES8ybvJZw=; b=XmmdbromAtsqlINRynCTYfMRiVQ3UcjYj16Cz7mYOJF3LEMidOrjMS3ElayDuWm0KVNvco Bk8ROQTyjhDuaawYDjOUaWMCvg1Is/sFWFUVq8PKTSZuQwaV6sRKTFF5KxWDYMyUUZK3EQ kUKdirfVPQ6GPtbQdpKVJtRgnrR2lkA= X-MC-Unique: UU2IY1NLM2eA9wSXAvMqdQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] qemu_tpm: Drop @logDir argument from qemuTPMEmulatorPrepareHost() Date: Mon, 1 Mar 2021 18:17:34 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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) Content-Type: text/plain; charset="utf-8" After previous commit, the log directory doesn't have to be passed as an extra argument but can be deducted from logfile path. Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index b11c5474a5..5ee5efa6b0 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -274,7 +274,6 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, * 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's persistent state @@ -287,16 +286,19 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, */ static int qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, - const char *logDir, uid_t swtpm_user, gid_t swtpm_group, const char *swtpmStateDir, uid_t qemu_user, const char *shortName) { + g_autofree char *logDir =3D NULL; + if (virTPMEmulatorInit() < 0) return -1; =20 + logDir =3D g_path_get_dirname(tpm->data.emulator.logfile); + /* create log dir ... allow 'tss' user to cd into it */ if (virFileMakePathWithMode(logDir, 0711) < 0) return -1; @@ -732,7 +734,7 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, if (!shortName) return -1; =20 - return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpmLogDir, + return qemuTPMEmulatorPrepareHost(def->tpms[i], cfg->swtpm_user, cfg->swtpm_group, cfg->swtpmStateDir, cfg->user, --=20 2.26.2 From nobody Fri May 3 16:28:50 2024 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=1614619085; cv=none; d=zohomail.com; s=zohoarc; b=LLHO1Ix+vFSJBYsKoKLXf9xQExs6+QhUQ2lhUrGBgG3yWPj6DSwJMzQ8G8Ylyr/VJgyuLSvNVBSnHDQ86OlgGVSH8my8FZD9L0hOOkKQRWNhaYDgttzcl9/kStsU0jEF/Ew9oFjOZg8QsJaxJKbUToR0+u00/vsfaeERFxEenZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614619085; 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=rYDN7R7wPVSNFFqzn8Tc1sbUwE0wD6L9SSv1Nuuk494=; b=gF6PPOD16RFJJ/aNYYdA9U+70Oss5KTn4Dw68wU9sXsixCNzPfrHlrSv90tC9a/T3kWm85E1DOdFghXA7uJqOC+qFbXQKMyNxHYLDDn7iUSQAvEQlyHZVeqZe+xKAqZsgnFLsroWRIpnT/YDz7XmmnC+X1RTTTFhJbIgopujW6A= 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) header.from= 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 161461908503394.11482791020012; Mon, 1 Mar 2021 09:18:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-9FCS64gpPjqjktmqdnPh1w-1; Mon, 01 Mar 2021 12:18:01 -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 2807410066F4; Mon, 1 Mar 2021 17:17:55 +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 F28375C1C4; Mon, 1 Mar 2021 17:17: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 BA8D418095CD; Mon, 1 Mar 2021 17:17:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121HHiNW004889 for ; Mon, 1 Mar 2021 12:17:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5EA271002388; Mon, 1 Mar 2021 17:17:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4C2010013C1 for ; Mon, 1 Mar 2021 17:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614619084; 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=rYDN7R7wPVSNFFqzn8Tc1sbUwE0wD6L9SSv1Nuuk494=; b=Jfbn6hAYpT6cKqSOL7B8rYGnadeuqnco9vdJAw+sRZlEFOwNUmd3JAI2WgQJW1KKVEkeDs /AYTldTALbowVinnTeJlI9B+1EFcbH6yMAhdLuMzFK67pehvwDOP0VYNi8PwjuRswnqOfL 8aCjzfQdvG6va+7Qv8Nlyewy+eaHqOI= X-MC-Unique: 9FCS64gpPjqjktmqdnPh1w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virtmp: Fix @path handling in virTPMEmulatorInit() Date: Mon, 1 Mar 2021 18:17:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" This function finds "swtmp", "swtpm_setup" and "swtpm_ioctl" binaries in $PATH and stores resolved paths in global variables so that they can be obtainer later. Anyway, the resolved path is marked as g_autofree and to avoid its freeing later on in the function the variable is set to NULL manually. Well, we have g_steal_pointer() for thath. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virtpm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index b41eb00619..cd860140d3 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -323,16 +323,14 @@ virTPMEmulatorInit(void) _("Could not stat %s"), path); goto cleanup; } - *prgs[i].path =3D path; + *prgs[i].path =3D g_steal_pointer(&path); =20 if (prgs[i].caps) { *prgs[i].caps =3D virTPMGetCaps(prgs[i].typeFromStringFn, path, prgs[i].parm); - path =3D NULL; if (!*prgs[i].caps) goto cleanup; } - path =3D NULL; } } =20 --=20 2.26.2