From nobody Mon Sep 28 01:14:57 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=1786048026; cv=none; d=zohomail.com; s=zohoarc; b=X/prRTmyxUGFLgU14SOA0QErIpK32Ps+44luCKLixUKl/o9WvXfgNJIKLkg4JJKXTBS+k/5bvSVeuF91Klt+mpuv2KhI2Enf5WNXDUWmKQgiPfcCEOZWoYG4NPjFeKg0bgYcJ4viYw6uZl5L9/vktWh1GDIxVzqbsaDw6sBPFO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048026; 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=EWHONfUCX/FGEBUZFGh5qRrolvfMef8ddxzy0OMFxgM=; b=n45rrl/8OYnMk4h0coAKYjb841/q3M3LiZ7ZeEwXHOd5vVIswsDQvve/4hEiy6jkPvmfEA9cEFHohjcZhZXwHLz7Ma2valXLnvivZUnjWJA8ZjUNn7/1/tm0FKqIENPhfKIomrnhZCSPG/NvEIayp1CIM+0oTIxxHOrljKsaDpk= 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 1786048026014596.8469340204991; Thu, 6 Aug 2026 13:27:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4fz-0003u0-6X; Thu, 06 Aug 2026 16:26:52 -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 1ws4fl-0003pL-8R for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:37 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4fj-0004y6-NG for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:36 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-84536ecfc5bso3292353b3a.2 for ; Thu, 06 Aug 2026 13:26:34 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786047994; x=1786652794; 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=EWHONfUCX/FGEBUZFGh5qRrolvfMef8ddxzy0OMFxgM=; b=F8x23kXYkyi9DdrZI0m/10YCiQ13Zh9MhjYJrCpR+89mtY7cxE55zcaup4l/RvvFkG tj0t2OtH2Nl5zWRRtL4PZ8tu98BYW1Q5dXCpiiJar43fXIL/3zemkqGhj/CsFdoCogTl QYlGlvoCcobzS5eNFv3R93jjNSIe8+VH2XYnSy/2guLGcIhO0cGWJbq1NsO3Mr1aJtCU H/gc9itFNl+DjO7x3AmF+2dKQQcHVCdPs2SfGPOHfKcaPzM1BuTGJMpNlvRCBzMC8gxm AwMFgnhP0qcdlL6Tp0pdcl49Hn2TkbfTiCii2tarp+9xVAvapptdM6VHopQG0coigl1E SVZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786047994; x=1786652794; 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=EWHONfUCX/FGEBUZFGh5qRrolvfMef8ddxzy0OMFxgM=; b=s34IzA4Y0Ck5vlXgTpRRBo2rRdtR04FUuGYjwCPL8z5tw/gngfLNcApRBHUwegNwtw EZRksd11LD/5J/CoU9eRW3iKnVsKSiTHMuGTvGgqHo1clX4RMDHpeJhxGQ84jVksMfU6 LRYa2gCo+whLqMDXk5RTFzyMv3ubyQOaSXvrPzFhYPa1HdqGPmHI2nTKauoHvfBEIa9K qAckuIakFYd4ExIkOvadB+lZVHQxvEWDmfXVfavx9QL+x48fsetPyzNMBngehBgxGH7v ccJayI9OnuaMuw2F5pizVoEbl593SVPVFdo7Zk4hwo+3ML28eLmRdyn1t/MGicn1WNQV vBwA== X-Gm-Message-State: AOJu0Yw4CNx3uvPSNTiFXN6WHxUYFl+906PTPO7DOh43bMnS1+vNSmdh 2Vx02WxDYWz0Rs1eR6Egj+9bZ0Na5a2ZjAAXq85y2JtlzL9YRFpmNtQZGGBgc/+yKowjXmeU X-Gm-Gg: AR+sD10mJF2RkZtCUxx8jk3AMV6dnUbjTfFjaO0Mi6+BasbGBqNy6LMNhUg08VziNFf Xsz+kZFcedAEKx18Ml4bOH+2FLFvUGK+C5sTcpbjMXVJVpjQFigtvKN5lL3Y3hk1GLySjMd5FKy Bvu8nLiHp45Cs57m7tjE6i9gQNYCytbS2VQF4422JMPW9WoaLXZ2pzkpomhFQU6GHsUcSzOR+Go sVb7Ut/bI/uurLKvNbxkZDWp2Qpt2l2Q7zSV3lG839w0oOSmbiuV20p8+TjbyK/cFLIOMGuZvOE LcHNj0j4aTTUJId+1x/tz6z5MsdHxcSpSYIQbMKBk7ik+Fmjp0N2I3bJt3+igbWFhWUPSK5wkAd 5K/RAeZRnrP6XEXHWEL6/j2DBl4Hpz2xYfS1ytoryr47UfXLiXKHsCwhPEAvZ9ulYuufwGv1Uv7 1slHHeKpdMslnjZYmpGYvX35M9F8kL4/Ydsw9Dvlwup5vrQf1SJxu/KcsYOdZgm7S+mqbE9ouaL 98govzjhuMnmc83 X-Received: by 2002:a05:6a20:cfa2:b0:3c3:875d:c52f with SMTP id adf61e73a8af0-3cb85dc28femr23180052637.10.1786047993817; Thu, 06 Aug 2026 13:26:33 -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 V11 01/15] qapi/misc: Fix missed query-iothreads items Date: Fri, 7 Aug 2026 04:25:10 +0800 Message-ID: <20260806202531.243806-2-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::434; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x434.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: 1786048028316158500 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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048115; cv=none; d=zohomail.com; s=zohoarc; b=cg2rrOWfHkT8zTvT+3X25gj6MSPMdqYExfRCTC1WjgUi/qOEg+OciY8TIHS1sehQ/Xv77REPOpFa3Ar4yk4a3Jq4MfGZZiSmZYa3HZxkIxuCQNbV6MLxDNZT58TgGK+/Kt4bDT6OsS44gLQxfe/K2AlgNrf+X25S22Rc93sptOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048115; 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=c0+uA5b/iWy554Dx3iSq0wK/n/K2FnKKcA9qcdKVJkY=; b=b6bO3A1biD0bmF42vXXsSeXze85dstz4frEOe6lnR/0Vz3ybLe7tw5ZHXvZomS70YsCF+sb+lsD3+5F+qSAIXQ+TbV7v/Pye6gbO+dc5FJLekzBveRQkFr1DExPVTjj2lywCSYNSB/OO7BGXk9H8oYLkBtiL9RPYM91kInTFUeA= 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 1786048115351236.82758164083862; Thu, 6 Aug 2026 13:28:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4g7-0003wl-62; Thu, 06 Aug 2026 16:26:59 -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 1ws4fr-0003sj-1D for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:43 -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 1ws4fo-0004yf-15 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:41 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2cf452def93so11188985ad.1 for ; Thu, 06 Aug 2026 13:26:38 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786047997; x=1786652797; 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=c0+uA5b/iWy554Dx3iSq0wK/n/K2FnKKcA9qcdKVJkY=; b=Gh7URdNxl88SVURk5dYVLTVNqNgkWehn2uUgDJ9nTou2njNVSZda1rMHABUl3LGd5w Cpv2RrCzJ0pZlJBWCAbH0gJlDoXBVaS/xpX3uxTF5g9JEYZw66KFp+rF8TBSz14L6w0q VBtiQQqOxscQXZBlotGYjqGRvvHTxSMEwljZZSXrkRAQYq07NDl8/+bLBTeld+2XNV2c CJHZFGGso0GzxWVyh3Hp7yea8IdFgkDcG0OmWc3XI4WJmcp34ktGOql64QzNVugDbPnS nXsipr8Qji4ItInMpyXbhvJWaStf8lOjr1x3QnpFjDD47d+mRTnJMbuwYUQK1nmgUmv0 U9OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786047997; x=1786652797; 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=c0+uA5b/iWy554Dx3iSq0wK/n/K2FnKKcA9qcdKVJkY=; b=RBOIucTnqiWVKOOiNQmANMFjj11CSuyuA4gRL6+yHsyoxXgHQDWEqKoBObpCPlKJif Edn09rWEEMyyFVG3SrjmY1+3buyFPEQizzTY8ojJJwcCaQA9NFOxAEgznK7J3d6LBUtn 8FF2tkMWFhjZDx73Gy7sY0S9crOU54tAbCnn9U1DMicnyBJHeC75W/Ej40150ANtY8hE TmicE4dlGzIQBWYcgGiecV9ihO+YNdBp/6IZFnWyP9R0YmUkY2g3d3VwSAaSx4GHseHT uVXOUd2C04GvV3Zk0y1yIkyET0jM+GgDvG199n39w3qUija5KwBBHWSvh/0iQAvKQoxU SuKw== X-Gm-Message-State: AOJu0YxvSyTDrEs10qt2xALdM7oBofi+tyVwm+OhHecxRc7RvsuFWyhq +Q/35zczDqgiG06dtcgNrCV/KI1IFNDLu4dLRlxm1VeC8GtDKppSwySehqy9P5qka4nQniTZ X-Gm-Gg: AR+sD13K2w60l/xx9RO620G9XB9Sfif/5lLHrV2Nwk0FI5/eqasGgUiXxhz1zV6fnuy LT08v+7lRlzdyDEX7iMUbSNdc1HnsVbur3beDwTfJS52zxoYUIj1TpO19NyYfaa8pasDKnl/k43 OWRrEAmdKz6cG+UvK9Hs38LjdDNrPvCTRncNZF19p2fHREcc/SZu9Vd06dp2OcTTuj7CQzKjcKD k25hudcb/Td7B3Ua6MGQIcMjWkHEyHQu2GvS94Jkid1RSLE1ntjh/5J+sQM7sPHGqt53va7gXeE yCF3gThFE4Sntpnj3rUCQfIl/MZ5U3dKdsDRmpqlg/ri9cnNXWQUkitLlQ+DBhh1wbes3KxiogX IoCrcUtN+9aA+nvjusmEQau4Zjms6+HtQn1tx+7WMRkjLZvfnGhccZZ47Dmae5AMXa8QjLO61MP ZfltzRdLsVfVeBjHQS0XcNkHvRHBwM5FkWNc7vSPAFC0/r7R/w0JC7XUhTsmD37oGljG3S6dUvC aoS7awo2KKT8h1tSVgVU6TZPIchjmLCxq41Jwc= X-Received: by 2002:a17:903:3885:b0:2cf:af20:4254 with SMTP id d9443c01a7336-2d0f1c0dc3dmr113660155ad.10.1786047997234; Thu, 06 Aug 2026 13:26:37 -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 V11 02/15] iothread: introduce holder tracking Date: Fri, 7 Aug 2026 04:25:11 +0800 Message-ID: <20260806202531.243806-3-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 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: 1786048116375158500 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. Signed-off-by: Zhang Chen Reviewed-by: Stefan Hajnoczi Reviewed-by: Markus Armbruster --- 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..2a4c92e08b 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_b->type - holder_a->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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048070; cv=none; d=zohomail.com; s=zohoarc; b=hWQ6X/v/nrgnVxcG7KKuyJ+JVjDGenJ4aMXbGdywuKN61bK+6EuhfX+3hpo0tZF8RNg1VErkrPGnmta8rmJ6HdTs8En6pDKc05qAjJ6/HX0iTnwCX63xSpRuXyekKhvmjwey0E69I1C8fLjNpVHNyGhFeJoZ8If6EV9gTKEfYtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048070; 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=SaYapBLbD9XCZZx/Z5KC+hEKo+tfsakv4kbFa0GStzE=; b=ObaZRoQxx4k2zgbaZfRBPm1hEZ1s+2GrAKwV6NLB5YnEVdw8C6P4PCkAVGzZJ3eKNWM2cE9574i/0vyxqiRNJ8I81/HVoGLbPhsKEmdk/dWdHBUhQfAshggQq+2uxyzcfg3jeWWRwaVNjUXjnR749b5YCvcqkoqM3LPsFzbajS4= 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 1786048070286917.7437754246296; Thu, 6 Aug 2026 13:27:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gC-00044C-LU; Thu, 06 Aug 2026 16:27: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 1ws4fs-0003tF-Dk for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:44 -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 1ws4fq-0004zE-Pk for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:44 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-c96c92c0980so1719867a12.3 for ; Thu, 06 Aug 2026 13:26:41 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048000; x=1786652800; 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=SaYapBLbD9XCZZx/Z5KC+hEKo+tfsakv4kbFa0GStzE=; b=lOXR2vUTjPO8CN0k66IzalwToIivIVNB19G4DUL5PkUfGXdxl+2gp8F4tU1+yhh/Bb jE5IuBHnlkm2Cx9bDJcKIqqeMGG7mEFCCKck7ee7HX21FaW9e5k2xyVsFj+PV1c1Ps+/ VdIIoMOdJcRrsTUJ+tKg2nXD9Sx9Z8P2q9jFumLfayKzmfBOepgC+/PalY8SMgjGKBe2 cpllh1rZMu6ov5UgjOhoIlx+tq+0O5r9z/ewaiU7dnkLPTG9kIUwpFLaT8KEnV/FV+Uq s2fxHem4XiyRLVpgTuOQ7meGj/JmFJYwTnQQJMumeJgfYyIRZI5DcsgblamCivwOVxbd OEIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048000; x=1786652800; 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=SaYapBLbD9XCZZx/Z5KC+hEKo+tfsakv4kbFa0GStzE=; b=CRBgJ6cmuK4ZUyuWUaE62r7FsLI4RLFNBe9gGQcAfnRnHTMHWBV6kh5YFIwVBAiyYK vmuP03QchGCpJyux8AQC4xcuTu9g6AmTgQoYpAruwtyHUgtNBJgqSIrhvAe6ECJuEK8e E+zMvv9l6HLMNUWlu4W0NnZlnLNwef06Z6UtAgFDxtjF0j5DTMDa5Bg2Z6nntPugx32x spMCXQnK4axcqpDe5IdKKlIs7/K9nzdFpcxSRc2s53vhKDb/NPM+JZC5Ga3CfczIOD8I Ht2ja+mzO5QSOupLoxJx/kHERRlIcgfAhUjbBGkyhVu0HivEoCF7WiIvcxxgmt2BbHhq zaLQ== X-Gm-Message-State: AOJu0Yy6VBJPT5YbjOpVI1avroD3oX96jjcbq19WV3FU1orYRT6BeBhC EgBeGkSAWGP+IW1g2ovgGMvpnW4z3K1wua8ckKukK2nb2lqunKDj2B4KwprC9aahpaGBUPvi X-Gm-Gg: AR+sD11VhseWzJ3a6SH6kSaMpLUrgaenp1wYUiLp4Cy+wD1ODhLKD9gIC8jfDh7sVDP 5e9beGJA44Xo27up50ywAa42VCFajsg29o+H3DCEH9ct5OLv3hRcx2gyDx560nLE42GkDXB/gCE Y3dXPXpO4E8BsasIpPAtOlQ/KIR9T3d/QORP4VrU4yURPmUCpLrdlV2L5falac8beoxOBZA1Jj2 /DdhioWmrB8uUSnbh6FMCLjmnAD23LEm2AFzMiElvShyTM6e5GJBgeOTyZMs8j43YZKXudSSNV2 Mg+nVvyA0Jfox5dp0V23wfEZ9IZNkmNz0L42fQfHGa4uorJ1BaFDciEJl27Bmqmfue3UTDabrow IMcO8urhp+d1MKSeQYh5UXZUstH8azubp4EqzXal38kcVXjLycxDF7pE+qXo0FPZQqe+4+RfT0e WxEheGEZyRvbPj2jKdzDKKsmaBThKj1HlPlXayjxa58O4X/chgZX0grFmO9lCGRH2jqQ6lwJ2JL pQ3V1rcXD000Vcs X-Received: by 2002:a05:6a20:db92:b0:3c4:147e:98f1 with SMTP id adf61e73a8af0-3cbadcfd00emr5711890637.31.1786048000558; Thu, 06 Aug 2026 13:26:40 -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 V11 03/15] iothread: track users with holder name Date: Fri, 7 Aug 2026 04:25:12 +0800 Message-ID: <20260806202531.243806-4-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 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: 1786048072177158500 Content-Type: text/plain; charset="utf-8" Introduce iothread_ref_and_get_aio_context() with a holder argument and its counterpart iothread_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. 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. Signed-off-by: Zhang Chen --- include/system/iothread.h | 21 +++++++++++++++++++++ iothread.c | 23 ++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index b8aeb32b0e..b6664e7a38 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -67,6 +67,27 @@ 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_put_aio_context() with 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_put_aio_context(IOThread *iothread, const IOThreadHolder *ho= lder); GMainContext *iothread_get_g_main_context(IOThread *iothread); =20 /* diff --git a/iothread.c b/iothread.c index 2a4c92e08b..0cc8344ee6 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,21 @@ 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_put_aio_context(IOThread *iothread, const IOThreadHolder *ho= lder) +{ + /* Delete IOThreadHolder from the list */ + iothread_unref(iothread, holder); +} + static int query_one_iothread(Object *object, void *opaque) { IOThreadInfoList ***tail =3D opaque; --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048051; cv=none; d=zohomail.com; s=zohoarc; b=Tc+KFFDVe9OCH7HzGNakpqAV5M5sozzD181o84l/0N5EiM54JJqFLXiLAR7pCFS2ic9HZLlNvZFHfoTgDP13bVw+1B1hvAvOQRB1FjLZoGoN0CKCOKKLmdLFoUrww/Y3GPYV9Gs17A6LvxrM2KL7FGAA2I/LCircT6ZiYpG7DAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048051; 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=zJmtyUkklFhBPEIpsWKaEmdq4HWMkw7BrqZ8d0rzmAw=; b=So0PBSoXaa5w/yRxkkghC7RRUb74t/za8W1XBxlRhF5qO9XYT66tNIKrlqCAwNqLoPx+wO0npotvczyJ4o/6rKAdNnmgxfL8u8Ixo3Lybq5dhAMhVHgbAHoQuw+h1DQEE+QTD5ohSiO+bLuu7v/9+48JS6xglKJe6wk1LOZMLK0= 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 1786048051293610.6354864673756; Thu, 6 Aug 2026 13:27:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gB-00040T-3O; Thu, 06 Aug 2026 16:27:03 -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 1ws4fu-0003uu-Tb for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:51 -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 1ws4ft-0004zg-AJ for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:46 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-ca97d139d8dso1764299a12.2 for ; Thu, 06 Aug 2026 13:26:44 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048004; x=1786652804; 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=zJmtyUkklFhBPEIpsWKaEmdq4HWMkw7BrqZ8d0rzmAw=; b=Mp2O/8xPSBB4glFvZzM0Ds75cfDHboTXWfGk7K+FQ+wUGmDSERWGRhNxEV5uoHNxRz 4nNZWnws/M9NqlYhJ5tV4sLpFbaLOAvE8Hzg5F2ufEVQE71q676w8oSK+4lcHM+EQ8Mx jCyKMUVTl3ave6xXmpfZ0Vpkcft3gka0ZfOzfoKhofhrD+jz0SWDB9yTTbzknQejmrVb k9ggjBRiq4bYXzYQ3gXeahUpPG551qj6j2F/QGTXEniOcqW3TsdBkXb+kD1K1CD7TX7A k7Os7bYxlCpWW+ysLBH1m1t8G1BMo8Erj/lWj4CGv1wDuYPruMtcBQvRrwaeOS7PHLyZ yd0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048004; x=1786652804; 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=zJmtyUkklFhBPEIpsWKaEmdq4HWMkw7BrqZ8d0rzmAw=; b=IofJNPBohkyXKi63+CM+GsTjgof/7D/nj1xQ37nEY/0Kw5jC2u5dlB7xcZ5PqvxiS1 MHnwbvpjont88LI6+UYZ428J7Zx/z0SwOQtJsxPC9z42pkiv6CXyopNz9kocqLRt29j/ Gp7GYvdo2oq98UeQZWNY5I3woc1wx08nEh6J6g8mMR7k8iGlQwG72Q3+kNfo91iuxXlr UvNptt5oEumzqYMlNMeZ4n3m+in7vgTRsVG7+fASkZxa1TmeRo5nqOvRGUlWMFijo3ux ePM8rj/k74btQwK9x63IYGRrUtm8FEh+xjKen3tTGndAhKnndg4p7ChaaCVCpv2akOBP 5ZPA== X-Gm-Message-State: AOJu0YxHOgqM/VsZtoXlrAM7uYuNR5C61VPeTkjczhMN/GxldCqy3gRV FsZVu4p2h+iXBJg7aVY6AOr4/D6KNf8VFo0ZbQPSgFrLj2D2cfo5BwsyaK/SI6NlOw8e8UdY X-Gm-Gg: AR+sD10k3F+NVkquyHG96XXUZ5iOarjz0u3IKhN8bBYdGEEqzLb8yGYC2eCu2Ssj8Nt F75d9QGFwLad0spa2JjF9LeeSDKtnKlW2stgTwFZOhYX0kdH4VdaKi49hsr/PlwsJrF7Bm5mRb+ D4mt5exNdEizxvd0a1vsluFoXT/JNAsC3Svt3hOSXQLnvJncHP0+pyAHGphp6Q3V3R2b4wvSSFX 6FN82OK23udnXSRg3OtxbxCxediYHuDSOzAcld+LFKk0FeqJvEfcfreX4gLtOHYc6qGvbMgfX3u mgDxiJGqIx9hgY+yy2nNyx40GRckgHsnQEGjEJez85NXDAYLapVtnNsH1cjdAmffuHb2C/3RlQw QdFfyPpI3LunwI61n4SJ63A27j/RPTlDTYGU+rGIHDYPtts1mN66Rmezk014zEHZvLgKNiduAls iXf7TF72QfGUeuUbeK0ckFKedWX/JcMmtTRWDSiwhfINrtFIP05l3nJlZIOtcqYN1DmLI9WfRHD tgpAap3LNQZKKmD X-Received: by 2002:a05:6a21:1b85:b0:3c8:d3a4:7b40 with SMTP id adf61e73a8af0-3cb85ded978mr22825451637.2.1786048003924; Thu, 06 Aug 2026 13:26: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 V11 04/15] iothread: introduce iothread_unsafe_get_aio_context() Date: Fri, 7 Aug 2026 04:25:13 +0800 Message-ID: <20260806202531.243806-5-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 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: 1786048052020158500 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(). Signed-off-by: Zhang Chen Reviewed-by: Stefan Hajnoczi --- 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 b6664e7a38..cf1b6e0cdc 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 0cc8344ee6..43f42c65c8 100644 --- a/iothread.c +++ b/iothread.c @@ -442,6 +442,11 @@ void iothread_put_aio_context(IOThread *iothread, cons= t IOThreadHolder *holder) 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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048059; cv=none; d=zohomail.com; s=zohoarc; b=XjC8n58RMxKwKj2i07ktK0DzVXZg8PHdf1IH2IKFho+jVR0OqJzukKFiJ/dVqZ4WhB8243tTPmS9W0JDDOe/6WSGTU3Ct6vdfd/hJfafFk8afO0SRt4H16wXQadQFibMPVqMR2hminiBK5OTSixgzgZxcGaZLK8E0KdqViHPEfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048059; 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=5X0V8jZCbDKykpmj6x9x0QhtPxCJ1NJOlHyWr2doyqQ=; b=YJKn9NGNPL5UU66Yy3wK9iZ5fskhBjmINg/138PN91qN+8VyWIPWMmJqlUuLIrfCC1DIQT0OEO6glILRJHKco8cDysjotyYJ7JzkM3kLlq61K0H5368lD5GD9mMhtxmKFnSKGQyyOsYygjmDXhRP+j4vT5/ub6xFUJt8zZnntt4= 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 1786048059912560.4072003005782; Thu, 6 Aug 2026 13:27:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gB-00043H-Qs; Thu, 06 Aug 2026 16:27:03 -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 1ws4fy-0003vJ-Iu for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:51 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4fw-000503-SA for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:50 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2cfff5f88dbso38608055ad.3 for ; Thu, 06 Aug 2026 13:26:48 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048007; x=1786652807; 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=5X0V8jZCbDKykpmj6x9x0QhtPxCJ1NJOlHyWr2doyqQ=; b=b90SdWbjX229vjnUW746MJD9WaeHy91h8IejfN6miK6D67C6g8aayZx2DH1nfAV2lU KoJp0TMmtV2stZLDfH8Shwssa1leSSyHQP2mmDopRqUVeNUur89YLQycCRXqReCQIMbp Lssh3i6b7TsVaTJrC+UyXSLRdnovWtnrFHROsxN61qM5z6mTf7qYdh5fFg0SKRbQ4VRt ACsm7h6JkUb/OCYzIOj1TeX3REXchoK7eN7XUoliV7wXuDfymWDsh+47i7w89tfvalUc 7lt8LSlPm8F/0Lz/K9T5NJxuUSGQ9wprXDskAuOpo0ezxBVduFKwfNe+eEAwFBIv28DD F6dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048007; x=1786652807; 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=5X0V8jZCbDKykpmj6x9x0QhtPxCJ1NJOlHyWr2doyqQ=; b=jhSVsvkrEsCsLpyIl4GuQnU8TMBSwi16EoEqku5YaBQO0fQqEyms9j8eD0cXZz4UzA GpU7Rgl1/0HLVrcQBqWuonvg+wn6S0cxWngyVmj1kCxGslf6hStE7J4er+3yHhEEJVst E3oeTZkccUDj9ev3Jpb1CnbCoxf6F3TxCKeexd2kMPypX8X8PRqX6VUvSXj/v4QhabyU HBpoDH07UIbF1TmP7/xP45vTVgL/2xqV5qhXUyugwl3aJMi4KZ/AaM9G9w857diyMDSH YUkVJfuTTfZsSMVEqjvHS9gRdKrolodMwH8n3ZPGP0xPwTvTxLZdmoLdN0i9jLfjTbWm LNEA== X-Gm-Message-State: AOJu0Yw25zbkcHQHEcTF1DqQ1hWMvg7HnGKFhU+y8OsnFbGeRYOlJYUH Gu3vPbo4i99XTC1o7V/ulFU/E+LK4XZRe3/WJqW9+ZQMB5g73mZC6ECAnNNxDsmY3q/NjfUm X-Gm-Gg: AR+sD12Ly0jEObk6K9oqRX8u7iI4svDWDj+RUrFlzDkSW2T8cfuRGm4C5lH4DIcKOPR J4za7P3t3fPFbXbZ7/2Kz2gb8Y9NTgljnGWA0vOlK43k47fzNBYfURD7nwMTFcYva8cX8ejnzVP rrFwS/8C9yToujhv0TF/ebd0/P7QYnrENTGgymcj2uWjnN6FRTy11zq5a1omDXxugz+fQWO2GrD QMvxNI+QRd1eYafd/KBcyJv7AJ6NUt7ub/ghGiwcfTb6cEWa3jD6jyd8cCQKMUfPzNJ5kpN5vxO URtUeIIlAJ+6EedBZBhW8fo0VWFpZPYtbL23zpghq2tz8l7Eufzohqqvy7c1IkZd7m02Z4i8bL7 qAbDoBDsntj9U1jhi8Nzy9cUL0iIxdNYy7G2a2eBmu3EDM5DXhIkL7d6Rulw+a0521PtAfelPs+ h95q06xtk5+r37L8/6cjBfbPWTYaMVTu+4psXFcoH+ydcSi2h7rTb0QXVIDr/ckVqcsKa1m9K5G MH+hAfzOCjIUhCuNEPZYy995wQ= X-Received: by 2002:a17:902:f605:b0:2c6:9f66:d573 with SMTP id d9443c01a7336-2d0ca71b3f0mr224490305ad.2.1786048007391; Thu, 06 Aug 2026 13:26:47 -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 V11 05/15] block/export: track IOThread references Date: Fri, 7 Aug 2026 04:25:14 +0800 Message-ID: <20260806202531.243806-6-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::633; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x633.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: 1786048062136158500 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 --- block/export/export.c | 79 +++++++++++++++++++++++++++++++++++++----- include/block/export.h | 6 ++++ 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/block/export/export.c b/block/export/export.c index b733f269f3..96d719418e 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" @@ -85,6 +84,8 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Erro= r **errp) AioContext *ctx; AioContext **multithread_ctxs =3D NULL; size_t multithread_count =3D 0; + g_autofree IOThread **local_iothreads =3D NULL; + const char *holder_id =3D NULL; uint64_t perm; int ret; =20 @@ -139,7 +140,16 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) goto fail; } =20 - new_ctx =3D iothread_get_aio_context(iothread); + holder_id =3D export->id; + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + + new_ctx =3D iothread_ref_and_get_aio_context(iothread, &holder); + multithread_count =3D 1; + local_iothreads =3D g_new0(IOThread *, 1); + local_iothreads[0] =3D iothread; =20 /* Ignore errors with fixed-iothread=3Dfalse */ set_context_errp =3D fixed_iothread ? errp : NULL; @@ -163,8 +173,15 @@ 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; + holder_id =3D export->id; + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + for (strList *e =3D iothread_list; e; e =3D e->next) { IOThread *iothread =3D iothread_by_id(e->value); =20 @@ -172,7 +189,9 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Er= ror **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; + multithread_ctxs[i++] =3D iothread_ref_and_get_aio_context(iot= hread, + &hold= er); } assert(i =3D=3D multithread_count); } @@ -225,12 +244,15 @@ 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 multithread_count, + .iothread_holder_id =3D g_strdup(holder_id), }; =20 ret =3D drv->create(exp, export, multithread_ctxs, multithread_count, = errp); @@ -250,8 +272,32 @@ fail: blk_unref(blk); } if (exp) { + if (exp->iothreads) { + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D exp->iothread_holder_id, + }; + for (size_t j =3D 0; j < exp->iothread_count; j++) { + if (exp->iothreads[j]) { + iothread_put_aio_context(exp->iothreads[j], &holder); + } + } + g_free(exp->iothreads); + } + g_free(exp->iothread_holder_id); g_free(exp->id); g_free(exp); + } else if (local_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 j =3D 0; j < multithread_count; j++) { + if (local_iothreads[j]) { + iothread_put_aio_context(local_iothreads[j], &holder); + } + } } g_free(multithread_ctxs); return NULL; @@ -269,10 +315,25 @@ static void blk_exp_delete_bh(void *opaque) BlockExport *exp =3D opaque; =20 assert(exp->refcount =3D=3D 0); + QLIST_REMOVE(exp, next); exp->drv->delete(exp); blk_set_dev_ops(exp->blk, NULL, NULL); blk_unref(exp->blk); + + if (exp->iothreads) { + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D exp->iothread_holder_id, + }; + + for (size_t i =3D 0; i < exp->iothread_count; i++) { + iothread_put_aio_context(exp->iothreads[i], &holder); + } + g_free(exp->iothreads); + } + + g_free(exp->iothread_holder_id); 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..a093dea0b6 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,11 @@ 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; + char *iothread_holder_id; }; =20 BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp); --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048059; cv=none; d=zohomail.com; s=zohoarc; b=mbXjyGq8r1Qv2JLY1rbvfmF3qkGBuB/9ZVzSekGkEg/esctJCgr+tamOKiIZJJHfRB73nlkS62cJpMjuqjJdjGlFW/dWTxnWBeFawqlgqYdPDYof7KAUD1lQjrU0CRvp2oTukwzl4jA5Me/idBd6V5opcSo99aWr7O+69G6QHzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048059; 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=LoaJlgwcktjHXrOouiKAsKzyyrNL0yFJ17NEbpvvh8M=; b=Pc8t09UlgBg4TUCj8VhQIUKFuvypNQ9+Tg4c0ScpVh8KH+NTpJr8EG1dV3eA7ZwJH8zus4CcDPLBh0m/0SOabm/FAmAHE3Koj1qzJtzgwT2cq18MHr2kWwDKBuCxQ8h/+8BkdpcbQ1LR8uUq9+B8GIk4aaSY3c4XamwQO6ugdBo= 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 1786048059697751.2673351771932; Thu, 6 Aug 2026 13:27:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gB-00043A-OM; Thu, 06 Aug 2026 16:27:03 -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 1ws4g1-0003wk-O0 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:55 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4g0-00050H-0v for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:53 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-c981c2c37cbso2006102a12.0 for ; Thu, 06 Aug 2026 13:26:51 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048011; x=1786652811; 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=LoaJlgwcktjHXrOouiKAsKzyyrNL0yFJ17NEbpvvh8M=; b=aMQjxIEze4TSPpa2/Iz8l+FUNehWASyAepvEKKn0mUne3sXcYDwH7O6M4r+dlHPQDp 8XU6wDitka95BAMaA5O/6nkQTmc49fE2rT8vj6mKhpnM0xSb13e+WGIa4/3ivHt+Amx5 CGIHU0KKmAy/RMCD8WsPiWfKjFIjHuo3nRJH4rOQofm0NHiVgWMI0mtlxy6bddfsJEqj VRqZRMFFaSxBnoTIZK/zcWxylUwyBJBkfPbV2UVvYolTJMqDV0xPCmel2uQ86ZoFfJzP b6BTlJJw5gqytxKpgmrsPDLNFCNvdudIPyljvioxlunPGDZASKhG3DGidJIH9K4p4NsJ aNnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048011; x=1786652811; 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=LoaJlgwcktjHXrOouiKAsKzyyrNL0yFJ17NEbpvvh8M=; b=oIxq0hF5PQCTI09+ZFE5Gc033iLtQHfFhaNrPdwhX25xll44v0f7AztPkiWNJx0+Np tf40S6mx75bYSb1XHjXsquP6HZCG10kBop/EGs++DVbW+fGioKZCgrT5nPo2LIHjgjAW 6DKUZS7b8BQQYgZj0ePCGAyJfDSpE6KJCdxxJ0dFBRpsRGb31SjlHvvS+4nzORCMOcrh mMbD/vkj4tZA6+A+76NyAcWxX2C7Q9wjNOrlbzADScellDZCtIXyvxetWYjADbpFyEnn 8MsGZHMS+3gc4Cau/EQHutIwY/C+3nKPeC70FMQ/bOzNNxPyNIi0pT4xDDp0DjdKVgBu iZHA== X-Gm-Message-State: AOJu0Yz2H1jtZVut5m9zbRdsjthXt+GcdQma8u83eepc4q6d4BIb2NMM Tm9VNi3W6a99W6tHeWZvmdhioapJMTmBNb9r5nKKa8l7s3Zcj09OOsG60td6NBTdSW8nSqdn X-Gm-Gg: AR+sD12f9wRUVPBJQvsJyptmLvq5KEfxEWmqi86oYJ9qGnsYMk0gcdWc3bX3YO7oJsx UISRcJkSsuoR+buikErCsSR3HKHShEBNdAvSFPJcryeCi1vqwEcd8L2gHkOmujM4XmDm0oX9PI5 YwiJMfo0j/8g6Ij3g/uWMkIkP0LTFyO/3FvuDct/dL5T+hgRE5gX05vUWetpSyjMx3+NPFVXsYF BUUm0PPtVEKeHkM0kmBksLlrq06MSa8HDHW8zhp2FUeUm4ZgwRlDflwIhzJOgOxUOPUlQOXqWWw 2fEsO6JdGNuhcgMe2ikHvKeyzyhrgI/jtqdL2mtKuMRMvzwm6E4k0wjaHWQrB0eaG7jvCgpSXy5 Ln1qfAiFfElrzUyBXays15yVXTHSnGviyVuqVrIr0eRmuUQCIZo0ULNDuMCWATo5StCWzn42DZc 9wPXQ/jaAN1b76fQomUx7RPsaVP4s22MWgcrkbpCVk3Ppgz9FZWmOBueysY9f4I2S8VIRWt/0bA 0GnxByBsKHwOrSQ X-Received: by 2002:a05:6a20:9e48:b0:3c3:875d:704d with SMTP id adf61e73a8af0-3cb85ee77c2mr23474694637.25.1786048010668; Thu, 06 Aug 2026 13:26:50 -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 V11 06/15] monitor: track IOThread users with QOM paths Date: Fri, 7 Aug 2026 04:25:15 +0800 Message-ID: <20260806202531.243806-7-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::531; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x531.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: 1786048060144158500 Content-Type: text/plain; charset="utf-8" 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 during global cleanup and dynamic QMP monitor deletion to provide an explicit acquire/release lifecycle. Signed-off-by: Zhang Chen --- monitor/monitor-internal.h | 3 +++ monitor/monitor.c | 26 +++++++++++++++++++++----- monitor/qmp.c | 16 ++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 23829f32f9..caecceec93 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -153,6 +153,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 ed195fd97b..840a579247 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -573,7 +573,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); @@ -668,6 +668,17 @@ void monitor_cleanup(void) qemu_mutex_unlock(&monitor_lock); monitor_flush(mon); qemu_mutex_lock(&monitor_lock); + + if (monitor_requires_iothread(mon)) { + 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, + }; + + iothread_put_aio_context(mon_iothread, &io_holder); + mon->ctx =3D NULL; + } object_unparent(OBJECT(mon)); } qemu_mutex_unlock(&monitor_lock); @@ -713,7 +724,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); @@ -732,11 +742,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 338d37cb7e..51a724d545 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -733,7 +733,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 { @@ -788,7 +789,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 @@ -796,6 +797,17 @@ static bool monitor_qmp_prepare_delete(UserCreatable *= uc, Error **errp) monitor_qmp_drain_queue(qmp); monitor_fdsets_cleanup(); =20 + if (monitor_requires_iothread(mon)) { + 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, + }; + + iothread_put_aio_context(mon_iothread, &io_holder); + mon->ctx =3D NULL; + } + return true; } =20 --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048075; cv=none; d=zohomail.com; s=zohoarc; b=fnusJ1yluwJiQK6WNMtiKGvX1T8Zx5Yv+W8br1Annua5y80IInxrWhqx9bsQO6wK6ptQjHRR9FX+s2XTUGZOdiMU3Q9MwJHuczw+NyounsUmqJtP5f2eocJbywsIScvg/h/3P/8BYZNRzueR2ZNcmAUQAvDW7nyueopum50I1Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048075; 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=roMLuC4QA71TtSV8k+RZp39kgVvreNxkTYnoEYN3Thk=; b=DGeTiZ7pMzLr6yiX7BrF+QN68DCleGxwgBj0BnslxAqzaCOJkBArdvffwcPI0DTUm1xYmhbGH6KJrvz8vEZBFhutq4Vj6rm/Tq16m+kFRcT0GRcFfYNPnl3qjQGdaWtb+Bgj6DbUZUAXbCs3fZn4MawxWFs01tLsYUINFrGSIpE= 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 1786048075761417.29861164775286; Thu, 6 Aug 2026 13:27:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gD-00046Q-OG; Thu, 06 Aug 2026 16:27:05 -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 1ws4g5-0003xy-QP for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:59 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4g3-00050i-Nn for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:26:57 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-8486ac3f347so1561673b3a.1 for ; Thu, 06 Aug 2026 13:26:55 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048014; x=1786652814; 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=roMLuC4QA71TtSV8k+RZp39kgVvreNxkTYnoEYN3Thk=; b=einJoHRH8oqvQscA7MjkWBKoxRjlpzYRm0yhCAVoCNSElHbQ9yxMo6EKRsL5mBakgr MOZXqFyfWmL5JX8gT1tW5/F6UxtKqWwUgmOXDKMXfYuIFZ+RJCbMySe9QQBEhJ/Qo8L1 sxFqkA6Qzs+6N2v/niOWYmrtoZAz74mHIn4/mT0m7ddrq1zw3aZHO/rObZCPxMtfH7ui PPUNaG4scnIPQlY0I/DynCInM//GQKHHHSPY0ARfbVD9x5cNdhi/xuUzoHAh9zrISVCG HJVM+78EI+LfO49DS16KPICozwmFJ6giWvs9Se6/59SdEPfsBOY9APWezNSV0IEpBfyD tK7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048014; x=1786652814; 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=roMLuC4QA71TtSV8k+RZp39kgVvreNxkTYnoEYN3Thk=; b=N/00H4uZS8/7a1mENQH0KehPYupzU89ADn+hrg5TKu1oDjrEm535nCYh/bPcsEMshO WogzYJaxoVtiubctaSD2hJVVyDrODwkrGfVpZR2jzFrVC3Fj/cfwumkru/9hV6B4kZhH Ket6YDfsB7h+24TP2w4sWOuuNUdyMYcJl7pTje8xNia6pN9GW1M3QiRV/aqgRKZyLoj4 3JeIzZFqJYMo6q7AT4Jynuj/BUEAdJy+vbi6qEXejx8NHlk23TK73JV62oSBaPUYA0CI 8/6IMH84dHmZRJVmBdIJQ0ynA9aqyGfeVZ3No+omWUxOiAqdEeyVrDEcUrg91u7D4nz5 YSnw== X-Gm-Message-State: AOJu0Ywte9MaZjJjtx6W99Gf5mb83Yc42oEvKAcdFV1tYOW8ZPWk57w6 m9qx1/PHm/njE/xWQuxN9Ob/TrLXYxnLBcH8VEWwJ6SmYYzRLWPxsliBgcbrDYjmEc/0V65f X-Gm-Gg: AR+sD12O/J3iSRPGtQTbDdd1n3A1yX3F1o48EoK7HQ6/NjPxCgfhKjWdIeXcdkb32QD 9az/9/M0KAHRBlLfoPloQ5d8dZz4aUpWPL6or9b1DIFOjtq86bLm6wtI7AizkqqwzW+1NAsgMKJ 1wRdiEUQKddUE7hgMgMr8zmyTVV+YsnizAQthucFUlmywnrmZhdNLAcCsCnrUh+/k9MK5L04rfD MaqnCO3VKObiccl6HDTh5t9J29CeMQqA2IpPMLoPDJzPM/79qAJIZu7bL1kBwQVV0U6a5Ba15EE W5U3q/5JKahXnW5xGZ5UoaBCBrVTL9nfTojZY7aEuoYLtrk+a4/53vLbI93/VpFFhQhvLrdgd1N 31uWb0HVZquX8luZ0X0S8adV40+ZWLNFSDPuspBKOkd0+zoxbjOFBrsJrtRJeOb7h3aRWvg9c7V BCU4T678XGHGDGGnHCLGBttox5Rroem1QvPH1f7AHWa4yJ38Gq+BixFN27lL4Euc/NrzEmgfElM eHXKB619N25fRLZ X-Received: by 2002:a05:6a21:9cc8:b0:3b4:7459:85a0 with SMTP id adf61e73a8af0-3cb9c291f2bmr12091110637.18.1786048014323; Thu, 06 Aug 2026 13:26:54 -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 V11 07/15] virtio-vq-mapping: track iothread-vq-mapping references using device path Date: Fri, 7 Aug 2026 04:25:16 +0800 Message-ID: <20260806202531.243806-8-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::431; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x431.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: 1786048076184158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_get/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..2cb48dd387 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); + 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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)holder, + }; + + iothread_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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048126; cv=none; d=zohomail.com; s=zohoarc; b=JPAjgngIzEmgg0F6kQ7OMBBsWzzkSKzeSs0vAanBmW9Sw6FOQRX0Tic3qYCrbmBh8bY2/cawoSPhjQFsFsSKNibF/4YmC5TRbiL+LkW4vmgrzZuTxBmL6GprzuUSNjuJ6E5YzYsA/YeMiO9oa/lzf3xSnCi2822UA7jKmIbSg7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048126; 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=kmPyeuWz8Pt7P5vov7sIiPPIHc2mQKkYrZZFQcAkq6E=; b=YppTww6oiIhlNPBulN0SV744y+gf2UEPgaeIUwHU3idah/SkAlPy/WvGXRkPvJiFgvcaRXeADfqBHiwYdBloAKJHHaqaBJMfq16EmK1BIXxZWs50wgI5iqSiKiMNELgPrByYdKHjsAAWKl4HojIpXAA32C7YpE5fhKME33BVVYo= 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 1786048126258829.3162444961633; Thu, 6 Aug 2026 13:28:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gC-00044T-P4; Thu, 06 Aug 2026 16:27: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 1ws4g8-00041X-Su for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:02 -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 1ws4g7-000516-1l for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:00 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-38e07ebd263so1808005a91.1 for ; Thu, 06 Aug 2026 13:26:58 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048018; x=1786652818; 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=kmPyeuWz8Pt7P5vov7sIiPPIHc2mQKkYrZZFQcAkq6E=; b=fOvLSOYzgWZh0CXTv6d0caOvyb2Z993XRlMGDBKzCziaG9Dj0I42WQaE1o10P03/e6 V+pk+yE2XMO8NWQIGj1CNuz6YUBeLGoGgJ6C1ObJ+9HjcXsIzJN+X3WPQJIb1W8mrJVt V5zC9Z+nqL1Ku4LZaAnmNazuAjXNApIshL4u4TSiF4Y1J4zGsok/vdM2yOdWRQK9x1BV PAbsbn3M370ZmROzihzHJZUjwyY93gNaeZ3P8lJ5uN5SEyr7DELb9eMLHnrMavgyL+lY JpQFzTdQiECgAACT/dyMWwBq7Wx8+tndovpTFieSIG0qakm55AioEXezymSbwjHtUmXc ZB7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048018; x=1786652818; 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=kmPyeuWz8Pt7P5vov7sIiPPIHc2mQKkYrZZFQcAkq6E=; b=DvPtE2A5vWF7HBhM1lsxhOXpLn9t9SCorG+NZvNXsz42i20ofFOqT35/V/LUbyuSfA adwDKRpqvK8K0k/5zLs6cmzCRqDd/Zx2AbAfu+BN1y+GvsFEhGjCnxsJ/YdtMTmVoCJq hEryGI7iem+zyIZwUQAMLL46u0LV225Y+scMerXQ1RZkqn/xV3lhmM86GrBSLLYkLFKk KsU2AYMIzZGTCklMUXKy1GDJvnydqyh/5Rg8nxqRZ4N9NBeOpEMXqrVz9lB+GVYUqv8c aQgEkxt1jpqP0Lcn2a/XOJ9FD5BCPpcFxXLrlc1Jn1pyK/yEYSmoz5srfx4aanv44Gpd xb7g== X-Gm-Message-State: AOJu0YwDnzbZYeS/v6R1L1nAdp2uKOr+9Usoej43zQG3HGNu8oxTkAGy 5Ass/Z2S8fyxokaCoAukm6UiWK3f+x5sJqV7bSlES4JuZQdKHe7WSug0TIkndbKUL0DcaavA X-Gm-Gg: AR+sD12msqyT6kbz76LuPOuk6y8xOqpyM1Ny6oRdErgi0yiIkZptO8E7dcAOF1sa4u0 HkMsNCiCT7upSzGs30GvfmMXYWjCAsP0ZbfUGJBvmiQobR+8UapIfsxw42V2KdnQahMYB5MnPF3 76IKBPPv5YY/iuzPIC0J31mBa5YYPSpzhj0r0D7VoRxEoQCeKDztNcb7U883lC0Qg0aPYXVQWNO vGe2Se0B/9KgXevpnxCDzZCA/O4Qgk/8iJoUPhiOqQd83Tm7E4r01+iKgw88LSlbkwtyn8O7uhG 1L87nFb8qPVV3roDmLmBVt9pUkw+C+yxjr7NV6d4iWPSe2G/DTjT9Ztw+Y7AMuSmQDslLWArY5C atOlXrHJxQR8hYAnVp62Qr1WHAO5Y8O8VBCKH/8IGX2R0J0LBUo0jB1X0F32WrW62GJrHdoQNu1 VQMml1odrOwHv2MzFuwRotFWYvM9vj5OEK+sU+J0rOsxHCi0xE0d8DGb5nuFUz2TEY4hQOcdVrG Ilji8i1r0TYxg+s X-Received: by 2002:a17:90b:5343:b0:37f:a915:1c29 with SMTP id 98e67ed59e1d1-3909d9174b2mr3985296a91.19.1786048017494; Thu, 06 Aug 2026 13:26:57 -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 V11 08/15] virtio: track IOThread references for thread pinning Date: Fri, 7 Aug 2026 04:25:17 +0800 Message-ID: <20260806202531.243806-9-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 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: 1786048128404158500 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..c92c0d39e9 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); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)path, + }; + iothread_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..c71f33b41e 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); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)path, + }; + iothread_put_aio_context(vs->conf.iothread, &io_holder); } =20 g_free(s->vq_aio_context); --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048092; cv=none; d=zohomail.com; s=zohoarc; b=C/758OrKrlcvQNXfL2ouOdESJkVs9O5Q6fXJfUHIYA/hbqTomGxhVkOvH23dd0IbMfNs+ug1jJT8hVigft1JJl6pGPQuh0dms3m+hMD/zPThiiwacEyiqYSQZFpQuOM1icDqjnVCeW3eCcN1vAPDMGivUzIBZzu9Sr1sKvzCrIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048092; 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=vcuPzZbEPssoF8dH/040Ip6InnRvByiG6K9pUW3WsSI=; b=ikPhpRU7JbMrGR37ijujiVhWsv1CiduSLgEx33GVR202z6mE63teHZqauB1NHWRxkNtXaX0Nq+tTnsGdPDDa4Kl4aqYpGqlVaj+2zxOrcjcNoSC/x1o8Z+UBDy92CxP+ZyXq82EmCZ48SA0sxmGnLdNh1BJ4uyFyKUbd++1Xi4Y= 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 17860480923001008.9077319486007; Thu, 6 Aug 2026 13:28:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gE-00048D-DR; Thu, 06 Aug 2026 16:27:06 -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 1ws4gB-00043S-Rr for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:03 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4gA-00051b-8k for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:03 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2ccf2360620so26144105ad.3 for ; Thu, 06 Aug 2026 13:27:01 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048021; x=1786652821; 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=vcuPzZbEPssoF8dH/040Ip6InnRvByiG6K9pUW3WsSI=; b=ghY0pmRVf6DL2c8BkOXIfT+aZ2Xht4lyPhsu7+z4yvlIVuHMbh2oLW6bcplKYz7PTI MEE7gNMo7Id4m4XRJcGQpULARusDTIPZZ8Y3O3GYZUsLpX87R08lLtomIFZbFZXFGQh2 STu+AA4qALzr1hgLIHW5s3AVRrM5UxyDXrUXsJwgSNFsygw+WcDsnLymfEKAQOM6OcWJ +oznhxQj34tJVP6l9b/kLVL/W3kU16tROMMzGAet6E36hZT1M1E+GudnunGo+lcEkAhs bFAILcvKtTdiDXugkuruPAf9wU2e8UFW98tylZBNEj6LJuPtjn95TKZcgcAUZDsYKU+U 6APw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048021; x=1786652821; 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=vcuPzZbEPssoF8dH/040Ip6InnRvByiG6K9pUW3WsSI=; b=SqyVukYsy0DnBSwFfZkUVLB5hN5ae97I33c6sVz7jRAqO9mzqwz/KLFB4NyqDdnsmE LUNEIQg15JLSL2puPF8uw2TCZsgiDtewMqlbfnVfXOM+BeBSQP/iTM4xvqo+hU01mPCv 03ryzGaNrV67pMYpGaxligRq5GCk/EBicWu1rok20LsoFFks2/1KVXoy2B4fRRNXk4Fh nyruo1BBO20VMdV9GtGFZIS3nUraQSIpDv+HptmvexPp5yX7JDgvz6wrqiHAzV9t+ntH OGsfuiMrH2QT8qtyZNc81WtF/GTbXv9TuTk8R5lJyGZ3dk90PBHTLvHvqJbdZPv6vtZV CPFg== X-Gm-Message-State: AOJu0Yy+78QIY8iotrcB7Q/hbEDV0pQHZb/gaTl6qobTZSqnz6Na7kAh QmIQPEVYIrXlhtFffxRhZn1/eFltsHUA7D27R2na/oa3e+umD0CtMm78rxCsICP4rkbQrqi4 X-Gm-Gg: AR+sD13nvlKM0izzqvYzmF+NYJqIymwazF3Ei+AZkXyBlZwqMqgdjObGs7B7siK3Z0o O3p2vMnS3aN5lFQE5vRYsZsz0Xp6ThEcZStmjcAUEucfyKNOYzYhQEW7coReSA9umb7aYAbLr6E GP2lVeXT9xVFyve1TWs+/0rxcAeTF66EH0MW2Iye33a2FP16G6guOw/SlZbMfIdanvd5/nXi4GA sFzJ3nD11l3OipLxONlzj9yiKH/8/O5TyTmsLi/MFwZGgQ76j3wNvgd+424pndwqIaBNeFfhim2 g/GDzd3LpNiaEgT3iBt/WRcS3Xu5mTSlgH46VVS19aSp8u74cmb5qHup7tZItoDQ8jrZIvqKP06 rE0tforIPJjMc5GVJQz49nVExxMJr96Aw2SMi5SiGB9YosLSUVXaTPak3TK5EaZyOQUfUeQJOwL m9Oy4zhp+0YAOc8sDclI1SYDwPvuBr19shWfRryU8COjLTsLHKynN/+HugyOnGNxc7mNDovadgi 3VpZ/0hd4MSnO4xukpo4MFJ3Ic= X-Received: by 2002:a17:90a:ec85:b0:380:f85c:94b4 with SMTP id 98e67ed59e1d1-3909d8075eamr4532768a91.7.1786048020792; Thu, 06 Aug 2026 13:27:00 -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 V11 09/15] net/colo: track IOThread references using path-based holder Date: Fri, 7 Aug 2026 04:25:18 +0800 Message-ID: <20260806202531.243806-10-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::62b; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x62b.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: 1786048094405158500 Content-Type: text/plain; charset="utf-8" Convert colo-compare to use the iothread_ref_and_get_aio_context() and iothread_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..a7bbb1056d 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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)path, + }; + iothread_put_aio_context(s->iothread, &io_holder); } =20 g_queue_clear(&s->conn_list); --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048101; cv=none; d=zohomail.com; s=zohoarc; b=QG2gusjOtKWo8/lXB/uAO4A+KXmesItAWSAkuTD6Bfk5oVWuRkeVw8v/eSeP960BFMEf4XAePueUfTBMrIYgBUF7ws+IbEh2MgBM4Uzo/kxYOuTjoYtYdPwF4BFtqBa1XCDxsrvny8eMwWrRTOy2tNHdlfPc8LGo4bOa1hGgumc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048101; 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=siXGvCcgP1Ec19oXDZvBjrP0pURCAyCLQMkuuwkWUhU=; b=TcFxUiMSQr3Kyma99GumryvZnCKZSofL4s+3waroGbYog62e1z4b/V1yKBSsG5hi46KDKA5wEI3m1j1OXQ/AYyupYZiNYiN0Ec9Fc9brtq9krRQzHVf8qPv5XtOKm/8Nv6coiBVRqkJ1C0joURjnxV2s750D0GNUVxCKQogqmN8= 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 1786048101977747.4503899733719; Thu, 6 Aug 2026 13:28:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gZ-0004Qa-1Z; Thu, 06 Aug 2026 16:27:30 -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 1ws4gI-0004Ak-1B for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:12 -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 1ws4gD-00052U-KP for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:08 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2cc7ef7ec27so34047745ad.1 for ; Thu, 06 Aug 2026 13:27:05 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048024; x=1786652824; 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=siXGvCcgP1Ec19oXDZvBjrP0pURCAyCLQMkuuwkWUhU=; b=lyOdzzpHYyKpjo3RJFE+w+KkMYexgjkuw5Tb6kNwJ9p9a3I3lLsGx+4AkcZL9kqtk6 aP3d+fTzIXKZY/e975umlMSayA6/qh64zzF9Z7MSzL8Jc1u7k4rfTtF8o9z+gvparv5d lmmEFLI/IX5DSlWDvPoxH/xoQbl0ZSxCX2o2QEdhlrapM4nl6ACjcb3x03lZR9ihwWIC gv683CohmtFHug8cB3PCrkkI1/WECLmhiOf9NrFVpwfufVj3w7DJ5Ja2EglWz4EAJvEc A4igse6FEsIS+flAcLa4wxusIWPB25+CC7FUvmOI+zuLq+V5Rsyvy5cfkfhIBtsXp5+P eoFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048024; x=1786652824; 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=siXGvCcgP1Ec19oXDZvBjrP0pURCAyCLQMkuuwkWUhU=; b=UG/Xe2fumIMTe67pTJBfoQQajqqzJ4+0wk+4ZxwNLoNRqOj+mKQg0GcyzjZaHNDWc3 n+p+2BeWCho2o0GoEA9XBkCY7tlpM0AQt1/jcc470xiDRzXDstjn22rWYSFiou+ofoMr Nfr+pM1nB+cy9dR8GJzBIvZScS9Hv2b8OK5F89vjSm0MVK4/1JxEsX4RP+6Z/2m2ZWKF uMNlEEUBiRDrbZl5gAocup0eXACOC+PW//aV96vIQuQWE1I8m6oLMZDgU1lLbekkJQ+f s+kZiBT9/7+ID/4d+S+DxURmmFCou9CDpimyh7RcBwRwuOCD2YHJJlDWMXqEAfbNgUTO JTCw== X-Gm-Message-State: AOJu0YxoQuWD4bMyxcHuJXg/JuUWTm5uNjbvKUJ2N+r1mR52ZS5GR8Tj 7+sKM2qUmWPvP7SqBZcRe347m4ZWwG5t/oWvlr5yftmZiwcNSJ8MgL8Cdi8sckKi+1HS+1Dl X-Gm-Gg: AR+sD139lYqHS4Ug6QJZoeEwYlv/Dwq8e6j+Kr/gXYbQKkaAKt2Urb1wIHs9GlYbrsv DCPklv2Ehe07Bm9AU+T48lw+gwbxFSLNwJoh0Mi/t+1VLdiLcr/NKyX+xixzwYKOi9NETP1uVZr E1dJLJxmOpF0ZKUeGBHwJC8y5VTqG9NN6saBHKEVsegbR1tGIYVgoU8p4Art+3Fw0FJHbbMsaO9 6fZ0fiZXRFX5Tr8yci1gyRQIt51QI/LqzDBsIc+HO3SynWU60wpqhdW+mYJLLyVLvT1u2ET+Jy7 e0DDUxd3D+DYZC7GoKJFQbbCCEsN1H14zHCXUcFXUlcfj9Aq6UzlQT+/ddlFw9kvt+8qRoMI6vj HXgWMyeni/2NotcAWzzAonFZ6iFOFIT1SoRBblAsndRqBmjxkg2aPTVkruQygR18CpN0FLO5fM4 pBU+IZbG5XG1tnIzKhG9EhZDVJZxwc2D72/7HSL/gHwkn5zK9WB5H7mDj/lTOO7PMI/0T+iFQFN GiJUPOmpwLzFg6yjp3rDROgSIuL X-Received: by 2002:a17:902:e885:b0:2ca:e565:7b15 with SMTP id d9443c01a7336-2d0ca7f8a67mr180406275ad.10.1786048024293; Thu, 06 Aug 2026 13:27: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 V11 10/15] virtio-balloon: Update tracking iothread users with holder Date: Fri, 7 Aug 2026 04:25:19 +0800 Message-ID: <20260806202531.243806-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 1786048102208158501 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_get/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..e9d023b4ec 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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)path, + }; + qemu_bh_delete(s->free_page_bh); - object_unref(OBJECT(s->iothread)); virtio_balloon_free_page_stop(s); + iothread_put_aio_context(s->iothread, &io_holder); precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048093; cv=none; d=zohomail.com; s=zohoarc; b=MiM5ls5w3W0PcfBhB2orJTyXIgg/iybBNtpmm0hh0eSC7pMoaDxj2tkTBaRPrQYL2NqpUrWA6EyFEr4UlDaSxH2sBWTYktE8gbEG21nKAzdp1k1mJd//txNS2o78B+qvqpeuGR/XrI6Bsg4IqNsdkG/MugcXXqfP9ctZPWX4UM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048093; 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=EPzzHTwezjyg9C2LHZLrU5axZC+fE/LKwUjgro3vN0o=; b=jIxRh89BoRG1r1oqGRTQIPFwNFD9JduTMVU/S7f9DGwMmAet83GMjXa0gGhYp5//KxSJJTmf8vV+8KH+5xgXPzYbJKqJe0Z4MgcEfMosJLaEM8eDa9nE2dSKHo0KA/fMSTj9RqxowjZKimGqgydTD3dmmBMYtqW10NtFX4YDvpk= 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 1786048093543388.5251222231768; Thu, 6 Aug 2026 13:28:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gi-0004W4-H9; Thu, 06 Aug 2026 16:27:36 -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 1ws4gP-0004HQ-90 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:17 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4gH-00052w-PP for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:12 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-38125cebfdaso3272218a91.1 for ; Thu, 06 Aug 2026 13:27:08 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048028; x=1786652828; 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=EPzzHTwezjyg9C2LHZLrU5axZC+fE/LKwUjgro3vN0o=; b=EnXoblr/2PkeYldxWF9GhLt3jXZJ0KjeHH+BJF/rJdUrggehHCvOfGnY1Bva0DhHYy 77Lfh7dk90tmyin65Y6IxhdW5S+48HiEEeTaFV60ycKWizl9gBcyEBEEGT22fVFJ31jm lH0HR9mT5XdxMpEVmv+RjhVlPxEf5IDexExxSEXxd36QRkeHHL7nPhtIq1mMFB36YJYk asRna/NRjQPeTNUbLXgPYXZVsoJ8DhZpsmSYIHbwGc9+f/DUttl/Jdi5az50OppGfpBP ruJWJw61foaIGBcCAY5wE5CZ7Phz9Lx7wX5Fs2howbddgBZIVN1dKl6ROOau/TN7Lq0x xzGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048028; x=1786652828; 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=EPzzHTwezjyg9C2LHZLrU5axZC+fE/LKwUjgro3vN0o=; b=lGAeZzhPe/aG47Gx3QOj7g/wTwjd1Qk43rM6zHfZPTnVQAkWPe4PjQVHLqaDP1g9kF Ofu2Rr5wr9a+jWouxzfw+iLQVA6WKPGmxgUm+20T1WyxqfZPUz8HnTMp/G3MGcCfnWuG JaOFaRDoGMTVX0dsAu2dcKwVOhJecwktXkUeXXXtjGsxbnOTfx4iLxA8lebXWIT0Xle5 RT8H/eQ3afVE2u58xCVurk18vRftEJCXa9O/8XrL6wZR5nCUVm80KFcEGD+fa6OvrwuX /CKiD+/++n2j47PtUK41QpaNKr3sk4kVKewv4VyVy+/Ge8pxMbKuHMGJcSm+cF+Ee30b o6UQ== X-Gm-Message-State: AOJu0YzPXFHt8sO9dV1CQZv67sr0p3J3RsYhjsgOY1gPz07pgBivtk3Y yNbEbm0VOw4yFzQv/qO8SeUBK9tOdWM6n7v64hCTMsCG0bvoYA6TJ492LNPBv7xGg0hJs/Qr X-Gm-Gg: AR+sD11b1RBRoc9mMA4J0ztgX3F1L24UIWhiMpnwDYZ0LoR72JBIIwce5LBOvHDjGZX UHWf8791Iu8ihh5O/ibS3iRcr97qHY93BvJ5P6omappoxoTmiHhUXC8gQC1P34YgjhUjmaej5jd ZDqgyMjljbUAtjh6fuvhUyR6c3F4oBP65Ee0BI+et0+5NU3hUk0+4QbOOlcu2i/fyTyEQcEqIyN DXPK0vBnnAPwpLk1JkOklao6LMEQpMMJXmEQJNVgyTVQ7wrIzSFsexIBuZTthTsZhKvIVERYK4P BpjX29RI05HuTTAyyF7BLeYLUgrHGJw2gIuEMlEjDso4rZqfK7qEOTQiqzL1BnbNMW/nRVyHCco cD1sB+x//AAQGcLJ8wARYl0mmWCRKSjtvwuaMBzAee1TYytyO6AHmSNDXV+Nuu38QvZRLXtN9xX WgK5uwf9e5V2Jyfgy0jYKzYcPTwrGG7c04DyoJWEXuUpCJP7ERl2iqfp9dnx50eMa9BKHZDYZ9g 0ON7XjhufJlJMnp X-Received: by 2002:a17:90b:5111:b0:38e:64b0:8bce with SMTP id 98e67ed59e1d1-3903c633720mr19454281a91.20.1786048027596; Thu, 06 Aug 2026 13:27:07 -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 V11 11/15] vfio-user/proxy: Update tracking iothread users with holder name Date: Fri, 7 Aug 2026 04:25:20 +0800 Message-ID: <20260806202531.243806-12-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::102d; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x102d.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: 1786048094374158500 Content-Type: text/plain; charset="utf-8" Add object_ref/unref calls with iothread_get/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..5ef1547357 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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)= ); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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_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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048124; cv=none; d=zohomail.com; s=zohoarc; b=TujVlZhpEZLfK+oEy77MSthfrToeoWOpIVGeG/Sv0KoRFmMeoI1u4fUcXgsqRK31xI23WlvqjKsGKIVd8HHoSyfncD5chIhmY+/xjP2hX5CAz0Anl2oBBXiQxY///nyx5KIWfweX0b922ZqsPNSm6deMvmZZEWw8fE68M4t5eQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048124; 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=6xLe0/DHX80s0USXiFrzk4okArGfVrM8T/PSH/T6ddk=; b=N4ovbn/Nk0MOPCSpf3Ph27D6qAQSf+uo+0mkQnL1DVy6MHzoAiJBSQIUSKaPg5YaOxoTKJKcTg4UH88jJOq4OazDT+WqWG54jtyedDOODRXiSD/hXkGmUBkGN4YlpFGZlmX7gKcClc4rSHdTOd30eJEc5AiGyEFqE3M0Ors9LIc= 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 1786048124948112.77754324814794; Thu, 6 Aug 2026 13:28:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4hA-0005Lx-PH; Thu, 06 Aug 2026 16:28:05 -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 1ws4gR-0004Ki-7A for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:22 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4gM-00053C-62 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:18 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-84f38f3b36eso1829901b3a.1 for ; Thu, 06 Aug 2026 13:27:11 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048031; x=1786652831; 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=6xLe0/DHX80s0USXiFrzk4okArGfVrM8T/PSH/T6ddk=; b=GRHeOY+ey1gwdKCq6k/cjtuXLNWVpCEWleH93jvZWhgBRrE2QOBdK/AKtFuCiI1+dr 1UTliIIKykNEI1/BGzQQw0TT+qDv7xKn1za6cTaNkHTkIj4zxgxdDNcRXcRIIK+SELka 3u+wu7PKdaja+EVZQgzVqhxcZMGPTiud7q9wYdqVy55703Cg6aypXjAOvYsIPDu88JkH nUDzvVrCIOLj/lvxqTh2+XVtJpOaPPVG43J/IqtgVi53NYzbB6/8jzjAkHAiXpFxkIXa LXrA/ljjE+4aqiQz/LtJpg2k8dofuo7NtHuCp03sNAAOlU60V2abbtetZuZhrVwcVVD2 wIkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048031; x=1786652831; 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=6xLe0/DHX80s0USXiFrzk4okArGfVrM8T/PSH/T6ddk=; b=N1Y1ONdco0NUY5KNDxDT+AF6bLGJ/2S6pLfEsJM7XnnGN6u0n7qpTOkYmBfqhraYfa ubZP1OWKSXUPXEW14H4g4cuuTQwjEBevmGuSB1BImfRcLKImc/hObZUCns2SISY3R9lL UzQjMfNAxnGtKPo95P2OlivdLWE9kiq3JYpdf7uHZHGI0rk3Dj+R/saC3Me8Mh/fhqiP XgJHlyYnJjpVgqk+4q/V7hf49Fu/0aiQhix5+zVAIqx064y+BMHP1TQDG0FIPpAhy9iV pPBIk1zQPLzZPGEktc/PpUVwsS+1gQoCE1A2eyMR+1YsGfrc7vMJapZBVG7gZxSZPfRz FErw== X-Gm-Message-State: AOJu0YyUQ7qhj/UaLLlSrIvCPrhZFA0x/PwMMb8UR4Jx6JT9xxB4UP/S sQGJ3Cn8Mde4wv58uo7YFrkIRyfe4p4GzA6CIRl8zN0GNDJwA1UqceuLQlCxfa3LZlheGiCM X-Gm-Gg: AR+sD10CxAKE2THDArk1adHtJkxoOOlAgQKv6n+1cAAuAeVowGKEpYpChfPF8EhMgWm 3UPbJseaaH+pJp5hcEpaUj4lXtm0YJw1DNqmuTpI2BLzVposhQYCB/16OXqAWBfZ6GK/reP45m/ Uz23GZtXriMKwJ5FUIg3PWu3CTmBbfSYEsPGy9PkWjPrI8WwGOku1UFUkKseRnKsPpX5FJB1Hc6 U4C6aYXY3DYtEgN5WigZ4nfNEQQM8R/IeS49UuE+74KNVyxyx3liuP8vtq6ZNvpCsQ6FN86gDWO TgIKlsOZXVpvANg5I14xHqcWAcf30eOM//ZXtRVpxNHTsSs8HL6fHNx0uZrBYRDDxLz/Ke34tim wQ/wp1PqPqaCZZ+1ap8FxE7t/E9NsNAbsDW/mxTr04PpZ289oq1pOHMsamf4ktrVS7k2xTG3bJs IDHiRKjLYMWqlffjS159716DeCieh3f2l2L9pviZ5j4KKtwRwoO8mT1UZrys0CohoR+joeteHv9 HmRVd34nrN6Djli X-Received: by 2002:a05:6a20:9c98:b0:3bf:7ab7:98a4 with SMTP id adf61e73a8af0-3cbadc97c0amr5273212637.27.1786048030899; Thu, 06 Aug 2026 13:27:10 -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 V11 12/15] xen-block: Update tracking iothread users with holder name Date: Fri, 7 Aug 2026 04:25:21 +0800 Message-ID: <20260806202531.243806-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::42a; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x42a.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: 1786048126336158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_get/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..b5bf8d359f 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)= ); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)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)); + IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)path, + }; + + iothread_put_aio_context(dataplane->iothread, &io_holder); } =20 g_free(dataplane); --=20 2.53.0 From nobody Mon Sep 28 01:14:57 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=1786048134; cv=none; d=zohomail.com; s=zohoarc; b=ZiX+OMSpaSfTNevefIaQOuB7X/Br6BUhY6AFt02+FiqBO1vraiTkn0ySmisZ5g5LIGo88u9UcgrmIM7vL6/IFFSKdKybsyB9Qv4Y+Im5F2waVbDugdkgFwC3/NJb6zvzKP53LxphDez7uZQoV1Z9cdvwTxUnUwCkXaJk1X/ZZNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048134; 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=fXw3JpLk88kYCumIZlgonrFgtVcpDQ29a7De2HxhjDQ=; b=b+S/9LpOHN73VpwMgXpAYOuM+S2wdSuj/pDR+2m14/lV9yd7Sxf/ItmKHczGuiD6htF+mQvaixdnlbUGFkYlWxSDmqYq+UjLL2wGjfxIJ9F2A6RtIFrJ5pJjGP0pECQkADOfKGeDH25odU7xZHoHc8PxclLb2jsGsoXRRK9NToc= 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 178604813481121.66327271782825; Thu, 6 Aug 2026 13:28:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4hC-0005b6-L6; Thu, 06 Aug 2026 16:28:06 -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 1ws4gS-0004Lx-Cd for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:22 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4gP-00053Q-8y for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:20 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-38dc4553f62so2824944a91.0 for ; Thu, 06 Aug 2026 13:27:15 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048034; x=1786652834; 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=fXw3JpLk88kYCumIZlgonrFgtVcpDQ29a7De2HxhjDQ=; b=YVLQXlVpm1BqOtjqhYGde5GCueCGGfZW1F0eNuh78nqbNV7n3dLNlwp19l0lPHOEr1 4YbU02EUKHnTgfa9++LprmB5B+GewAZTgk1iu4EzBFNsCZZGygni7pRSKWVAk1AL6t7B bjKhP8I7Hqvxj1SZNCNQrbLo3prEgrN/XGYe8S/jwfvKYBoVdU5fBrYb1OulWpDXtszT j3bUD3R8kd/IhSxOmjJmgZZQ1MxyenXuyTamBeuYrXHWcEwqGhbxUuJaodqt8H1RrB3o 3KmcUJxAPelWDsSAfjX5TrO6JyA13wQG4WaPDOPIyr9u2zuL1NckTUkbpHqOeBuMp3gL 2j/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048034; x=1786652834; 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=fXw3JpLk88kYCumIZlgonrFgtVcpDQ29a7De2HxhjDQ=; b=dSl/WJW+k4GfsfcbzoZQpw3HSf7l0H2Hf3xDBed9fXRPQpBZAgqJykilkza+msZYyC JL/b3M408VHW4/oHEkp+aAPkrmLQCpBMIRXWp2IIcv+/BQM55Ze8rrvA8V7zjyx3JgIP 9T9UsoWzMB5DvfOK/jYKXp8bP0BfwfQ36+TvObKs+zf0cXJd2z3RQZmdvQ2VCSRVZ2Xa kCuDWbM8m1qIgjNBvBKf+MbE2qyQNTsUvjkjcYpmkB/tIkxz176j7EaYJFpUfz7xDkEE iWfuiNM9mb5Quhz1O86j+fCBGYYuP2p8OL2YkpH5RuO99kvL34T3C3jGqqTgu92FZKR0 WBww== X-Gm-Message-State: AOJu0YyDJZZxl1uXqxbrudNACbibpVdYkvX8GR8jhxNyVmnFeSln9ByB t/dNM1CN1lx6qPXNJthHILG2Gs55fYzcr6Cu8nLsX9XA/LmX8r41cNEEB13EZ77F7ciKbxLZ X-Gm-Gg: AR+sD11+371xMoFB3yfX02wFrmVtk6CbwVrCWrwE+5QdLqc0mvPNVm/ztaFy24DCRdj +sLhSr6A3ijSp376KW302R8QBRJ3mddHTaf71DylsvAL/3C0lH4DxT5ZkwmElI83+wMnOh26UpM Oy+kLYHgpH6tmgJYbJlo2B8zllPrO/xmHE33+7hA+9VceAraMmUSqasAfn2dOrj88DoPswJMiba L+cRwXWLbrDGJNyV0aFfnI4ZDDAiqlTALI+LMReP6Jo4VBrvxcXyljwII9T17RnQHqAhUf0/t40 0yyVPHeJCx2iVNpBF39IuyD66GCNwEOfSBvw/XG+XMu9slcDJC7oCtwouAiuVvmiCvD99XfhuAT yCkzkOoHU0aCTP5QSmFJJ14NCai01Bsh7BujgEEHRQc561MV0zUSdTz1+nPA/b6Y/Sjpu1l17SS G4OWEJTGXDkkxDr9y6g4tBgG4rYx9YlgEE/P2tKQcGBA+ZO4UCew4Dyq6Ak9QbgJcYUmsGZN4wS K2TjHx254awpb3t8w== X-Received: by 2002:a17:90b:2785:b0:37f:e1af:df22 with SMTP id 98e67ed59e1d1-3903c5f03a0mr19648526a91.17.1786048034065; Thu, 06 Aug 2026 13:27: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 V11 13/15] monitor/hmp: display IOThread holders Date: Fri, 7 Aug 2026 04:25:22 +0800 Message-ID: <20260806202531.243806-14-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::1035; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x1035.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: 1786048136396158500 Content-Type: text/plain; charset="utf-8" Display holder information in info iothreads to aid manual debugging. Omit the holders line when an IOThread has no holders. Signed-off-by: Zhang Chen --- monitor/hmp-cmds.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e9fb8d827a..de37f83a72 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -240,11 +240,33 @@ 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); + if (value->holders) { + 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: + monitor_printf(mon, "[unknown]"); + break; + } + } + 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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048140; cv=none; d=zohomail.com; s=zohoarc; b=MfZaxs/vPzmUyR7meqzgLRZNpbQiC6Obu8imGLRCOPuKPyTMPjbHh/a0/45PfqzMyVjnkctVV8C0N2D0AvHhKh0Ddi2URrFDKfzTIHjLOwYZLxEfxQiuwTD65pPJKIv5aVyVDj+uFqhgtzhjFbGYc1yZ/kZTgc9/FoSNNZ6rvWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048140; 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=TE6CIxrgczOwgOd5q0qHaw4i0YRa6nQhecXzWOxzpJY=; b=etIgnO9CCRrXK+83t2VEx+/hTXI8TVHuWyI/4sxduquv+SZc6s3alzphN9Qn8BXdZz+u2IQRM5yz2IORgWBM0y91GIcfwkvRP6SynlRz4ylPPzFdRuSOYkmUnAuensnTQT4OOvFXeIaphYV63lHr/wgy1CYQBvgxrE4IO+egjDI= 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 1786048140449759.3249702189327; Thu, 6 Aug 2026 13:29:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gx-0004sZ-Fz; Thu, 06 Aug 2026 16:27:53 -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 1ws4gV-0004Pj-0p for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:24 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ws4gQ-00053g-Vn for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:21 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2cfff5f88dbso38614645ad.3 for ; Thu, 06 Aug 2026 13:27:18 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048037; x=1786652837; 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=TE6CIxrgczOwgOd5q0qHaw4i0YRa6nQhecXzWOxzpJY=; b=rslwLphEuDIJIJXtU30FxswDDqb3TswsXm4AMOmJhGvAnXAPP09r9sf2/+0W3Up98b xqRg28MiqtioT/bqGFJxPC5AMm4hkm8lHr05x2r+Cf7FOlQ1EtCx+edKjySFlMfEFn9T 6sY2MwfubYicPQR0vvpZwIhdrHJ3bzjidHLqjNM/MLBJU+H++zZwlapzMVWkMoyb/zAE NUJmuVtILmzjLZ2bb88uKYiudQtnigB9MRJkj8ydZ5FxeDrrOvqiZklBlRoiYzGjDxT8 lZiNWT5/FaaOy1IwRJgpMYSpWA2l+iJBCzgLEKXv7fMCpGdikP+Z5EMwrSNaqvSq763o BH0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048037; x=1786652837; 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=TE6CIxrgczOwgOd5q0qHaw4i0YRa6nQhecXzWOxzpJY=; b=N4MIIDYlV9cKAJzxRHLBnX/zOvblTIOCA4GDtgq+X5L95e1BSEyFFdN3C3wDxE+Tu4 NDfbFFnfg7q935eqUIvtT8TNrvhIzuvZPO5twjxzk7JNIsHIbRLaw9fN5bjeGP3BhTHe tEkwoSex600kZ52p6+n6IMPFieJPojozDrq55tcIXtdpj5IVI++nqtrU6uke3yRB1+qT ntOwBpgpg8npdSvhri03xJyev2csgTJ0ju8PD+p+rgNQdPzQXzyZqd11AHtgaW/l/Egk Qg8/6Jf9eLWUYqm5aMRAsLkMgGmckG+tRTDtteHZfwI1b6gNpbR1CdnHWK2ju8VtZ7vo 2h+Q== X-Gm-Message-State: AOJu0YzkmesBbe0314QJJ/6s/tFsAoqfiAdGb2nu804VTr2KJKEXwQoo 4bZ2k0vjATiClVNIn+LhvHiLYzvLlFzu9L2hCvYCjdPZ+7zZoOgkCVRj6NT9OR2y7dXZhndJ X-Gm-Gg: AR+sD13hA77n1ERD8WhqjA3FgXGjQ9Zz/7anbeXUo3Yd3r9f69pLL7Z5DkYRM4MEOE6 qohTJNam1PIgfGmaKMbJw1NLIoAor60Ow2Y/dHImd1aOn7JatxuYKUr/JUHfRK2IOWzhz3TcWTI ZBJqfE+wrks/FkH66s5gjtn056UG5CcLNo/keRzZXsqfvk/oGUE5qewhA6g8QkfraExjsLGtan3 eiEkT7M5wkDrW/k4lUE5Cs+NLz+HK20pNe3mvrh2a83hvPijiZEOnGteD/ngH0oeh6EiodV6iWB aR8uOoKONnnvDsY9kIGA3pR3OKqG5oFpTq9dzMTRdsQ6ovAf6V/aZNLQRGGhcZp2lGdEWnudQ/p tLzifp9nalKm77e/Ia3DJX7SjZv+HXiNzEBlcCKTJIWIohKsns9WsMn2zBUsLE23t/e4uv3LWKR iIcwlhOZaEIGOHTIHPhAB2p/Mc0gamDJdZ8zkcUJYA5rEjEP54QlH2n00sGCq8GCjU6YeKx3bVB g7tGawm54UHIvGax7aDP3pYx18= X-Received: by 2002:a17:903:ac4:b0:2cf:a1c0:d4ca with SMTP id d9443c01a7336-2d0ca961ad6mr227793105ad.22.1786048037501; Thu, 06 Aug 2026 13:27: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 V11 14/15] iothread: remove legacy iothread_get_aio_context() Date: Fri, 7 Aug 2026 04:25:23 +0800 Message-ID: <20260806202531.243806-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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::633; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x633.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: 1786048142362158500 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 cf1b6e0cdc..2e28fd3ad0 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 43f42c65c8..06c5926b6e 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.53.0 From nobody Mon Sep 28 01:14:57 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=1786048085; cv=none; d=zohomail.com; s=zohoarc; b=VvwynSE1iVYa3qEnwfenN1cF9EvD37xiDLVEv9z9WTlKbKrqb5LQUAC9ORN4R9gxSRK/S+Rf4Vc8ixgPYXnodeJbo8BO8U+H9ftbqYzH1ptQKJ8Q/bxKZ/BtUR4C3gpX2AAXT/lh41nQVPUH2WQy0hBRbrx7Liau/r7+SiiijbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786048085; 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=X9i2b0/bv1/lcQlTp+wSwwnIvPyYL1lQMTbimEi5moo=; b=Opg1s4w+lXboRLijqv/QJ+l3L1riBhTgzxLr0ww3F/9EzxuLtwwjNMdeT7yei03uCQXf8P36Jr5nmYsDB2FOFUA0Ys4m7j9g/O9WAwMja5rJMKHFmb6ue9FH3fBcVf3w/zioPgQ6BjsFn/UhiARbeUppgbcfpJRBu/ikPeH+pv0= 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 1786048085472986.3551578582296; Thu, 6 Aug 2026 13:28:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ws4gz-00052J-JN; Thu, 06 Aug 2026 16:27:55 -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 1ws4gY-0004Rb-02 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:26 -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 1ws4gU-000547-Mf for qemu-devel@nongnu.org; Thu, 06 Aug 2026 16:27:25 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-38f0f132f56so1068112a91.0 for ; Thu, 06 Aug 2026 13:27:21 -0700 (PDT) Received: from t-kidd-X299-AORUS-Gaming-3-Pro.lan ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863fd2b3sm33140471eec.7.2026.08.06.13.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786048041; x=1786652841; 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=X9i2b0/bv1/lcQlTp+wSwwnIvPyYL1lQMTbimEi5moo=; b=I5TSr2zWmvuQUHRWFj6ptUPJygTnh8+YC3RQ+8u/td9iIAiYAIdnxvwFKODQ4Wex6y VLKgWy/D/8tAzEGvmJIO/gA7W2wMuTDY8U1SeHsKLOMnLZYaPROYX1bOZC6fxNDeqPOH a9Z5YjlHLBQFO9nktRY/mEYs1+A9m2BmkXkVNKHeSnLG9uQnHPSG31YvFX10h7fJSLnN /5nyayL7qW3vsKdMr9EXlR1P1ij5DkYKyYxuVSZxOaVJl8N8aukr5AzV5rg0SeVWnp49 JKTbBd9KetMjB5QQN8I9uGAvDcH/VtAcV2h62RuaLLTZW/SXREtowBUhTrW9ODLfX40S mWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048041; x=1786652841; 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=X9i2b0/bv1/lcQlTp+wSwwnIvPyYL1lQMTbimEi5moo=; b=GxhfMrXAABsUE/QiutCBnqp5qhIDBCmD4ywYj5op+lSif+J8JSsyHo1c3Q+Yv+3/0z THCKTpgn4C8cD6dxAFUAT8hANX9UFxiYtK/JbJKJoycEcGuo3UYbuXeVHvjL5IvxJUn5 RD2bX/WWP4tnWMf7+f6kbMQEwP0ciqtwReKRz5c5qjcGWt1TGesFo5cCB8pURz76VsZi rczZVMzlrnJiTxg5kujcErJFrv/2LpwO47Q20JSY8j8ppef7qsVgo0u7HlonqcPYVKtk Pqu71KTdqnK/oNFHrV1Wokynkeybr0ov609+8Jg2IH8GVXax03igl8FGi26dAX1zSWjn GrgQ== X-Gm-Message-State: AOJu0YwzeOpBC7b/LEJFJg4/AD6H/QiBsQ7GPO1QVe0TZ/iFQQCePDdf Q67+QAVTc7XM4CX82uAiIxITZz2GJbGfBxcN3MBrzbgbvYfq6dbgehqIE8iHlAeu9jPvNUHt X-Gm-Gg: AR+sD10Bq/1ZmADWk+xqAw75yW7E/PK5324M5XC5V7CLiNP3bJJ9Tvt25Zq9EpMc2c5 NikgZktQkMljFcbLeAT+GbBK4I7pmY4vnHBJ7vdRUZa7KentHCQufHPNf9Iz9zM+TnLn+eB7PFs jZf6rl6R8PqykQcqZEx6JzcjJ6/Sw2DJeeG9Vc9nHe0l9ydtw5qANb1Xq2pciRJ8w/iKaSGrHCP TxhFFeHYSuvi1s9cUYuEBhW/M/Zef8GGjsEAe2WZBq9MZL6iCPBGrEdvcSdX+IE/kPIHRBUkPQY Gv27iu06UvTrNXHw29jk4Ykda0nLpZgp7FL5xZ+Ll6Ol2R/9wfEoSgzEuyxseEyb1qo6qJuiaeQ NDBJvUQyhpVxem1iMCuSx45DAkvMFmazVbcsQ9sENFK3kyXXm12eNVGLEkDZauQhix3oUDONLr8 7d/m5QUFBidNHhPTL/hX/hjpsHUG/aYxSCFiuqMUFpbrJkQlRxQLz8ACvJnuRLuMcDJa0ilPWQV kfQS7qz19h/Z8s0/QlO62tIwT4= X-Received: by 2002:a17:90a:c887:b0:38e:4e61:c9e with SMTP id 98e67ed59e1d1-3908986dcf8mr3422564a91.21.1786048040885; Thu, 06 Aug 2026 13:27:20 -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 V11 15/15] tests/unit/iothread: update AioContext ref/put helpers Date: Fri, 7 Aug 2026 04:25:24 +0800 Message-ID: <20260806202531.243806-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806202531.243806-1-zhangckid@gmail.com> References: <20260806202531.243806-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: 1786048086226158500 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_put_aio_context(). Signed-off-by: Zhang Chen --- tests/unit/iothread.c | 17 +++++++++++------ tests/unit/iothread.h | 6 +++++- tests/unit/test-aio-multithread.c | 5 ++++- tests/unit/test-bdrv-drain.c | 18 +++++++++++++----- tests/unit/test-block-iothread.c | 21 ++++++++++++++------- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/tests/unit/iothread.c b/tests/unit/iothread.c index a363bf8f70..af3e264e02 100644 --- a/tests/unit/iothread.c +++ b/tests/unit/iothread.c @@ -30,12 +30,22 @@ struct IOThread { bool stopping; }; =20 +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + IOThreadHolder *holder) +{ + return iothread->ctx; +} + +void iothread_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 +123,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..49e97b43d4 100644 --- a/tests/unit/iothread.h +++ b/tests/unit/iothread.h @@ -17,9 +17,13 @@ #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_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..a63e54fe62 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_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..b9b153f95d 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_put_aio_context(a, NULL); + iothread_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_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_put_aio_context(a, NULL); + iothread_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..391b28b73a 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_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_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_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_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_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_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_put_aio_context(iothread, NULL); } =20 int main(int argc, char **argv) --=20 2.53.0