From nobody Mon Feb 9 06:02:15 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=1671608651; cv=none; d=zohomail.com; s=zohoarc; b=SJhNYaguf4e82Fg0aCQa0W37YJmemuvQ/suswcUDga+r4Q/KxZwxwSUrzQghQx9oGG/4Ab8oHszo5Rm92sIqn0AYYHhoNpGWMtIgSbS9hNkR6GiH9Ru5s9HeztQYoQOIeVkjVCnXm3ZPN7YdJc7wFar/Xeuk5T00UIGfZScf+CU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671608651; 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=NiUY3FPNaYEObOXM+BlynTrRWNC9J8+H+kg2SFRurx0=; b=PMkb1w5VIzm+iVS6YSMbXTWasNQ1PcaJjr6Kp4AbKBaaR984xeMpVZbWi2T2PRYk8R5VRt3yuqTdkuih6D/ltQROuNClYv3Qb5bt/jAvPmcDQt/rG8n0qHmj58DnhvggSemAisVJiTuepomKsDxRBvWkpWxBPZ2cveB+3CbsxfA= 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 1671608651286583.1775584477978; Tue, 20 Dec 2022 23:44:11 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-495-JHyxhC5TMiSGqhD9St368A-1; Wed, 21 Dec 2022 02:44:07 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D1A5F802C1D; Wed, 21 Dec 2022 07:44:03 +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 BCBA240C945A; Wed, 21 Dec 2022 07:44:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 230931947049; Wed, 21 Dec 2022 07:44:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 49BFE1946A78 for ; Wed, 21 Dec 2022 07:44:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2BBF0C16027; Wed, 21 Dec 2022 07:44:01 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8F2FC158BB for ; Wed, 21 Dec 2022 07:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671608650; 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=NiUY3FPNaYEObOXM+BlynTrRWNC9J8+H+kg2SFRurx0=; b=RNCAFaqn7ScVNme3DmcH3s8Rl9Hy2HxCNgTKUDmRtMFb0Hln2nt8y297JgnyeVuZ+3gxK1 p9JeNuWR7q0NeOn0oJWtmjfQ5wo5MEswEVbZ5+hC7zDApnHIw15KdDLUFZGN4ZDoKEAaY3 fid8GcmfGyBczPuqw+40I13vwgtlqOE= X-MC-Unique: JHyxhC5TMiSGqhD9St368A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] qemu_security: Introduce qemuSecuritySetTPMLabels() Date: Wed, 21 Dec 2022 08:43:53 +0100 Message-Id: <80478fb565f3acfbf8557ddc5468fad2e1a8e6c1.1671608556.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671608652874100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that we have qemuSecurityRestoreTPMLabels() we might as well have qemuSecuritySetTPMLabels(). The aim here is to remove qemuSecurityStartTPMEmulator() which couples two separate things into a single function call. Therefore, introduce qemuSecuritySetTPMLabels() which does only set seclabels on the TPM state. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_security.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_security.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 82d686b0e3..daf01bb803 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -576,6 +576,32 @@ qemuSecurityStartTPMEmulator(virQEMUDriver *driver, } =20 =20 +int +qemuSecuritySetTPMLabels(virQEMUDriver *driver, + virDomainObj *vm, + bool setTPMStateLabel) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int ret =3D -1; + + if (virSecurityManagerTransactionStart(driver->securityManager) < 0) + goto cleanup; + + if (virSecurityManagerSetTPMLabels(driver->securityManager, + vm->def, setTPMStateLabel) < 0) + goto cleanup; + + if (virSecurityManagerTransactionCommit(driver->securityManager, + -1, priv->rememberOwner) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + virSecurityManagerTransactionAbort(driver->securityManager); + return ret; +} + + int qemuSecurityRestoreTPMLabels(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h index b6f917a62f..198f8ef0d4 100644 --- a/src/qemu/qemu_security.h +++ b/src/qemu/qemu_security.h @@ -94,6 +94,10 @@ int qemuSecurityStartTPMEmulator(virQEMUDriver *driver, int *exitstatus, int *cmdret); =20 +int qemuSecuritySetTPMLabels(virQEMUDriver *driver, + virDomainObj *vm, + bool setTPMStateLabel); + int qemuSecurityRestoreTPMLabels(virQEMUDriver *driver, virDomainObj *vm, bool restoreTPMStateLabel); --=20 2.38.2