From nobody Sun Feb 8 13:39:33 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=1669996619; cv=none; d=zohomail.com; s=zohoarc; b=Eu5NbbWioiEWREZk+g10MvntcR6WZKLcNyNE5GVvRm6sbtyBhrhF/XNiECEq/AvkTVlXvwuE9iwzFIFPYQMGr1MuUglbliLw/hEr1nZ7dqJuNw2DcDShyve+hH3uQwKRM9JvpvGf/hrDE+lpUOqvO9m3CZJUpQvyPk78f3Fp3D4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669996619; 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=DrRZg19Ue3uEJDykFaMJYrdbYtNyHLW2Ocq9YaYGzAE=; b=hdtj5fMIeZuRks6y4TSCBJNdxDm7QaPRdi0cuo3GRz2Ae6j2Vj7MBX9ZykGIsFQaGFWzUEQJeRjo2HNtGndQ9KMDM0DXXxdZ+nwp67MHozBNwJ2ejoFqdX0c4sUH+uTmx7a2rY/ujDT14ynD/XJymbv1ihgAcZ5Mz6qiWCZkV1A= 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 1669996619631880.3021036029926; Fri, 2 Dec 2022 07:56:59 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-7qhWcPPzPfCTAEs8lONReg-1; Fri, 02 Dec 2022 10:56:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 892FC1C0691F; Fri, 2 Dec 2022 15:56:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 709B4C2C8C7; Fri, 2 Dec 2022 15:56:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A10A41946A79; Fri, 2 Dec 2022 15:56:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AE0D61946587 for ; Fri, 2 Dec 2022 15:56:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 913AA111E410; Fri, 2 Dec 2022 15:56:41 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3622D111E3FA for ; Fri, 2 Dec 2022 15:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669996618; 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=DrRZg19Ue3uEJDykFaMJYrdbYtNyHLW2Ocq9YaYGzAE=; b=b6DikP7YXVRkxeacjNRtkCKDyUWXmS9ZTpaW3PvmaDWRyAPvjAQyONg6vz+5ARWedYRm1I EFWPqtD7isYbhxxZoFHH3AXUxie6rA4KuCm6eHweGakhPCCNbBLMpMLsBFjGY++kCBHWF3 t4aMSHdGr9mAeQ0zwzoJDGdhORFLpUg= X-MC-Unique: 7qhWcPPzPfCTAEs8lONReg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] qemu_tpm: Extend start/stop APIs Date: Fri, 2 Dec 2022 16:56:37 +0100 Message-Id: <9399f89dfcc5b77b4e37e43bfa2d9022c202783a.1669996391.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1669996620455100002 Content-Type: text/plain; charset="utf-8"; x-default="true" This is basically just a continuation of the previous commit. Now that the security driver APIs have a boolean flag that controls setting/restoring seclabel of either both TPM state and log files, or just the log file, propagate this boolean into those APIs that start/stop swtpm emulator. For now, just pass true. The juicy bits are soon to come. Signed-off-by: Michal Privoznik --- src/qemu/qemu_security.c | 13 +++++++++---- src/qemu/qemu_security.h | 4 +++- src/qemu/qemu_tpm.c | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index d9a1ee5f56..def4061488 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -507,6 +507,7 @@ qemuSecurityRestoreNetdevLabel(virQEMUDriver *driver, * @cmd: the command to run * @uid: the uid to run the emulator * @gid: the gid to run the emulator + * @setTPMStateLabel: whether TPM state should be labelled, or just logfile * @existstatus: pointer to int returning exit status of process * @cmdret: pointer to int returning result of virCommandRun * @@ -523,6 +524,7 @@ qemuSecurityStartTPMEmulator(virQEMUDriver *driver, virCommand *cmd, uid_t uid, gid_t gid, + bool setTPMStateLabel, int *exitstatus, int *cmdret) { @@ -535,7 +537,7 @@ qemuSecurityStartTPMEmulator(virQEMUDriver *driver, transactionStarted =3D true; =20 if (virSecurityManagerSetTPMLabels(driver->securityManager, - vm->def, true) < 0) { + vm->def, setTPMStateLabel) < 0) { virSecurityManagerTransactionAbort(driver->securityManager); return -1; } @@ -560,7 +562,8 @@ qemuSecurityStartTPMEmulator(virQEMUDriver *driver, virSecurityManagerTransactionStart(driver->securityManager) >=3D 0) transactionStarted =3D true; =20 - virSecurityManagerRestoreTPMLabels(driver->securityManager, vm->def, t= rue); + virSecurityManagerRestoreTPMLabels(driver->securityManager, + vm->def, setTPMStateLabel); =20 if (transactionStarted && virSecurityManagerTransactionCommit(driver->securityManager, @@ -575,7 +578,8 @@ qemuSecurityStartTPMEmulator(virQEMUDriver *driver, =20 void qemuSecurityCleanupTPMEmulator(virQEMUDriver *driver, - virDomainObj *vm) + virDomainObj *vm, + bool restoreTPMStateLabel) { qemuDomainObjPrivate *priv =3D vm->privateData; bool transactionStarted =3D false; @@ -583,7 +587,8 @@ qemuSecurityCleanupTPMEmulator(virQEMUDriver *driver, if (virSecurityManagerTransactionStart(driver->securityManager) >=3D 0) transactionStarted =3D true; =20 - virSecurityManagerRestoreTPMLabels(driver->securityManager, vm->def, t= rue); + virSecurityManagerRestoreTPMLabels(driver->securityManager, + vm->def, restoreTPMStateLabel); =20 if (transactionStarted && virSecurityManagerTransactionCommit(driver->securityManager, diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h index e01d4699e6..969a47fc17 100644 --- a/src/qemu/qemu_security.h +++ b/src/qemu/qemu_security.h @@ -90,11 +90,13 @@ int qemuSecurityStartTPMEmulator(virQEMUDriver *driver, virCommand *cmd, uid_t uid, gid_t gid, + bool setTPMStateLabel, int *exitstatus, int *cmdret); =20 void qemuSecurityCleanupTPMEmulator(virQEMUDriver *driver, - virDomainObj *vm); + virDomainObj *vm, + bool restoreTPMStateLabel); =20 int qemuSecuritySetSavedStateLabel(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index d2f5bfb055..8dba716ef2 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -962,7 +962,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, } } else if (qemuSecurityStartTPMEmulator(driver, vm, cmd, cfg->swtpm_user, cfg->swtpm_gr= oup, - NULL, &cmdret) < 0) { + true, NULL, &cmdret) < 0) { goto error; } =20 @@ -1139,7 +1139,7 @@ qemuExtTPMStop(virQEMUDriver *driver, =20 qemuTPMEmulatorStop(cfg->swtpmStateDir, shortName); if (!(outgoingMigration && qemuTPMHasSharedStorage(vm->def))) - qemuSecurityCleanupTPMEmulator(driver, vm); + qemuSecurityCleanupTPMEmulator(driver, vm, true); } =20 =20 --=20 2.37.4