From nobody Mon Feb 9 03:52:02 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=1652196390; cv=none; d=zohomail.com; s=zohoarc; b=EoFx3x+jW22linR4DLqJjIdc5+tNW8SURC17N22EMmBx0xHBLLs3dz/qcmEzG/pjgLulbU8k7DddKRiY0XwTvQnYYdmplgeomDxgKhKynkF9P7sMpaMMqffCGe62NU2CjWrreAOHT04Yx3ogIQTD5ZXGFUra91+Y1FNpgxjrEg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196390; 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=8D/bxVFbEviVuAUwDC3fxSkmVReBf+t+eYtlF8lG9mA=; b=hVvZEU0m+niy8DZx+yOgfqANZwPUZxpa9snsYmqP0gmyMYIAtKw6XwbAPTeBmEBgCNqm//1y+1Tpb4chCorDaqfjZSiVfekJjpRCcPZ5z2cpF3cQ+CVZCCXoq+7OEPUFJYLtSnLg9aA5WwFR5QvKSSkovTHvVz/NDH+NmOx9y8g= 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 1652196390269232.29408686331226; Tue, 10 May 2022 08:26:30 -0700 (PDT) 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-407-Zapfvy0uMh2PPwDFrRU9uA-1; Tue, 10 May 2022 11:20:39 -0400 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 5E5062919EBB; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43CF8C28106; Tue, 10 May 2022 15:20:29 +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 28934194706A; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3F0FA1947055 for ; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2098B202699A; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FBE9200C0DA for ; Tue, 10 May 2022 15:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196389; 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=8D/bxVFbEviVuAUwDC3fxSkmVReBf+t+eYtlF8lG9mA=; b=b0uCIgJEqNfeLYMRxTOFK1OY0Yqde2whDL3zieXt+G4CNqmIWyNP9Sp0J6+kj+6SS4pR7T qeuHh/hR6Z5m+QN71WOb+/8ofCbMs1uZO2PUXbso++6wJtVFl/NVHDaEm2yzuYugLWuS9A dHYyB6kZFZcYCWyPzKiuL4O1a7zoCKE= X-MC-Unique: Zapfvy0uMh2PPwDFrRU9uA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/37] qemu: Clear 'qemuFDPass' helpers of char devices when no longer needed Date: Tue, 10 May 2022 17:19:47 +0200 Message-Id: <389d6a5b6c3edaaadfb259ef20d7ce36916a9713.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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 2.85 on 10.11.54.8 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: 1652196390881100001 Content-Type: text/plain; charset="utf-8" While the FDs are closed right after use to prevent leaks, at certain point we don't need the whole helper any more. Clear them for char devices after hotplug and on start. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_domain.c | 14 ++++++++++++-- src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_hotplug.c | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3032cbc623..95632827cb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1526,6 +1526,8 @@ qemuBuildChardevCommand(virCommand *cmd, virCommandAddArgList(cmd, "-chardev", charstr, NULL); + qemuDomainChrSourcePrivateClearFDPass(chrSourcePriv); + return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a726e2624a..2df02943bf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -908,13 +908,23 @@ qemuDomainChrSourcePrivateNew(void) } +void +qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv) +{ + if (!priv) + return; + + g_clear_pointer(&priv->sourcefd, qemuFDPassFree); + g_clear_pointer(&priv->logfd, qemuFDPassFree); +} + + static void qemuDomainChrSourcePrivateDispose(void *obj) { qemuDomainChrSourcePrivate *priv =3D obj; - qemuFDPassFree(priv->sourcefd); - qemuFDPassFree(priv->logfd); + qemuDomainChrSourcePrivateClearFDPass(priv); g_free(priv->tlsCertPath); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 358f1c163f..e13c6be399 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -356,6 +356,9 @@ struct _qemuDomainChrSourcePrivate { }; +void +qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv); + typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate; struct _qemuDomainVsockPrivate { virObject parent; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 62cfc29a16..e8e028706b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2293,6 +2293,9 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver, if (teardowndevice && qemuDomainNamespaceTeardownChardev(vm, chr) = < 0) VIR_WARN("Unable to remove chr device from /dev"); } + + qemuDomainChrSourcePrivateClearFDPass(charpriv); + return ret; exit_monitor: --=20 2.35.1