From nobody Mon Feb 9 07:39:07 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=1644422632; cv=none; d=zohomail.com; s=zohoarc; b=Wel5HaZeBdZ17A88PKa8tuyXC1TBxjL8kHKAERLpj1g8633zT0ERsp5u3DGI+YMHPUTn1iAj3jYIY5yqBrupTGWcIUDIFqPI9Z80e5zdTKD+hoc3OsJUPreF3MxlUtPBPHDQOrZHxR0qYZU9WOarca3BLTW7YemFz+YXYQ90/Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422632; 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=3gyMwW37bDCiaXT0EcSpPAGxPTodksy0xnCDIKwRhpQ=; b=FAAhM1DvYKECcCYfVCcoZ8sdfAwZOhweHDhwAwtJinxBMppQR6cb8pQKrWJoxN9as5M89eFVRFhPkfxHCBYUf3pIPgTXn3IToTFaSr+VQRIPDdLWmQA6JfoFUipan1stZJCy5232T9AtP24RLDRHiIHSzE/RSPExsYlmydaMzFo= 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 1644422632438498.3109168283688; Wed, 9 Feb 2022 08:03:52 -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-540-LvelwvQLNPan_-2JFTdTUQ-1; Wed, 09 Feb 2022 11:03:46 -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 223C61091DBD; Wed, 9 Feb 2022 16:03:17 +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 F1BA47DE52; Wed, 9 Feb 2022 16:03:16 +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 568BE4A705; Wed, 9 Feb 2022 16:03:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G31qJ012549 for ; Wed, 9 Feb 2022 11:03:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id C464F7DE4A; Wed, 9 Feb 2022 16:03:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AB92838C6 for ; Wed, 9 Feb 2022 16:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422632; 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=3gyMwW37bDCiaXT0EcSpPAGxPTodksy0xnCDIKwRhpQ=; b=Hm+1IQWcdFFnw81nU3/cDeg9cnpyusliv4vb3KcEqwukG3M6dWn0bH688r/K7xQ6ofapnO 1nnwxTzyh3Hil9cbIrpQ+tnwE749OzkX3SzONNQxWfHmUTUCqVhFcne6JlTrKZajReHtgJ iC2FQnlgQ3LL3x+mdhSBU+CHbaHBtqA= X-MC-Unique: LvelwvQLNPan_-2JFTdTUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/27] qemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally Date: Wed, 9 Feb 2022 17:02:18 +0100 Message-Id: <148a44a0331071b970ba3593a29052568745a624.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422651225100001 Content-Type: text/plain; charset="utf-8" Since 'cancel_path' is constructed from the 'tpmdev' argument, we can push it down into the function opening the FDs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 15 +++++++-------- src/qemu/qemu_command.h | 4 +--- tests/qemuxml2argvmock.c | 1 - 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9a51a373b0..7169b8ff90 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9737,10 +9737,14 @@ qemuBuildTPMDevCmd(virCommand *cmd, /* this function is exported so that tests can mock the FDs */ int qemuBuildTPMOpenBackendFDs(const char *tpmdev, - const char *cancel_path, int *tpmfd, int *cancelfd) { + g_autofree char *cancel_path =3D NULL; + + if (!(cancel_path =3D virTPMCreateCancelPath(tpmdev))) + return -1; + if ((*tpmfd =3D open(tpmdev, O_RDWR)) < 0) { virReportSystemError(errno, _("Could not open TPM device %s"), tpmdev); @@ -9766,10 +9770,8 @@ qemuBuildTPMBackendStr(virCommand *cmd, int *cancelfd) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - g_autofree char *cancel_path =3D NULL; g_autofree char *devset =3D NULL; g_autofree char *cancelset =3D NULL; - const char *tpmdev; *tpmfd =3D -1; *cancelfd =3D -1; @@ -9779,11 +9781,8 @@ qemuBuildTPMBackendStr(virCommand *cmd, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - tpmdev =3D tpm->data.passthrough.source->data.file.path; - if (!(cancel_path =3D virTPMCreateCancelPath(tpmdev))) - return NULL; - - if (qemuBuildTPMOpenBackendFDs(tpmdev, cancel_path, tpmfd, cancelf= d) < 0) + if (qemuBuildTPMOpenBackendFDs(tpm->data.passthrough.source->data.= file.path, + tpmfd, cancelfd) < 0) return NULL; virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index b7fcf15a1e..d84de3f093 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -251,11 +251,9 @@ qemuBuildVsockDevProps(virDomainDef *def, /* this function is exported so that tests can mock the FDs */ int qemuBuildTPMOpenBackendFDs(const char *tpmdev, - const char *cancel_path, int *tpmfd, int *cancelfd) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - ATTRIBUTE_NONNULL(4) G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_= NO_INLINE; const char * qemuAudioDriverTypeToString(virDomainAudioType type); virDomainAudioType qemuAudioDriverTypeFromString(const char *str); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index f4e2f52680..08f176667d 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -263,7 +263,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDe= f *dev G_GNUC_UNUSED) int qemuBuildTPMOpenBackendFDs(const char *tpmdev G_GNUC_UNUSED, - const char *cancel_path G_GNUC_UNUSED, int *tpmfd, int *cancelfd) { --=20 2.34.1