From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1758795788; cv=none; d=zohomail.com; s=zohoarc; b=jNc/ssBxbhFoibU0l36qjc0fkOBFizZUhGDdjpCP0GzUu7qGnf4u6Oo6ps2/pS4kphCkeDrFnHUvScKDCY5Z5YSMWd/oQEWvOpC1V7z42y0BGp8i6G4VPyfcRInsCGPWgNjaUUPfuwR7WTC8Xa0wBWuRH7jgEbDLLjdKVEj5rtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758795788; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=0e0TFv/CGlxU/vse5VywmrVZx48lnld4r/92cQWi2Vk=; b=AnRGca1dlrUz4KqKK+v5A63hUwofyQkp6x3w6A+IglIYscvUKyl0nUkMzt93uXVpzXuytlr19+3pFroNFdSlz9RHenW3mdo96wBfsqTtjKMUHQ/VTByBGh9utoYNPbmMVEyQxGk1zXLvGfH0FgCAjZO1IeOMLD8xDtu3L3lUeH0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1758795788270681.8592184088183; Thu, 25 Sep 2025 03:23:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 11D3643E6E; Thu, 25 Sep 2025 06:23:07 -0400 (EDT) Received: from [172.19.199.14] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 7B8BB4419E; Thu, 25 Sep 2025 05:49:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id CE50043E55; Thu, 25 Sep 2025 05:48:24 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E1CB643E6D for ; Thu, 25 Sep 2025 05:45:25 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-agWRH4J8NPuSGuIukX37eg-1; Thu, 25 Sep 2025 05:45:21 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6723019560B0; Thu, 25 Sep 2025 09:45:19 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.163]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4C70830002D0; Thu, 25 Sep 2025 09:45:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758793525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0e0TFv/CGlxU/vse5VywmrVZx48lnld4r/92cQWi2Vk=; b=K7r6WD3Q9rznO2cLf5l4JnBlhe4ZfKcbWIgHfqDblt64SbvGzOvngek5jpsKBzPsb0GlPA U/vdVkWx/abt8uUiK2LyRm4WW4TBUTHzM/lCESfKVGskxrZbFTwW704bpExmgJcHNtpGRE NmPwxALUDR1EKzLQUMvDagMXbsrNUmM= X-MC-Unique: agWRH4J8NPuSGuIukX37eg-1 X-Mimecast-MFC-AGG-ID: agWRH4J8NPuSGuIukX37eg_1758793519 To: qemu-devel@nongnu.org Subject: [PATCH v4 05/23] audio: make jackaudio use qemu_thread_set_name Date: Thu, 25 Sep 2025 10:44:23 +0100 Message-ID: <20250925094441.1651372-6-berrange@redhat.com> In-Reply-To: <20250925094441.1651372-1-berrange@redhat.com> References: <20250925094441.1651372-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Message-ID-Hash: LEHVB4G5T7NTF76BXHFQN2GQB7IRU5VM X-Message-ID-Hash: LEHVB4G5T7NTF76BXHFQN2GQB7IRU5VM X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Hanna Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Kevin Wolf , qemu-rust@nongnu.org, Richard Henderson , Markus Armbruster , Christian Schoenebeck , qemu-block@nongnu.org, Stefan Weil , "Dr. David Alan Gilbert" , Manos Pitsidianakis , Gerd Hoffmann , devel@lists.libvirt.org, Paolo Bonzini X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9_via_Devel?= Reply-To: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1758795788608116600 This has greater portability than directly call pthread_setname_np, which is only 1 out of 3 possible functions for pthreads that can set the name. The new API requires a trampoline function, since it can only set the name of the current thread. Reviewed-by: Christian Schoenebeck Signed-off-by: Daniel P. Berrang=C3=A9 --- audio/jackaudio.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 974a3caad3..69dce3f302 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -629,18 +629,36 @@ static void qjack_enable_in(HWVoiceIn *hw, bool enabl= e) ji->c.enabled =3D enable; } =20 -#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) +#if !defined(WIN32) +struct QJackThreadData { + void *(*function)(void *); + void *arg; +}; + +static void *qjack_thread_trampoline(void *targ) +{ + struct QJackThreadData *data =3D targ; + void *(*function)(void *) =3D data->function; + void *arg =3D data->arg; + + g_free(data); + qemu_thread_set_name("jack-client"); + + return function(arg); +} + static int qjack_thread_creator(jack_native_thread_t *thread, const pthread_attr_t *attr, void *(*function)(void *), void *arg) { - int ret =3D pthread_create(thread, attr, function, arg); + struct QJackThreadData *data =3D g_new0(struct QJackThreadData, 1); + data->function =3D function; + data->arg =3D arg; + int ret =3D pthread_create(thread, attr, qjack_thread_trampoline, data= ); if (ret !=3D 0) { + g_free(data); return ret; } =20 - /* set the name of the thread */ - pthread_setname_np(*thread, "jack-client"); - return ret; } #endif @@ -696,7 +714,7 @@ static void register_audio_jack(void) { qemu_mutex_init(&qjack_shutdown_lock); audio_driver_register(&jack_driver); -#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) +#if !defined(WIN32) jack_set_thread_creator(qjack_thread_creator); #endif jack_set_error_function(qjack_error); --=20 2.50.1