From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192103; cv=none; d=zohomail.com; s=zohoarc; b=UpF5PEDkzHPsghmp7QMV6znYp47lh5LAf2LpEMwTOyBLU/C2lZCSlkaUzaJweCYHDu+yEzYXDQX7sDoheE0/SQFmTU1ORXNFtiutOUs06Z6qupxNsXcR2zWeSwao4DG/MGXCaGXkJwoQNSekVKngCGN/XHLIbkQUl2bZV7sBUdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192103; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=hvdkkepkG5WrDPH/R/+dpw68nYG2BpPlD0C8UJw8Na+K7MS42hLA3cIZPslHQt2Roqm2O1SvnEhU1t7BmM9i7jNWAMym5Ku+xtNgyPQNdnYWR2A4ujPSS7dCHKZTAG7KV2OkHNM7r5mnvcwJ6Ms3WiJx0UnpJ2gCrMSSWzO173k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192103237227.6591602228449; Mon, 31 Aug 2026 09:01:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14RY-0001qy-8b; Mon, 31 Aug 2026 12:01:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14RW-0001il-Dg for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:06 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14RU-0001TI-SP for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:06 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2d942c7cc2fso7864595ad.3 for ; Mon, 31 Aug 2026 09:01:04 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192062; x=1788796862; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=OwXLC/17X8jkAh2f4GTCH5flDjuxxU+27m0CBKF77ukpqZ8g2aBkdZU1YkSfGSKy2M HPN4Vj0UHkxrsAE62sMZxWgtvG1/XORRVTKYGCk81C4OD/7w1/+u+odU5qmBpc8pJGZk nQajFHYsRyko8V1pY7F1gBi4dwkAeJKxT8HJ6nh+QPp0wToKN9JhcVvyBEh/aKfIXfKT oXADsDj/oYJSoAgJVRMDsK4tELIMwHEEUWEUNnz98kI9qhgkjYmce0fRVEZjR016+HJq gpBhPtaXFNtu7bxdHF2B2hbyzIG6PlM6W9Jb4VC9V79ovDpRjzNltOCRqC+uRrTAuHf9 t6eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192062; x=1788796862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=eePj9kIULBqoqbK0G9z8mKDFXKfzH4KBpBbsCHlvRIeewR+5mrv15Wyqbod9snNzSd zsm11fLlthc1YJToHSMpycNPpYWkTdI5LeTZby2sE8LYlXDqgWL1Td2HNghbkpoi4wmP b20UWUKkt0cfpBjp+M7Ks5ZH/PsvavIzp2pf6wELvQSPooE06rqU6fCNU1iauUeXko75 RSZBPwGHTJkGMf9LYrpcnyNuWLi5WTJXgFXHfowItlp/of+gTYnmYeqIwfdHDC1KrVDY kAnCbB5N2Um2Zn6V1d2Za7/z/ARfME7dUxiwD1gVYkUPHrtMS6ur1X28AIPvEMj1XF3n lf/Q== X-Gm-Message-State: AFuF++mHETF3apsm8VuUBDvT1mFQBF40P6gV8NrrAPfiO8h2bhIkyXN5 GlJF8iNpNxkrji8pVHHmwYIO6E2riIv5KBq9SCUKDoL6Juuud50ZV3tbpSjX9WN9KF8tKybW X-Gm-Gg: AYBFou0d9X5wxJwkbpxV64sKcr4PLRfSLT65w5MFdaCYmBau6JsKttUaGTq/05J35Ur Z7j/JSfDUh/Y3K7OJY/qtyASZaqO1HmE04Ro4eHEmIJ1B8yq0hLQykAHZus/14bgMlnWQz47m3L +rxkDbXtN6GDFfA0VvP9+1NRTznhFU6J5oCut6ZkHqNdhqAwsO/dVt1n00pdDfhEkmCj0LQUIco +t4Qg8FvsVrJ6N+f9MmCvp5svRA/wfk6/B84kEIyvtdWSHKBqLyKsa43+buD9JQN69ORQFb5jLE Ne7iT7nugx3aQDvye7HHDbEWGirp/Esw6wluO7bUO/mtvThconPIktmtv3YHshR1WVC32QXbY3q gN5FcflmS/IVIk2IiOThuwvK4P8K/e6wuHO/QQ5rpZPgu+aYUXA8sYJKG2ZpJMNrtIKXSwfiYV0 cJ5FZQ8l8oAi9jAgMhHNMzx6Ro/O0bvPWLPo6xYwjVeNWwCR6oIXTtfL3tXbPQ73cwsFL+pMY8R uKLlhyB X-Received: by 2002:a17:902:e74f:b0:2d7:5ebe:a588 with SMTP id d9443c01a7336-2d75ebeabbbmr342355695ad.13.1788192062261; Mon, 31 Aug 2026 09:01:02 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen , qemu-stable@nongnu.org Subject: [PATCH V14 01/15] qapi/misc: Fix missed query-iothreads items Date: Tue, 1 Sep 2026 00:00:22 +0800 Message-ID: <20260831160038.221776-2-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192104841158500 Content-Type: text/plain; charset="utf-8" The example is incomplete: it misses members @poll-max-ns, @poll-grow, @poll-shrink, @aio-max-batch. Messed up in commit 5fc00480ab1 (monitor: add poll-* properties into query-iothreads result) and commit 1793ad0247c (iothread: add aio-max-batch parameter). cc: qemu-stable@nongnu.org Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Signed-off-by: Zhang Chen --- qapi/misc.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 22b7afed9f..c71a5fe657 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -123,11 +123,19 @@ # <- { "return": [ # { # "id":"iothread0", -# "thread-id":3134 +# "thread-id":3134, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # }, # { # "id":"iothread1", -# "thread-id":3135 +# "thread-id":3135, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # } # ] # } --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192119; cv=none; d=zohomail.com; s=zohoarc; b=kb9TivdIlDMciQx8FrIMQNUhBGUlSB7NRrgLGhtsc0ppHomdj3pWrICJY0+AhYA311+1OmkQoRWLOii6EuhDq29A9SWE4Qbii4/mzH0QeHbPHa2B1vbZCEWlMXGvRR0r8XNMJZyLvFa6Dh/enJceY2Hj61bbcs8x3KQV/y3IxJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192119; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7kTopEGydTREHYeOsabqtmm4GGKT4ofP/qcSIsI+niE=; b=icbH+9uoAZCyS06gzAOlDHMj0tBJ7srZhd4XC3Fk4Z6e3PPf5+93NjtaNjSTzPfuVQTC6IEMSx1dEWevwFxMnbe9LKheJs/CYe1bjDpTSadfoFwvEPThw/8Ld/ttQ/HVV+8Unv4745flW6IZ4XpN20BbXIptgly1jyODGFq0v+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192119286575.2288083050272; Mon, 31 Aug 2026 09:01:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Rb-0001zg-R3; Mon, 31 Aug 2026 12:01:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Ra-0001xk-4q for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:10 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14RY-0001U4-7O for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:09 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2d9201076b3so13482785ad.0 for ; Mon, 31 Aug 2026 09:01:07 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192067; x=1788796867; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7kTopEGydTREHYeOsabqtmm4GGKT4ofP/qcSIsI+niE=; b=Sy/N7kgcoAMbLsO4cmVlH0zMIrs9hBkUwP6zq6B9TkAeocs9Sxt0NsDF0+Orl2431/ 9p7Cvry87YDHspuSXbuaaBD+872oJiI2xdaFT5O/fP+Io5dalGZwBxlT5okgWLgBnKe/ x10RvTjnfEZC0l5BDcvl9z2fHgfLK8RtKQhbbq9KPuSGPDtjBOrNENf/88Q2RpjGxmkJ yy0MKfUOcXvK6F1m8Sa60V27zQe1q0gZlO1WypI8OCgecRuS4vaGPedFokNlQE7ntGp6 k8S8kxke1WwH9m4tnKrNOBlTJZjRqjQ3AeCy0S/Zg2DDey2IK6Vx3LFgyStNPvveCCEy fGGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192067; x=1788796867; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7kTopEGydTREHYeOsabqtmm4GGKT4ofP/qcSIsI+niE=; b=GiGuwQNrkEbVMu5SJPi5ydkUGr4/G22lcpZP5R5yGZvj5zfXXH69hn/Srhhk1Zjj41 ZQDvAyc44t5NsPjrGHDPN14JgdlemssllfEXTqLVLizXcbKTh/nw9Uu/qE5ujgu/Rs88 x8djQoF21bmp9ZVplF/YzN4+EAOdjzZD10zgXarBntp4f4nSP7hXeiA2i8o084NS5UHE R1diO1nbee3q9v/YI8RjRQwKOuGC9fmOR5YGxqplJ3ZnbkdWUVVHNs/AhRTiAABCVlTd /8/eL9Qxg5D1jqwAXzLLlFFJ+cWSYH1b9FCdHnIwK12GUUkUI9Bd1MjyWqiMtS+ZCsSM cWyw== X-Gm-Message-State: AFuF++leyagoTDKrUw/rsrd/+Uq6ql9EU8G9yVHKYjxQd15LfIoIQM93 3DRPcdej2Xi1ma9rv64/56C/gWLEMwzQQ7HSXGO9QCKYDcVd4AfhZ2kq4nJYeAWoHZJ8Llra X-Gm-Gg: AYBFou2yWpLpcffANCyQOMLZiuIcRdYKe3rIasCtHJ1eKueaTv2H4Bw1DSQ6HV8nfa9 5d5BeWGOKso2nBNMZLDK+VeRqGE69kiW40wpOJeOjH3p8eckZGRTh9cQC27zuXhasiCEV5VMQBV A48a7MznuIZA4zbqALRlgLs0HMnR9XUaOJk1oifnAS5mOAEXgVcxtgtW+d75rkLErUpKoBRSKo9 aCUhD/aXmpaX92EyTqkVcJSHJ2zpDUr1dp+LQ3VUPKD74IIfDqTcChTXPCy00FsCqAJsH1q689p wlvXfrje1Pdyqu1xIVQFTPcBunADnyXe/nFQuLrwzppjlF2amKsh/sgFmxWWqecXKtzgPdUS7ZD Mfi7pHMiABUfcYqTc4gYXyZy/C7xjN4PN1y3uyA0qXpiOVSSLMWd97KbCsOrly61wB+XBdjafT0 00h6lKLSfsut7LYkbDRU1/AhAcz6HOzAjjG5RSZFrAX3jttcpKl8Tbk23hggkO/3lqbpfcxOh5y 5Rmh4b6 X-Received: by 2002:a17:903:3c65:b0:2c9:bf82:dd11 with SMTP id d9443c01a7336-2d94a784931mr24325895ad.7.1788192066369; Mon, 31 Aug 2026 09:01:06 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 02/15] iothread: introduce holder tracking Date: Tue, 1 Sep 2026 00:00:23 +0800 Message-ID: <20260831160038.221776-3-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192121004158500 Content-Type: text/plain; charset="utf-8" IOThreads do not record the QOM objects and block exports that use them, making runtime introspection and hotplug debugging difficult. Add: - holders: a list describing what is holding an iothread - iothread_ref(): add a holder to the list - iothread_unref(): remove a holder from the list A holder can identify either a QOM object or a block export. A later patch will expose this information through query-iothreads. Reviewed-by: Stefan Hajnoczi Reviewed-by: Markus Armbruster Signed-off-by: Zhang Chen --- include/system/iothread.h | 5 +++ iothread.c | 63 ++++++++++++++++++++++++++ qapi/misc.json | 94 ++++++++++++++++++++++++++++++++++----- 3 files changed, 150 insertions(+), 12 deletions(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index a1ef7696cb..b8aeb32b0e 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -18,6 +18,7 @@ #include "qemu/thread.h" #include "qom/object.h" #include "system/event-loop-base.h" +#include "qapi/qapi-types-misc.h" =20 #define TYPE_IOTHREAD "iothread" =20 @@ -50,6 +51,7 @@ struct IOThread { bool stopping; /* has iothread_stop() been called? */ bool running; /* should iothread_run() continue? */ int thread_id; + IOThreadHolderList *holders; =20 /* AioContext poll parameters */ int64_t poll_max_ns; @@ -82,4 +84,7 @@ void iothread_destroy(IOThread *iothread); */ bool qemu_in_iothread(void); =20 +void iothread_ref(IOThread *iothread, const IOThreadHolder *holder); +void iothread_unref(IOThread *iothread, const IOThreadHolder *holder); + #endif /* IOTHREAD_H */ diff --git a/iothread.c b/iothread.c index 3558535b40..66dfde626e 100644 --- a/iothread.c +++ b/iothread.c @@ -21,10 +21,71 @@ #include "system/iothread.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-misc.h" #include "qemu/error-report.h" #include "qemu/rcu.h" #include "qemu/main-loop.h" =20 +/* Add a deep copy of @holder to @iothread's list of holders. */ +void iothread_ref(IOThread *iothread, const IOThreadHolder *holder) +{ + assert(holder); + + QAPI_LIST_PREPEND(iothread->holders, QAPI_CLONE(IOThreadHolder, holder= )); +} + +static int iothread_holder_compare(const IOThreadHolder *holder_a, + const IOThreadHolder *holder_b) +{ + const char *name_a, *name_b; + + if (holder_a->type !=3D holder_b->type) { + return holder_a->type - holder_b->type; + } + + switch (holder_a->type) { + case IO_THREAD_HOLDER_KIND_QOM_OBJECT: + name_a =3D holder_a->u.qom_object.qom_path; + name_b =3D holder_b->u.qom_object.qom_path; + break; + case IO_THREAD_HOLDER_KIND_BLOCK_EXPORT: + name_a =3D holder_a->u.block_export.export_id; + name_b =3D holder_b->u.block_export.export_id; + break; + default: + g_assert_not_reached(); + } + + return strcmp(name_a, name_b); +} + +/* + * Remove @holder from @iothread's list of holders. + * + * It is a programming error if @holder is not present. + */ +void iothread_unref(IOThread *iothread, const IOThreadHolder *holder) +{ + IOThreadHolderList **prev =3D &iothread->holders; + IOThreadHolderList *curr; + + assert(holder); + + while (*prev) { + curr =3D *prev; + if (iothread_holder_compare(curr->value, holder) =3D=3D 0) { + *prev =3D curr->next; + curr->next =3D NULL; + qapi_free_IOThreadHolderList(curr); + return; + } + prev =3D &curr->next; + } + + g_assert_not_reached(); +} + static void *iothread_run(void *opaque) { IOThread *iothread =3D opaque; @@ -129,6 +190,7 @@ static void iothread_instance_finalize(Object *obj) iothread->main_loop =3D NULL; } qemu_sem_destroy(&iothread->init_done_sem); + qapi_free_IOThreadHolderList(iothread->holders); } =20 static void iothread_init_gcontext(IOThread *iothread, const char *thread_= name) @@ -373,6 +435,7 @@ static int query_one_iothread(Object *object, void *opa= que) info =3D g_new0(IOThreadInfo, 1); info->id =3D iothread_get_id(iothread); info->thread_id =3D iothread->thread_id; + info->holders =3D QAPI_CLONE(IOThreadHolderList, iothread->holders); info->poll_max_ns =3D iothread->poll_max_ns; info->poll_grow =3D iothread->poll_grow; info->poll_shrink =3D iothread->poll_shrink; diff --git a/qapi/misc.json b/qapi/misc.json index c71a5fe657..eb3b89293d 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -67,6 +67,55 @@ ## { 'command': 'query-name', 'returns': 'NameInfo', 'allow-preconfig': true } =20 +## +# @IOThreadHolderBlockExport: +# +# @export-id: The unique block export identifier. +# +# Since: 11.2 +# +## +{ 'struct': 'IOThreadHolderBlockExport', + 'data': { 'export-id': 'str' } } + +## +# @IOThreadHolderQomObject: +# +# @qom-path: Path to the object in the QOM tree. +# +# Since: 11.2 +# +## +{ 'struct': 'IOThreadHolderQomObject', + 'data': { 'qom-path': 'str' } } + +## +# @IOThreadHolderKind: +# +# @block-export: A block export. +# @qom-object: A QOM object. +# +# Since: 11.2 +## +{ 'enum': 'IOThreadHolderKind', + 'data': [ 'block-export', 'qom-object' ] } + +## +# @IOThreadHolder: +# +# The block export or QOM object holding the iothread. +# +# @type: the kind of iothread holder. +# +# Since: 11.2 +## +{ 'union': 'IOThreadHolder', + 'base': { 'type': 'IOThreadHolderKind' }, + 'discriminator': 'type', + 'data': { + 'block-export': 'IOThreadHolderBlockExport', + 'qom-object': 'IOThreadHolderQomObject' } } + ## # @IOThreadInfo: # @@ -76,6 +125,10 @@ # # @thread-id: ID of the underlying host thread # +# @holders: the QOM objects or block exports currently holding this +# iothread. When a holder is detached or destroyed, it is removed +# from this list. (Since 11.2) +# # @poll-max-ns: maximum polling time in ns, 0 means polling is # disabled (since 2.9) # @@ -98,6 +151,7 @@ { 'struct': 'IOThreadInfo', 'data': {'id': 'str', 'thread-id': 'int', + 'holders': ['IOThreadHolder'], 'poll-max-ns': 'int', 'poll-grow': 'int', 'poll-shrink': 'int', @@ -122,20 +176,36 @@ # -> { "execute": "query-iothreads" } # <- { "return": [ # { -# "id":"iothread0", -# "thread-id":3134, -# "poll-max-ns":32768, -# "poll-grow":0, -# "poll-shrink":0, -# "aio-max-batch":0 +# "id": "iothread0", +# "thread-id": 3134, +# "holders": [ +# { +# "qom-path": "/machine/peripheral/blk1/virtio-bac= kend", +# "type": "qom-object" +# }, +# { +# "qom-path": "/machine/peripheral/blk2/virtio-bac= kend", +# "type": "qom-object" +# } +# ], +# "poll-max-ns": 32768, +# "poll-grow": 0, +# "poll-shrink": 0, +# "aio-max-batch": 0 # }, # { -# "id":"iothread1", -# "thread-id":3135, -# "poll-max-ns":32768, -# "poll-grow":0, -# "poll-shrink":0, -# "aio-max-batch":0 +# "id": "iothread1", +# "thread-id": 3135, +# "holders": [ +# { +# "export-id": "export0", +# "type": "block-export" +# } +# ], +# "poll-max-ns": 32768, +# "poll-grow": 0, +# "poll-shrink": 0, +# "aio-max-batch": 0 # } # ] # } --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192226; cv=none; d=zohomail.com; s=zohoarc; b=AJidgYF48C0Tmq8LTriyFx1zAPi3VnnSb/geUuYLGU3H7a/B7XH0Jvaj6Tl5BXUAz2X+HnqzQ3OUYXBlRenhojPBk36vFQPtK/9rFUBdxnKsk6JqwZrznPrjACQ2mNEjHgUqV666WCTW4cXISflINJfQN9WAChpszuhAmjh04xI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192226; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W884SMK/ObSjn0HriCAb/q7q3xniAJ75u4sPHtyJFWw=; b=fNlAKEe7BhCsMSViT2tzVcnFyc2osk3FsCci2fKYs9ZcseGBmvTPU07quStlzR8vmmr98y69TjqM60Tui2j+z6Fe2fwLI2WEvwzA5OUdrtQOodcvpkm0zGAvLHfX/OUeRetGTrlXEaaL9c8PyJZhShfLFBmVOHJTMbL5YNE/9lM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192226651972.4781058476082; Mon, 31 Aug 2026 09:03:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Rx-0002LM-JG; Mon, 31 Aug 2026 12:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Rg-00025Q-JK for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:24 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Re-0001Vb-Ov for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:16 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2d6d28aa26cso25855435ad.2 for ; Mon, 31 Aug 2026 09:01:14 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192073; x=1788796873; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=W884SMK/ObSjn0HriCAb/q7q3xniAJ75u4sPHtyJFWw=; b=q4z37CnxitvbMvz01zF2kkK95WshiF0uUcx3SlmUTILv2YYdMNH3PdCSTPkUljuQUH kXPODz0+aYhgxGvkTeuMveyg+6YRQUi8p2BlhATECqiyp8zQY4ELrUVzMO93+K9YksX2 o5P8Wj4jDSwPt77D9PBaSd4yxvSvzWnC3KK3uco+S0no5rVzYEDEZw3R/jS7DDqI6ypn Ocvqm5DTYR6m+ljveWpg5mq/cm74hcefxQfike2H14eQHFNCmTrDeLEX+b/mkF191dFH jnw+QM+mTnmg2yzzlaH84tF/eJE5vanqqjJ2aNrDQ2iy50aAfm7lqdm7qyKRR5kB6m1q d9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192073; x=1788796873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=W884SMK/ObSjn0HriCAb/q7q3xniAJ75u4sPHtyJFWw=; b=niImoui0M8t8Y71Giu/PC1B3xzA9ZKL/elV0gsWN1OdCKXr605hLb4ceAJDWgB+NQs 7reHQwGCZG4CJfb2Rme2N/AWLWNmHAuB5KbbITrOdWq/UFhn9M+PImlE9XnOtKgWbtBt NlxQXi9Kfo+8lsYUpmRzcaBisL70VS7+JB7+GfhVuKoH386cktvWz+Rz/sCURgwSzLN0 8tOQ/1+Bpj0w8FBsomE7+FhalZcA8Oz5Opr5oOkNi3eStlqyHPpPv0FiCADnGe0RDgFy bWIXQ0atvpCvCzFuW2yRFZp2Luf4LKFoN5I/9EE3d7ciZhwOLfKjHAEuS2KIGtmAuQFW tI5w== X-Gm-Message-State: AFuF++lQ7kujDKJMRI9Y+X8GxE+LXElbuwqRBh1SEEMJSslavqio6+lr gwcfGfJDTRsZ+YCQfOB39yyjCx+04CxmoS56guSpGfDSLyM1elchXpwpoGkZuIQlG1vYSWmc X-Gm-Gg: AYBFou0jR6Ie5BhGBqk1IL0P7SchnUUnZZqoB8TYw1TQF75UDoaMDwspKYplrp/2l5Y AxtaJglKiGRB5iuEZ0TTKOHngOg/lO1LDmyE6eEn12ubVEOn8MYdIGVN+aNBRZ1pco4jah9MEj+ gXlPJpSarruwH1prBz+P5YXN57qgQK3TO/ukjL/Z4SuuMix3iLKDJ1xmivIV0EjUtuU6c8Qwi0P yAJbueFcMjhlzepF7h7HqD3E4aYLZMNO5KTsbk+pMNQoQC31GdTadNfFUAFxPvru+FQiyoB6dQ2 cs0rujBkzakgt1SqEjI3kQ03i1/rRI33dAF+l+PvDk/g9bRltRkgPeDnZ/yAx3r9LU79ZWYaiqp zz2WQwJiEqgBaFKR229AKZRs/XUyjYrwe89LEzocyYTdXmwA7CVmB+tymJUOOmlxk2/dGq4rJJw bwm2XqCNo535Nvb5KCh1JJ5CjH6oyyOdNvFjgQ/RJH1GmWEf73umdw7nB8YtIj/gHX+Tudb4FHp bd/n8jF X-Received: by 2002:a17:903:f8d:b0:2ca:f21a:a6c5 with SMTP id d9443c01a7336-2d74dbea25bmr454472955ad.1.1788192071283; Mon, 31 Aug 2026 09:01:11 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 03/15] iothread: add holder-aware AioContext accessors Date: Tue, 1 Sep 2026 00:00:24 +0800 Message-ID: <20260831160038.221776-4-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192227930158500 Content-Type: text/plain; charset="utf-8" Introduce iothread_ref_and_get_aio_context() with a holder argument and its counterpart iothread_unref_and_put_aio_context(). Previously, users of an IOThread AioContext did not explicitly record their identity, making it difficult to debug which devices or subsystems were pinning an IOThread. These new helpers provide the infrastructure for callers to register their identity. Subsequent patches convert existing users to the new helpers. Registering a holder takes an IOThread object reference so that the IOThread and its AioContext stay alive until the matching put operation. Document the ownership and BQL requirements. Reviewed-by: Stefan Hajnoczi Signed-off-by: Zhang Chen Reviewed-by: Markus Armbruster --- include/system/iothread.h | 22 ++++++++++++++++++++++ iothread.c | 24 +++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index b8aeb32b0e..f6c5f95dd9 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -67,6 +67,28 @@ DECLARE_INSTANCE_CHECKER(IOThread, IOTHREAD, char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); AioContext *iothread_get_aio_context(IOThread *iothread); + +/* + * Register @holder and return @iothread's AioContext. The holder is copi= ed, + * and a reference is taken on @iothread so that both the IOThread and its + * AioContext remain alive. + * + * The caller must eventually call iothread_unref_and_put_aio_context() wi= th an + * equivalent holder. This function is not thread-safe and must be called + * under the Big QEMU Lock (BQL). + */ +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + const IOThreadHolder *holder); + +/* + * Unregister @holder and release the corresponding reference on @iothread. + * Calling this function without a matching + * iothread_ref_and_get_aio_context() call is a programming error. + * + * This function is not thread-safe and must be called under the BQL. + */ +void iothread_unref_and_put_aio_context(IOThread *iothread, + const IOThreadHolder *holder); GMainContext *iothread_get_g_main_context(IOThread *iothread); =20 /* diff --git a/iothread.c b/iothread.c index 66dfde626e..58dace351c 100644 --- a/iothread.c +++ b/iothread.c @@ -33,6 +33,11 @@ void iothread_ref(IOThread *iothread, const IOThreadHold= er *holder) assert(holder); =20 QAPI_LIST_PREPEND(iothread->holders, QAPI_CLONE(IOThreadHolder, holder= )); + /* + * This guarantees that the IOThread and its AioContext remain alive + * as long as there is a holder. + */ + object_ref(OBJECT(iothread)); } =20 static int iothread_holder_compare(const IOThreadHolder *holder_a, @@ -78,6 +83,7 @@ void iothread_unref(IOThread *iothread, const IOThreadHol= der *holder) *prev =3D curr->next; curr->next =3D NULL; qapi_free_IOThreadHolderList(curr); + object_unref(OBJECT(iothread)); return; } prev =3D &curr->next; @@ -199,7 +205,7 @@ static void iothread_init_gcontext(IOThread *iothread, = const char *thread_name) g_autofree char *name =3D g_strdup_printf("%s aio-context", thread_nam= e); =20 iothread->worker_context =3D g_main_context_new(); - source =3D aio_get_g_source(iothread_get_aio_context(iothread)); + source =3D aio_get_g_source(iothread->ctx); g_source_set_name(source, name); g_source_attach(source, iothread->worker_context); g_source_unref(source); @@ -421,6 +427,22 @@ AioContext *iothread_get_aio_context(IOThread *iothrea= d) return iothread->ctx; } =20 +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + const IOThreadHolder *holder) +{ + /* Add IOThreadHolder to the list */ + iothread_ref(iothread, holder); + + return iothread->ctx; +} + +void iothread_unref_and_put_aio_context(IOThread *iothread, + const IOThreadHolder *holder) +{ + /* Delete IOThreadHolder from the list */ + iothread_unref(iothread, holder); +} + static int query_one_iothread(Object *object, void *opaque) { IOThreadInfoList ***tail =3D opaque; --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192222; cv=none; d=zohomail.com; s=zohoarc; b=HJ+SM/U5RNIWNJM4m2Rv6jvPaX5TDidXjLM7OR8u6oGRb6/qAZuZ09KvXuprlUYOSMTNRzyWsHp+Wjwek33A0Bq9zxoRVQkg2aVVwadfvtT0L3SyxOKA7JUHY+w4dzDSqSfzYkxzZ2DY/r4K4VD4lBkcCVvoQ5EhPJHu4Tao9mI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192222; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZazPTB8lxfIB8WM1wpaGEcezQFI0+RTAozYokTq4HPk=; b=SQ1qxKx67XlMsDjodoGVUW7OTCy6Yf8q+m6r/k9PQ4F8u2l+Z4TOUd4nBIo9w58QC0X8ZJuT0ptQnG/zQDJzj/WtSjwBUl8Kp52YXVUWAxILCchwCdezxqA7hIR6rshy7pAZbVxFhTtM92Qx7y6eA4SC37qsknOt7BqS0iZ8Gl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192222858290.0927832190223; Mon, 31 Aug 2026 09:03:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Rx-0002KR-9y; Mon, 31 Aug 2026 12:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Rm-00029D-R5 for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:24 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Rj-0001WR-Ne for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:21 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2cf452def93so20165ad.1 for ; Mon, 31 Aug 2026 09:01:19 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192078; x=1788796878; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZazPTB8lxfIB8WM1wpaGEcezQFI0+RTAozYokTq4HPk=; b=eaKCgeodP95iBi1qdHw5mqelgbYCTI/wRlMA1Pp272Uv/XsRuxz4kNMdtGNRWv9Qbi +t+H22Ohm4Vp6VcmJerEwD61jhZ5Te2AhR3jJvMcDOkeILq2lI5+xvWS5hNJmNhekzfw pmB8//xIvPwE1weEDVDDQSsdkGw0W7Mf0CE89u3Qe6OhzTL2JT5rNfbUsB8610W38j8P OM6KueLNVTk5CYddHnYGyF1bW8NUx9mS4pIxdS/3cSwbjcI5axhkgqzreCizWSiNzNtO sltQOo8q67BQ8/u+X6YjcOd01bcf/kA12DIYzVx1cVgOO5nyFfjNkUwtq3E9/ozuM0Au 8Q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192078; x=1788796878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZazPTB8lxfIB8WM1wpaGEcezQFI0+RTAozYokTq4HPk=; b=Jl8yCnzI+sOozwJ7wcIHHs3NyTERZSD78h0J6bTLIBSNVN4onXsm3ke/NgIGfnFgXC irV3/04ctuK35BHTefY1KGs6XMppgiTqcN42JpfD4AyWY1PHO55U8IVjS0lXmVIEW6UB Xd29pNxwdqHriUcA9eMyln6vEyQ9S2+xClvCL/Yomt35Jai8lSBX59H4+dd8SU++QC3q c/AioqKrr8o9vKJx2k+IrUgLCLJfC/v1MaPsBV33KXzcAVZNSJdBFY6ZARim28zJ9f8h CWn019Xo+S0q5x01od79h/r81/V/DaMeyWaJXay13wMAryKkpH3mV/F2ttX1FSdp3Wph V/zw== X-Gm-Message-State: AFuF++kG8QeSo9iSN0jsTJulUsX9SV3AHjVm8l9EiI5Ut0hiXASKeoJm kOlK5qtkgeYAhczdBTtZdzy/lebCoy7A0KdZX3cHiGLlozIT7IZ4QZAdroF0HqS30xupRSSj X-Gm-Gg: AYBFou1WLnghNlSlBM9e7ciLdISTlDyrrxc4/wjuRounjJ7F/DmBZIxbIDdN6duDirE W3UIVn7YMEDSqAK5u/lQZTKZODFhWBGElq/Nc2CaqxnDVgccX1/Pq8AVZIAs6eEIbi/2v6+q90c ufgdHPlIDg5Z/rhi0oSuKlcDEk6e7hoaHfwY/LXWFwFinvRZNxFK9RQvNToLnLD4EXxzUd4nIq+ BU4/jMOt+9u1qMWriG2lzsHjVthhrJZVjiAxwptQlVNhM8il55PlMfnOZPzx4LhATnx1COsENl8 2lIZEmAcCaBpjUjAEcuI7g4jkJ2LPvPQZu3vltd9sLhLn3QIUxQyWjvQyGtJhVktvMazrWLAKS8 7NgNWKjpgY72sGOGhDwk0JIWCxxydOKmqmwK70awh6dkjiV/5qef7WQIW2lz+LhmC9pywu1Qinz v8G0q7LLd94KXFNCz3pPgTOJyYj9rrmLokyEUgQ3DgtRlL7KJTpgwaxGNLzvIKoSvQtZ1m5YNJc HZgfOI7 X-Received: by 2002:a17:903:40cc:b0:2d6:ee34:c043 with SMTP id d9443c01a7336-2d91b018bf4mr72436985ad.11.1788192077727; Mon, 31 Aug 2026 09:01:17 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 04/15] iothread: introduce iothread_unsafe_get_aio_context() Date: Tue, 1 Sep 2026 00:00:25 +0800 Message-ID: <20260831160038.221776-5-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192224412154100 Content-Type: text/plain; charset="utf-8" Add an explicitly unsafe accessor for legacy callers that cannot provide a matching holder lifecycle, and convert blockdev.c to use it. Keep iothread_get_aio_context() temporarily so that later caller conversions remain independently buildable. It will be removed after all production callers have migrated. New code should use iothread_ref_and_get_aio_context(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Zhang Chen --- blockdev.c | 2 +- include/system/iothread.h | 10 ++++++++++ iothread.c | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 6e86c6262f..baeab3a3e1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3683,7 +3683,7 @@ void qmp_x_blockdev_set_iothread(const char *node_nam= e, StrOrNull *iothread, goto out; } =20 - new_context =3D iothread_get_aio_context(obj); + new_context =3D iothread_unsafe_get_aio_context(obj); } else { new_context =3D qemu_get_aio_context(); } diff --git a/include/system/iothread.h b/include/system/iothread.h index f6c5f95dd9..2ef8c1a1bb 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -68,6 +68,16 @@ char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); AioContext *iothread_get_aio_context(IOThread *iothread); =20 +/* + * Return @iothread's AioContext without registering a holder or taking a + * reference on @iothread. The caller must ensure that the IOThread remai= ns + * alive for as long as the returned AioContext is used. + * + * This API exists for legacy callers without a clear ref/unref lifecycle.= Do + * not use it in new code; use iothread_ref_and_get_aio_context() instead. + */ +AioContext *iothread_unsafe_get_aio_context(IOThread *iothread); + /* * Register @holder and return @iothread's AioContext. The holder is copi= ed, * and a reference is taken on @iothread so that both the IOThread and its diff --git a/iothread.c b/iothread.c index 58dace351c..803d6ce3c3 100644 --- a/iothread.c +++ b/iothread.c @@ -443,6 +443,11 @@ void iothread_unref_and_put_aio_context(IOThread *ioth= read, iothread_unref(iothread, holder); } =20 +AioContext *iothread_unsafe_get_aio_context(IOThread *iothread) +{ + return iothread->ctx; +} + static int query_one_iothread(Object *object, void *opaque) { IOThreadInfoList ***tail =3D opaque; --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192240; cv=none; d=zohomail.com; s=zohoarc; b=IoI1Ev+OT9oeTHKsjpTqW3XyJaLmu+1zA8AwOIOBTwgEjmMMmOv2VC/03+SLGCiQnUnYgaARJPh1X+ejnHMlz/KZSGUokXdvV31+yEJBv6wt4zrGAP9zXmwNs3g0Oa9seKcP98BP/llvg+/IMCCd4Q2bRjHoIO9vYA5JWScEUfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192240; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=bMkZRZcyJCm29oLh6jmGh9a4NL0YRwNoI6czK2otpILJif8LOpSl1SHRjb+FvZPLyJYUYqM9RGk7mW/mf/SSm1foRQQHu4qIil9ZGWm+u6Pqgv0m79uyoxWxJt2DucjGvjyDxmXKEHVAW/8wwYVBpuxC23u+WHAuhjh1C+psdSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192240368758.1231922535945; Mon, 31 Aug 2026 09:04:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Rx-0002Lq-UY; Mon, 31 Aug 2026 12:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Rq-0002Bu-QO for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:31 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Rp-0001YB-0U for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:26 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-c9e7391839cso3885980a12.0 for ; Mon, 31 Aug 2026 09:01:24 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192083; x=1788796883; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=bcJFbVIBsrGc95HF95TEN7xn48gIzzLJclnT1A0YfAjnwCrkTG0545+W3+u7saatBO T2TGZTFos5QwmBbGrbAVP5ewd7fWwfhli4sixwezQudZQhKzAj+SHyD8YiOe5tm2NTuQ 2lvxV/5YTmqzazIOkVmfcvcuAGGyOawd0VQdJxJLRIt8lDlMdja7BKw3v2A/8tEre6Pl vLSmhhzoQexax3eB0qQ8E6hbQ5o4O1pg4Tq+bWSyqEhg/PKS7smNFd9RWt7+EyiMU5Ue MCILtlEVky++dVZIxc5nBR4DzMcDTfmVr08WRH0fKBo+Wf95o4chMhzn9Vz8ZdbNJaB0 bAWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192083; x=1788796883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=ss8Sg/fhRmm7iFy+VuQzCDCVfNZKHJu5X39PE9w3UC/JxzzwLNxCucVR5ggu6t8nzM Sr/8lyadO12tMJdEFWZUpMwUzKMMe90RgA8ZsTPosdVFpvYpUCeAfEgdwxrxqF/CLBIi A+SexJrzUotu78LFOybmjssB9byjwCWqKalJAXw7hsGWGRrKJ+Y3iCmqVodXF5JwatGG jOnE/WP+Cxit1ALiv/SnTUlubr92K80sJ3+V+Mx/H1kQoYkSMPzMlmIibuFh8hRMbZVa 5174uf7JwoO8jlhCqPGzPZmCorQ5iFGmzd380kutx4Ur1Bx64MwrX/RBITAZ4ewMer23 +1uA== X-Gm-Message-State: AFuF++nm0Xd67c06eNC6FuYolSI6BloYGX6iss0ywsXqvd7dC+h/18GY Vc5I4ZlSDuKbGELVIW37508W0kxpnoao1EKNgvC2n9/S4N36Ao99NZ0lcOiNf01NU1wwKu9R X-Gm-Gg: AR+sD128DLs9U1gzMlPawTYTOlzc6CfnYiSHU68Zlbbl39G76bY/Eo9gigYi0Q37NOk +Kwx7hNhwsVHPd8N4KXxwx53YjtK1fG0npXnLnQCnz7ts2Amdich8vzvh5TPzVRgMkzDA4+ifab AwMI140RZyysYQWpGq9n7+jPnxraHWT1YOiJEPUv5ih3EGPlWZcwm+B6nF9HKAMg8ufjIekOaRZ tGDC+m18TMiCL134frkyFounpbAeLH6/bfg3hvhgz4VorCC2TvoDB0sUACOGQgiuFg8QCo1n5DW Vtku+n6QErst2ajeN/DK0nAhfWS+pl4UakutvlbZg+491FKfg87PHb4U59pLuoRlGLer429qbOr fSdZd34FphgdFcsItOVPWZHgrtNXFXkkUQR2eQZnbnaYBHzoGccgmpNW7TSgze3ICgOhXrNg+sN ZaOygYHW8segTIBb4t0Bec1cB2EPevElgbMgMzqexDg2WHAXKoJA87IcGTr1K00GjwsGsyuJyNw y+6+APa X-Received: by 2002:a05:6a21:6004:b0:3d1:9166:5c68 with SMTP id adf61e73a8af0-3d265f403d0mr49688934637.8.1788192083315; Mon, 31 Aug 2026 09:01:23 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 05/15] block/export: track IOThread references Date: Tue, 1 Sep 2026 00:00:26 +0800 Message-ID: <20260831160038.221776-6-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192242210158500 Content-Type: text/plain; charset="utf-8" Track the IOThreads used by a block export and identify the holder with the unique BlockExportOptions id. Acquire holder-aware references during export creation and release them on error or export deletion. Support both single- and multi-iothread exports. Signed-off-by: Zhang Chen Reviewed-by: Stefan Hajnoczi --- block/export/export.c | 62 ++++++++++++++++++++++++++++++++++++------ include/block/export.h | 5 ++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/block/export/export.c b/block/export/export.c index b733f269f3..0e019545ef 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -15,7 +15,6 @@ =20 #include "block/block.h" #include "system/block-backend.h" -#include "system/iothread.h" #include "block/export.h" #include "block/fuse.h" #include "block/nbd.h" @@ -72,6 +71,32 @@ static const BlockExportDriver *blk_exp_find_driver(Bloc= kExportType type) return NULL; } =20 +static void init_iothreads(const char *holder_id, IOThread **iothreads, + size_t num_iothreads, AioContext **aio_ctxs) +{ + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + + for (size_t i =3D 0; i < num_iothreads; i++) { + aio_ctxs[i] =3D iothread_ref_and_get_aio_context(iothreads[i], &ho= lder); + } +} + +static void cleanup_iothreads(const char *holder_id, IOThread **iothreads, + size_t num_iothreads) +{ + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + + for (size_t i =3D 0; i < num_iothreads; i++) { + iothread_unref_and_put_aio_context(iothreads[i], &holder); + } +} + BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp) { bool fixed_iothread =3D export->has_fixed_iothread && export->fixed_io= thread; @@ -85,6 +110,8 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Err= or **errp) AioContext *ctx; AioContext **multithread_ctxs =3D NULL; size_t multithread_count =3D 0; + g_autofree IOThread **local_iothreads =3D NULL; + size_t iothread_count =3D 0; uint64_t perm; int ret; =20 @@ -139,7 +166,10 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) goto fail; } =20 - new_ctx =3D iothread_get_aio_context(iothread); + local_iothreads =3D g_new0(IOThread *, 1); + local_iothreads[0] =3D iothread; + init_iothreads(export->id, local_iothreads, 1, &new_ctx); + iothread_count =3D 1; =20 /* Ignore errors with fixed-iothread=3Dfalse */ set_context_errp =3D fixed_iothread ? errp : NULL; @@ -163,8 +193,10 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) return NULL; } =20 + local_iothreads =3D g_new0(IOThread *, multithread_count); multithread_ctxs =3D g_new(AioContext *, multithread_count); i =3D 0; + for (strList *e =3D iothread_list; e; e =3D e->next) { IOThread *iothread =3D iothread_by_id(e->value); =20 @@ -172,9 +204,12 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) error_setg(errp, "iothread \"%s\" not found", e->value); goto fail; } - multithread_ctxs[i++] =3D iothread_get_aio_context(iothread); + local_iothreads[i++] =3D iothread; } assert(i =3D=3D multithread_count); + init_iothreads(export->id, local_iothreads, multithread_count, + multithread_ctxs); + iothread_count =3D multithread_count; } =20 bdrv_graph_rdlock_main_loop(); @@ -225,12 +260,14 @@ BlockExport *blk_exp_add(BlockExportOptions *export, = Error **errp) assert(drv->instance_size >=3D sizeof(BlockExport)); exp =3D g_malloc0(drv->instance_size); *exp =3D (BlockExport) { - .drv =3D drv, - .refcount =3D 1, - .user_owned =3D true, - .id =3D g_strdup(export->id), - .ctx =3D ctx, - .blk =3D blk, + .drv =3D drv, + .refcount =3D 1, + .user_owned =3D true, + .id =3D g_strdup(export->id), + .ctx =3D ctx, + .blk =3D blk, + .iothreads =3D g_steal_pointer(&local_iothreads), + .iothread_count =3D iothread_count, }; =20 ret =3D drv->create(exp, export, multithread_ctxs, multithread_count, = errp); @@ -250,8 +287,12 @@ fail: blk_unref(blk); } if (exp) { + cleanup_iothreads(exp->id, exp->iothreads, exp->iothread_count); + g_free(exp->iothreads); g_free(exp->id); g_free(exp); + } else { + cleanup_iothreads(export->id, local_iothreads, iothread_count); } g_free(multithread_ctxs); return NULL; @@ -273,6 +314,9 @@ static void blk_exp_delete_bh(void *opaque) exp->drv->delete(exp); blk_set_dev_ops(exp->blk, NULL, NULL); blk_unref(exp->blk); + + cleanup_iothreads(exp->id, exp->iothreads, exp->iothread_count); + g_free(exp->iothreads); qapi_event_send_block_export_deleted(exp->id); g_free(exp->id); g_free(exp); diff --git a/include/block/export.h b/include/block/export.h index ca45da928c..ce8e4eb604 100644 --- a/include/block/export.h +++ b/include/block/export.h @@ -16,6 +16,7 @@ =20 #include "qapi/qapi-types-block-export.h" #include "qemu/queue.h" +#include "system/iothread.h" =20 typedef struct BlockExport BlockExport; =20 @@ -89,6 +90,10 @@ struct BlockExport { =20 /* List entry for block_exports */ QLIST_ENTRY(BlockExport) next; + + /* The IOThreads utilized by this specific block export */ + IOThread **iothreads; + size_t iothread_count; }; =20 BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192212; cv=none; d=zohomail.com; s=zohoarc; b=RQDs95B26t5Jjdz2PWkej4KrGN3i/g33lvy82NFMVs+UvisrAfQd+Lpqzf8WM9brnIPj6N6hG4i+lE0AT97UDwa6ikYJB9X0RBqVTNqZhHxL1mC0edqOsNivenp6JhxiilM0PnTxvU32y1SwfDjV6uC9DLKMrv+9T/jUrSu9jsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192212; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4rfb6Jbonhaou1RoYtf8O259hLggyyPStAvNjAohNW8=; b=FIcCBQ+9TFtmAZ3RyLge3HficLNmYxkh2PurJSWZqsp4djuXyCx1zzIdKjiDB5QBT0jp7udO4xCI4EOgIfXjO7Mxf+R+skt2QuukSAXu3+Jk4ukS5yXtMMDAvI+YFklJPQiW4Atjbw+VVmpFsPu7P8QdMM919xXIduKWMHThyuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17881922126095.026043834266488; Mon, 31 Aug 2026 09:03:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Ry-0002MF-6e; Mon, 31 Aug 2026 12:01:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Rw-0002GZ-LB for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:32 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Ru-0001ZP-AN for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:32 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-39647aa9d52so63549a91.0 for ; Mon, 31 Aug 2026 09:01:29 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192089; x=1788796889; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4rfb6Jbonhaou1RoYtf8O259hLggyyPStAvNjAohNW8=; b=jMdHhjhTR6X0/YVIuckXF/f9PDTgSvkckcnvb1Q4aO9S9PuCxaZCosZteTkYIfai8U UHeCdHt0rr+RxdFfMuGNZkukiiqSdefmlbfCuQYZzBbEuJDwSyvg1ZUL1tD5ihQKAeW7 hA97gAu3HudEVqCJQPtvzh+RgTcjrLd5WX8a37g55vrXBusy+C+yIcpQZ364R9HOMaUC cxLvwKfxXUGLKHwrNBHRE5RPOQpLjymX0ktlHPE0znIm1gxYM7VOTkEAvidn64nfCb1Z /KYFvybh/I7cijs28ziXZNNj8ZFZUgYWKQTXjp9mfG/vIVm7fjwBwZV2gNittbJigxYz cgIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192089; x=1788796889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4rfb6Jbonhaou1RoYtf8O259hLggyyPStAvNjAohNW8=; b=SVF8qHreU+8193eplvWXo6u9KKwXsUAMPKFolRdGXG4lCZV8+HbQ8tY24DuMok+6Qf NzEtoTZfrgyysn1cYsnS4beHnQAgpIjVmlDL/+2m0GISHpeWecDFE3KO7dp181FYmcXj VcGAX6Ey5yq8NmmvukwdeXveQrPeGnkX64ZDsz0DGAivZMdbvFGjKvMfFNGZ7YP1K5Y9 Z/KLa+0lWANFEzHXFAqLJOoeQ3ggOBqQ67/aL9mkySJVPGgzEJG1tydOFodlK11v9YFe 4GIVToTlSjOkyppq4VYSiIVoOOIPmnSIMz4CwZfPVWWgV/tp23KpZmN7WyJqzQKctX9t Ed1A== X-Gm-Message-State: AFuF++m8M8szhSFUyYZM81D4KreqRedwEWkiU/8U5Cwipt3bcar5QWpl nQZ1c9urd/1OtQUDKfS9CNoge3w/8Am5YPe+XQzVkn8ZN1B5RKlbqM5RDkZU4Wrc9L+Xx00z X-Gm-Gg: AYBFou2fgqds8zZqASs8sMlXMTHtq+p0kSuLJu55c/btRkdOJAj5pNGqkj8OzMrR7cP Kay5+ZkhRNHw5LT4Axny4I0ErIV64YE1M5z7rR0Bmy56F3Qw0uFC09uce5VScp4+PwMpX7ny3OV PHkukWvWuD9tpB4GgCMO+uENTL1Shb0bylgOjFp57hUdVp3FkS3qnrJ28u8WrKT3j0jgUboBG7k MwmFrsKG/N9aFci3xg46x3n026luWhE2px91MATVubNNTeFEh8Mn+CvQBZyxKooS4SPi0bsi6BO l+lGkNZDs6p4mIxHZNf+jsQzVa+oZ2kPfdbRdAKrNdBQz4Kq6yrbtkc0wMFUwXmnpyeNdIFAKjC Tc2GfMJy8YuTIy3UnIf7QWI1PWIE4xMsozdtCOEH38tGlF5KOq1h4+8IvivcCaBEPc5wghDx2Qp o7HiWiAm0piMe07KCNb8CXQ7nML+YJ/mG0GtFpDaZtSUx9xIB2A74j05agclwb+BjX4rUzQAFet vDpgLE9 X-Received: by 2002:a17:90b:4a04:b0:398:9beb:a2ba with SMTP id 98e67ed59e1d1-398da8cc72fmr7852072a91.28.1788192088488; Mon, 31 Aug 2026 09:01:28 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 06/15] monitor: track IOThread users with QOM paths Date: Tue, 1 Sep 2026 00:00:27 +0800 Message-ID: <20260831160038.221776-7-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192213840158500 Content-Type: text/plain; charset="utf-8" Monitors that require an IOThread share the internal mon_iothread. Account for each monitor explicitly in IOThread holder tracking, using the monitor's canonical QOM path to distinguish holders. Acquire the shared monitor IOThread AioContext once, using the monitor QOM path as the holder, and reuse the stored context for later operations. Release the holder from the Monitor ObjectClass::unparent callback, while the canonical QOM path is still available. This covers every object_unparent() path and avoids duplicating the cleanup in monitor_cleanup() and monitor_qmp_prepare_delete(). The internal mon_iothread remains hidden from query-iothreads, as before. Management applications therefore cannot use it to determine which monitors are using the IOThread. Nevertheless, track the monitor holders so that they follow the same explicit holder and IOThread reference lifecycle as other AioContext users. Signed-off-by: Zhang Chen Reviewed-by: Stefan Hajnoczi --- monitor/monitor-internal.h | 3 +++ monitor/monitor.c | 33 ++++++++++++++++++++++++++++----- monitor/qmp.c | 5 +++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index e0a124a317..74ea15c85f 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -154,6 +154,9 @@ struct Monitor { guint out_watch; int mux_out; int reset_seen; + + /* iothread context */ + AioContext *ctx; }; =20 struct MonitorHMPClass { diff --git a/monitor/monitor.c b/monitor/monitor.c index 6af09f2f6e..9e3b639eff 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -81,6 +81,22 @@ int monitor_device_index; OBJECT_DEFINE_TYPE_EXTENDED(Monitor, monitor, MONITOR, OBJECT, true, { TYPE_USER_CREATABLE }, {}); =20 +static void monitor_unparent(Object *obj) +{ + Monitor *mon =3D MONITOR(obj); + + if (mon->ctx && monitor_requires_iothread(mon)) { + g_autofree char *path =3D object_get_canonical_path(obj); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + iothread_unref_and_put_aio_context(mon_iothread, &io_holder); + mon->ctx =3D NULL; + } +} + static void monitor_finalize(Object *obj) { Monitor *mon =3D MONITOR(obj); @@ -116,6 +132,8 @@ static void monitor_class_init(ObjectClass *cls, const = void *data) { UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(cls); =20 + cls->unparent =3D monitor_unparent; + object_class_property_add_str(cls, "chardev", monitor_get_chardev_id, monitor_set_chardev_id); @@ -575,7 +593,7 @@ void monitor_suspend(Monitor *mon) * Kick I/O thread to make sure this takes effect. It'll be * evaluated again in prepare() of the watch object. */ - aio_notify(iothread_get_aio_context(mon_iothread)); + aio_notify(mon->ctx); } =20 trace_monitor_suspend(mon, 1); @@ -715,7 +733,6 @@ char *monitor_compat_id(void) static void monitor_complete(UserCreatable *uc, Error **errp) { Monitor *mon =3D MONITOR(uc); - AioContext *ctx; =20 if (mon->chardev_id) { Chardev *chr =3D qemu_chr_find(mon->chardev_id); @@ -734,11 +751,17 @@ static void monitor_complete(UserCreatable *uc, Error= **errp) mon_iothread =3D iothread_create("mon_iothread", &error_abort); } =20 - ctx =3D iothread_get_aio_context(mon_iothread); + g_autofree char *path =3D object_get_canonical_path(OBJECT(mon)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + mon->ctx =3D iothread_ref_and_get_aio_context(mon_iothread, &io_ho= lder); } else { - ctx =3D qemu_get_aio_context(); + mon->ctx =3D qemu_get_aio_context(); } - mon->accept_input_bh =3D aio_bh_new(ctx, monitor_accept_input, mon); + mon->accept_input_bh =3D aio_bh_new(mon->ctx, monitor_accept_input, mo= n); } =20 int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp) diff --git a/monitor/qmp.c b/monitor/qmp.c index aec0315775..de56345456 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -734,7 +734,8 @@ static void monitor_qmp_complete(UserCreatable *uc, Err= or **errp) * thread. Schedule a bottom half. */ mon->setup_pending =3D true; - aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread), + + aio_bh_schedule_oneshot(MONITOR(mon)->ctx, monitor_qmp_setup_handlers_bh, mon); /* The bottom half will add @mon to @mon_list */ } else { @@ -789,7 +790,7 @@ static bool monitor_qmp_prepare_delete(UserCreatable *u= c, Error **errp) =20 /* Synchronize with in-flight iothread callbacks. */ if (monitor_requires_iothread(mon)) { - aio_wait_bh_oneshot(iothread_get_aio_context(mon_iothread), + aio_wait_bh_oneshot(MONITOR(mon)->ctx, monitor_qmp_iothread_quiesce, NULL); } =20 --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192116; cv=none; d=zohomail.com; s=zohoarc; b=kVCf8eqkJJuJZCghHKdrdvdY1qGWkhxt78zD35vsxDOhN4RUfX/ul7OtNoW7CQGAAVe05ylwQFYjrcDA8mrSQntOtVDHw4mqBFFNpftdrMtGyIup/tnhKeJZjcAaGzxJaQG3If4wIJSxqwpdHlzy8HbmuoBt17jjlvWl0/Lii34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192116; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=bR/Aii3Zhl2KV6cVApT5Ql4m3BU/jMzjw+Xgx4WvJ6JDax1fQSOhdLKd63pY7J9fc5prRUt9IaWKp7lcWmLXeHNWC/+k758XYily2Po9PUN0GevUJXWv+IWd5w2WvgBZlrdutaRop/pIaAIE8JyyRxYUGELZBO9jA1q9crbgMrA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192116159946.8103233401694; Mon, 31 Aug 2026 09:01:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14S7-0002Rh-Bl; Mon, 31 Aug 2026 12:01:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14S0-0002PF-Ub for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:36 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Rz-0001aR-4J for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:36 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-3856d6fbcb3so3607670a91.2 for ; Mon, 31 Aug 2026 09:01:34 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192093; x=1788796893; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=Cxf7rJ8ITE4M9hRgNWWMwOA637w7bgh7/2WniJHl9baM8dhRtjB5kiRCsLNGKk82f/ wiHyQGC5foxQvGK9SBgztuxm6BL/jhGNL8mo5cf88k6oz71/o5f1wyQ873qcbX/Wfed/ ksKiIRZ6ykz8D8NpI7BFWZXt9gKPFA5dm5l7s1q/4F+yvhro1P7itz6aPZjfwMwPtlFB xiCqdb7vvMgOLQlPDQ+/qYrfY320+fh/V9AtrzrTKG5GW/cNX/bkncM2j7kIVm58Xu4c 4QtGN5cPw9PEcctTKE49+EpMXpfklKe3zlVGsf8w53V9yO7Ewxc+lz0nnhEYheITxe0X uglQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192093; x=1788796893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=jWn5736T9NeRkfnFf8OnQyvdtn7TVQ0IEGkbIUqJiEnrljphx4ZWePwYRwj8Waqycx g95IYdCtfkADtzMaFdk0qfEv+RmYlznN9ODbWrUVGX0leF/UAJJr9O3UR8USNvhZ7S+n ffm7dLVh+Ix3mAHpRmvB0nHozJKYkWZkMRjVFCbdNr3UHHlhG/Nxu/H/XL0uvNG5G6yj 65xebShKd465sPNIRfKk/wg7osnAEllN1HiFz/wSI689Whq07eF14lBbmqMwOCgQCz1b YQULjSV27oC9yEkwnAEAoPg3/8reHqrLFaHf5n2pm5SYuFbeKChkr30XUTzUNfdVsXSe 6byQ== X-Gm-Message-State: AFuF++mH3bSMqhztwG5nLm0A4FuYDSSTi5483TjXrOIivBQup/77vv2j PvKXzaFMFe/3anfxooZi7ZDfFFau7PFPANgXmQUhh4OVj1kUXWBOouXPVw13Rg== X-Gm-Gg: AYBFou3fP1NFu/LG+r4hw2xrtxm8IfB0Y5XjkWazotjipmohNHBRlSbwiHMlnR5wKXe 5RNnjBR56Lq5o/kVzyiN+0fS5fi0WjcOQidtI2PNvUHhRsaeOYAslTfIhJuggTR9tT7eck4A8ql mSVNTlxSEt/OBsh09lzhw9H7JiytoqcRBqmWSH5EVvOuYjZqJG9NWVvj1aaW7I62hmUl2qE9xyv bD5VHKfVSp7WuZHyBwJWzMeCBE3KQK0ymKZ7z6sL0fzoA2/KFzOjNFp07eiXuPH4fTMAnSnhNxh 3aeXwxa0GUHjwaaQZn579JLbSOa0mp0hLqitpvVcFTy32eCd9ceqiyzt5sd9iwVbMd7+XJjxHAz WvYw+8e/33hLAoAxe9XU4GrVpervOEGNld5l5R3+3YnJ1ezEY5JBd5zWGjIYZMkW/ylguqbWOYe btNhThN/VmFovThzruEmZqjPRrt0MZTN0gSHAsSgdcIbE0zLVhp5+a29gVq8nO9dDwhZ67/LuIX gy7HwZe X-Received: by 2002:a17:90a:d2c7:b0:398:9bd1:3210 with SMTP id 98e67ed59e1d1-3989bd135c0mr28827763a91.17.1788192092733; Mon, 31 Aug 2026 09:01:32 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 07/15] virtio-vq-mapping: track iothread-vq-mapping references using device path Date: Tue, 1 Sep 2026 00:00:28 +0800 Message-ID: <20260831160038.221776-8-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192118857154100 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/ unref_and_put_aio_context in iothread-vq-mapping. This allows tracking IOThread users via the device's canonical QOM path, improving lifecycle traceability for virtio-blk and virtio-scsi devices. Signed-off-by: Zhang Chen --- hw/block/virtio-blk.c | 8 +++++++- hw/scsi/virtio-scsi-dataplane.c | 9 +++++++-- hw/virtio/iothread-vq-mapping.c | 20 +++++++++++++++----- include/hw/virtio/iothread-vq-mapping.h | 6 +++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 6b92066aff..4b2cf3d52f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1493,9 +1493,12 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBlo= ck *s, Error **errp) s->vq_aio_context =3D g_new(AioContext *, conf->num_queues); =20 if (conf->iothread_vq_mapping_list) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); + if (!iothread_vq_mapping_apply(conf->iothread_vq_mapping_list, s->vq_aio_context, conf->num_queues, + path, errp)) { g_free(s->vq_aio_context); s->vq_aio_context =3D NULL; @@ -1527,7 +1530,10 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIO= Block *s) assert(!s->ioeventfd_started); =20 if (conf->iothread_vq_mapping_list) { - iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(VIRTIO_DEVICE(s))); + + iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list, path); } =20 if (conf->iothread) { diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 95f13fb7c2..26ecefd547 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -65,9 +65,11 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **= errp) s->vq_aio_context[1] =3D qemu_get_aio_context(); =20 if (vs->conf.iothread_vq_mapping_list) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); + if (!iothread_vq_mapping_apply(vs->conf.iothread_vq_mapping_list, &s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED], - vs->conf.num_queues, errp)) { + vs->conf.num_queues, path, errp)) { g_free(s->vq_aio_context); s->vq_aio_context =3D NULL; return; @@ -94,7 +96,10 @@ void virtio_scsi_dataplane_cleanup(VirtIOSCSI *s) VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(s); =20 if (vs->conf.iothread_vq_mapping_list) { - iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(VIRTIO_DEVICE(s))); + + iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list, pat= h); } =20 if (vs->conf.iothread) { diff --git a/hw/virtio/iothread-vq-mapping.c b/hw/virtio/iothread-vq-mappin= g.c index 55ce62986c..60e1d55005 100644 --- a/hw/virtio/iothread-vq-mapping.c +++ b/hw/virtio/iothread-vq-mapping.c @@ -77,6 +77,7 @@ bool iothread_vq_mapping_apply( IOThreadVirtQueueMappingList *list, AioContext **vq_aio_context, uint16_t num_queues, + const char *holder, Error **errp) { IOThreadVirtQueueMappingList *node; @@ -93,10 +94,13 @@ bool iothread_vq_mapping_apply( =20 for (node =3D list; node; node =3D node->next) { IOThread *iothread =3D iothread_by_id(node->value->iothread); - AioContext *ctx =3D iothread_get_aio_context(iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)holder, + }; =20 - /* Released in virtio_blk_vq_aio_context_cleanup() */ - object_ref(OBJECT(iothread)); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, + &io_holder); =20 if (node->value->vqs) { uint16List *vq; @@ -120,13 +124,19 @@ bool iothread_vq_mapping_apply( return true; } =20 -void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list) +void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list, + const char *holder) { IOThreadVirtQueueMappingList *node; =20 for (node =3D list; node; node =3D node->next) { IOThread *iothread =3D iothread_by_id(node->value->iothread); - object_unref(OBJECT(iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)holder, + }; + + iothread_unref_and_put_aio_context(iothread, &io_holder); } } =20 diff --git a/include/hw/virtio/iothread-vq-mapping.h b/include/hw/virtio/io= thread-vq-mapping.h index 57335c3703..0d39caddf3 100644 --- a/include/hw/virtio/iothread-vq-mapping.h +++ b/include/hw/virtio/iothread-vq-mapping.h @@ -17,6 +17,7 @@ * @list: The mapping of virtqueues to IOThreads. * @vq_aio_context: The array of AioContext pointers to fill in. * @num_queues: The length of @vq_aio_context. + * @holder: The QOM paths for attached device. * @errp: If an error occurs, a pointer to the area to store the error. * * Fill in the AioContext for each virtqueue in the @vq_aio_context array = given @@ -31,15 +32,18 @@ bool iothread_vq_mapping_apply( IOThreadVirtQueueMappingList *list, AioContext **vq_aio_context, uint16_t num_queues, + const char *holder, Error **errp); =20 /** * iothread_vq_mapping_cleanup: * @list: The mapping of virtqueues to IOThreads. + * @holder: The QOM paths for attached device. * * Release IOThread object references that were acquired by * iothread_vq_mapping_apply(). */ -void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list); +void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list, + const char *holder); =20 #endif /* HW_VIRTIO_IOTHREAD_VQ_MAPPING_H */ --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192150; cv=none; d=zohomail.com; s=zohoarc; b=ZxFxwoodFVSLhtKKrOXB6ejAP2PhhKr1OBNtxeAp7Vy3vi0HIkImPL2O/Tqc6RRlGWntSDW5Fdvhy9lba1rTg2bmC6noy/D+SuLfKMfEMxeAMDXXucCuyF8EyZbCJ5b20CYkReJNh6Eumk+ZWPtvB9HLm/7Xzo+47kVnYHFSqb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192150; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=dcjnEVA/z8YOhgtgyfG20d3/t8S0EmlN9Y0IE6wWtiCAiF4b8Mek3JIaGAWvACw15O5/4nmPUO8GDef9JwYuiguOaNl9aKWQIgVj09Vw9mM8mXD7ktYBOPPxZSSq8om32oEdSLJSYsbhekV03NEOizQeBJaw06jmvGUPg6EsTEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192150969324.093073482072; Mon, 31 Aug 2026 09:02:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SI-0002cY-RA; Mon, 31 Aug 2026 12:01:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14S7-0002UJ-Bm for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:45 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14S5-0001bf-21 for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:42 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-398e9698a70so1009579a91.0 for ; Mon, 31 Aug 2026 09:01:39 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192098; x=1788796898; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=hdInomzICFRqRccVzAKAogBNgw17lptwhiDpPtqCi7w+PSDWlthta4vUEuEurTBqxY AqYeQoxbmg77VRmQauzAoK6aLbKGRCTXooTnOp39DufUKlNfWWqM/w+b3sg1+uxJlyhW Y35GdQSH0DmCKGsDzazJz7W2lIEdW9I5/pKQ1I+lZ1KVG8Arv2lHATOh7FXsCKS/zLO0 KUkBkB7pb024YDfsSW9bZTBb9sqcy6HmQ87ueAyd7mHCqtS/9/bFdrSHRmBFSqsxzLzP yAM2JZ2oWqp6ny0cNqLyLoGZf4vIXbPPHrkmIWFXSX2LQJ+wfOfubD7zhR/MOxW0X92F 1UgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192098; x=1788796898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=TcMPeO+WSBbgX9Smi8g652qjc+mSE9j1kzwYN+ep3FZdlYZt+n5glWfUKB4hRya1zr HMbnphRcaJnAsl8HcuCmqZEN5sAFXq65yGkdHbnc//ZGnmjkFTan9umpvoZzPFMQUhJX XBI2A21S98Tl7YwyXNZ4kCKszM+iByXNBx81Ieugg+T+8hhvn+l4lQ7RqsvfRAGZ0V5K qZxuSJcuiZe8X7lMwgUodSG9iB8J6e7jAU3mqY40G8+w3GCw/htJpSKixsctAFh4SGG/ RNHLY0VajkRuO5uxeA6vavhsr7FJGhxv3uBNFLYXQHU6vUMzvIfoDfwTLfFaA2hlZsGm D1og== X-Gm-Message-State: AFuF++m3P7umP+WNvGOHW9EwtYZLJpp31A39gRAeNAi4aj7UKxcGg3ja yZKfNzZKWGVKcNvheDocZPz3nYrQz+8Q9Bt7BqMeWyENryWiDDgdNtcKc5rxF4QiiiV/9zii X-Gm-Gg: AYBFou32FP3y5J0/VQeXWaQKPI0MFN7T5AvW3MYvkVThUNQrEuq2RWcFdSdwRbOFB+7 //V7+BiD6iQaMf8WCmhNZocDIAEyxH9u4nYsBVAAhB25IWh24maSRnriHDZBu0LsmMBIsNc2yy8 4/Wrcy6YK+OpL3hE1YUDstG0xUMVtxffqlEsOMvck3HVLNfj85jqKTSl1HvCkpGuP40J0i66H33 TCxJiyeC2kTRBAJaS84XKaN4x+P8qc535tT03JdwSGa4e2lnplQfmFbqQTxCKiHtibM2w3mM9an f7lLKTIB63j/9DwF19Tu/1YO5pwB3rDSs9CbnpQvxyuZc+36UaTPVouVox7gmiu7fFhvz55vxdI Of+UfUefB1cNM04vLxEvgB7kf9gIGJWNaPfbmB7aABjBj0fjCgFiypxjWCwd+aIMaYXq+h2u1Ob f2GLuQxeUxxHsbOZUJ/uaJZ4Parw7hsM7pbP2DRiZj32HpXJvc3qxFzK87WVcont7lSGNsVei7y J7reXAD/jLi4Robw3U= X-Received: by 2002:a17:90b:4c4e:b0:398:c794:ca26 with SMTP id 98e67ed59e1d1-398c794cb09mr16325034a91.25.1788192098282; Mon, 31 Aug 2026 09:01:38 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 08/15] virtio: track IOThread references for thread pinning Date: Tue, 1 Sep 2026 00:00:29 +0800 Message-ID: <20260831160038.221776-9-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192153195154100 Content-Type: text/plain; charset="utf-8" Use the virtio device canonical QOM path as the holder when virtio-blk and virtio-scsi acquire an IOThread AioContext. Replace the raw object references with the holder-aware acquire/release helpers so the users are visible through IOThread introspection. Signed-off-by: Zhang Chen --- hw/block/virtio-blk.c | 23 +++++++++++++---------- hw/scsi/virtio-scsi-dataplane.c | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4b2cf3d52f..db7f513da5 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1469,6 +1469,7 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBloc= k *s, Error **errp) VirtIOBlkConf *conf =3D &s->conf; BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); =20 if (conf->iothread && conf->iothread_vq_mapping_list) { error_setg(errp, @@ -1493,8 +1494,6 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBloc= k *s, Error **errp) s->vq_aio_context =3D g_new(AioContext *, conf->num_queues); =20 if (conf->iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); - if (!iothread_vq_mapping_apply(conf->iothread_vq_mapping_list, s->vq_aio_context, conf->num_queues, @@ -1505,13 +1504,15 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBl= ock *s, Error **errp) return false; } } else if (conf->iothread) { - AioContext *ctx =3D iothread_get_aio_context(conf->iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + AioContext *ctx =3D iothread_ref_and_get_aio_context(conf->iothrea= d, + &io_holder); for (unsigned i =3D 0; i < conf->num_queues; i++) { s->vq_aio_context[i] =3D ctx; } - - /* Released in virtio_blk_vq_aio_context_cleanup() */ - object_ref(OBJECT(conf->iothread)); } else { AioContext *ctx =3D qemu_get_aio_context(); for (unsigned i =3D 0; i < conf->num_queues; i++) { @@ -1526,18 +1527,20 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBl= ock *s, Error **errp) static void virtio_blk_vq_aio_context_cleanup(VirtIOBlock *s) { VirtIOBlkConf *conf =3D &s->conf; + g_autofree char *path =3D object_get_canonical_path(OBJECT(VIRTIO_DEVI= CE(s))); =20 assert(!s->ioeventfd_started); =20 if (conf->iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path( - OBJECT(VIRTIO_DEVICE(s))); - iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list, path); } =20 if (conf->iothread) { - object_unref(OBJECT(conf->iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(conf->iothread, &io_holder); } =20 g_free(s->vq_aio_context); diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 26ecefd547..55bbf045ce 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -28,6 +28,7 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **e= rrp) VirtIODevice *vdev =3D VIRTIO_DEVICE(s); BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); =20 if (vs->conf.iothread && vs->conf.iothread_vq_mapping_list) { error_setg(errp, @@ -65,8 +66,6 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **e= rrp) s->vq_aio_context[1] =3D qemu_get_aio_context(); =20 if (vs->conf.iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); - if (!iothread_vq_mapping_apply(vs->conf.iothread_vq_mapping_list, &s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED], vs->conf.num_queues, path, errp)) { @@ -75,13 +74,15 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error *= *errp) return; } } else if (vs->conf.iothread) { - AioContext *ctx =3D iothread_get_aio_context(vs->conf.iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + AioContext *ctx =3D iothread_ref_and_get_aio_context(vs->conf.ioth= read, + &io_holder); for (uint16_t i =3D 0; i < vs->conf.num_queues; i++) { s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED + i] =3D ctx; } - - /* Released in virtio_scsi_dataplane_cleanup() */ - object_ref(OBJECT(vs->conf.iothread)); } else { AioContext *ctx =3D qemu_get_aio_context(); for (unsigned i =3D 0; i < vs->conf.num_queues; i++) { @@ -94,16 +95,18 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error *= *errp) void virtio_scsi_dataplane_cleanup(VirtIOSCSI *s) { VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(s); + g_autofree char *path =3D object_get_canonical_path(OBJECT(VIRTIO_DEVI= CE(s))); =20 if (vs->conf.iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path( - OBJECT(VIRTIO_DEVICE(s))); - iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list, pat= h); } =20 if (vs->conf.iothread) { - object_unref(OBJECT(vs->conf.iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(vs->conf.iothread, &io_holder); } =20 g_free(s->vq_aio_context); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192128; cv=none; d=zohomail.com; s=zohoarc; b=knbTxv1Gm4pQxcw7Zck+URHtpPm9HUgu6huPTsQBt77rVwn/uKWBjanvRaoq40xkW81Sz5N6e8f/vJKxEvajLCe7LdCncJb2x3CmrX16tIMEpkVKhSrCT2Ws4GF5Mxt4qKWDquV1yPuDJHhDoa2AA11Wc2mRnWMz41lxvIvm+Ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192128; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=b52cC1fb/ZtgqYYHp/m11AZToFP5MtenG+jQxnzF62EeM/DtwQe8VAeoGpLX5azbesLW/y+LConqA8URQYfMAoGlltwZ2XAhc5QX9h2EMfgF1H2epJBcou/X1UWYgKlMfEZb2mCYwh932FbCSsel0pyK1CzKGn7iAMprPAAtz6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17881921283231010.2005820737877; Mon, 31 Aug 2026 09:02:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SK-0002h9-08; Mon, 31 Aug 2026 12:01:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14SA-0002XE-Mi for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:50 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14S9-0001dJ-0e for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:46 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2d9004f39d3so19441335ad.2 for ; Mon, 31 Aug 2026 09:01:44 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192103; x=1788796903; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=LpGeSm7QUk0ux5U1pg0grizm1ysxUlS+HwNJ5yjxmrOc2UXQy+I2T9dfel5RFpl2MS O/EkZVRQ5g8ybftUCm0CJDJPJVFYmuP+nyZ2ByAUgtj19LAe4YiqU9qkQkboLuPrWs8u 5jB0Adhx3G6DUPSAErKTSUWvYDFOi6fMlPii9rQ+EUwnXcfeYG21ybeSxv2+bKqSMZfK 6a+ec5nf/Cv09VVab2RLuH16iitEOpnEIs8LMpQaz86Y1dURBJXZUe+P7YEzoGsEe4QV pRqbjFQZtfE81GbF31ORcAs9155I4imPK7W+sbGTaBA08nnvSMhGQonbm4W4tcR4sCT3 f3Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192103; x=1788796903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=XkYqvXO6hFVWDSeHHVmzTsAoX77s3YTXBS5PyAvKzGPLepOH589q7HZm6vZPB7CA3g FfKPZmTBtrP0P1vMmwT1BNDcH0LWUyzCi71ok95KtvRv0cr3bnnmbfCUhqBM+k6V2yrU fkaoltmRdFWBD9aoNEnv5mTaR8sfOWMduE+rgM7m3R6D3Yg2gepOb70djNSaDYx2ites 5uL5/XJHlebTSt+dhEMpSOE5z1sRAjfOwdCgYceeDR4G0cEAi7/9VUfDnzgPdovbo/cC h8HLhqn0B0LOrWjFSKOh9bkx3gSw2ufvfa42bEcT/B/RDYr6VZ1SFJA9EyeN4FG8Faee 8yzw== X-Gm-Message-State: AFuF++maeYDIaS8u1ASmW64uCYb61bKSQF11SjCxJGuOZpwC9euSEdud 0mNXaTZfcqHegZWmOYJugGgYdpwLvD0WqJCyeOev9e2NeR3Qpcf1vXTGULo1JgE49TJcWPbu X-Gm-Gg: AYBFou1bE86vNicAhMYbWltIKZNJOhRMtW7HVBeRZmFWjMm5SEXfG7uyzR1hHyGw8s8 NC8uUUBOJlS7+R++zz+zC0oRj9dKJsQK0JmdNEIya9dL5T09JKTDQK6f7WNn6qcAa66U5Io5uXe j0ya4SEDDQm+WxswfYUm6gcAUEo5VOsE9dhZvB3Qo90HN9ObeStk4UUtpYl8PxB4Ng9SvvQ69rZ wRfmbre/IfAyPWGMUPqaMAR7LSNbpC+4BPNBx5zMcxnPF4UG2S5HSISh2sJSv4PV3ZuXr0vzusH eg/jRpslcT5MgWZEHkbnTXhzpRJobvQL0ZOc7avsgHfkj/vKt+OKwVwJsjqBM98tNm4zj4qKTfs LhWahQZcENdNRmUcASQGP4pZkx294HPgg5thTpvr8549npdDOTiEyhw01tJNO7Xs61F+RhwUODP PNTCmS191LdKQuBv6uCsdZe5CXAAI9wr+LJOsJvH+YghiCtZOnTyDhIhlZCRnr48FqBq5NSzFX9 uVPm4Zm X-Received: by 2002:a17:903:38cf:b0:2d9:4358:73ab with SMTP id d9443c01a7336-2d94a96743cmr22831435ad.19.1788192103273; Mon, 31 Aug 2026 09:01:43 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 09/15] net/colo: track IOThread references using path-based holder Date: Tue, 1 Sep 2026 00:00:30 +0800 Message-ID: <20260831160038.221776-10-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192128977158500 Content-Type: text/plain; charset="utf-8" Convert colo-compare to use the iothread_ref_and_get_aio_context() and iothread_unref_and_put_aio_context() APIs. This ensures that IOThread references are tracked using the COLO object's canonical QOM path as the holder ID. This refactoring improves IOThread lifecycle traceability and aligns the code with modern QEMU iothread reference management patterns. Signed-off-by: Zhang Chen --- net/colo-compare.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 5986fb1e88..361ee32729 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -130,6 +130,7 @@ struct CompareState { GHashTable *connection_track_table; =20 IOThread *iothread; + AioContext *iothread_ctx; GMainContext *worker_context; QEMUTimer *packet_check_timer; =20 @@ -922,9 +923,7 @@ void colo_notify_compares_event(void *opaque, int event= , Error **errp) =20 static void colo_compare_timer_init(CompareState *s) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - - s->packet_check_timer =3D aio_timer_new(ctx, QEMU_CLOCK_HOST, + s->packet_check_timer =3D aio_timer_new(s->iothread_ctx, QEMU_CLOCK_HO= ST, SCALE_MS, check_old_packet_regular, s); timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) + @@ -964,8 +963,15 @@ static void colo_compare_handle_event(void *opaque) =20 static void colo_compare_iothread(CompareState *s) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - object_ref(OBJECT(s->iothread)); + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + AioContext *ctx =3D iothread_ref_and_get_aio_context(s->iothread, &io_= holder); + + s->iothread_ctx =3D ctx; s->worker_context =3D iothread_get_g_main_context(s->iothread); =20 qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read, @@ -1404,6 +1410,7 @@ static void colo_compare_finalize(Object *obj) { CompareState *s =3D COLO_COMPARE(obj); CompareState *tmp; + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); =20 qemu_mutex_lock(&colo_compare_mutex); QTAILQ_FOREACH(tmp, &net_compares, next) { @@ -1430,18 +1437,20 @@ static void colo_compare_finalize(Object *obj) g_clear_pointer(&s->event_bh, qemu_bh_delete); =20 if (s->iothread) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - - AIO_WAIT_WHILE(ctx, !s->out_sendco.done); + AIO_WAIT_WHILE(s->iothread_ctx, !s->out_sendco.done); if (s->notify_dev) { - AIO_WAIT_WHILE(ctx, !s->notify_sendco.done); + AIO_WAIT_WHILE(s->iothread_ctx, !s->notify_sendco.done); } =20 /* Release all unhandled packets after compare thread exited */ g_queue_foreach(&s->conn_list, colo_flush_packets, s); AIO_WAIT_WHILE(NULL, !s->out_sendco.done); =20 - object_unref(OBJECT(s->iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(s->iothread, &io_holder); } =20 g_queue_clear(&s->conn_list); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192148; cv=none; d=zohomail.com; s=zohoarc; b=E/32rGmrOVdqEe327Q5h/Fsd9bZU1MUt/5kzkoHqogb2WRV03D1oiryqfab4HHrV1MNd2s58agAnjn/+2cjE/ppjLANT6idypdL4uY9vkbAk9uRHxiWFjfJQw9K4mvjIc/kG5uD02bf354NHULtjRIAUwLhSA/75iHBUd5+IvBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192148; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=MGrZw5MZZkPjgUqOq886pzg1+akBStdb7bBZucJsXCHJKJCr5UCOnK0bYbuyKCLpooVORUbIAd7DtRGV0LiSFJyDwmTXAtx5CcMe6uQZON8e5+JQc2tMrpGldzUKvXpr4L0ZpAoccYZhuoPsRGY2NRXUDsvqnDCFiO7k8d94xf0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178819214889962.61282128636344; Mon, 31 Aug 2026 09:02:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SL-0002jT-6q; Mon, 31 Aug 2026 12:01:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14SF-0002Yt-9f for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:52 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14SD-0001eZ-Pq for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:51 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2d71d1cc8b2so32631755ad.1 for ; Mon, 31 Aug 2026 09:01:49 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192108; x=1788796908; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=IXbi5VG6OUgQQMsJwq5ISo4zfo0+HpbW/QILfGrLHPHIKjP+ZPhmPG3xVW08wswfyX 4raIbcfiX1YgcLfOfMd5kXd1mrDbF/WS6yZ/5OvQ0h7w3m0o81539hO8hOQy9n5lR00f BxwCPUGvX1dlMB2r/dxLu0+yckD9kjVmcX+FgPCyWYzxMDEWVvuErX3iaQ45jlAF35Sa 0ul/1Lqk0jDDw4QTMDJaNPxHeMyEQUUsFNWD6hR0xK2bNOSVrt4OOw1QiU5DVUBRvMHB SCfMvncGe/G7Rh6Y2vuNPSu7V1pWgCKYQqwEVfKCe4HuaENZ98sBMd9Z/gcAZFFVu0Jq fpkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192108; x=1788796908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=mKwTWvn/j9Li2ld74i5gMOVOdYy7FLZtoLKrnSPMMr+IrQ8F7oAmD1OpHsHTWnbejx zFxNGrQAcQjWvf4kluViZ45BsV9Yx7zFDrF6PbMDFDdJszCSKuM5xrwJOyQixi06a5zJ W6dudzhsh0tMBrOOTMEAI4jtcBrgAydxNXSOYAi1LwI8bi2JiRu1jpsnM3z5S+rVok0W atjawbBHxKU4jKXYOgSMck8NR3Tz96oFZ/2a4Ww+cCRZGelYeTtYhxPPHUD/Vee+scjU f0hQZZzGUoVpRWaVqh8r2LjLC4DArGhpZAIWJLVcWO+0VeLsfaHqj1J/L4jVjdBicn8V wGrw== X-Gm-Message-State: AFuF++lVbkR04h76nvWGYKb3+ZQZe3Ul2ov3bOSKupLU59a3JpUfnKvy 1EB2shJl4vpHygvtDQEISknkd0vQLgqlIXBfnUwXaeGXkJwDc98x3m12i6h0AKShpBKxwcaY X-Gm-Gg: AYBFou3/+WZIpcZ6LGpwzAM8qZQKzAxv2Gj/uf+qezblU6SeNuv0H9kmZS9N8lWzBsV 40eUyuBfd5hA1489k5VbNMHJDD+uNtxTXwAyQoD4RRfaM8NeGyDcmHLN25qB4+eyTrYqggjDbkP AL+dduaBPoKljG8jrl4vs/Y1DfimGo/putldl+RlSBCqEs8FbSQFU4gU7+7tGOpOUMKoZ5YQXss cI5JtXCmG3zoWhmvyIQcGHjKhKH/Rp1ajaWqUxa9xVoVHFFGoTJO62rx2SPCa7yPEpgAmpbuX4r tHtQcVE+enVK976n5PW0AIAXVLa3JOXCbcW5eMLBgpe9FEL1WLn8M6zbPDa4iIylukxh36ZL9ZR qrTQXP/qE3hLGXmoc3E6XkqVknj5VlE3m9Zy4RtjnY6v5lvIr41B4BbF7ctJFfYFKba5CfGHRYu VHQSychu6vRvJiJby/TP478XnV6fJNeXT3zAEWPt3miXov/nHbweXAJ6UqW809xBcdq9qkf5gDA zbsHxAk42d8HYDuG3rW X-Received: by 2002:a17:902:f786:b0:2d8:d4ce:7e3d with SMTP id d9443c01a7336-2d8d4ce836bmr299993485ad.18.1788192108124; Mon, 31 Aug 2026 09:01:48 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 10/15] virtio-balloon: Update tracking iothread users with holder Date: Tue, 1 Sep 2026 00:00:31 +0800 Message-ID: <20260831160038.221776-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192151360158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/virtio/virtio-balloon.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 4c5f486ba2..7c9c8d2a41 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -892,14 +892,20 @@ static void virtio_balloon_device_realize(DeviceState= *dev, Error **errp) s->svq =3D virtio_add_queue(vdev, 128, virtio_balloon_receive_stats); =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_FREE_PAGE_HI= NT)) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + s->free_page_vq =3D virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE, virtio_balloon_handle_free_page= _vq); precopy_add_notifier(&s->free_page_hint_notify); =20 - object_ref(OBJECT(s->iothread)); - s->free_page_bh =3D aio_bh_new_guarded(iothread_get_aio_context(s-= >iothread), - virtio_ballloon_get_free_page= _hints, s, - &dev->mem_reentrancy_guard); + s->free_page_bh =3D aio_bh_new_guarded( + iothread_ref_and_get_aio_context(s->iothread, &io_ho= lder), + virtio_ballloon_get_free_page_hints, s, + &dev->mem_reentrancy_guard); } =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { @@ -919,9 +925,15 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev) =20 qemu_unregister_resettable(OBJECT(dev)); if (s->free_page_bh) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + qemu_bh_delete(s->free_page_bh); - object_unref(OBJECT(s->iothread)); virtio_balloon_free_page_stop(s); + iothread_unref_and_put_aio_context(s->iothread, &io_holder); precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192142; cv=none; d=zohomail.com; s=zohoarc; b=mgtQxP/88QpxESXNZmywiULxlUVsO1RgDzOEEaeUXKAaKHoAPPqOFjC91UtWKzNq0Ah2KHhod9Zt8c38dE6ZYNE6mPqvceU59fHeHEyqNrfodacZRqIek+i9lOO//QjdSNxknXWJHkLbFu8pK6NHm4vqp97TCqLvftfor3iM/pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192142; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=nERwyiAxtE8nOE38GE3W0QwK7TSeWhDZQpW7kw3P1yP1lTqPudl14hCByOcI2lm8oyVAT1h/wPTeAvaJUPM5C47mFs+8kNH/9zHUS2hXvlwzHbKbVFiksrojvThFwsn5R4KW9seGxt96hHdTMFSAoiYrE56GQpzNhGB8sViXH0M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192142410772.8925757528314; Mon, 31 Aug 2026 09:02:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SS-0002pp-Ig; Mon, 31 Aug 2026 12:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14SN-0002nK-Rj for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:59 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14SJ-0001gB-BV for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:01:59 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-39647aa9d52so64242a91.0 for ; Mon, 31 Aug 2026 09:01:54 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192114; x=1788796914; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=ULna3fzr/Yhx69Zx6VGfVre+0mB6/daz0Nr1FVi1/D/PBgyJwHOo82SqUlivgIZ02G IiaGYnE6KEAmD7ph08ywzdm0NY6QsSG1VvKtbZ89dLfghY7VvqKzwKT3fuzQr/IAFMW4 5tU9i3ZJByvp8OasRIcfB51NiYnZoSIwVeKffBoyvALWAsg7x6kz+CzMGiUfTzJQzRht T6hXqrxCxpeMNHxiQKuPyr1ayFhjZq/RXYv7uOGKxorZ0a5/LuOmcO9dWkCo/cqp8hfK 2k96q8upGQEgHT0V7VQiYDwjq32ZtZDjY/elRkJg7oCjjgVC9RA8c8rukHk+SIRCnbHE yj9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192114; x=1788796914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=P39rDo96aHB1+Pztz1jU5nFFpKVipzNkVQog9klRFgTJMSms9N4yPi/Ll4aSlg8ojN ZngFcqUeDXlLaqDbH+xv+CyUy7Hykc/w8L9wl1F4a2giXJP8LOru8TyVEZWhp3TNFJhe 8KttbOaBaDV5ni93kufYVMcLZqeDL7gHIgiUdHc3XLFJsLTfZ4fpmxRtfhGO08Li8Zbd 2hFL4LPA81sdLpTm3uO6rj0b/hqGhsmUIvdlBKZcPIaxebmTVNa8DCUftHuwtGbUfYML 9JmpmZpq2C+fHF59/2KuDzAYE5CF+1bhukAc95iiLBe0I3NWT8J8n8Vgs+nv1wEetxkW z6Rg== X-Gm-Message-State: AFuF++m/aMR6cIAiY1dUFHTxjE1zk+ygs7Y0NH6Mz3heOCaM4yUu4g6z PjoO7OrB+7JS9QIS0y/XXiZz3PCP4g7nBdAyYjRIJ3CWt4vHIoZ5dsxD0fepjQ== X-Gm-Gg: AYBFou3N61YJfAiYyKnNcULHwzFzrCJVjh6UbrCRybF5SUwWBFwJQsQ4wc3623lXwMc tx4D/8I5z7VQ/LYDS+vO+7y/MwKte0WJ7JS5TkPIDThUJg91PVIhrQvkWVdwtoHhAXGrMu5yg4b bS9fQtoM7LU3QFuJoLTjC2d8XN3QULQmG8/mMa4nqu90xlA7TB1S+y2J8Z6/yQa+9VFQGhpZi9y UJZRGOeQuI69B3rGgla74MufRphCi6gKn4+rHHowo5YJQfm8ckyb1TSZxhmsQ4iG0CYuhO+3YbY GFODuqb+o4+w5oUISBtWbDuj36qwhgMN0cpXRBO3N2RG2DnBp6176cvuLiBTGtw6swFjeJn6i86 i8JiT98Q//fVqKD4hWPWlwo0iehimcqOYG2RvEuXbAr7LlFfyyum4q1b7pJGiZ0suPu7FOFQe7u IFRtvTqJWVISG8r28S0EBS6tWAcRfYQryWTmmxiLbTF8nlvsyiFQGsKusPpUBFofoyQRVzWG92U KIPR27Z X-Received: by 2002:a17:90b:3889:b0:398:c8f3:d076 with SMTP id 98e67ed59e1d1-398da8d5422mr8104261a91.31.1788192113600; Mon, 31 Aug 2026 09:01:53 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 11/15] vfio-user/proxy: Update tracking iothread users with holder name Date: Tue, 1 Sep 2026 00:00:32 +0800 Message-ID: <20260831160038.221776-12-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192145014154100 Content-Type: text/plain; charset="utf-8" Add object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/vfio-user/proxy.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 197aee07bf..e642fb0ad3 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -898,6 +898,7 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *add= r, Error **errp) QIOChannelSocket *sioc; QIOChannel *ioc; char *sockname; + g_autofree char *path =3D NULL; =20 if (addr->type !=3D SOCKET_ADDRESS_TYPE_UNIX) { error_setg(errp, "vfio_user_connect - bad address family"); @@ -917,6 +918,11 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *ad= dr, Error **errp) proxy =3D g_malloc0(sizeof(VFIOUserProxy)); proxy->sockname =3D g_strdup_printf("unix:%s", sockname); proxy->ioc =3D ioc; + path =3D object_get_canonical_path(OBJECT(proxy->ioc)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; =20 /* init defaults */ proxy->max_xfer_size =3D VFIO_USER_DEF_MAX_XFER; @@ -936,7 +942,8 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *add= r, Error **errp) vfio_user_iothread =3D iothread_create("vfio-user", errp); } =20 - proxy->ctx =3D iothread_get_aio_context(vfio_user_iothread); + proxy->ctx =3D iothread_ref_and_get_aio_context(vfio_user_iothread, + &io_holder); proxy->req_bh =3D qemu_bh_new(vfio_user_request, proxy); =20 QTAILQ_INIT(&proxy->outgoing); @@ -967,6 +974,11 @@ void vfio_user_set_handler(VFIODevice *vbasedev, void vfio_user_disconnect(VFIOUserProxy *proxy) { VFIOUserMsg *r1, *r2; + g_autofree char *path =3D object_get_canonical_path(OBJECT(proxy->ioc)= ); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; =20 qemu_mutex_lock(&proxy->lock); =20 @@ -1021,6 +1033,8 @@ void vfio_user_disconnect(VFIOUserProxy *proxy) qemu_cond_destroy(&proxy->close_cv); qemu_mutex_destroy(&proxy->lock); =20 + iothread_unref_and_put_aio_context(vfio_user_iothread, &io_holder); + QLIST_REMOVE(proxy, next); if (QLIST_EMPTY(&vfio_user_sockets)) { iothread_destroy(vfio_user_iothread); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192177; cv=none; d=zohomail.com; s=zohoarc; b=FGDEm6Nm0nrv8wmCtAMenicNqu/V2PIm+7kaiz/OYTSmU2q3ZoZw9/G+5QS3jubPqgcnrTTVbAyZ4jMH/IgW00gj+4BPtEllFjcAuGzB0PJxk08S3h5ryzDa7DDMCC/Tspkul2upjWVQTwhaonPo2szWfTvfoY9F9rVAR8lLYjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192177; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=HfjA1f6SqeR2Gh3he8MpPGsOkVErNbNUxVqjJfgvVfqiFGCDs5TIlb+hyrleDNNfQkV/3VaUW+Sb9wgJthTGM0sPn0cIuygnjnh8TGZk10ZdCcJaeZXbj1S2TTcHWfSsaN7rURVysx5+cuAUvmX29XqsbPxLpKhteghb0lX1ejw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192177309161.33311246453297; Mon, 31 Aug 2026 09:02:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SV-0002tc-Eb; Mon, 31 Aug 2026 12:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14SP-0002ps-Ru for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:04 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14SO-0001hF-AO for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:01 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2cc891373e0so32606255ad.2 for ; Mon, 31 Aug 2026 09:01:59 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192119; x=1788796919; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=pUDmWVI0HIDx/EWyd2DlCdPGAlz2fZTKRb5sJaiFswf1WvWiszxmeC1zXhgn0bYEzy 0weaRJunpWmWpuJ6YBkbVLu0KRKZEkPYhalDW0m+0vSIjfQcO5hvWkpM6O1QT+DDHdQL Ue0jSirhdAVCubCyI9jWg510RBmo/2CHeE2KBQk6+/BN7boPv3o50K3AHQi7WZ46xlWR OgIFCET61btr6RuuuNN9mr/nNFarainiAundsdmSlXjB3mt6LsOa9KGzd1VuLzDIhJAR GkNWEkfwTztnFcHJl3xEMkAxc0UHHDMAk9NtpQvDGRKu4JqEhoEi1Wdck/N3+YBj/KGo RJLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192119; x=1788796919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=Jl9IaAVQ/de4Rc5KGTR4NaN/qxgDPegYYVD0vNB0t8VkuULaGg+zKr7BRZTX48ozwG 3cCned6Anrs4Yu2UIm/OfIioaqitIlOrvePJf/hajE2CnX4iTyzws9fY/ry0OeQmdrMd S5wX3SQgAMNS1IEmFEQpJJyd8L5JWolJ4oppk7mmmDxMEfJDA9CyRCMT8bk8ZL5SLIXe sOl0m7BsdbmptCpKvIt2F0ekUFm3eewseVQZ4Tg7kWsdtbfL57Fg3N5NIdD+VNFLeKqX WhUpVwjr128ZgEYfmOrQzGNKfWKR+RrCAt+B5xQnLQ7IbteUKzh7eI/4DNlmfkZO54vp 4pig== X-Gm-Message-State: AFuF++kJGYQWStvl5NJsMqXbzbwCPEdXU1eViFymxuVPZKHw4MoMpWl+ uizV8SuoZdogfOTMqyo0vtzTpjBISk9vcUPzireZ7jSyMaIGe6FH0LpH5Y0QMLiZYJP2NxJ5 X-Gm-Gg: AYBFou2W8aANHi4ISa7fXLiRhddfsnvOw6vygj0qvr53KMgH14OebAcpCBSkW4AM5qc NMmyf3Gm1cBt2RAV2l/V7NXDwVEw4dmfonhaySsVT1eyc5m/veTS/5stqiLUza1W44yQXdk5rna 5uM93WVyTaKmV9YfI5Y+c6f12UO79Bt4vZ4kYmnrZ9kFvVZ+6xPyLZ2GIIxBxbzMSbEwcG1EPVi gWyK9OVkMhfCWPG0HCBpTJm5QyN8xXfsfK3AhcIwXMYKZHW/5Aknj/Z6GCxTyTnYuOghueFJJAw 6292VJtGlBOClOfH0kt9Q6kdeC3Vq3eHDtUf8NhAxrnapZ1vRYwGTdklq1s+dtPOnSmGGvxUwwQ 9I+cyn6j3CoEXVKs3tD+l0Ar8L/v42SovNkBduAzxrDd2gCs+77GMSxMMmiZfWMdu9XuqtwxmcQ 7c2TTHsJ620oRSiSgWf1ztE4Cb6C0Jfac3yUnUsFhel0Etz2Vg6DOwztXZuLOLTu9X/5cwQIJmF 1xi/gqe X-Received: by 2002:a17:903:2c9:b0:2d9:6db:9fcb with SMTP id d9443c01a7336-2d906dba09cmr192172265ad.11.1788192118814; Mon, 31 Aug 2026 09:01:58 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 12/15] xen-block: Update tracking iothread users with holder name Date: Tue, 1 Sep 2026 00:00:33 +0800 Message-ID: <20260831160038.221776-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192179459158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/block/dataplane/xen-block.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 48c2e315f3..9dfe06e1be 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -621,9 +621,15 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevic= e *xendev, QLIST_INIT(&dataplane->freelist); =20 if (iothread) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(xendev)= ); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + dataplane->iothread =3D iothread; - object_ref(OBJECT(dataplane->iothread)); - dataplane->ctx =3D iothread_get_aio_context(dataplane->iothread); + dataplane->ctx =3D iothread_ref_and_get_aio_context(dataplane->iot= hread, + &io_holder); } else { dataplane->ctx =3D qemu_get_aio_context(); } @@ -652,7 +658,14 @@ void xen_block_dataplane_destroy(XenBlockDataPlane *da= taplane) =20 qemu_bh_delete(dataplane->bh); if (dataplane->iothread) { - object_unref(OBJECT(dataplane->iothread)); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(dataplane->xendev)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + iothread_unref_and_put_aio_context(dataplane->iothread, &io_holder= ); } =20 g_free(dataplane); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192181; cv=none; d=zohomail.com; s=zohoarc; b=MENfRoifQomMELcXpVqY+oBF4iEMJA4ifRWhbedDdft21VKiAC+aR+HVOyCjmvGzhlHiK/DSoPJ080dvRrB6zYwf2+f1m+ThgScdYoBRV/ZtXlAHKyxpOEu6LN+pn5XRLT6f4BNhxVCL9AilFnAcD932Nncm3WzUsbsJmUBf+OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192181; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p1erpzxKuw30oc89FICNKXtNCzj0wppAW28NB6qgVRY=; b=UPFQIjXezFSPwVM8TrVc6tK+RSn/RloZGK9AtlSB7U/vWO2DrzMD77XYKgWhKXGB+331A5DGkCwste28jS2t2yKlP4jY6hAI/Tv4AgQlsv9I+T3gSCyyNIiZiZqU8XV0DKlZFtKJV/rlsJeqRF1W/Fu9r+LnwdilMOeYU3DnEWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192181778448.4749195520202; Mon, 31 Aug 2026 09:03:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14SX-00032Y-Jd; Mon, 31 Aug 2026 12:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14SV-0002vY-NZ for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:07 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14SU-0001iI-6A for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:07 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-ca12086c06eso2933885a12.0 for ; Mon, 31 Aug 2026 09:02:05 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192125; x=1788796925; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=p1erpzxKuw30oc89FICNKXtNCzj0wppAW28NB6qgVRY=; b=PpLpV3eNgOATSpj/b0KxaBsAHMbqwE3YWnUsinuyN53YIgtB0qhjXoAAQdHPj+O9nN fIjTkfFyedKZAHmm5qGTbzJcmQGONg7SXkuzDVGYaghrUCjkjA5nNWzOLJUQhGqrNnWU 79UALZIf/w3Vgto5FaY5P9bS2N1l0awY14Y0/Bxk28tGB1VxSLrOV/AWlUnbjaKYMqvw g3u+s9LfQuii/kS+JYhQTxVn6f5lUZXK/JWVas+eo8jeOcU5YSjmPkRgFw5SBbFf3Te3 n1FtKNZ3n1nnGPfZtxGTy59C5zQpwvO3Q6IyujdBaI2O7VC4qIDjRMZdThiFRcLM/VVw qQiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192125; x=1788796925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=p1erpzxKuw30oc89FICNKXtNCzj0wppAW28NB6qgVRY=; b=oQzmqbOg1q+75x2BvalZDS5dzDMWrWyzthJiArCeAtGPuQ0zhUXQXL4R2EWTAMwrpe AsWNAwA+fUqp24y2MUPpgLK/gzcKUWmVF46ovK5K5xxmBtepuj3QLXP5s0N8r4g+EmK3 BcxbZ4fwplvJR8cjLryw542HEaA8DMF974ENq4L2GJRCfSYOzeUAhYCV5/ZKSE6ohT1a DPr3zWuxjG3w437ANn8gOpnnTKRPKto7/M/DjJuwqll7nW/WcRsRnkLOHtk8qjG7+/lu JI2qL/8IJ9+uZjjDg65052Tbow9GP3wp4lsfwupEMpAONKYnE+I6+W+nwysmEfGCUjaI n3DQ== X-Gm-Message-State: AFuF++nCiCvnSAB1Ps6QfGkXRuQbYKtGc5NIGO5+y3AntiRaeknkY0vP L3ohoLi6J/Qs1NG9DxZx3uJrI4A6csqsuG7qBxQe+0wIfg7ImLaPYQ7hvDCvC+WbdgzzbhOf X-Gm-Gg: AYBFou2EwJ/TuriNs/1edZqEf6qEnJCmwTYoVEIyz0l7jAMSxAtFm91nk/keck2Xu1Q ZHg+x7R7TXX23jJ+3S6qWRvggYAbXLno0Hh6eu8hKK19ucPyZf3Tktg5foeFSASTB2w91Wzdyfd 5pFzsDbYZBAVc1RkzMM1bjMT8agRMy0Qqz0dzCM3aHCtkyEdM/6qix3HPtTFYkPw07esWtyQKcF 7q7XuzLJVhaCqZNoBVaZOKmady/ME1DEQnsHE+yJsX63rpVIrmBNtU+0OrOe7QbhuyebpyVJiYT nDvF2kcztf6vNpXq1q41fdqwQ3uYaePaOuT39bSHCe4WX9fEhQUcdnxn3936KveVz1o8x8iGVS5 47bslpOa+LeYAxdannhe6TGLVkHizqPQlz7tWhY6SnZmsZoFcpTKKZuLoNYXflPujb7xTWR5XqJ HIWVFr/mEJgWRIozVV0MWjNO3jjG3QybwIdL9TgESS0Zn9/3Q23bIrnYM+ub0s0BXDNMV9QEoqb 9MgiFm/ X-Received: by 2002:a17:90b:28cd:b0:398:9c00:29ee with SMTP id 98e67ed59e1d1-3989c003c08mr28238108a91.22.1788192124491; Mon, 31 Aug 2026 09:02:04 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 13/15] monitor/hmp: display IOThread holders Date: Tue, 1 Sep 2026 00:00:34 +0800 Message-ID: <20260831160038.221776-14-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192183613154100 Content-Type: text/plain; charset="utf-8" Display holder information in info iothreads to aid manual debugging. Reviewed-by: Markus Armbruster Signed-off-by: Zhang Chen --- monitor/hmp-cmds.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 4e8d996dbb..0e64af349c 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -240,11 +240,31 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qd= ict) IOThreadInfoList *info_list =3D qmp_query_iothreads(NULL); IOThreadInfoList *info; IOThreadInfo *value; + IOThreadHolderList *h; =20 for (info =3D info_list; info; info =3D info->next) { value =3D info->value; monitor_printf(mon, "%s:\n", value->id); monitor_printf(mon, " thread_id=3D%" PRId64 "\n", value->thread_i= d); + monitor_printf(mon, " holders=3D"); + for (h =3D value->holders; h; h =3D h->next) { + IOThreadHolder *holder =3D h->value; + + switch (holder->type) { + case IO_THREAD_HOLDER_KIND_BLOCK_EXPORT: + monitor_printf(mon, "[block-export: %s]", + holder->u.block_export.export_id); + break; + case IO_THREAD_HOLDER_KIND_QOM_OBJECT: + monitor_printf(mon, "[qom-path: %s]", + holder->u.qom_object.qom_path); + break; + default: + g_assert_not_reached(); + } + } + monitor_printf(mon, "\n"); + monitor_printf(mon, " poll-max-ns=3D%" PRId64 "\n", value->poll_m= ax_ns); monitor_printf(mon, " poll-grow=3D%" PRId64 "\n", value->poll_gro= w); monitor_printf(mon, " poll-shrink=3D%" PRId64 "\n", value->poll_s= hrink); --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192182; cv=none; d=zohomail.com; s=zohoarc; b=Iqx/lEIzy2JFlTXc3ntdUSJL7BrLSccvUkjVlrkJL9O/1LFzE5xH7gOK9ICT9MHJZJG/wTKgAOl0bIvZlmDcFybL5taTGFAMiLc5J0bsm3hVixuaWVL+uObip0lA5bVhoyT1zl/DbsuRVg2Lnr9ZdQDyai45ortWj+3TBi+3U/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192182; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=ALhmjW3tWq+R5MEMa4TnRbpcYFvJC7mrOZNzizEW+DTOP3esMkFrbfXARerSO8tDs+ErCnWZv0CXHpBiwZpjtfYtz2TZsDVEcZ1AeBon2Xus8kE67K0Jvz4LO8nsy7tv8lhq1FPkLaCZbUSOAkfFIDetRw7J+XsJcyNEpTXqkuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788192182207477.25858356645904; Mon, 31 Aug 2026 09:03:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Sn-0003hZ-LS; Mon, 31 Aug 2026 12:02:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Sb-0003DR-73 for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:17 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14SZ-0001jY-Li for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:12 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2d71d1cc8b2so32635585ad.1 for ; Mon, 31 Aug 2026 09:02:11 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192130; x=1788796930; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=Xs32XbzH3k0UxsOJWJ6KkZGMt7sQrwZM6/pMtOZz89ztqLiuQGK4cTofSebmRpDOR9 gitzqwNfy0xyiR8lX14XA9xXCS/z7KueSQsYy56cnGvPBmPRbf/Ibx+9YUakx+SVZ5Cs SPPODf12sDset/Y06yxSWULXgtSIzMgY5/1Mrz5VlAfQrh3okWWIFFilq1nyD/A1HGRk 4IxLcS6XMcYkAfC8XkXuocf/OAOh9PeuT1xXmcqJYDKtp+fTgJapMlIje1WQeF2JCysq 6O4Si1p49jF7QF4MXXaeBWclLj8Oe12pP+2RhQrjQRhy7cPnhZEZrVSrXRwLYxunsHyc OlWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192130; x=1788796930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=gxMdF6NusaMma8oolHEvuZBlpYagmDs0IBpeg1tSgvOvM2Yo6RJp5GvxsR6CZ8Rzdp QSw+EeCB0EOzPCZv4F9+52q50PEn6DxC73VA47rhiFz4CQWeInIhX1Fov4DWBtcJiv23 w/7diKhFhmNnz07p556hyaunKa3mWHaajCP6sylWzEO1kKKEMt1EeXfCUOG75nOCiDDq pC10Dn7GGLOdueJw3KPKqnn5sUWXIToOmE9yz/Ka5MDM0SaxADsWtNLceoIFdjBBU+wD 7ltm9wQGUGZ5YIaX3YJD2hQ0JGgRT0I5B4o5K28aOUUuh/q3NoiE2IVrAB79H32bIiG5 J1MQ== X-Gm-Message-State: AFuF++mq7ALLQ+D3PugwcOsQ1YEWUTXgPerskVHIniEb3ULLx19KVc7O DgjyjKK3430SPOILflUgRjoT752+b7jntQ9vUiD+iIUzwOuOwU56VTQ8e1lgSPYVeyoyMi0e X-Gm-Gg: AYBFou0rtx51fMyHRZSz0BJLhFgUqWZYxXnRdCnA2ASDCXw4b7M6llM0McfCtfXqzxr Pxb1+BD+g4yrfnkW0bATPCtLpbK3PzwgBK2vOffodb5AWG61vx4LBKsQL9Lpz3/hsxywcXXoQIH /aQVID+H8Q2ZHHNSY2rHD/GY0rXT4s0r/zGbFoMtvsr55kwoyr5Sm6yYchOojrfo6hvdffEsxKV 67tyD/7l5vghhzYq5V4+bahuEOXac7UGwU6vBlUsByvW5cVORoZs0HUchV6EhQLA4kztXMV/xxZ iiXvOyABieql6HMDFqe+fPXZhpZiBp+J+/gDb0oxqNPv0EMVIOpI+99bI9CUQje81BkI9PqBQhs Boy4zInZu3rmItyZeSesh8Y2QRgawIV5a1mmCeVxHuu9IAgDJFlotLPe6YEvrnvuRCy3rBTC90F Xyu3gCNqLjuifLJn7PGN8ZlU1IaKqmck/CVsxslVG94xtmz78NOdpAVoylah5syxV+hM8mYfDfR nh1JuO/ X-Received: by 2002:a17:903:38c3:b0:2ca:e19c:97b with SMTP id d9443c01a7336-2d74dc30f3cmr460226265ad.5.1788192129951; Mon, 31 Aug 2026 09:02:09 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 14/15] iothread: remove legacy iothread_get_aio_context() Date: Tue, 1 Sep 2026 00:00:35 +0800 Message-ID: <20260831160038.221776-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192185607154100 Content-Type: text/plain; charset="utf-8" All production callers have migrated to either the holder-tracking iothread_ref_and_get_aio_context() API or the explicitly unsafe legacy accessor. Remove the now-unused ambiguous getter. Signed-off-by: Zhang Chen --- include/system/iothread.h | 1 - iothread.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index 2ef8c1a1bb..9850cdb3dc 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -66,7 +66,6 @@ DECLARE_INSTANCE_CHECKER(IOThread, IOTHREAD, =20 char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); -AioContext *iothread_get_aio_context(IOThread *iothread); =20 /* * Return @iothread's AioContext without registering a holder or taking a diff --git a/iothread.c b/iothread.c index 803d6ce3c3..3a092119ee 100644 --- a/iothread.c +++ b/iothread.c @@ -422,11 +422,6 @@ char *iothread_get_id(IOThread *iothread) return g_strdup(object_get_canonical_path_component(OBJECT(iothread))); } =20 -AioContext *iothread_get_aio_context(IOThread *iothread) -{ - return iothread->ctx; -} - AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, const IOThreadHolder *holder) { --=20 2.55.0 From nobody Sat Sep 26 20:50:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788192202; cv=none; d=zohomail.com; s=zohoarc; b=NFtajwpe4dGj74h95jvNWsq3IOiFXze+FJ68PZU5hWDVOKax8ijhV1zKiHjkhKfvRe+Ita0toonVIlH8j0GgBunwiXXC1waciZN/ypX72jRacXYJ+lf5utVC0KX1yjgWIB/ZsViFU+vPYredx5vRrL27P0W/UYgInLG7/Z0+MPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788192202; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=OQIzJcwv3Z808YS9WH/m/Vq/wa1VJnwxQckQJlNDaR389jfLNIrMibSnFz0NyBm8ajVc1ssgTEWBUu2bIDmc4y8HrIwlTAi3IbETfMmY44rmYOdqFzCvfhOmzhKemmolWWNXb3Y6uR7wmxrJyT4Gj2Lhhym1dHvLxSdOYX57Yr8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17881922023801022.1178141997555; Mon, 31 Aug 2026 09:03:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x14Sp-0003lx-Dn; Mon, 31 Aug 2026 12:02:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x14Sg-0003Ti-Nd for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:20 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x14Se-0001ko-7j for qemu-devel@nongnu.org; Mon, 31 Aug 2026 12:02:18 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-c9b373d5af0so2905976a12.2 for ; Mon, 31 Aug 2026 09:02:15 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32b28ab0571sm22689520eec.4.2026.08.31.09.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 09:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788192135; x=1788796935; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=le6DyAe4bwvSd50DqA88tE5jXZvGPYsNFBwALLZiysiimPAwfTa4hGWsud6KtMdMqf p0Xz4WopeiSAH/pqSgK4FlizRB+XPUglnxkiGprK2IwHen3IVFgwVCPLPKm2gP2fT2OW GID8c3rz+hBWrLNvK+2k0zNGCHmjIXQwrCWo/EZJ7nDC02+rTxt4YFHKjdMYt8X4Hrlm 0Bs3kQvS2a1GqFbVmxaZt+pm1uMUDU3fABRF/80T8tmKgK13N2QIBMpn1H8TkeNy+MyQ fz3PpwZo7QtvN1TtaPsLMWUZ12eep7/0QUjEOtsZFZM76X9U9A2ewl8mIqFhWKr4plth aTwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788192135; x=1788796935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=KRKHZtf9zLV47VaZ+cSGoFW9qUv7kX45JG5HaWhwnJm6pkMn6vK9hCJi5hAfBV44El 5+CjgvGwkWkNHv0aLCOeUnw/ocCL8n/WvwWou/TSfnrtLMIlBw4MAeVUKHaBvdCRXAGV Pv1sgl3tdJB5rpCOEIob9wvjOnpl5lQSPALX6Qkn5V1sWQtzyAl9gX0ioNH62kTJvnyB jpNvJ8qQjNOKq64ekNH17BmGcyUWsoeo3ju/FRebAVbOBKRr4zQlerMZLouCcpePkr4P tnPmZfsrB6a5AsYloWj2ESf+pX1W54V5YopAnTUc6cXS4Vd9xAt/cTPAwP6X70XRxBQN FXZw== X-Gm-Message-State: AFuF++nFNEIyOclANsU5ijCRdr4UxBZK1Y79ULazidYk9EK/StFTSvku DF7r9Gu8B17shiiA2TpiZjkJ7NBpO3d8nqHRl8gsa3Ci0OREmt2NQubkoDY8bjDM7fOH7ZbV X-Gm-Gg: AYBFou3PJv4josclRrnd6pCeq6NPSd4j4uXYR5yh/zrR7mi2ige5/Kd+QK56lwbGAxQ QpsTj2oue4bI7Da1mmweGiS9DWvm8Lv/6KbT1MKxJYp6Bzv43V+7PfBXuxz02DF2zNRcV0kdLX/ yd+ORxYWSkfJ2cedgOUCX9RDKyFJ1Fkm7cwXkbV54bR30r+ba0OODCieY+D+r0F4b72aS3XGgxI +bLhluYk58sVLGsa+JD+Un6hOfWIzitEEhOs4gndlf0gBHmn+JXaLOhUL5hIVFSKldbQJni73Zx KH3vCEGq4H8aWJFllCkN/gmq804b0qdMgOaIn23F5pSMrtxt5cf12JwfQFyooLpSibOEIRU1bmW OgN5L5iba8nvkU9gvVVySSpO1vIB/yIO+9aWbNVsW1BUTu7IjLfclf9Mq/vEHrg31Lr+Yva16m+ HMKWBrv+7+ffesnfE0PW/npCbEJxawTzMLzVWBDt6J63Vv/1RpIFDMW0yxAi+ydOusM626S0IGP jLwaCq5JlYN7rkH818= X-Received: by 2002:a17:90b:4a06:b0:38e:9045:bac0 with SMTP id 98e67ed59e1d1-396d0ea50b4mr37536396a91.5.1788192134349; Mon, 31 Aug 2026 09:02:14 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V14 15/15] tests/unit/iothread: update AioContext ref/put helpers Date: Tue, 1 Sep 2026 00:00:36 +0800 Message-ID: <20260831160038.221776-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831160038.221776-1-zhangckid@gmail.com> References: <20260831160038.221776-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788192206091154100 Content-Type: text/plain; charset="utf-8" Update the unit-test IOThread stubs and callers to use iothread_ref_and_get_aio_context() together with the matching iothread_unref_and_put_aio_context(). Signed-off-by: Zhang Chen --- tests/unit/iothread.c | 18 ++++++++++++------ tests/unit/iothread.h | 7 ++++++- tests/unit/test-aio-multithread.c | 5 ++++- tests/unit/test-bdrv-drain.c | 18 +++++++++++++----- tests/unit/test-block-iothread.c | 21 ++++++++++++++------- 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/tests/unit/iothread.c b/tests/unit/iothread.c index a363bf8f70..790cd2dce7 100644 --- a/tests/unit/iothread.c +++ b/tests/unit/iothread.c @@ -30,12 +30,23 @@ struct IOThread { bool stopping; }; =20 +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + IOThreadHolder *holder) +{ + return iothread->ctx; +} + +void iothread_unref_and_put_aio_context(IOThread *iothread, + IOThreadHolder *holder) +{ +} + static void iothread_init_gcontext(IOThread *iothread) { GSource *source; =20 iothread->worker_context =3D g_main_context_new(); - source =3D aio_get_g_source(iothread_get_aio_context(iothread)); + source =3D aio_get_g_source(iothread->ctx); g_source_attach(source, iothread->worker_context); g_source_unref(source); iothread->main_loop =3D g_main_loop_new(iothread->worker_context, TRUE= ); @@ -113,8 +124,3 @@ IOThread *iothread_new(void) qemu_mutex_unlock(&iothread->init_done_lock); return iothread; } - -AioContext *iothread_get_aio_context(IOThread *iothread) -{ - return iothread->ctx; -} diff --git a/tests/unit/iothread.h b/tests/unit/iothread.h index eb4d0c77f8..9bdac074c0 100644 --- a/tests/unit/iothread.h +++ b/tests/unit/iothread.h @@ -17,9 +17,14 @@ #include "qemu/thread.h" =20 typedef struct IOThread IOThread; +typedef struct IOThreadHolder IOThreadHolder; + +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + IOThreadHolder *holder); +void iothread_unref_and_put_aio_context(IOThread *iothread, + IOThreadHolder *holder); =20 IOThread *iothread_new(void); void iothread_join(IOThread *iothread); -AioContext *iothread_get_aio_context(IOThread *iothread); =20 #endif diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multit= hread.c index 9179cdc6a3..66ba5a466b 100644 --- a/tests/unit/test-aio-multithread.c +++ b/tests/unit/test-aio-multithread.c @@ -69,7 +69,7 @@ static void create_aio_contexts(void) =20 for (i =3D 0; i < NUM_CONTEXTS; i++) { threads[i] =3D iothread_new(); - ctx[i] =3D iothread_get_aio_context(threads[i]); + ctx[i] =3D iothread_ref_and_get_aio_context(threads[i], NULL); } =20 qemu_event_init(&done_event, false); @@ -87,6 +87,9 @@ static void join_aio_contexts(void) for (i =3D 0; i < NUM_CONTEXTS; i++) { aio_context_ref(ctx[i]); } + for (i =3D 0; i < NUM_CONTEXTS; i++) { + iothread_unref_and_put_aio_context(threads[i], NULL); + } for (i =3D 0; i < NUM_CONTEXTS; i++) { iothread_join(threads[i]); } diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 43b0ba8648..05c31ffca8 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -537,8 +537,8 @@ static void test_iothread_common(enum drain_type drain_= type, int drain_thread) =20 IOThread *a =3D iothread_new(); IOThread *b =3D iothread_new(); - AioContext *ctx_a =3D iothread_get_aio_context(a); - AioContext *ctx_b =3D iothread_get_aio_context(b); + AioContext *ctx_a =3D iothread_ref_and_get_aio_context(a, NULL); + AioContext *ctx_b =3D iothread_ref_and_get_aio_context(b, NULL); =20 QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 @@ -612,6 +612,8 @@ static void test_iothread_common(enum drain_type drain_= type, int drain_thread) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(a, NULL); + iothread_unref_and_put_aio_context(b, NULL); =20 out: iothread_join(a); @@ -762,7 +764,7 @@ static void test_blockjob_common_drain_node(enum drain_= type drain_type, AioContext *ctx; =20 iothread =3D iothread_new(); - ctx =3D iothread_get_aio_context(iothread); + ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); blk_set_aio_context(blk_src, ctx, &error_abort); } =20 @@ -892,6 +894,10 @@ static void test_blockjob_common_drain_node(enum drain= _type drain_type, bdrv_unref(src_overlay); bdrv_unref(target); =20 + if (use_iothread) { + iothread_unref_and_put_aio_context(iothread, NULL); + } + if (iothread) { iothread_join(iothread); } @@ -1398,8 +1404,8 @@ static void test_set_aio_context(void) BlockDriverState *bs; IOThread *a =3D iothread_new(); IOThread *b =3D iothread_new(); - AioContext *ctx_a =3D iothread_get_aio_context(a); - AioContext *ctx_b =3D iothread_get_aio_context(b); + AioContext *ctx_a =3D iothread_ref_and_get_aio_context(a, NULL); + AioContext *ctx_b =3D iothread_ref_and_get_aio_context(b, NULL); =20 bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, &error_abort); @@ -1410,6 +1416,8 @@ static void test_set_aio_context(void) bdrv_try_change_aio_context(bs, qemu_get_aio_context(), NULL, &error_a= bort); =20 bdrv_unref(bs); + iothread_unref_and_put_aio_context(a, NULL); + iothread_unref_and_put_aio_context(b, NULL); iothread_join(a); iothread_join(b); } diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 5273ff235a..fc9735d056 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -466,7 +466,7 @@ static void test_sync_op(const void *opaque) { const SyncOpTest *t =3D opaque; IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; BdrvChild *c; @@ -493,6 +493,7 @@ static void test_sync_op(const void *opaque) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 typedef struct TestBlockJob { @@ -549,7 +550,7 @@ BlockJobDriver test_job_driver =3D { static void test_attach_blockjob(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; TestBlockJob *tjob; @@ -595,6 +596,7 @@ static void test_attach_blockjob(void) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 /* @@ -612,7 +614,7 @@ static void test_attach_blockjob(void) static void test_propagate_basic(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_verify; @@ -658,6 +660,7 @@ static void test_propagate_basic(void) bdrv_unref(bs_b); bdrv_unref(bs_a); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 /* @@ -676,7 +679,7 @@ static void test_propagate_basic(void) static void test_propagate_diamond(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify; @@ -736,12 +739,13 @@ static void test_propagate_diamond(void) bdrv_unref(bs_c); bdrv_unref(bs_b); bdrv_unref(bs_a); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_propagate_mirror(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx =3D qemu_get_aio_context(); BlockDriverState *src, *target, *filter; BlockBackend *blk; @@ -807,12 +811,13 @@ static void test_propagate_mirror(void) blk_unref(blk); bdrv_unref(src); bdrv_unref(target); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_attach_second_node(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx =3D qemu_get_aio_context(); BlockBackend *blk; BlockDriverState *bs, *filter; @@ -840,12 +845,13 @@ static void test_attach_second_node(void) bdrv_unref(filter); bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_attach_preserve_blk_ctx(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; =20 @@ -871,6 +877,7 @@ static void test_attach_preserve_blk_ctx(void) blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 int main(int argc, char **argv) --=20 2.55.0