From nobody Mon Sep 28 00:01:13 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=1787434485; cv=none; d=zohomail.com; s=zohoarc; b=nOU0IouOHtGY+IODlYgY1ioCX8EsgD04TYnbI8o1y8yDhXXLNn3IbD2GENNjijOo4fTtOutL52BYqKyfAZcK3laUGjq61ERMSiRsMspjOB5fyswc2Q8nGAXANh0w13jofb38z+FS1pgDFz8n/Qh6G91+gB7Pkyme0gNXLKGEsAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434485; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=C7B569J3GSvT6Mmv4iIuh2ugKdBgveHjHXtrr4AV4doA0JtAQ0ZUYBf6czGQIBdvugAHHyNwY5YoD+XTU5Mt/jQF4EDIdRPycXMUO6rv12kWaYL+qOhPEhKIKZUp+uvb/u6lA4lApXtqJodJoEdIJIrzjpfh940Ap3ax4UXIkAA= 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 1787434485854932.5977550937704; Sat, 22 Aug 2026 14:34:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtLw-0003cZ-1U; Sat, 22 Aug 2026 17:34:12 -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 1wxtLv-0003c9-0a for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:11 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtLt-0000f2-Lb for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:10 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2caea3f742bso35189875ad.0 for ; Sat, 22 Aug 2026 14:34:09 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434448; x=1788039248; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=SdA8p74APHQ7SYzsPQvpF6ZesS0qcAbjKDVVzvLuvm9zkF4HemVSNnfhc19uWh15rz w9LOvFOH9YSB/xJeLKldxcIYmZW3RUx5zMGT7seeiGy9Zu5cV4OKkkMEw0HXXcbagEHU Qg6g5kPmX54bg+5im7uze+vUrB/GCJGV0VPPkqwNjD0HYoThR5hUPgivOmWI1fF4xpQg jNh/kCRfjn9pfwuM09n9v7J+qgXqjmRbJVOqpKZ7K8XR85sldH/Y1zCZ8UoDNQgci3oj l2D7rRYA/siSOf5Ika5Uoo7wB8ogvaXuer6xU3pSBZUXO8QRo/3/sdwFfz8s1ws7CUee ZahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434448; x=1788039248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GKPbyoUsJ8IzjDSZ/9gIj07Iz6lN96BBEtJXGjNiovA=; b=tJGYFPcYAq0l+SpM8P6JhwGR23AdQo+WrITS3ABL5j2z5vnUzGqNgWKhuW+mvBemej YV5S6wX1clCqbeJUt/a3n9qj8pzF7NGPgi826pZOVmqTmRUiprFGrA/5pxMsXSA/j9Fd AiwNjlGnTYJHrcB7ZgEWY4m00k36Kfa3TG1/F/I0rPTiR6Ovxg0hKkdShpP3iFj8NgFf RBHN/w/tjxtK5QC2FY6VzIkU4Lss3C7sqv2RY2oCvVUxkOR/xHWSVLh+dBS+PP/oLamI PBexaJ1h7mwF2ID6Xq0dErQRm48VUTCUbQUSAA2+6OhFouzVor7AKVTa+nnorDFAyUfY HYDA== X-Gm-Message-State: AFuF++k3XjtqYh7KByD3W/QwSKxdkA+iMFUQ9CZ7v83HwTJzptVnrFbr LAAUTy3jUnOWAHJIluAByRkLK3GFXYF7AQEpJAGAPGWIkJ6FsgXkHadz/iHU6WahByouCYgd X-Gm-Gg: AR+sD10+5T7qkfFpsnDFvFcNb6TKJV/TFHI1ip5GrO8XZGmDCDroNyK6vdtFqpI0M6h +WWQJsmN7FdyHwpxOPX5UneClK4vnP+RlP0OGxlSpVBvO4oVZDAasVcsR99OWFeq3bdgfuECBNE aiUmZaG3q46mNiXEOr5JmQZ+BVxzZAV9VzuWCCz3MlZUmZwSL196z7BqO8HQrfVHKxwkqSVUS3S 0aDeV1cZCBHxz0FixoDenzB48I/hkdF4e2jmlMLq16wKG+zxKFsb9skUTT7eSW4xTGjiIswoOds IOPkNbizKBUbLsdoPzyWfgQo9e+d2ylBfoIrkSVUmmkGg6HAy1Jh86t/lxhEkJ1QLdTOSz059ei rxQv7QFZFDf0j5qeig2Ph+rM2vMRaOjHVkr/Tw3bda7wqkNZpFrME7fUR9RTw1wrpTmaL3oHytb EvTXMa1qGdE7nf5ZjZv981vgIZ44Ecusybd+pLR3P2qvjWmxMU77MbTN9rMusEYJws8gVk/8y1G VsanCCU X-Received: by 2002:a05:6a20:43ac:b0:3b4:8f18:33a with SMTP id adf61e73a8af0-3cd2fd8e233mr32283538637.1.1787434448283; Sat, 22 Aug 2026 14:34:08 -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 V13 01/15] qapi/misc: Fix missed query-iothreads items Date: Sun, 23 Aug 2026 05:33:24 +0800 Message-ID: <20260822213343.661939-2-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787434487892158500 Content-Type: text/plain; charset="utf-8" The example is incomplete: it misses members @poll-max-ns, @poll-grow, @poll-shrink, @aio-max-batch. Messed up in commit 5fc00480ab1 (monitor: add poll-* properties into query-iothreads result) and commit 1793ad0247c (iothread: add aio-max-batch parameter). cc: qemu-stable@nongnu.org Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Signed-off-by: Zhang Chen --- qapi/misc.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index 22b7afed9f..c71a5fe657 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -123,11 +123,19 @@ # <- { "return": [ # { # "id":"iothread0", -# "thread-id":3134 +# "thread-id":3134, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # }, # { # "id":"iothread1", -# "thread-id":3135 +# "thread-id":3135, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # } # ] # } --=20 2.55.0 From nobody Mon Sep 28 00:01:13 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=1787434532; cv=none; d=zohomail.com; s=zohoarc; b=lC3s7XqVU3TrgY2ZboFYcsfLCCw5fARgdI9xjNJtIEGn6qJcul90OBkNmn2nSObXEluV70+xOjjSBn/UofoZiTYxkvrGgltmQOUIwQHiG9QQUfMGy5FTCIsY3kwcYU3/6hIcGwwqhWg1De/Q/pRX2/Skq2BYfr9FicSr8dVzMjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434532; 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=P21I7BlC9KiDPWorOkMHQQSb9zd3quXLdeYsYZUoeoU=; b=VC2yohgZFSZM+s1zdJOUupvc7lfsjIYVCwq+IjefBE5kh52KYkrhXvureZFHps/VakR5GLwxLc8G1uase+O3WIhSBqB2R/4gP6SGesbdIS4HsnvkR4gw2HEK8W/kTGIh14Uf5pnPgECp/SLUOyk2CbcrZNM8I1HVgqv+VysmZsY= 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 1787434532133914.9646140257572; Sat, 22 Aug 2026 14:35:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtM0-0003dj-Kb; Sat, 22 Aug 2026 17:34:16 -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 1wxtLz-0003dH-73 for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:15 -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 1wxtLx-0000fO-92 for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:14 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2cedda2ce6fso13008715ad.1 for ; Sat, 22 Aug 2026 14:34:12 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434452; x=1788039252; 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=P21I7BlC9KiDPWorOkMHQQSb9zd3quXLdeYsYZUoeoU=; b=n/3PYQM/S3jBCTltDhErD9Nt5dWyxGXUuqY6eZcqIx3yU5auhlpe+BdoLVv/tZA1RO dBpbMS7OZm20wD2yYGyNxFCaGfBirqEQx44Y6uY9j+8S637IDHJtAFNxmN+JgX22b6Lr Itk9CoQbQyWMzdpMGFnLMKGfoJBU1IGZm8iKOb7f/1Qsqc/pKm+Uy8HYGqR/YRjEOMy1 wqfbfcxLGxQcYxvHi/1yRzl38kmmHyVrJCwfDUbz1s5g4euwiXYow9UGqgCKM3V9ep2Z /m2eRA3QjpiNr/umkqqGptu+KMldyyoRNB44Gv3bnh1+p1r0t2UK2+sBbF5nPQh8cOw6 wTvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434452; x=1788039252; 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=P21I7BlC9KiDPWorOkMHQQSb9zd3quXLdeYsYZUoeoU=; b=cT5l3Jqo/JqjAZ9XNpdydfM6hXrDdD9IZljAM5bhGwxzbITRCn6xQ6pypELrXFnO6Q 5EilSMHk82x+hmu8GleNBNT8/HOOjRmu7e5TTGShEByNbWJIYKMJEAf4G05Khobhhr8j ftPB2E/C4oic1gdDbSPRG/9de12DO4UtGslwEG1BhVCj5LpGHNih5/b0vjstdu4rcoDf syzkOwVET5/gP/sT/PdlA6I6jff2uf1yCWFRBlM9qg2F6nt9dR+HiybX1luAcLgrdz2B 4/LxrfFiphF2o3PeRLcz9AEVLfgf63GiYTFRrTGnuwzpsadDjGv6iYnXKtd/nhQ/D3AV V5Cg== X-Gm-Message-State: AFuF++k64Cu1vIFlhN+4ocaPi0rheq2IadZqxjdIZsJ2flDbcZbHf1oM Cj7WavSu1BvGVmSP3oIoCpSLMcuqlP46uzg+CW8TeV4DKrbg3jNsj8j6kOQ4OwFrvOFdgqIW X-Gm-Gg: AR+sD11ASBPUraWr4TvMzXwsMXY4OpS7lmBQVjGtC/TVj2BEuGCtnqJQtznuedH+HI+ YgspZZMNMiv8ZURT4/QSf834M1FKju5msB78m2zurlg/DnGK7ZIXwxpSCDCrePVfKy/AMIDbVrs ze7OHmpe1O0rO4gtL/eKQi6sP6vt/b7c7b747hBtoPzolcDSKKJYX/Wz/HovK4e0GjGFRasZb+A pAM2igteaj7nK5y7ZqtLzFvV5lUnA9HXve/r/fgo4vu3wCo+crCrUvKLRHCGTe2cg2KQZAAQoc8 bCnMEoAAdWf1PEOG03zynp9qcXnptAHA5/XnSZ5XdOYMl5TMwnDPdfwNx5VUR/OEhOHIiIZqi1g 1s5VRb8KcEPMLafE07P2DI8eUUbGoWuNmXk5uDretqlSSPuqrFeS7i9Mhsd9rloXb9JgR+yi0QZ HreSD0nOzc1ByHENi3lXYtzb70K7BpFoNlTVr+LsJDI+1tN0lrX5q+Ywha/V9nbDyaeG3Cuafhr StuJoC3 X-Received: by 2002:a17:902:ebc3:b0:2ca:1479:d9dc with SMTP id d9443c01a7336-2d64b0427fdmr307893565ad.12.1787434451746; Sat, 22 Aug 2026 14:34:11 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V13 02/15] iothread: introduce holder tracking Date: Sun, 23 Aug 2026 05:33:25 +0800 Message-ID: <20260822213343.661939-3-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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: 1787434533569158500 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..66dfde626e 100644 --- a/iothread.c +++ b/iothread.c @@ -21,10 +21,71 @@ #include "system/iothread.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-misc.h" #include "qemu/error-report.h" #include "qemu/rcu.h" #include "qemu/main-loop.h" =20 +/* Add a deep copy of @holder to @iothread's list of holders. */ +void iothread_ref(IOThread *iothread, const IOThreadHolder *holder) +{ + assert(holder); + + QAPI_LIST_PREPEND(iothread->holders, QAPI_CLONE(IOThreadHolder, holder= )); +} + +static int iothread_holder_compare(const IOThreadHolder *holder_a, + const IOThreadHolder *holder_b) +{ + const char *name_a, *name_b; + + if (holder_a->type !=3D holder_b->type) { + return holder_a->type - holder_b->type; + } + + switch (holder_a->type) { + case IO_THREAD_HOLDER_KIND_QOM_OBJECT: + name_a =3D holder_a->u.qom_object.qom_path; + name_b =3D holder_b->u.qom_object.qom_path; + break; + case IO_THREAD_HOLDER_KIND_BLOCK_EXPORT: + name_a =3D holder_a->u.block_export.export_id; + name_b =3D holder_b->u.block_export.export_id; + break; + default: + g_assert_not_reached(); + } + + return strcmp(name_a, name_b); +} + +/* + * Remove @holder from @iothread's list of holders. + * + * It is a programming error if @holder is not present. + */ +void iothread_unref(IOThread *iothread, const IOThreadHolder *holder) +{ + IOThreadHolderList **prev =3D &iothread->holders; + IOThreadHolderList *curr; + + assert(holder); + + while (*prev) { + curr =3D *prev; + if (iothread_holder_compare(curr->value, holder) =3D=3D 0) { + *prev =3D curr->next; + curr->next =3D NULL; + qapi_free_IOThreadHolderList(curr); + return; + } + prev =3D &curr->next; + } + + g_assert_not_reached(); +} + static void *iothread_run(void *opaque) { IOThread *iothread =3D opaque; @@ -129,6 +190,7 @@ static void iothread_instance_finalize(Object *obj) iothread->main_loop =3D NULL; } qemu_sem_destroy(&iothread->init_done_sem); + qapi_free_IOThreadHolderList(iothread->holders); } =20 static void iothread_init_gcontext(IOThread *iothread, const char *thread_= name) @@ -373,6 +435,7 @@ static int query_one_iothread(Object *object, void *opa= que) info =3D g_new0(IOThreadInfo, 1); info->id =3D iothread_get_id(iothread); info->thread_id =3D iothread->thread_id; + info->holders =3D QAPI_CLONE(IOThreadHolderList, iothread->holders); info->poll_max_ns =3D iothread->poll_max_ns; info->poll_grow =3D iothread->poll_grow; info->poll_shrink =3D iothread->poll_shrink; diff --git a/qapi/misc.json b/qapi/misc.json index c71a5fe657..eb3b89293d 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -67,6 +67,55 @@ ## { 'command': 'query-name', 'returns': 'NameInfo', 'allow-preconfig': true } =20 +## +# @IOThreadHolderBlockExport: +# +# @export-id: The unique block export identifier. +# +# Since: 11.2 +# +## +{ 'struct': 'IOThreadHolderBlockExport', + 'data': { 'export-id': 'str' } } + +## +# @IOThreadHolderQomObject: +# +# @qom-path: Path to the object in the QOM tree. +# +# Since: 11.2 +# +## +{ 'struct': 'IOThreadHolderQomObject', + 'data': { 'qom-path': 'str' } } + +## +# @IOThreadHolderKind: +# +# @block-export: A block export. +# @qom-object: A QOM object. +# +# Since: 11.2 +## +{ 'enum': 'IOThreadHolderKind', + 'data': [ 'block-export', 'qom-object' ] } + +## +# @IOThreadHolder: +# +# The block export or QOM object holding the iothread. +# +# @type: the kind of iothread holder. +# +# Since: 11.2 +## +{ 'union': 'IOThreadHolder', + 'base': { 'type': 'IOThreadHolderKind' }, + 'discriminator': 'type', + 'data': { + 'block-export': 'IOThreadHolderBlockExport', + 'qom-object': 'IOThreadHolderQomObject' } } + ## # @IOThreadInfo: # @@ -76,6 +125,10 @@ # # @thread-id: ID of the underlying host thread # +# @holders: the QOM objects or block exports currently holding this +# iothread. When a holder is detached or destroyed, it is removed +# from this list. (Since 11.2) +# # @poll-max-ns: maximum polling time in ns, 0 means polling is # disabled (since 2.9) # @@ -98,6 +151,7 @@ { 'struct': 'IOThreadInfo', 'data': {'id': 'str', 'thread-id': 'int', + 'holders': ['IOThreadHolder'], 'poll-max-ns': 'int', 'poll-grow': 'int', 'poll-shrink': 'int', @@ -122,20 +176,36 @@ # -> { "execute": "query-iothreads" } # <- { "return": [ # { -# "id":"iothread0", -# "thread-id":3134, -# "poll-max-ns":32768, -# "poll-grow":0, -# "poll-shrink":0, -# "aio-max-batch":0 +# "id": "iothread0", +# "thread-id": 3134, +# "holders": [ +# { +# "qom-path": "/machine/peripheral/blk1/virtio-bac= kend", +# "type": "qom-object" +# }, +# { +# "qom-path": "/machine/peripheral/blk2/virtio-bac= kend", +# "type": "qom-object" +# } +# ], +# "poll-max-ns": 32768, +# "poll-grow": 0, +# "poll-shrink": 0, +# "aio-max-batch": 0 # }, # { -# "id":"iothread1", -# "thread-id":3135, -# "poll-max-ns":32768, -# "poll-grow":0, -# "poll-shrink":0, -# "aio-max-batch":0 +# "id": "iothread1", +# "thread-id": 3135, +# "holders": [ +# { +# "export-id": "export0", +# "type": "block-export" +# } +# ], +# "poll-max-ns": 32768, +# "poll-grow": 0, +# "poll-shrink": 0, +# "aio-max-batch": 0 # } # ] # } --=20 2.55.0 From nobody Mon Sep 28 00:01:13 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=1787434539; cv=none; d=zohomail.com; s=zohoarc; b=AddO0yPOv3BHVHIAHL/9HHByt+vIxHKULZ/hlr2Oz+95UVmwbPEtWiP2XzoD9enzOj0MADjVrr8+8hLUvSpz3mG932/desISEtTx/hvkdGDbhc6IeeUvQvZTMmmWTTXN8AiTLdN8YcTNcwink0n3HFAyO0gGpeH+tSEZ4jJcKc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434539; 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=rMyDEXSasPWxbd315x54YJsjP/j+H9a0KUGXEiE3g1w=; b=GMYqcL/CWO/gOVB0sjiF3zxYjUBzFK/wETjjZu+/sDz/HoU8evL4YBxfEqxy7s93tmpsB/Qh1iEFzvvfYrsoDssKGpDMK9bvSGZZ8+Y6p4sZqxDHEvVJx+5TY2jNAJg5ZPmAik9wPH5z2vI9cKGKkWBV0yGC0WuBDwERhrqiatQ= 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 1787434539842805.8163033787318; Sat, 22 Aug 2026 14:35:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtM3-0003eD-8N; Sat, 22 Aug 2026 17:34:19 -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 1wxtM2-0003dn-2l for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:18 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtM0-0000fY-HS for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:17 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-cbb8b54fcf8so2212009a12.0 for ; Sat, 22 Aug 2026 14:34:16 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434455; x=1788039255; 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=rMyDEXSasPWxbd315x54YJsjP/j+H9a0KUGXEiE3g1w=; b=gjiyU80uHwDLI5S0D5wOfIyKhYrhpNID1z4nPjgkv4dvVncAoNJwcXjnvUevwm56US 6otBcd9SIka+9SZ+jigR+9E9t0b0FOgbY4fGTzhxc5Rw2/URTVz8zZ40Q5ObwEIO/zMt J5chKfg9TjX2nRH6MWPbrKKzPy/XLi4Xg1gODrnSUX94QTx1B8Xm4n0XIYhjYJ/eUNk4 f889FJ3QgWR8KOl81icjRpao1i0/PjFYS1UCAE+QBNIzieBij9zWOkYt3jW/m6tqH6fp x/YuhaVj1YujfLth5JbZCsekXKwEajxQSC/TruJ5z+wlX4287tMUnWcRjEcz3/0NuyFU 8ZdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434455; x=1788039255; 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=rMyDEXSasPWxbd315x54YJsjP/j+H9a0KUGXEiE3g1w=; b=C8hTRm0bdJj0vBqFEifI0y9Al0SpVJZVK0wUrHODfhIRckuvxncAk4CqJ1SJloPTzR O4FFEjF8DKHLrGLY6kUkzV4wIi7KnllD1W0E8q8s98Dvao30HBCC9kFxFOu9imIcd4Am PZKJSmdItdEfdPeJyosUv3pi6LGFzjqHZPxD93O2mLpQDQ5dylCIxxzUFN7I9UgZa1KI u9oHyKGAOOV2/2mJYX3gYU0CAtE83RpbRK/I91bP8EOdId6zy8jG3z+fvCe+4lA/+d1K Yxa90DG9+3IPDiLKgp+sA5H7GkigooruFfBm9A1qN77Q2RGQhrRYKSJnPo+XLqE7vRo/ 6Cfg== X-Gm-Message-State: AFuF++m+li+CVSu86WV4uHu562R4Rb/1PqGnkjjRNpCkI9E63/CDyUoQ 531Mge9Zbi7qHw8HfIpwIj73W0Qq65dUzPDGRxZ5lSKdGZrsDxeH2cUvX7KNzykOsEWyGNUN X-Gm-Gg: AR+sD10qjZnvK2zdlLIONIaUY8nB218TUpRBmJohmckDFV2fnkVA5Zi4hzdBpQR3lV5 CHV6tXSCopXink9HnZB6l2SnRtY+DlnOWPSPjrjR0KLKdfl16QZeZEWJIwhkHXAt+ijPAK6ozag i7d8Q03TpA1SHcUpQR4D9TUQRbfaw51vKKLmg/QEymW8ytqwKJ1duKcCLyukZ+XmkM6WLGRQsz/ wUZPL2X05e9No/0u8RkWN9LegxQqaWp7PgrXOiVUYuwfMNcHG6ZbS4sWp5U8/EBTcDJdW4yBsw+ DbR7p04Dl8glf7kQ/5XbptEoDvRdJlbHoxffVNC6ih0UNpkFNX1TPmnoOsBlAsPtl+acPSc/Oly k6375ubGG15+Xh+W7VlULvBLh3433pozcBtmDFOiDkCdmwnzS2E1kysgd4x4wf4YkbmXmLYW2ph 9+uQbvUIMfi6DX/o5yD1bfc9OKV3mgIbETiPkN1tBvPuiUfKevlUBJ1OSo1cWZoKkHq3llVYZ0J hMINYeXuw== X-Received: by 2002:a05:6300:6d8c:10b0:3cd:4fa5:1b88 with SMTP id adf61e73a8af0-3cd4fa51bcbmr8515340637.0.1787434455095; Sat, 22 Aug 2026 14:34:15 -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 V13 03/15] iothread: track users with holder name Date: Sun, 23 Aug 2026 05:33:26 +0800 Message-ID: <20260822213343.661939-4-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: 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: 1787434541667158500 Content-Type: text/plain; charset="utf-8" Introduce iothread_ref_and_get_aio_context() with a holder argument and its counterpart iothread_unref_and_put_aio_context(). Previously, users of an IOThread AioContext did not explicitly record their identity, making it difficult to debug which devices or subsystems were pinning an IOThread. 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 Reviewed-by: Stefan Hajnoczi --- include/system/iothread.h | 22 ++++++++++++++++++++++ iothread.c | 24 +++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index b8aeb32b0e..f6c5f95dd9 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -67,6 +67,28 @@ DECLARE_INSTANCE_CHECKER(IOThread, IOTHREAD, char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); AioContext *iothread_get_aio_context(IOThread *iothread); + +/* + * Register @holder and return @iothread's AioContext. The holder is copi= ed, + * and a reference is taken on @iothread so that both the IOThread and its + * AioContext remain alive. + * + * The caller must eventually call iothread_unref_and_put_aio_context() wi= th an + * equivalent holder. This function is not thread-safe and must be called + * under the Big QEMU Lock (BQL). + */ +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + const IOThreadHolder *holder); + +/* + * Unregister @holder and release the corresponding reference on @iothread. + * Calling this function without a matching + * iothread_ref_and_get_aio_context() call is a programming error. + * + * This function is not thread-safe and must be called under the BQL. + */ +void iothread_unref_and_put_aio_context(IOThread *iothread, + const IOThreadHolder *holder); GMainContext *iothread_get_g_main_context(IOThread *iothread); =20 /* diff --git a/iothread.c b/iothread.c index 66dfde626e..58dace351c 100644 --- a/iothread.c +++ b/iothread.c @@ -33,6 +33,11 @@ void iothread_ref(IOThread *iothread, const IOThreadHold= er *holder) assert(holder); =20 QAPI_LIST_PREPEND(iothread->holders, QAPI_CLONE(IOThreadHolder, holder= )); + /* + * This guarantees that the IOThread and its AioContext remain alive + * as long as there is a holder. + */ + object_ref(OBJECT(iothread)); } =20 static int iothread_holder_compare(const IOThreadHolder *holder_a, @@ -78,6 +83,7 @@ void iothread_unref(IOThread *iothread, const IOThreadHol= der *holder) *prev =3D curr->next; curr->next =3D NULL; qapi_free_IOThreadHolderList(curr); + object_unref(OBJECT(iothread)); return; } prev =3D &curr->next; @@ -199,7 +205,7 @@ static void iothread_init_gcontext(IOThread *iothread, = const char *thread_name) g_autofree char *name =3D g_strdup_printf("%s aio-context", thread_nam= e); =20 iothread->worker_context =3D g_main_context_new(); - source =3D aio_get_g_source(iothread_get_aio_context(iothread)); + source =3D aio_get_g_source(iothread->ctx); g_source_set_name(source, name); g_source_attach(source, iothread->worker_context); g_source_unref(source); @@ -421,6 +427,22 @@ AioContext *iothread_get_aio_context(IOThread *iothrea= d) return iothread->ctx; } =20 +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + const IOThreadHolder *holder) +{ + /* Add IOThreadHolder to the list */ + iothread_ref(iothread, holder); + + return iothread->ctx; +} + +void iothread_unref_and_put_aio_context(IOThread *iothread, + const IOThreadHolder *holder) +{ + /* Delete IOThreadHolder from the list */ + iothread_unref(iothread, holder); +} + static int query_one_iothread(Object *object, void *opaque) { IOThreadInfoList ***tail =3D opaque; --=20 2.55.0 From nobody Mon Sep 28 00:01:13 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=1787434571; cv=none; d=zohomail.com; s=zohoarc; b=mBoRxVNXaWDkC9M+XfUMjJtMnKCH76yX69KVwBkHnSXePfUttjXjxb6mBLCUB+5rV8xlFQymsuY8DqdpsiwEjASQFZffC7p8YhLnfqm+3RfAJE0S9l/W8g1OOplXW9rIOY+YSYzEUTpqNnr1TMmt+ZAmJu8taqDaSNa5qosxU5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434571; 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=Pezo7fi75ZfIl47wCCjUatKsRrnsz18bI2OMJSruO40=; b=glpx9Gtj7TyPaEH8G4n8K/5hLptEnnqYc6tXT0pcucDo1Hj8VXkF3dotwRfbgrovuCBW8bNgMlq5hh/+awFU++Gu+5Id6stg/JTX/OPhuM66bubh5l9cOkNUKs1g71sINBNdFsDaBbtq59IGG7EctWgGDFE0kx+O9fBo6qIwt28= 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 1787434571241138.17750422215317; Sat, 22 Aug 2026 14:36:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtM7-0003eh-0B; Sat, 22 Aug 2026 17:34:23 -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 1wxtM5-0003eT-Mo for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:21 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtM4-0000g1-7p for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:21 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-c9e607d81fcso1334417a12.2 for ; Sat, 22 Aug 2026 14:34:19 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434459; x=1788039259; 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=Pezo7fi75ZfIl47wCCjUatKsRrnsz18bI2OMJSruO40=; b=ecfPtH5kKPOCLbJO8EVjuDWxMdf7eWT7qBldhWZ6Rc3VPJYWrwpTvCngGnXbUJ4DK7 04KQPeIGsrasu8o4lHLLOFL3lFqKLnqkE7qQGWJqq7t+6BBub4+Nc7SQ6oyMXeeuh13p cBjJtVSba7+GJtnp2PLhaRYxxuUG2uXm7nBRcXtzxbtdpcYANV95yrk8Qcjo5YsuYVgJ M9UJi0Vr1y4zyWb8QsVl2hbMmmubok/R45IE6lrYRnczZbXGxveVR6EuGt+6Y5cEBsp9 5O0r0q4xvv3wJ4F8tRAugOWflQnXevzajwF90kuA1txmmpDdscpHEepwl3nvFwUdrZn1 ghwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434459; x=1788039259; 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=Pezo7fi75ZfIl47wCCjUatKsRrnsz18bI2OMJSruO40=; b=Us+3NzzsGOK1JraoSJfhneRdGZQTVnYby5BiHs7D7mR9v+cIHe9LYvvxlOqiVnoOZX j4A0rgIrN/P0/Sb+FjGMpcdTtZJyvKBhv2C63vXmDur5xMYn864EZULntHZ5x3RPMhai HM1uNRBfJrimoUzT3fL80hEtYd3K5GXxc4buCjjWfLnWcS/+3FaeuZSOzKUX8N3cz75o UuAcuo2VT11XnWcQgD/rjiH6AS1UWmSfvxdZSeOwwiEYxuzsOl+rOHnbPHIbV8PSNdTJ dXDwRail6W+jDcnS2RXzHVO7MX8gVMnzSz+WAc67CpP0ODhXuX5wtLrDy0d0iFP2fBid Q0Rw== X-Gm-Message-State: AFuF++k1TCFSvP+PJ4OZrGvj38GaCP5zT9rFmunxckc+2dOhOJf3wAnD NXPZnEXAJPoMi4xO3aidK7nlfTIjAAsyKHM+bnG/BuekeLDIPlZr5k5K8b2KoPsEchRjJPYZ X-Gm-Gg: AR+sD10Z54ExZ1LAAv4wdIAiiwWJXeeQDh9MinZx7/e4ifwy9wt+l8SoNmJ/xr47UJ3 25iT80HUc+y7Cf/78rN+Um/GXSRUNq32V/yZ9kVjtEhdvHjRnkCyTcZh0Y3GJYNumejg+/4WZvF pKNAPiJ3ynajAE15d/ElTIznpytkoJjQ+2/waYyqaaR/hOhgkP9TX1TERZ3u9vvB8znAU4faIGX 1CZmB35I3q/QuloL4G4Jgvw05qANygF9RkC3JrUp7XYafi4p+yfYVoDzOwWE2QrkuSCdqa7CSJd 2CNTkBWmJaKrJeESfzbwDe3zOuymtXVARaKr5hDlCBlgIwu++8f143Z6OK0LlIn5o+wImvy/k/N TbBFeY4lHgihwWRzbtFEiVToZlDCT4uOd8qmhXSkvRN220BcOHilyD/DHt+DvAzOKXdq/tEUGfO 7dOWqz/rC7QVGQxUIk58zRfh0M5Pj5SuagdoGr3Q4z06SK5IwSERPx1SbJguvcnUKM0vGT4H9EO qt/MU5gi2t0O713Znc= X-Received: by 2002:a05:6a20:c705:b0:3bf:63af:85d with SMTP id adf61e73a8af0-3cd30178908mr33305095637.18.1787434458857; Sat, 22 Aug 2026 14:34:18 -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 V13 04/15] iothread: introduce iothread_unsafe_get_aio_context() Date: Sun, 23 Aug 2026 05:33:27 +0800 Message-ID: <20260822213343.661939-5-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::535; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x535.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: 1787434571768158500 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 f6c5f95dd9..2ef8c1a1bb 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -68,6 +68,16 @@ char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); AioContext *iothread_get_aio_context(IOThread *iothread); =20 +/* + * Return @iothread's AioContext without registering a holder or taking a + * reference on @iothread. The caller must ensure that the IOThread remai= ns + * alive for as long as the returned AioContext is used. + * + * This API exists for legacy callers without a clear ref/unref lifecycle.= Do + * not use it in new code; use iothread_ref_and_get_aio_context() instead. + */ +AioContext *iothread_unsafe_get_aio_context(IOThread *iothread); + /* * Register @holder and return @iothread's AioContext. The holder is copi= ed, * and a reference is taken on @iothread so that both the IOThread and its diff --git a/iothread.c b/iothread.c index 58dace351c..803d6ce3c3 100644 --- a/iothread.c +++ b/iothread.c @@ -443,6 +443,11 @@ void iothread_unref_and_put_aio_context(IOThread *ioth= read, iothread_unref(iothread, holder); } =20 +AioContext *iothread_unsafe_get_aio_context(IOThread *iothread) +{ + return iothread->ctx; +} + static int query_one_iothread(Object *object, void *opaque) { IOThreadInfoList ***tail =3D opaque; --=20 2.55.0 From nobody Mon Sep 28 00:01:13 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=1787434485; cv=none; d=zohomail.com; s=zohoarc; b=H/HUzjClRe1EUsx17ZpymCl/cFoXteWJm50bhhrkpkT1hS5a+ZFSLAEhekDaWJr5SMb/WlqALYw/YeECj7/t9MEG5WBYv7nXxpmcJXTwoBh95ECF5jaVLHTwkv2Wq81zWalUFKz3LK9riD0gguBdcUyvM1hnDvFJPy21nkfhzVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434485; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=WqfD4h00x6IQegsH+fdZYnZ+D8pdLOnt9KBJt9s+kKmVyO0DEyulUGZTOJfl2Z9BEBVYLoctY96mKbfKLOHfdAvTbx25L0zUU4Wh/86maYB4UcD8e9u5c6n5FhbNRHT/IjsIXb8XlXPSKB7Z5XkUU3QHfZ9X6Kc25FYjFNO683E= 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 1787434485784853.1651391670539; Sat, 22 Aug 2026 14:34:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMC-0003fT-0r; Sat, 22 Aug 2026 17:34:28 -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 1wxtMA-0003fI-0H for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:26 -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 1wxtM8-0000id-7M for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:25 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2ccf2360620so18922395ad.3 for ; Sat, 22 Aug 2026 14:34:23 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434463; x=1788039263; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=qUrtQz2+5QE9oQJnxl5vqqbt+vCleIksgA/5FSozl95xwNSCyIN0DD5hsyVe5WahBs C2CMWCNOWkb02c6KGqV1fF7coVpdux5od2GtnD0CxgpeN6zu6xe4PD3gm7f3Db6ULZl/ /DMIiLw1xregQ1C+ctN5qiPbKVfW+tGYtVn2B9/LkOSdJa2zeMW6LIhJPOpOINHzGRhW QUxkwzjpM4sOV5+4f9M0EQpN9R++E688GMDxyyLRMSFYosxwPqP+UQlcXbuuCXwrHHlD PFPOT5ay07Lhzfl3RNaXEnuYwkwmuqkgKGmO5s89ZaVZFBc9FcLtN2JWMEwbkywNPKN3 8Q2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434463; x=1788039263; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=c0DnY1gZpaIvaTUJhEOKC2Z/nQXIBJqQ3bcd/TsVWjI=; b=HBeIuh4y8KuY6VUUzEHwZ/IuK90tXZcKBTxgcvEj30VSTqUt/TtY0kptJCph2oIfs4 LPdBIfQU1mQ9ffTnM5MgaIFPmk1FR9uxGMx4dkBEj9w/s3Fuy49980MUb6oOIxovXASQ ixdDPV4v+6GaJIiJuRu7XM6Cm5g0urHYJoCQ5k4Uvp4PtlwKiNkFrSJn4OXZNvnhWIfY NxJWUnX7Aa2sU2P3HaAfajUeFzuQBTDDMIhtsI2OsoBoO8xbhEVmHEp5KflwLkyYibF+ ht2fXjEbjlKbM6nuCEIpnr2v2nXAw3tNmbTWkf1QhURqj202tly3tmb6/vNWN1L33T+F 1QTw== X-Gm-Message-State: AFuF++ntGTqMYid+EneFgBa705P6YpPztmgQMPxx7422+jseZYcy0BVe dh+OBFTrTOM4Pri5eFHdHdu32CglOK6NhnE0BFv1DrsiVbf8wmCKaQrGA194IWiPWAqTES0W X-Gm-Gg: AR+sD12IlOv6yOTc/yVA0YuLMDDzVVlc7ocRG3AlfChZn+IB7JLtzO2fJtCyCzIJq6W XA3eQ83A39bsWm410Z8hfPi7myC+tsaigp5bt6PKkvTUtvB3E+P82ZFNxpIutSuEjAjFp8qZfzf fji71Zs/w3286FjR0UJbgawHenuUsOHOY7yThxK9+Z5aC0TOUudid0r7X+GMOO4WPsUCl0Afpom n+GFJJsjbWw6Q2k3SeXJVQaf823hgecqDuO6S1Gf+Tc8o8iLgVGW4b/aSvaLykn44jN/HCvDxvP 6zUK475KZrqMS0n1t6YreifvL+HCPREvLOQ8kKNbSjVP8kwRHItU8tKiuP0GkrhL4JZWLBdYF/J irCjU/3H3HB1liNNqTr+sBt+Pa4BhElbJ4DBpLMxJtq3ZWXmCB5vTsHEpUDFuvUl+KNWg2yLmtH znx1kTvEbjVGWvT9y6mJE7UzjN/xeSSvRTQ/gukJdcDZhKQdn3sYI9kNWo+8QjuWUk6ZtJYI542 riUp2CNns/6ebLyB7/B X-Received: by 2002:a17:903:3804:b0:2cc:777f:d67c with SMTP id d9443c01a7336-2d64b0c5704mr306978135ad.13.1787434462714; Sat, 22 Aug 2026 14:34:22 -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 V13 05/15] block/export: track IOThread references Date: Sun, 23 Aug 2026 05:33:28 +0800 Message-ID: <20260822213343.661939-6-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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: 1787434487869158500 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 | 62 ++++++++++++++++++++++++++++++++++++------ include/block/export.h | 5 ++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/block/export/export.c b/block/export/export.c index b733f269f3..0e019545ef 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -15,7 +15,6 @@ =20 #include "block/block.h" #include "system/block-backend.h" -#include "system/iothread.h" #include "block/export.h" #include "block/fuse.h" #include "block/nbd.h" @@ -72,6 +71,32 @@ static const BlockExportDriver *blk_exp_find_driver(Bloc= kExportType type) return NULL; } =20 +static void init_iothreads(const char *holder_id, IOThread **iothreads, + size_t num_iothreads, AioContext **aio_ctxs) +{ + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + + for (size_t i =3D 0; i < num_iothreads; i++) { + aio_ctxs[i] =3D iothread_ref_and_get_aio_context(iothreads[i], &ho= lder); + } +} + +static void cleanup_iothreads(const char *holder_id, IOThread **iothreads, + size_t num_iothreads) +{ + const IOThreadHolder holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_BLOCK_EXPORT, + .u.block_export.export_id =3D (char *)holder_id, + }; + + for (size_t i =3D 0; i < num_iothreads; i++) { + iothread_unref_and_put_aio_context(iothreads[i], &holder); + } +} + BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp) { bool fixed_iothread =3D export->has_fixed_iothread && export->fixed_io= thread; @@ -85,6 +110,8 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Err= or **errp) AioContext *ctx; AioContext **multithread_ctxs =3D NULL; size_t multithread_count =3D 0; + g_autofree IOThread **local_iothreads =3D NULL; + size_t iothread_count =3D 0; uint64_t perm; int ret; =20 @@ -139,7 +166,10 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) goto fail; } =20 - new_ctx =3D iothread_get_aio_context(iothread); + local_iothreads =3D g_new0(IOThread *, 1); + local_iothreads[0] =3D iothread; + init_iothreads(export->id, local_iothreads, 1, &new_ctx); + iothread_count =3D 1; =20 /* Ignore errors with fixed-iothread=3Dfalse */ set_context_errp =3D fixed_iothread ? errp : NULL; @@ -163,8 +193,10 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) return NULL; } =20 + local_iothreads =3D g_new0(IOThread *, multithread_count); multithread_ctxs =3D g_new(AioContext *, multithread_count); i =3D 0; + for (strList *e =3D iothread_list; e; e =3D e->next) { IOThread *iothread =3D iothread_by_id(e->value); =20 @@ -172,9 +204,12 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) error_setg(errp, "iothread \"%s\" not found", e->value); goto fail; } - multithread_ctxs[i++] =3D iothread_get_aio_context(iothread); + local_iothreads[i++] =3D iothread; } assert(i =3D=3D multithread_count); + init_iothreads(export->id, local_iothreads, multithread_count, + multithread_ctxs); + iothread_count =3D multithread_count; } =20 bdrv_graph_rdlock_main_loop(); @@ -225,12 +260,14 @@ BlockExport *blk_exp_add(BlockExportOptions *export, = Error **errp) assert(drv->instance_size >=3D sizeof(BlockExport)); exp =3D g_malloc0(drv->instance_size); *exp =3D (BlockExport) { - .drv =3D drv, - .refcount =3D 1, - .user_owned =3D true, - .id =3D g_strdup(export->id), - .ctx =3D ctx, - .blk =3D blk, + .drv =3D drv, + .refcount =3D 1, + .user_owned =3D true, + .id =3D g_strdup(export->id), + .ctx =3D ctx, + .blk =3D blk, + .iothreads =3D g_steal_pointer(&local_iothreads), + .iothread_count =3D iothread_count, }; =20 ret =3D drv->create(exp, export, multithread_ctxs, multithread_count, = errp); @@ -250,8 +287,12 @@ fail: blk_unref(blk); } if (exp) { + cleanup_iothreads(exp->id, exp->iothreads, exp->iothread_count); + g_free(exp->iothreads); g_free(exp->id); g_free(exp); + } else { + cleanup_iothreads(export->id, local_iothreads, iothread_count); } g_free(multithread_ctxs); return NULL; @@ -273,6 +314,9 @@ static void blk_exp_delete_bh(void *opaque) exp->drv->delete(exp); blk_set_dev_ops(exp->blk, NULL, NULL); blk_unref(exp->blk); + + cleanup_iothreads(exp->id, exp->iothreads, exp->iothread_count); + g_free(exp->iothreads); qapi_event_send_block_export_deleted(exp->id); g_free(exp->id); g_free(exp); diff --git a/include/block/export.h b/include/block/export.h index ca45da928c..ce8e4eb604 100644 --- a/include/block/export.h +++ b/include/block/export.h @@ -16,6 +16,7 @@ =20 #include "qapi/qapi-types-block-export.h" #include "qemu/queue.h" +#include "system/iothread.h" =20 typedef struct BlockExport BlockExport; =20 @@ -89,6 +90,10 @@ struct BlockExport { =20 /* List entry for block_exports */ QLIST_ENTRY(BlockExport) next; + + /* The IOThreads utilized by this specific block export */ + IOThread **iothreads; + size_t iothread_count; }; =20 BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434486; cv=none; d=zohomail.com; s=zohoarc; b=KROLE7WMYft0wzBQDjMVVCoomNWIiQQuSEYstLvq9nz2gUb7XGx7R8s6LtQxalvjcljClU6MmITi6Gv0aZrtHDP68GyJ/lrSoAjsRYuTo6T1zG0/zy6aNZKhiBH2wTPe1rkZNp6vyKbXT3tkwkqrusHFgBq+Z5e7D3UYde5l3H8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434486; 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=lHpGhiOPUZ1iwhuBAHzhClfV+0PVtkn7WRLA3fGT3o8=; b=L8kX9EmPFV59K+0cPdM9O1iBm0JfSIIU/3VgZIfStuIKh21nAWAYoIH42TctxYHCHtaO97xec72C5uOl4p7I1fyXlnvbNBZhCuiM0R+FS3QU6TLg4MGaRsvlXhvwW1VksKIMZQ9HXN5kOYHmB6lKHGDaiGkihFHoJQ/L65EVL9U= 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 1787434486062893.08832772107; Sat, 22 Aug 2026 14:34:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMF-0003gr-DI; Sat, 22 Aug 2026 17:34:31 -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 1wxtMD-0003g2-DT for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:29 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMB-0000ix-NK for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:29 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-8487214ad2bso2979938b3a.1 for ; Sat, 22 Aug 2026 14:34:27 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434466; x=1788039266; 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=lHpGhiOPUZ1iwhuBAHzhClfV+0PVtkn7WRLA3fGT3o8=; b=SjBNMUh5ERQ1REsQc5ifgct8Y7RTy3NTnF/aPOaxJPtp8KGVbmkinSr1J939QXQcIE 4kXagoaeU2wtpGKJXNQoBWfPBMFZDmuPQ7+vAMqzjvyMky1RJVwFCh+y2juSFoxCPElq MkTlrNF8KV5mqk3ow4nFN7KYjs+XHv+yvGtSW/Ec6IygdO6qLhXJFolxtU2RQCond2Db 83jndvuuAoeaGPjhd7vgSlVHI6KsVpc/mJhaUO5V7pN0cdriNL7HL1wB6hAPmqJYjW4Q jzf88hB51BALuyCdTbkeHxPg25kiBs+jBtSd6xlpj4xHRJBaHXy4//EA9cbgx+53iaMW xpNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434466; x=1788039266; 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=lHpGhiOPUZ1iwhuBAHzhClfV+0PVtkn7WRLA3fGT3o8=; b=XcRBtTvIkJEpO6A7psQKMP93jITujRCOdfrBh6BoIEsR6qA+dR64LKBTPwFjj4TRfb N8tZG7NimvLx202bFuoNQijGdWPdI94BxZ4ITuCXtggyT+8d52Jr3xsg+hQSgSm+oVdA tp2ypHH51PC3HHGQooQ03x5CUAOah4wk6BoOh6nAP5gPK5kfAnelPgI3imEqE2xEkNim XvNcjxmuSBFRTlblnoh/pG230UouXPeLJ/JGVySYQ6+hcMv0HIen9z4Frq1w3vpz+aql vvW9YMBrzPSQH0vAxNIgPgvlKpXkcBNmxkGtpp/G3YM/vyCoh/6DCB8mGsjTG1O7myqT 9ixQ== X-Gm-Message-State: AFuF++nLqSSeTkQHdIndvIgphfwDem5glg7Of8JmVBqRCyjsSPqFHfeO KEEdzlicXlLydjbJhR6q8CzdFJ51wrTmXKyTu0hvhxqc6Kii/FLke08/TDptD5ln5Z94GfJX X-Gm-Gg: AR+sD10UULz9igT2HPTfMTAhuUHMUQ/sQ1+r6VN7O2V++Q904GOZulcgsuvR5q+ne0M p17guiK2xEKDxbUxnG1oER07Ir495RujWFW8jf2pOkBu4nVF1Ss0vnhLG16n2fl0xWoeCfvdvWj U+Rb5P/YUCOv3xK3xDelW9gwmO6w71Zp6h84ZHY+ADSuGV8fw1oObnP6VYsollVUfkBFCMphZ3n 8rLiqRlRjj3NT/k+7lbYOftBr6DSjkvXZQ2GDKqSUqHY9w5oJ73Y+k616WoL3t6gdg7AcTKFGBY bBz17zpai6ZwRCPLcJc2fjc5P1NzmR2RmGiAFpxyqNFvRyO+9V3Nn6tGdun9WkX7jiJrHbDSuN9 DC6vmRbG4CbwGvWoo6x0Wb5B1CbO+4U9qMkEiIwsBvegF8CyrSCjusiPVxoaxijiWrtmxZpcD0X DJdlKnVHGZhQ6oIx0SNFGWGVjgUyotCJnei+8qs7wNbBO7QpLM/gq7zZhRhS5Oq7zovZEdF/u2w UJ/F0v0 X-Received: by 2002:a05:6a20:1605:b0:3c3:b57b:6285 with SMTP id adf61e73a8af0-3cd3003dc4fmr32540591637.13.1787434466108; Sat, 22 Aug 2026 14:34:26 -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 V13 06/15] monitor: track IOThread users with QOM paths Date: Sun, 23 Aug 2026 05:33:29 +0800 Message-ID: <20260822213343.661939-7-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::433; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x433.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: 1787434487863158500 Content-Type: text/plain; charset="utf-8" Monitors that require an IOThread share the internal mon_iothread. Account for each monitor explicitly in IOThread holder tracking, using the monitor's canonical QOM path to distinguish holders. Acquire the shared monitor IOThread AioContext once, using the monitor QOM path as the holder, and reuse the stored context for later operations. Release the holder from the Monitor ObjectClass::unparent callback, while the canonical QOM path is still available. This covers every object_unparent() path and avoids duplicating the cleanup in monitor_cleanup() and monitor_qmp_prepare_delete(). The internal mon_iothread remains hidden from query-iothreads, as before. Signed-off-by: Zhang Chen --- monitor/monitor-internal.h | 3 +++ monitor/monitor.c | 33 ++++++++++++++++++++++++++++----- monitor/qmp.c | 5 +++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 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..da6d18f475 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -79,6 +79,22 @@ int monitor_device_index; OBJECT_DEFINE_TYPE_EXTENDED(Monitor, monitor, MONITOR, OBJECT, true, { TYPE_USER_CREATABLE }, {}); =20 +static void monitor_unparent(Object *obj) +{ + Monitor *mon =3D MONITOR(obj); + + if (mon->ctx && monitor_requires_iothread(mon)) { + g_autofree char *path =3D object_get_canonical_path(obj); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + iothread_unref_and_put_aio_context(mon_iothread, &io_holder); + mon->ctx =3D NULL; + } +} + static void monitor_finalize(Object *obj) { Monitor *mon =3D MONITOR(obj); @@ -114,6 +130,8 @@ static void monitor_class_init(ObjectClass *cls, const = void *data) { UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(cls); =20 + cls->unparent =3D monitor_unparent; + object_class_property_add_str(cls, "chardev", monitor_get_chardev_id, monitor_set_chardev_id); @@ -573,7 +591,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); @@ -713,7 +731,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 +749,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..cf1c8644cd 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 --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434534; cv=none; d=zohomail.com; s=zohoarc; b=bWbVtSbQ6g8xeUn/teYtcWpDhxK6xhsziow4iT5s84dznWxug9Xv1Zvjs8zDCBHeHLXjcRH4W531A9XKl2sGzLhKi9XCHX2tjf6abCtOOIW4FomQBVOO38KeAwohVqt24DGl4KomMDbynnSRNdmailQyrWKJrdo7m0cFOcEQqNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434534; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=Eb44cSfViIyZiLBOvGhOkEsmWexzmwOiYoKpumZH4lM6QCloBM3nTvfVXjq1wc3vzpYvZVl4HiLGr6SgEqpaK+B18TqWmKKM8zuQN/VspXtPCszoEw3xnOVjjytQ56ZoNTdIYd0fgNXzTj+fLBcw4jEnxeB2KFfmLCrbj/UsvHM= 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 1787434534451597.3779327264248; Sat, 22 Aug 2026 14:35:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMI-0003hf-Np; Sat, 22 Aug 2026 17:34:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxtMG-0003h9-Ne for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:32 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtME-0000jH-TI for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:32 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-cbeea240819so1288597a12.1 for ; Sat, 22 Aug 2026 14:34:30 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434469; x=1788039269; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=eA4VJR9N4N9OVKYHxtPU1WyZRZhzyNF0mywewZjqBHzbaBVP06/wfBrQ3lWSacy5Ge RE24ZrHa9BBrhkJRDYc07wFysXgUpx1h4MkV3QJgzvTEJJ+PygZlM+NKSD/rOw2+QYL8 l+03ZLdeDENc8Ee75P+qWdjcRhYOLYgwQGSPX19f+tjNZSk+hae8jjmTxQ94IbjME1Vy pMJdpVwMX+IDHA5p03zf+QuSoY5MKLNdM5/FQZvPhGGRUy+ypEjEVeJlXNzwwNJUrM+v pJEDTg2+GOA97DNG2o/RdciRm6R4qtNU3wBoj0qOfLx2Zf64WuhdbjpP/NoQSZfhgfCN P9KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434469; x=1788039269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OfTK4NEmm/XRmWubXK0Z8g5arShKsR66Fb+JdHHZVEI=; b=G+HhMDLO+ZlCHCWAa7ugy1zALK4K7mvgSZgHAfC8ATc9bdIfPETkzBf1VpbvCxSgvg nDpKQli1l/SVy+rkXIMSBKEVpK0T/4TTQG/J9AF6HUIwc5yw4QjEHmkx6zJjftFKs5/n 9JsePSm/9PcsJS51+dNykXQ6DNoxYqPDsV5SmTFjvCYEWEyh2uySnkMOkYx8TZl7kIej K0MLo6m7kiXFKOTRYnFpi7AVea1eKOcIgFf0lp+OQbItXXTiouvemEy2/iZpdTMHg2VM v5OFc2nDZFoxSrAwcxCN/ZwK98N3ZzVj7+Du13IAXDMGuByS1DzqBElyxKnM4mfr0T25 h0Zg== X-Gm-Message-State: AFuF++klIm+YFBICLSy/Kb98ZLU1D8TU2HloFR0G3nPGtBZbi/JMOehL RANLJ2Vak4igLTvEQQHHtNmDgO/aH2250VgxoBYd816i1szkUpeu6ylClbyCopkOqxNzQ2pL X-Gm-Gg: AR+sD129Oj423hcD1sj6pPiBaQt6cBEB9UIf+D8kBpFQoxRrs9xxFDfZnH1s9KaObln z7z4EbiDGPTBMVT6LO105IS6OEjilazLU3Xsx78vC2t6ic0DB5mHci1IYjohbQs4UJGS874qZ2C 19lYgYPfomPK/MDk6i4F7aHAw1+rT4qbqWFyQdUW+wITdHAw+juwqZN0sc8jDGIqfJ0664h30l5 /rxWoJbvS4q37J1Ui4sKE4AwH+Uz6InJ1Zmbo3Lv1w66I4O4VXZZmU/6/kbLAA/U5QSpM0WqBbC IL7um/1exYYEIp1kBEd+niV3pLyqXLgn0GL4+z7M8BD/3dSlNcuTjDsZCAQhLpqlzThuYM/BjzJ xU7bhBW29Vhw31DtDccE+XYtoPG0OzhOAI/hV1lUKuqIDoq442n/cd47W/zVyZ6A+yVrUX89G4j VLiuZeZPn4pkC/muE3zJXHYVn4D6BFU7EvgbiJdF3T5JBlorUGWbch7RDWU6CF0BBSJEcuB5t9/ REkZ/we X-Received: by 2002:a05:6a21:1191:b0:3cd:2e96:5929 with SMTP id adf61e73a8af0-3cd30156961mr31745905637.14.1787434469423; Sat, 22 Aug 2026 14:34:29 -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 V13 07/15] virtio-vq-mapping: track iothread-vq-mapping references using device path Date: Sun, 23 Aug 2026 05:33:30 +0800 Message-ID: <20260822213343.661939-8-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::534; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x534.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: 1787434535566158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/ unref_and_put_aio_context in iothread-vq-mapping. This allows tracking IOThread users via the device's canonical QOM path, improving lifecycle traceability for virtio-blk and virtio-scsi devices. Signed-off-by: Zhang Chen --- hw/block/virtio-blk.c | 8 +++++++- hw/scsi/virtio-scsi-dataplane.c | 9 +++++++-- hw/virtio/iothread-vq-mapping.c | 20 +++++++++++++++----- include/hw/virtio/iothread-vq-mapping.h | 6 +++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 6b92066aff..4b2cf3d52f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1493,9 +1493,12 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBlo= ck *s, Error **errp) s->vq_aio_context =3D g_new(AioContext *, conf->num_queues); =20 if (conf->iothread_vq_mapping_list) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); + if (!iothread_vq_mapping_apply(conf->iothread_vq_mapping_list, s->vq_aio_context, conf->num_queues, + path, errp)) { g_free(s->vq_aio_context); s->vq_aio_context =3D NULL; @@ -1527,7 +1530,10 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIO= Block *s) assert(!s->ioeventfd_started); =20 if (conf->iothread_vq_mapping_list) { - iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(VIRTIO_DEVICE(s))); + + iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list, path); } =20 if (conf->iothread) { diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 95f13fb7c2..26ecefd547 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -65,9 +65,11 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **= errp) s->vq_aio_context[1] =3D qemu_get_aio_context(); =20 if (vs->conf.iothread_vq_mapping_list) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); + if (!iothread_vq_mapping_apply(vs->conf.iothread_vq_mapping_list, &s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED], - vs->conf.num_queues, errp)) { + vs->conf.num_queues, path, errp)) { g_free(s->vq_aio_context); s->vq_aio_context =3D NULL; return; @@ -94,7 +96,10 @@ void virtio_scsi_dataplane_cleanup(VirtIOSCSI *s) VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(s); =20 if (vs->conf.iothread_vq_mapping_list) { - iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(VIRTIO_DEVICE(s))); + + iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list, pat= h); } =20 if (vs->conf.iothread) { diff --git a/hw/virtio/iothread-vq-mapping.c b/hw/virtio/iothread-vq-mappin= g.c index 55ce62986c..60e1d55005 100644 --- a/hw/virtio/iothread-vq-mapping.c +++ b/hw/virtio/iothread-vq-mapping.c @@ -77,6 +77,7 @@ bool iothread_vq_mapping_apply( IOThreadVirtQueueMappingList *list, AioContext **vq_aio_context, uint16_t num_queues, + const char *holder, Error **errp) { IOThreadVirtQueueMappingList *node; @@ -93,10 +94,13 @@ bool iothread_vq_mapping_apply( =20 for (node =3D list; node; node =3D node->next) { IOThread *iothread =3D iothread_by_id(node->value->iothread); - AioContext *ctx =3D iothread_get_aio_context(iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)holder, + }; =20 - /* Released in virtio_blk_vq_aio_context_cleanup() */ - object_ref(OBJECT(iothread)); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, + &io_holder); =20 if (node->value->vqs) { uint16List *vq; @@ -120,13 +124,19 @@ bool iothread_vq_mapping_apply( return true; } =20 -void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list) +void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list, + const char *holder) { IOThreadVirtQueueMappingList *node; =20 for (node =3D list; node; node =3D node->next) { IOThread *iothread =3D iothread_by_id(node->value->iothread); - object_unref(OBJECT(iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D (char *)holder, + }; + + iothread_unref_and_put_aio_context(iothread, &io_holder); } } =20 diff --git a/include/hw/virtio/iothread-vq-mapping.h b/include/hw/virtio/io= thread-vq-mapping.h index 57335c3703..0d39caddf3 100644 --- a/include/hw/virtio/iothread-vq-mapping.h +++ b/include/hw/virtio/iothread-vq-mapping.h @@ -17,6 +17,7 @@ * @list: The mapping of virtqueues to IOThreads. * @vq_aio_context: The array of AioContext pointers to fill in. * @num_queues: The length of @vq_aio_context. + * @holder: The QOM paths for attached device. * @errp: If an error occurs, a pointer to the area to store the error. * * Fill in the AioContext for each virtqueue in the @vq_aio_context array = given @@ -31,15 +32,18 @@ bool iothread_vq_mapping_apply( IOThreadVirtQueueMappingList *list, AioContext **vq_aio_context, uint16_t num_queues, + const char *holder, Error **errp); =20 /** * iothread_vq_mapping_cleanup: * @list: The mapping of virtqueues to IOThreads. + * @holder: The QOM paths for attached device. * * Release IOThread object references that were acquired by * iothread_vq_mapping_apply(). */ -void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list); +void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list, + const char *holder); =20 #endif /* HW_VIRTIO_IOTHREAD_VQ_MAPPING_H */ --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434544; cv=none; d=zohomail.com; s=zohoarc; b=BldHQyubKMKb8QPRpJ4D/M53Yyv2DFVCPcfw+nIkygrCRgkPlI0Adwup1MNBHUhRtZuVeW4boGx0qUOSZJCvx8hWWkh7qipwq3cJKPRhoF9vtRdog7G/LpR6qccDOo1po18J5ziEyYenTwmv/IT0AMo25juDHiQcN3Q8gfYX+Fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434544; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=HWmc3Wga+5+XPv2Kt478ProJEBPCFLfdGWMLcT1udzbmu0uQQ8UsRG37gwfvDaUtBD66L9npsUfLEVxMz6L5rZ3UmgccS5u7ucVcxSR7w34rBbatSCgidhy73etkxrgvSVytEdZMlLoPCNe8CIapJiN1U0Rs+Z34tw0iriwijuQ= 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 1787434544853598.2594774784362; Sat, 22 Aug 2026 14:35:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMN-0003i3-Eb; Sat, 22 Aug 2026 17:34:39 -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 1wxtMK-0003hq-6m for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:36 -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 1wxtMI-0000jT-G2 for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:35 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-c9e607d81fcso1334472a12.2 for ; Sat, 22 Aug 2026 14:34:34 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434473; x=1788039273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=NPfI4kIE6v+A14Eq25VSgz19ryzymZvdo+iT9Hj1jExmAUe3MgkA1Sdw8uo8aytQB+ XxlcNbvYfKyxknz/rOS/czQQTdR6/Ot1IeIFTLDZ96eyIvyB339orULmuZsCvd33BOPv TYh/LpjY6s1owXQDJKoUd0Kr0buzrlnjnPieuz6FqHEQ2SfpSZx3i0LqAHMm/naH7Z6x xsefJs1lZQO0MoJo97GtZ20ELhAGjfwuwFbiNCSM3WGuTekDqyqyF6e3Wxwse6z/EVM9 h8UUbesw3fMkFsLllWJxhS+/IExUhw4rT15REHoyVADvJX+pueRHPgkzStPcHTDfCEds gR1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434473; x=1788039273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4pWn6FsJfOpSFK+gwenZ9GknoUKvDRZidZ6l+4QLqTg=; b=WaAU1JL4RkYhItYp7neU/TDK+v/eCGGp+/4hUwalJeR/D0Kh641LsT7PsziIIQ5HHo 0C1IInU61JIMmoeueVtkK3EZHFT5l9KXmgUY6Kck0Ru4fWA+Ovt322WKVG3Wlnydksog rPumILyZanErrI2FDhZT6jjGWP6peZ5tZbg5Sq14tOySUY2Q/qhQKe/tkA/tQmjoYOQ3 z1gDiYcoKPpmO1NjF9WkgARXKRoZWYNOx7/Sf56oUQDHS+Bfcd4di6mnrJMz/hPR1jod fmBcn96HY/2TrPUc5lIZIHBkp5+2r+WPW/kDiYorREIK8Wf43y4nF8M4DV1r1HJHpb9s 298g== X-Gm-Message-State: AFuF++md6VOLbzg7IirJxzgNiLRRt4xyfxlvnpyq8UJCaMQD/UtbelJk da1frYXYZHHFyGFd7nZGt21RrRy/dPXyDTBhWYxPsus6gPBpNNx+NfAHI2mcRWeh8DY8N+yX X-Gm-Gg: AR+sD10PYGiENh5pYzgDuSkEUNWI4xsOQfgkIny5IHPvblMflbWekXajaFAWStMnYln RDIatjp0ZQTtd0iC+sV4Px0M7zzntWjWs0MAz4/DT/SrN/8z4wEj0+UbJoT7gIr2UYHFBxBxJvk kh7toSxHmrTMqfDQZA3XB/EgKctX2+mNAC/blMkkGtCOy3uJg5aFBMaUMTFUb59F0wCyGOXWtnE V/9JG8gJ4TjtwKvMPJYjN84C//UpVs2s8efGAoXi/rlHteNNjyw0+cpi7L16Bb9MirCbfLYdjbx cJIr6s/TlTdSRcDVIGNIRDbNxRxkny7v/p6haMHIkvW71dqIuzJvl6OnHClGRBhfsYd/nxnOT4T CYuszPXXi9nFK4voMJOx9zCkpeVvaImfIatMWH/x2XGZrFnCvPZk1/3jvWiSZN7eIy8obz+K1u+ Xe9T+qBRnwTcF+bEnPvcQ5VNqXT2t36paYqhJ5KyvfpMQ81rFHHGeNFiZB+bE9u7D0/thQaf8mZ r3pnKz8 X-Received: by 2002:a05:6a20:3d1e:b0:3cc:92d9:80cb with SMTP id adf61e73a8af0-3cd3003b104mr28076738637.12.1787434473155; Sat, 22 Aug 2026 14:34: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 Subject: [PATCH V13 08/15] virtio: track IOThread references for thread pinning Date: Sun, 23 Aug 2026 05:33:31 +0800 Message-ID: <20260822213343.661939-9-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787434545610158500 Content-Type: text/plain; charset="utf-8" Use the virtio device canonical QOM path as the holder when virtio-blk and virtio-scsi acquire an IOThread AioContext. Replace the raw object references with the holder-aware acquire/release helpers so the users are visible through IOThread introspection. Signed-off-by: Zhang Chen --- hw/block/virtio-blk.c | 23 +++++++++++++---------- hw/scsi/virtio-scsi-dataplane.c | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4b2cf3d52f..db7f513da5 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1469,6 +1469,7 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBloc= k *s, Error **errp) VirtIOBlkConf *conf =3D &s->conf; BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); =20 if (conf->iothread && conf->iothread_vq_mapping_list) { error_setg(errp, @@ -1493,8 +1494,6 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBloc= k *s, Error **errp) s->vq_aio_context =3D g_new(AioContext *, conf->num_queues); =20 if (conf->iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); - if (!iothread_vq_mapping_apply(conf->iothread_vq_mapping_list, s->vq_aio_context, conf->num_queues, @@ -1505,13 +1504,15 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBl= ock *s, Error **errp) return false; } } else if (conf->iothread) { - AioContext *ctx =3D iothread_get_aio_context(conf->iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + AioContext *ctx =3D iothread_ref_and_get_aio_context(conf->iothrea= d, + &io_holder); for (unsigned i =3D 0; i < conf->num_queues; i++) { s->vq_aio_context[i] =3D ctx; } - - /* Released in virtio_blk_vq_aio_context_cleanup() */ - object_ref(OBJECT(conf->iothread)); } else { AioContext *ctx =3D qemu_get_aio_context(); for (unsigned i =3D 0; i < conf->num_queues; i++) { @@ -1526,18 +1527,20 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBl= ock *s, Error **errp) static void virtio_blk_vq_aio_context_cleanup(VirtIOBlock *s) { VirtIOBlkConf *conf =3D &s->conf; + g_autofree char *path =3D object_get_canonical_path(OBJECT(VIRTIO_DEVI= CE(s))); =20 assert(!s->ioeventfd_started); =20 if (conf->iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path( - OBJECT(VIRTIO_DEVICE(s))); - iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list, path); } =20 if (conf->iothread) { - object_unref(OBJECT(conf->iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(conf->iothread, &io_holder); } =20 g_free(s->vq_aio_context); diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 26ecefd547..55bbf045ce 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -28,6 +28,7 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **e= rrp) VirtIODevice *vdev =3D VIRTIO_DEVICE(s); BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); =20 if (vs->conf.iothread && vs->conf.iothread_vq_mapping_list) { error_setg(errp, @@ -65,8 +66,6 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **e= rrp) s->vq_aio_context[1] =3D qemu_get_aio_context(); =20 if (vs->conf.iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path(OBJECT(vdev)); - if (!iothread_vq_mapping_apply(vs->conf.iothread_vq_mapping_list, &s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED], vs->conf.num_queues, path, errp)) { @@ -75,13 +74,15 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error *= *errp) return; } } else if (vs->conf.iothread) { - AioContext *ctx =3D iothread_get_aio_context(vs->conf.iothread); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + AioContext *ctx =3D iothread_ref_and_get_aio_context(vs->conf.ioth= read, + &io_holder); for (uint16_t i =3D 0; i < vs->conf.num_queues; i++) { s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED + i] =3D ctx; } - - /* Released in virtio_scsi_dataplane_cleanup() */ - object_ref(OBJECT(vs->conf.iothread)); } else { AioContext *ctx =3D qemu_get_aio_context(); for (unsigned i =3D 0; i < vs->conf.num_queues; i++) { @@ -94,16 +95,18 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error *= *errp) void virtio_scsi_dataplane_cleanup(VirtIOSCSI *s) { VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(s); + g_autofree char *path =3D object_get_canonical_path(OBJECT(VIRTIO_DEVI= CE(s))); =20 if (vs->conf.iothread_vq_mapping_list) { - g_autofree char *path =3D object_get_canonical_path( - OBJECT(VIRTIO_DEVICE(s))); - iothread_vq_mapping_cleanup(vs->conf.iothread_vq_mapping_list, pat= h); } =20 if (vs->conf.iothread) { - object_unref(OBJECT(vs->conf.iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(vs->conf.iothread, &io_holder); } =20 g_free(s->vq_aio_context); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434529; cv=none; d=zohomail.com; s=zohoarc; b=V80CTUmW8p6Q01NvrNImxbJQcTJ6xk+07eE6w2v3anOnR472aimLhgzHD+Add9mKk1vpgYK0uu/Z7jf5DdO/swzv9iJ0zu3/DSIGb0uhtisSRJZAIh/UEJqEwwlZUaF0Wa1W2IqTJa2cFFkSeRip72D5aPPnQvPdIAp5HFADhaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434529; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=DNRS4YavB7dL8cUjSkJLKOmlhs5usOl21VpjtombaZWMc7YijpJl4z+HCxYqFW5Ywh2T3Zn0BWjvQKLhyFOBsVVl8nleVy0zyskd6q/qKUVD/sHh+ZGEg5t15iAXlt+p2d+Gw+F4sFTrqYnVIPnn0bZ7VkOo4ZavYj6jg5idTkE= 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 1787434529632198.74050093943913; Sat, 22 Aug 2026 14:35:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMV-0003qk-5Y; Sat, 22 Aug 2026 17:34:47 -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 1wxtMP-0003jb-Gh for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:41 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMN-0000je-6L for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:40 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-84a2c90e383so2407728b3a.0 for ; Sat, 22 Aug 2026 14:34:37 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434477; x=1788039277; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=glU/gbJRKxHaruv+rFDFqLLPNO3rS7RM7rQoBT3LuuKEiem8+MU8aBRaXHkyEyaOvp YeY4RCkfU/sYnyPmWrdkt0ZXYZzrIpZedL0Ov3yx748abqZ0pqBgzRU59biDkTzSNsa8 GwzG9q5rHMsqNIprbcaual2ebNlUkaCzlxMH6EbX3rFXr2s6aAGBEPI52SoDakEzdILe ji1Mz+CRVJs09rnnt3TVLpNJLQ0Wwx3Rp3dunc8XDZCO25pSwuP9OqxZCJzf53H/uM+n Axr5b56ZbwQjKIaDidE7CzCciuhHEGUU+km+LdO/OYiSUlWHnEYKJZgkmQ8kCqJ8njKI tlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434477; x=1788039277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lKz22n5M1p9e+lq2eACw61LK9eCTpfpP/G3iYA7eH9E=; b=r1pYb/DTpKpGDf8Y7gXiUaeSc41gVWKfR+1BQoQ8WUCuLVNAIY08ZWi1ob04i87uwe 0aUN8lsdmuzF6/ODhIVoIS+pvLiSbneIiTEQUP+gCmL6upUOPCYZAcfN7AMYeMs1cLmJ 92o3xQQX1TSdNqJJ321rFWxf0m7ftAUu8zcaL2DxpBtFiC/Xl2POxDUz3UVURspsnGnL HYEj/c9xJViuPHpcZPcdYkM4jKWMhabo0zflY8y/qcNJvs9UEe7sBuXE0uXXsPVfzjqf 2+5Gwj04a743pcGkL7MA4P0QshIWTLmGYfik/7md4i58k8cjEtFu8UKwAM0ApRz7uOAv Y4gQ== X-Gm-Message-State: AFuF++ldVDJu42GAgFIftPHyfmG1TWq9qRqdMCR5/EMzJYDeNyGricU3 oslW4PoU35SLvqU7A2etqPxLv6z9Wz7Q8sApK/8kEwbyXt0Zbg3mZHJ4SIVMrWX5+gOAHcrw X-Gm-Gg: AR+sD107eVkOBYWdaOfrMgXl2TIdDq65k/FYYGaUOW5SM7FYjdDFp5h2uv3xMYk6gnt /RMc8S9g4xwB4Eizwaug/DJLTQUNhsSZopn91ZpccqCg7gQiQ2hvMn0jSDE4QgYgW0YeqiW89ZZ PT0+2cU+e68RFzZNjyOPuHx0YFhU2NsB7EDpzciNsVM7Kuh8c7S/kx0OjHJ7oRxXmxepqq4OLAy WDzuT2+IvaFXIN3QEwDJN0g9kBazumIMU8/UDJ8nL17+KApw2pcg31htUuQRURTkpjUms6cR1ww WzPTWlLsFF4EiTV5RHRCtqgbOlrGIrwvvIukYh0seD8WSKrJNh/mH13MJnIXK5W0tB9HWMt2mqw ZPO2F38L1vDfwiWE0Ommm/1eO6E7Xelkf/hJewuUQI8RlLjHtM9hnUxwr7q+b0cozFFrjMzMtI/ deyJc6x55PZAjmalEg4LIZTGTgXZeLkwzcf9Bcqx2z5mG7iNkwhAx34i7m4VErW2DWUHWJ3VTUE xQUkjnJNFqy1UlGhaY= X-Received: by 2002:a05:6a21:482:b0:3bf:9bd9:cf60 with SMTP id adf61e73a8af0-3cd14d30051mr27930190637.6.1787434476675; Sat, 22 Aug 2026 14:34:36 -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 V13 09/15] net/colo: track IOThread references using path-based holder Date: Sun, 23 Aug 2026 05:33:32 +0800 Message-ID: <20260822213343.661939-10-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::429; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x429.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: 1787434531657158500 Content-Type: text/plain; charset="utf-8" Convert colo-compare to use the iothread_ref_and_get_aio_context() and iothread_unref_and_put_aio_context() APIs. This ensures that IOThread references are tracked using the COLO object's canonical QOM path as the holder ID. This refactoring improves IOThread lifecycle traceability and aligns the code with modern QEMU iothread reference management patterns. Signed-off-by: Zhang Chen --- net/colo-compare.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 5986fb1e88..361ee32729 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -130,6 +130,7 @@ struct CompareState { GHashTable *connection_track_table; =20 IOThread *iothread; + AioContext *iothread_ctx; GMainContext *worker_context; QEMUTimer *packet_check_timer; =20 @@ -922,9 +923,7 @@ void colo_notify_compares_event(void *opaque, int event= , Error **errp) =20 static void colo_compare_timer_init(CompareState *s) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - - s->packet_check_timer =3D aio_timer_new(ctx, QEMU_CLOCK_HOST, + s->packet_check_timer =3D aio_timer_new(s->iothread_ctx, QEMU_CLOCK_HO= ST, SCALE_MS, check_old_packet_regular, s); timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) + @@ -964,8 +963,15 @@ static void colo_compare_handle_event(void *opaque) =20 static void colo_compare_iothread(CompareState *s) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - object_ref(OBJECT(s->iothread)); + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + AioContext *ctx =3D iothread_ref_and_get_aio_context(s->iothread, &io_= holder); + + s->iothread_ctx =3D ctx; s->worker_context =3D iothread_get_g_main_context(s->iothread); =20 qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read, @@ -1404,6 +1410,7 @@ static void colo_compare_finalize(Object *obj) { CompareState *s =3D COLO_COMPARE(obj); CompareState *tmp; + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); =20 qemu_mutex_lock(&colo_compare_mutex); QTAILQ_FOREACH(tmp, &net_compares, next) { @@ -1430,18 +1437,20 @@ static void colo_compare_finalize(Object *obj) g_clear_pointer(&s->event_bh, qemu_bh_delete); =20 if (s->iothread) { - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - - AIO_WAIT_WHILE(ctx, !s->out_sendco.done); + AIO_WAIT_WHILE(s->iothread_ctx, !s->out_sendco.done); if (s->notify_dev) { - AIO_WAIT_WHILE(ctx, !s->notify_sendco.done); + AIO_WAIT_WHILE(s->iothread_ctx, !s->notify_sendco.done); } =20 /* Release all unhandled packets after compare thread exited */ g_queue_foreach(&s->conn_list, colo_flush_packets, s); AIO_WAIT_WHILE(NULL, !s->out_sendco.done); =20 - object_unref(OBJECT(s->iothread)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + iothread_unref_and_put_aio_context(s->iothread, &io_holder); } =20 g_queue_clear(&s->conn_list); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434501; cv=none; d=zohomail.com; s=zohoarc; b=MJGH8yblmSRn6iI+jnRtayxd8TQrZCd1w2JzbwszK1ZzWSXLa9w9oO7YKAX7JWaTRZAYc96jOjXpBrthECsq58QQy205Jx7bWAtYVH5IwpbhwIqMV8YsdKkOB/QG1Z8FnwNGMk7HYEVHGyTS8RofUn0i3ZQSIlabsNmDER3fCtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434501; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=VYrj8COLfiQJChlvjXwu4n5zhPSstDUCVFexv69wBhDiDTxZVKdDh5gQ7n/OTuupd+V/9elm0fvE0ZHoXdE9V8HtpHnq8790zSBL9uT9dyGkzckO9WJ+wMZjhXaJun9KbVFPsNFagCZ5MNkn/VfbWnSR0gMcdR2keTgLotrYcVc= 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 1787434501098499.06510394832674; Sat, 22 Aug 2026 14:35:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMX-0003uk-Ex; Sat, 22 Aug 2026 17:34:49 -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 1wxtMQ-0003je-Mr for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:43 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMP-0000jz-9k for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:42 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-cc147d86bebso1833780a12.0 for ; Sat, 22 Aug 2026 14:34:40 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434480; x=1788039280; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=jKJbjLFsy+fFtlU5HoHR/KR9RVKipMqf5PjXS5z5FwogsC7Ek7iJAtLPL111n6+cis XGne4PNWnylxKOD49kl2I/vgbeppNgHQBe8ONhIfhPW6NKUsOKFRAt0sDn1EyfjUgrcp PDFw+DtHFvPk1FSb/lr2zNFycrLw19HIDpizZtm25VTjkH/KQs1g+pNo8R/Q1aLJpTCb fL+upj6Go+RLGXOa5wwiSEigRaKwPT8yz5FXQ7UtdHzS1gWiO96suBjfnmjHlWKzC8x3 3bduzMzvK4DOFeYxVd1XjQGGQGyIrrxkXlWGjYs5qpL36iZMjrF7kuw1t+Q/Rrjt6qQP EGGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434480; x=1788039280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=UR7W3Pe7W3BhlNp97UTwJZRPRNXtcAGA9dL8kQpcSkw=; b=BgvQHgYDkTcD89vyP4KfTwZTRE0Siufm/Lh6X5oMmY2Io+Zqd2WHzkvdZJF4DHV4Xk 9xR1KVb+a9kV0/ceX41Aa4M74Ea2tO+sAIGoluwds++ATU0TLg1zgxWXNGDU7ONlRdAS /R4xWaipQYT7FGmMnT2f+SfbAdSh9/65DqKdnoZuXhY9OTNhyKjPGhCR5WrnCq38vuBw wpoe2JlgXJRVh5yRS9CELztqhBpIIPz0ebO+YO7jPP0Y8q/glP91GCtIqHJaboKIye+M ZSP4shS7f01SUw4s7GYBowzp8LTR2b/ueXRlMj8utIF2+P3/Bc2LpRnKrNQX22KAXB5/ BKIQ== X-Gm-Message-State: AFuF++k5B4GxrqkIvfNfn3RhM++IvmuYrEhgNum/68KshgRK7Fg8qQP4 pSYNtMf3QMkMo0mYjHJuPEwVzFnJowpxvslmYyRihPwrLGt7VlH/rGW3qHdgis4x/xG1xJ+V X-Gm-Gg: AR+sD1350Q99OVrFloicnDy6EzLRV39EMQ6qL7CsYMhkFhrZ89ZPqomIDQaPdKE74xT EscUfiIO4XEegPPjPCBPiL/rP5Reaxb6lCau9PgH3n4v++Nelvg1Gbcn4wHYmWdqTHk1zslsHzB r0IXz/deJZ1wMhUmJ68wmuOPKPzhOjV4rFYl6jRedIIrwWf1khN//lr9v0Fa4Qpz4JTpdTf0GaH k9SnjEyJBwNaq7/ul7WklPXPWFDU0cp+RREypmfTeWgtqNq9CtOvigb+Gk3pPVX0mb7uuKejyBO JrghYJPrMxwfzFAKAWI14h4sN/03h/TPnSh7ZQACj+CmzkWc+LIqlUIuqpRvZNqdiwN47CjugN7 Og19cTkHKNsGk1YElS3lQmSnNB4D2blmFt8cezf08RgxpgZy8s/xY77AaqwOs+yhE3TTDrCbnGr 7JmFdAgOE8ODg52Bg/JbmLyUHoCR56y2UXW1KaHpcc6b5AUW49SMOka1HAh/Rf2tbnHHKiqS6H0 oqCFocT X-Received: by 2002:a05:6a20:a111:b0:3c8:e304:99d0 with SMTP id adf61e73a8af0-3cd14870281mr24821739637.0.1787434479996; Sat, 22 Aug 2026 14:34:39 -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 V13 10/15] virtio-balloon: Update tracking iothread users with holder Date: Sun, 23 Aug 2026 05:33:33 +0800 Message-ID: <20260822213343.661939-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::534; envelope-from=zhangckid@gmail.com; helo=mail-pg1-x534.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: 1787434501645158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/virtio/virtio-balloon.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 4c5f486ba2..7c9c8d2a41 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -892,14 +892,20 @@ static void virtio_balloon_device_realize(DeviceState= *dev, Error **errp) s->svq =3D virtio_add_queue(vdev, 128, virtio_balloon_receive_stats); =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_FREE_PAGE_HI= NT)) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + s->free_page_vq =3D virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE, virtio_balloon_handle_free_page= _vq); precopy_add_notifier(&s->free_page_hint_notify); =20 - object_ref(OBJECT(s->iothread)); - s->free_page_bh =3D aio_bh_new_guarded(iothread_get_aio_context(s-= >iothread), - virtio_ballloon_get_free_page= _hints, s, - &dev->mem_reentrancy_guard); + s->free_page_bh =3D aio_bh_new_guarded( + iothread_ref_and_get_aio_context(s->iothread, &io_ho= lder), + virtio_ballloon_get_free_page_hints, s, + &dev->mem_reentrancy_guard); } =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { @@ -919,9 +925,15 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev) =20 qemu_unregister_resettable(OBJECT(dev)); if (s->free_page_bh) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + qemu_bh_delete(s->free_page_bh); - object_unref(OBJECT(s->iothread)); virtio_balloon_free_page_stop(s); + iothread_unref_and_put_aio_context(s->iothread, &io_holder); precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434531; cv=none; d=zohomail.com; s=zohoarc; b=abvL8xdecD4NOBNA2CC4mkiAE1yKj7D0ntbR6trgOF7Yxf4niXeBfd4oZOnrjwBz3LRv43wKjL3AXJW9VvevkYjRC62pxIMVWMnGc4YvZqRvuBXTmqztFJzvAV1LIhwoMQMT49r8NIVXRbhPXBqtP4TA19jdEMvS51DLUT340fI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434531; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=n/CS8c3dUXwLFneHky7X0lmh4l1H3kEjg9VY5nIj+6R5wd0SBZf6S+xyFP+hd8miooa6ge2M4gSHFf7b3TgA4rnfboQMJa0PQQ4MKymXLCql7XpVZek90k1AFSYdnCrSMejH/i3s/Iaw+dkpRoy6InpoN7W7agvXLnzqEpq7iII= 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 1787434531669587.8770958816614; Sat, 22 Aug 2026 14:35:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMZ-0003xp-UC; Sat, 22 Aug 2026 17:34:51 -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 1wxtMV-0003rn-8A for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:47 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMS-0000lA-Uo for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:46 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2cc61541f8cso34952435ad.0 for ; Sat, 22 Aug 2026 14:34:44 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434483; x=1788039283; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=qmw6cKPnIGV+wAOirKt0Dw69EYq1I+tk0cyYPw/svYQcsiPukh2T91GnyVvu8+uwr+ muBMXTxCT87wPVKueK3SlQJ6uA6rVgGYUNYLb3EcPU6qRThA9fpxdI/IW9N4Hp6LfJsG 9VIOxErvX9W6z61IixZrrFDVsm56XYqiMT7gQyoB/IQOKecV+5L6ELM0Gq7cq72bU0du vPQGmKuO2mYy4lc/lTpuH6jJuZARXiLUJiGKzgh6JZkXumbbpr2rMrarJVf3UA4iV4Zt pDzYtJ5KJsPK/1cuf1opLdRX1Q0IGxXPbn6oslPxElY/ZNmkNnF/rL+vD26b6gaG/Otc v7gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434483; x=1788039283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qiABzT9brkBXTSb3Fx2nSHH2TcbG/h2o76wYEP9lGD4=; b=LNUUfXziXYGXiPBSBVh9gTWUye3dASPcPxV6+EsxPO1dyssK2pyXPcG06xlUJ3JdnR rK0Fqnlt5DTkkVt2Mmbj7+Pmo4ev+ARbpO35cY4bV8YOSXZyTzFwUD8eYFH6as1Oe6Ij O9waTA0F89/KHGKQwwvv5v5xVFCt98b4zrFYs54GYg77jDLmWYnvvmSlhJM0TcN2czw3 FM9vXsmCdp83lw6SPMV+fk7o4zkcK0Bhi3I0/yuVyLnLqUxEKPdFQFhPSxvYka5HP3AG LcUkyKMV/jsmb7YiBKokjpT4Rb7MSIl0V0ERJSD5VtrIei1JUMdixYZTxBCpdSQTHSoV 3IBQ== X-Gm-Message-State: AFuF++lqnoGcyEdtlCNiy+q2xMkaflvnFqYDjSgVaJn+Sf1TjXvqb6oB VjAka35O2Biqp85iWVvGnYtobodhcOKjYhTIhPxpwamz/OkO4ASVv/YBUmH3wwLk7bo1DrSt X-Gm-Gg: AR+sD132jGf6bETGCBJSvKb89+3YD09VrGSKpL+m+CUr4ryKcP2moAHFqLFC1jQ90Mm G/V4Dqm3i6zhIS12skV0miM6U8qnHdYD9M4C9N6RBfoJEh1UBOvDBC77XXC+RY3MO6T6guMLqvU sJNoZsEDtyJj8Qv94TJ0nLaZNLSjwChIpO7WVvk2rtPpaDR+TeoFuEdWhuHpNZH78zzRd1FLMHV PqtbRi0GdkWA55QdqvzmzIcOd6JvEnauAFISHlL5b7sYbI137tZsJOO8KSXoEasWomgtatGLw0f inSnTniO+N1uggaJLOzPsplccBl3rk0U70YdDVUzOix355voWFYlYD9+cebfD6jX4vw9XLOCaRi fJYP/+pVyfLPAQ/+7MpSGP9cjlLpmpgTJyOmf+rLdggNOpvaIeAzqYut1OVgXMtC7qmglLr9gk+ OwT+BaxbqSnRcvvnlvs8An8/bqnHLE7m2CKD1X4R8u/5rvlCxviIz4H9Thc1nX8UE+e1FJazc+v x1Ih/ei X-Received: by 2002:a17:902:ef47:b0:2d0:401c:2edc with SMTP id d9443c01a7336-2d61a032207mr289465385ad.1.1787434483380; Sat, 22 Aug 2026 14:34: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 V13 11/15] vfio-user/proxy: Update tracking iothread users with holder name Date: Sun, 23 Aug 2026 05:33:34 +0800 Message-ID: <20260822213343.661939-12-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::634; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x634.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: 1787434533555158500 Content-Type: text/plain; charset="utf-8" Add object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/vfio-user/proxy.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 197aee07bf..e642fb0ad3 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -898,6 +898,7 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *add= r, Error **errp) QIOChannelSocket *sioc; QIOChannel *ioc; char *sockname; + g_autofree char *path =3D NULL; =20 if (addr->type !=3D SOCKET_ADDRESS_TYPE_UNIX) { error_setg(errp, "vfio_user_connect - bad address family"); @@ -917,6 +918,11 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *ad= dr, Error **errp) proxy =3D g_malloc0(sizeof(VFIOUserProxy)); proxy->sockname =3D g_strdup_printf("unix:%s", sockname); proxy->ioc =3D ioc; + path =3D object_get_canonical_path(OBJECT(proxy->ioc)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; =20 /* init defaults */ proxy->max_xfer_size =3D VFIO_USER_DEF_MAX_XFER; @@ -936,7 +942,8 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *add= r, Error **errp) vfio_user_iothread =3D iothread_create("vfio-user", errp); } =20 - proxy->ctx =3D iothread_get_aio_context(vfio_user_iothread); + proxy->ctx =3D iothread_ref_and_get_aio_context(vfio_user_iothread, + &io_holder); proxy->req_bh =3D qemu_bh_new(vfio_user_request, proxy); =20 QTAILQ_INIT(&proxy->outgoing); @@ -967,6 +974,11 @@ void vfio_user_set_handler(VFIODevice *vbasedev, void vfio_user_disconnect(VFIOUserProxy *proxy) { VFIOUserMsg *r1, *r2; + g_autofree char *path =3D object_get_canonical_path(OBJECT(proxy->ioc)= ); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; =20 qemu_mutex_lock(&proxy->lock); =20 @@ -1021,6 +1033,8 @@ void vfio_user_disconnect(VFIOUserProxy *proxy) qemu_cond_destroy(&proxy->close_cv); qemu_mutex_destroy(&proxy->lock); =20 + iothread_unref_and_put_aio_context(vfio_user_iothread, &io_holder); + QLIST_REMOVE(proxy, next); if (QLIST_EMPTY(&vfio_user_sockets)) { iothread_destroy(vfio_user_iothread); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434518; cv=none; d=zohomail.com; s=zohoarc; b=fOooDzwjJ+UOxcbQh9Ulzh8y/IsJAuIg6F+S7t2NPoLvsGhcSSr/QOU1y9+HVA+kssw9f23sgx5o9sC0ZmlA4UPHB/uIw99naSufbpRL2XzlqvJc31BMvUzEaDhN2YoeaI5iwEzTP2OTyd4OVoA4RAJ/s8IvQTy8Lcuei0vK5N8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434518; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=J0h39NiOwRGCzIKrd4HSEeKEzsrkKJ008IU/h22+Mq6pi/REvJpUmsRloHnuti9a8HxXbFJkH23UVbhlQUdii5RlC5LJsz34xb09KVBMoijs1KXLkeDx4hNW31nwwsqHeoJqpOxlb326VhlmhydfyB0kpQwFenXs32gwqzw1kPk= 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 1787434518294829.5119681343846; Sat, 22 Aug 2026 14:35:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMa-0003yH-Rm; Sat, 22 Aug 2026 17:34: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 1wxtMX-0003wh-PC for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:49 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMW-0000lN-7e for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:49 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2cab973140bso29053075ad.3 for ; Sat, 22 Aug 2026 14:34:47 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434487; x=1788039287; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=a3kiPmOxgOLf/3M6lDmgM9xrnj8UNlKtM5LHyUjectUYOOhzA9f/XwQxu7Lim5RVwI DZhNgWQYM+SwCX6koWYtEuck7XxKNckCgQxn1vX1rXH6w7kHTjPz2udEH86ANDd58/oy 5WXFi+3ptA4l52Hn1J4DbpdhwZB4Qi602dQDN8jzd2uzbQTgxUqRO3NtLEL3ETl/wUtE 0cdA3quTn/XyjjHG9NAmugF0mHs5naIRkvXkMKmpyLliFxlbD0c1w6aX93VWXfwW6uFI aFml53Udq8ji0Oarcu+bfgP1oZMU51DleiGL7D86bQV0ttbcMvi4nQ8+da0jPJ35y9Uu i/eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434487; x=1788039287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YzyunjGqwnVL4+zZqn+0tH9PAMSOhSLwwJCF0/mtHPY=; b=iv//iKH5h3G2NFL2KuZLXuOUk8xWe12up/5omS/wG1+n1tAuyZ8s5JhVwih0Lv0ky0 Vj3dUZE/ibMk1PjZoY80D4x5Fd/pZcRtR7iuilVQRrfFtYe5fzLehCvD2o3VMS/AYCPs mNguRC5aLncVchkcpfC6IB4smlV1THeP4q4DJ6XNmJo2fYfi3JFJ8rsPoFs0nnnStdVa 2AasgzjlS7z2thW5mKoLlt3e4HL6XavGgNTGiA8Yd5DnJdD2+8m34ggzLO0fvXAHiq9/ mAuoSmmkMyQ1s8k8D8wdn4J8qY33/BRLPHB8cdJyVnVJmYBO8xczGCOCzsjU+CuQ+4Pi kMBw== X-Gm-Message-State: AFuF++mGLM7rZfZUUIcm+SCtBN8AxctwqN3ABKTgtOVq9mRT5yIAnR9J X5IbC9TOXdsicmtul09j9UdsnbxpQEGjIkZ2uoOqB8gxVyGH3M+nZeEEDnF9zThVJsNeTt4B X-Gm-Gg: AR+sD11EXXG3LB0Ytx0chfcjr/V0XRsNNvRL3FlNkLCDarJ57j/pKoXGvFB8R2YbXh4 cXGvD39R815fzI3FT6/x6GiaWDoie5C4Rx6HC6XeSfyxcMJeIpnvsJDj/BldenAUrWda7vwGae5 KUHW3bhXYybAbnUmX6Zdcy1nK797/bALyYwFM4omLTDDeevrTtxucUsSN+zKKq9AItMgCC5ptuJ 9BWw7nUp31ic9JYD70K7NUW5DP7z6WO4O60XnjIWuJeuU1FULbg2jDoR1sFLS2YtUXFz4ObZqCi FGBiJV3BfPzXenQuWV3PegF/aH1TYWCTUP/Up6IJ3b3JtIwfMbNsBpEvm02dVQu6aNXv0nW8F+I S6saEnpeS8zbng2WHgYwEYzf7sNGivoSWb2vORH7VGD/4ebO93MIJr7XQlbQ43GRtGUtak8N8uS KHxCEZ/cdQgqskDmYtFneTLRNmRsbbxqKFd9rVhLbCoyRegcXBVbn+Y8gvXF7SUicf6vJCAb8JZ I60w/59hWR3AqXoA9k= X-Received: by 2002:a17:903:1843:b0:2d6:3c22:993a with SMTP id d9443c01a7336-2d670b4c97fmr153787725ad.3.1787434486761; Sat, 22 Aug 2026 14:34:46 -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 V13 12/15] xen-block: Update tracking iothread users with holder name Date: Sun, 23 Aug 2026 05:33:35 +0800 Message-ID: <20260822213343.661939-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::632; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x632.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: 1787434519815158500 Content-Type: text/plain; charset="utf-8" Replace raw object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context. Signed-off-by: Zhang Chen --- hw/block/dataplane/xen-block.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 48c2e315f3..9dfe06e1be 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -621,9 +621,15 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevic= e *xendev, QLIST_INIT(&dataplane->freelist); =20 if (iothread) { + g_autofree char *path =3D object_get_canonical_path(OBJECT(xendev)= ); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + dataplane->iothread =3D iothread; - object_ref(OBJECT(dataplane->iothread)); - dataplane->ctx =3D iothread_get_aio_context(dataplane->iothread); + dataplane->ctx =3D iothread_ref_and_get_aio_context(dataplane->iot= hread, + &io_holder); } else { dataplane->ctx =3D qemu_get_aio_context(); } @@ -652,7 +658,14 @@ void xen_block_dataplane_destroy(XenBlockDataPlane *da= taplane) =20 qemu_bh_delete(dataplane->bh); if (dataplane->iothread) { - object_unref(OBJECT(dataplane->iothread)); + g_autofree char *path =3D object_get_canonical_path( + OBJECT(dataplane->xendev)); + const IOThreadHolder io_holder =3D { + .type =3D IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path =3D path, + }; + + iothread_unref_and_put_aio_context(dataplane->iothread, &io_holder= ); } =20 g_free(dataplane); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434571; cv=none; d=zohomail.com; s=zohoarc; b=VreaovxbjFPxCg7oQgp9sFjTPc1Gwk7tImuPrxUteWlFgCxKIJa1OhVxbTzDbnPrekyOEideFX+I2DNd2i4ZRHLdWPvMvzCYWhf/HczWbgt7Ogxn4TNmep/zERy3/f9+o+mAYzoWWUTmosnIj0aL7F7Ael2yL0XQGfUH27Ihnto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434571; 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=p88Xj8tRAR4HkpKYHo7ZuvFAB+eWTcwDzyO0qx9JXvI=; b=XWHOahHzAJrYG5inMLoc5U3ZbLLDgTMfU+yFRav036uzmT9eDBrO4NzuZ7bIoA+1psV6YQbK+0cDUyN8XG5WgGzvdz9crTiOZLpQ/navlLjNKwYVt7duB8JjXWi+7Emn066kFS2ipn7oPFuFAiMFpybx7DfvpDt2cVl25qtqiSI= 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 178743457104742.922805330416736; Sat, 22 Aug 2026 14:36:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMc-0003ya-IO; Sat, 22 Aug 2026 17:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wxtMb-0003yR-0o for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:53 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMZ-0000mB-Id for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:52 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-395ea741d07so404385a91.1 for ; Sat, 22 Aug 2026 14:34:51 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434490; x=1788039290; 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=p88Xj8tRAR4HkpKYHo7ZuvFAB+eWTcwDzyO0qx9JXvI=; b=RBJS6WzUfn9f40m59NweReP+SiHb4errSrobttSMDx8ugyNkfj0+0a7tEaEHH0h/i0 BJ0kLkN2JT32bTZ/iiEonI/zNxKkRL+9z9IcHfteZj5+PdKs6mmlWyrXQ9UM501lpmnu kA7ap/fvQP+gBlSqX9n3CEsdlCgOINe8vHLGAgYY1HJYf6Is1aAYRRgMJTsCuzAzAqk0 TrqGxM2Iv2ddBmaUq8QHLAqGj7XZ/gomPriJrJXrdXxiBh2lqHuAcQue0+u/yAWj7Szg 4CWAiO2RaqgItDDQsb9c4mms3XeIXYeZv/JEf7shiW9fzIfSvimgTNikGh3afxvn2cw9 LYnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434490; x=1788039290; 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=p88Xj8tRAR4HkpKYHo7ZuvFAB+eWTcwDzyO0qx9JXvI=; b=rIQzz0NjmTLLs2Cz0ggSQ+ZNFszmdPXMKtKpryeD+Cfzpwo7PXX0GN5Pp5qZrWbblb bfH9GpqQSZqIIqMBPYuOwbkf+pUcLbiA/CNKpJ2onIlYp38srVXhcMsokd6YjcSt8ZwN 66xInQptqUYxNtR+/RFR9Tb/88vEq/3YDU2UlfBMLNSpuSMkigB6GrQOHtM5JewK7R4N WlVez/iroy2TFZRo7usI7Qj+x8J1Bd6HOrrj9OJFslIM/0/F6/U0qOKg0WeF1y97muvm q/w7aIU1QW3lNkwka8BTQbOhindLNupFlHIoyJeuzx97x1GSNZpyknqN8tc/hlSlttPA UvNQ== X-Gm-Message-State: AFuF++kE/vz0G2NldHfxIPoLSYipzJXTxqESA88oUmyq52BBBVMPa+8y aU/gnKjeF/JfpydF/sN/cSAffiO1zADW2s6En5r/Py8kYkuqpd0i4V4dXNnLwc12so6FCnb9 X-Gm-Gg: AR+sD13igap4vyy9E2YViQidtvx0cHceWkLIRHcMPF3Or4e3KcFUR/GXoMH2Y9w46dK Q/Z3H2NY5n6FfFy95zjh1g44MDJHVM3lyls8GPjieTJBeHpwSDHsd/oBmaTsbDCequqjKefPBiT U5JAhpEST7aTnFO0nkwf5OjlqmB8C2YewfpAW88V8ZpzVgJ7bA3o2P6stO1DIO4M4h2Rm30KEoQ TscNHmFkyPdZngbbV0KPWZyuttfPnPzlbllUDT+NWCMGE6nnU86vTfaZRg/lZclgHoz18SnwSMd Rs8fGHBWftxCIdZ7xVJGscGP7w8xF144ZkZyIJSQyUsdNQcQ+ThqwfzDLc+jq7f3cqE1BVNGpHG dzhQsk7g5QqNDGcHwjNV7Hup+eQbV7B2zOj8/K9g1ufgMDL+rSwPcON7Gvuz/6vhSck3v/RvYrd BObSsCIZSMuN+OMqal+Mvuu9UBS2GNaJpn4V2EXP6auZooGqS4blR6Yw1ID8fgYSrrxL8vvJHFc umhEXPuv339O5Bxo3M= X-Received: by 2002:a17:90b:3bc6:b0:393:194d:5366 with SMTP id 98e67ed59e1d1-395c354da4fmr29061745a91.10.1787434490207; Sat, 22 Aug 2026 14:34: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 V13 13/15] monitor/hmp: display IOThread holders Date: Sun, 23 Aug 2026 05:33:36 +0800 Message-ID: <20260822213343.661939-14-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-1-zhangckid@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787434571736158500 Content-Type: text/plain; charset="utf-8" Display holder information in info iothreads to aid manual debugging. Signed-off-by: Zhang Chen Reviewed-by: Markus Armbruster --- monitor/hmp-cmds.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e9fb8d827a..87839a653f 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -240,11 +240,31 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qd= ict) IOThreadInfoList *info_list =3D qmp_query_iothreads(NULL); IOThreadInfoList *info; IOThreadInfo *value; + IOThreadHolderList *h; =20 for (info =3D info_list; info; info =3D info->next) { value =3D info->value; monitor_printf(mon, "%s:\n", value->id); monitor_printf(mon, " thread_id=3D%" PRId64 "\n", value->thread_i= d); + monitor_printf(mon, " holders=3D"); + for (h =3D value->holders; h; h =3D h->next) { + IOThreadHolder *holder =3D h->value; + + switch (holder->type) { + case IO_THREAD_HOLDER_KIND_BLOCK_EXPORT: + monitor_printf(mon, "[block-export: %s]", + holder->u.block_export.export_id); + break; + case IO_THREAD_HOLDER_KIND_QOM_OBJECT: + monitor_printf(mon, "[qom-path: %s]", + holder->u.qom_object.qom_path); + break; + default: + g_assert_not_reached(); + } + } + monitor_printf(mon, "\n"); + monitor_printf(mon, " poll-max-ns=3D%" PRId64 "\n", value->poll_m= ax_ns); monitor_printf(mon, " poll-grow=3D%" PRId64 "\n", value->poll_gro= w); monitor_printf(mon, " poll-shrink=3D%" PRId64 "\n", value->poll_s= hrink); --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434565; cv=none; d=zohomail.com; s=zohoarc; b=SyeLkqUJd+WtFtE94cJ4UcNv8tx3HsLeoOnW3JBoSyo8+zg2d0eGppK6C9wRWVM6Bu090WBrk3xMxERwkBeBKIxS7jW+Vc/067nH4jyb6PCBTsGtZLRgBPr/GN/dfdCNqYcS5a2llOJluf7cW9tQ3cvioqoZNfuKDKa5NPfE0p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434565; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=OhLjwiIfxZsamQzmSVlPClJB2YehDBevL3ucTrnVPJFEJwlAIvJQCyu1D0i5l1SokxSLf5/OmUKZBVs3AfYlzsgEIuKx1oOOHBSBzc5m7Z2q0OP+hsPme37ofM7RMpVBkS/T3fjxb729FJ+SaTbG8Logd38RBd3D/xhPKfqkmgg= 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 1787434565003574.3378227047021; Sat, 22 Aug 2026 14:36:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMg-0003zm-8A; Sat, 22 Aug 2026 17:34:58 -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 1wxtMe-0003zD-GI for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:56 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMc-0000mP-Uj for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:34:56 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-84867f07d63so2270079b3a.2 for ; Sat, 22 Aug 2026 14:34:54 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434493; x=1788039293; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=DPx+yxa5e3hbD8U4jtOsOs0P2QdklYJu8/VBabQDPdFRYdyOankGMRncZu/3QAW6K5 bv8/94a3t0Fp/CCQJzVtusH2T3ra7lMhgNi9baxaiV/VXFBvDG6n3PqzYGkM8vcsT6vK lf98MtiRr0INtn9mi9+i5M1X1KagfNhoKqcf4GFp7DQpaXqTTCjm6sJ5escw1yV9Qj1A xWe6S5Ksgnpq423FEMIK4vGmjt/fQqtGbZnlj74aTlj8CQDO0tQHkk3xDhvZWCS/n20r j0ziGG1iyZkqzzH0jGgr44N3dbrMFM8SOCE0oSxQQPPfOhbC9jXrhAfCjaOZpWfGKGTk hdTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434493; x=1788039293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=clK7NAadLjai2hYCbo19w/+DIioUQ3aPdbUwnfpG/gs=; b=hkO9RDWRv2mx0N7Ceo0VXrD0CK2hIOO3ZWjh4C1KM2Stdd7TCxdZKoZEJ2vHPDJqnt 1/lef6ABFozXtKII3KSKsTmmeFOi3YpEbNL2mA95QMOo/m5zGJ0NxVXC5PpVTsGoEUY1 j6scJZ9MqsFfYOgq7N6sxdyYFxJ+iEoO3j2eZO+9cKUt5f4MI7SsC1SezahaOjrnMC0B d897Z1J1k8l+vRgf23sULvAU+SZsgEOFXOLydd2vjgaLaiEYcHwOa+kA957f/A/bMerQ nEQJF3Xyz8prPsq+Lor1lVheATTrHZj9PYCpGpWKoH9qsHVUkPNeFPeooemuQBdoWAkz RggA== X-Gm-Message-State: AFuF++mN+jDrTvh89CwRnGDcu+eD00nmaXtu/u2GlGHY9djxtJHq7b2Z JmVFN63I3T/WN5BkUXy3wg8Ms3vsdSlkBtxnXToiL1y+gOP5j3xgQ1htJJ3hUdZUhbXX0G8a X-Gm-Gg: AR+sD13qulDG694ugxVLcjMxaMuk8yOeuf6LjMu7gP02d3cP0toAb2jD/6szRDr+i9q fFoSJsFDB+okvDZv9WbMrQQJlwfjzD0NP+0VK98CnMKk/Ao8VmRS9u7GStJnDHkkYEPgXkbEEQs YNJcvx9ZvpV+fW2ic5o8N7dBAk+etAgsLS/nnEvgmuByW12IRPSe2rlQ3NmAAMLTXs1dZmFIcUb LVQtH6WRU6tiUv2ArvY2LGbh/AFzAtPHAkODL2OViWgoc95hzEvhw4mVLtLG2vBjd0qSwR7C1Ut RIoQISmWQICiMZiIYbl36r4xA2AygXYk26MpAxIceXfCGPHbHwiMFdYAPaZcmOJA205F+XU9Qmi +D9vY4TK4j6U11hNLV2ZXRF4YUqW7e5YemGapv9ne899fnmuc4ryBTJHT9B1cMUtaBVwXTFrXuh SmlAQM6ClV6Q4m4ZEIPTCDbyQyOemrdoJpcGKiwrmSauMT8klg+H8M2iaeKEz2+0jERxlU+ewru O7MTQbZ X-Received: by 2002:a05:6a20:d48c:b0:3cc:9162:6bfe with SMTP id adf61e73a8af0-3cd4b68476bmr15769871637.0.1787434493540; Sat, 22 Aug 2026 14:34:53 -0700 (PDT) From: Zhang Chen To: qemu-devel , Eric Blake , Markus Armbruster , "'Michael S . Tsirkin'" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?=27Daniel=20P=20=2E=20Berrang=C3=A9=27?= , Jason Wang Cc: Zhang Chen Subject: [PATCH V13 14/15] iothread: remove legacy iothread_get_aio_context() Date: Sun, 23 Aug 2026 05:33:37 +0800 Message-ID: <20260822213343.661939-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::42e; envelope-from=zhangckid@gmail.com; helo=mail-pf1-x42e.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: 1787434565839158500 Content-Type: text/plain; charset="utf-8" All production callers have migrated to either the holder-tracking iothread_ref_and_get_aio_context() API or the explicitly unsafe legacy accessor. Remove the now-unused ambiguous getter. Signed-off-by: Zhang Chen --- include/system/iothread.h | 1 - iothread.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/include/system/iothread.h b/include/system/iothread.h index 2ef8c1a1bb..9850cdb3dc 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -66,7 +66,6 @@ DECLARE_INSTANCE_CHECKER(IOThread, IOTHREAD, =20 char *iothread_get_id(IOThread *iothread); IOThread *iothread_by_id(const char *id); -AioContext *iothread_get_aio_context(IOThread *iothread); =20 /* * Return @iothread's AioContext without registering a holder or taking a diff --git a/iothread.c b/iothread.c index 803d6ce3c3..3a092119ee 100644 --- a/iothread.c +++ b/iothread.c @@ -422,11 +422,6 @@ char *iothread_get_id(IOThread *iothread) return g_strdup(object_get_canonical_path_component(OBJECT(iothread))); } =20 -AioContext *iothread_get_aio_context(IOThread *iothread) -{ - return iothread->ctx; -} - AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, const IOThreadHolder *holder) { --=20 2.55.0 From nobody Mon Sep 28 00:01:14 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=1787434533; cv=none; d=zohomail.com; s=zohoarc; b=dYgff4w17PzWHmxkD7VDaMkXszQYr8xZYR9YdE9AVJHsJvbZ/6amKMt1+wVoHRqj4VCDUg8KfnTYCSWXiZ+KJCklNXWSx09s3VZBL4ZBIq44vb4Bb1tpkGPpdTW6WPrJox1LO4/y/cxJRhHHJZaVvRsHpxxSDxwbESRVxdviqog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787434533; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=as9uChAi+ORKmeGwPnrIrZ/rlGL2FmRUTztwZE7NBOVMMBo2hCD8g5clizow98hUwRgWO2zFKszWEK2fV1/WdY7DUozOPX7p6SScgevuyEE/KewT9nM3NhAsRB04KokQglWpl5NBkz8VnIgf2faA6584UsLVcN+JRq1Ppawb3jM= 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 1787434533178343.86160492537886; Sat, 22 Aug 2026 14:35:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxtMj-00043g-Cn; Sat, 22 Aug 2026 17:35:01 -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 1wxtMi-00042y-IU for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:35:00 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxtMg-0000ma-Il for qemu-devel@nongnu.org; Sat, 22 Aug 2026 17:35:00 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2cc7e86e7aeso29592205ad.2 for ; Sat, 22 Aug 2026 14:34:58 -0700 (PDT) Received: from catgo-fnos.taila0cd24.ts.net ([104.28.201.73]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f909c6c9sm11633181eec.6.2026.08.22.14.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 14:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787434497; x=1788039297; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=s2bh41guehRgTkJCSaGoUHLHTomORSP8r0/gyQCzdCcm84zHjRK3PWrmNng9TuV3dg JK1rNG4IyrltVn43rNDCbZ5vWfvHsyn2O+9uN/qiXPOI5HasfcOEft9Zv5NY6xIBa7kk RSy6cAemZ4lDqmLF3tp0V4nSA47KvPHbUGtj13FNnHYy6x6qmlWYW/25/TxxYmCbz2Eh MTT3hSHQE5kygHX8EOUSm/VgwKmeaKD/MtEM6h9NCav2Vim5sGNm+1x5cqgH2tVAELGO OPts6tW0IFYczviL1514rGp4uHm+TTwbvtFJeRxVl+klkeeLg43ihA4bN2toOS9t7e7+ oczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787434497; x=1788039297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iiKC3bRLwWYp06/joq+pyoTs6m2P49xoeita0l+E+4c=; b=A2UnK6kLgSvjfvurb6iQTdUxXpMbwlmsiK9tMLKMNMANPnMY+e5aXO7WaZwhAMGQHw TYQMNnXgSH2MR5amiBPzcTPFjB/Q1tf20aHu4mL26IyCaFrprgp+fGs4OIqDgoIEb26l LZ9wWjj2YjMYyRyHb8/toSNpcHJGuBepz2qQD4sf6DbL8OQNyvf04dRW2cIaKT3zb586 1MR+ewy+dO4ekXO3qhOFVOsati3a6XUATXv1UEjP3t3XLO0Ptg3JSQrWVjedZSfDKWqW N8sXp/JLFsUX8GNYdgrpydSeAYLBscYiUxhMhEMVlSnAOgmfvAwNnuBh54Pk1COnGg0A ax8g== X-Gm-Message-State: AFuF++n6kB9R/xnUPs3p0Vi4Lpf8gia6RdmEHKNuKn1hepuJzDnF2DOj mGWIoJXceB3GBxnDoSK5qXcaSZy/FH8AgeOE9gW5VlvxzrstLl3erBL6AcC9FnW6pUnm2wAF X-Gm-Gg: AR+sD12Am1rufoGGPp5b3Utdlo+f0Qd2QyS9RB+4EvW44jTT+Br86kKDbZs4kPW4WzS G1sjwnRo7SOCnuKuG2QrG82IhhwrO2K+UGXtSMHqDZ/+04sDr83YdJATqs3GYYCTRxVr+vdxfdP wl1nGkIPWQYjuNsLuftLXuJq/IBT6naKjqcjhWgzyED1MHC1G9EvqXrjn7cmYA3v4hGmulYdUou n5zT3YyX/1W2BO9/u5r7RSTsOZqNo2RJJoneCJUebqrDQ4r43CEY0bM+JizFiVzDuKq5whjj/Q1 Fivg72hCxiOO9K+4ZTCMf2EhE3QrZYwTPGWf+O8uHzTp/5SRHZtEX7lfTxIxmCpRqfVw2j7RaJL xnYW7ZIzJdtHjbIYjtS6Vh3EfpcnmxcDh1axAendPuHi0tzXIi678Mrz8bIqh47JyIJ4wiU838G 5Ymor2+l0B+H22q67ue6gAhNsaK57RmxI62G5GTiQoxKVDKGauYLRJmmQykjCYJjGy+xzFdFGpI fmdokSX X-Received: by 2002:a17:902:f68d:b0:2ca:660:b1d with SMTP id d9443c01a7336-2d64b025d01mr266665905ad.11.1787434497007; Sat, 22 Aug 2026 14:34: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 V13 15/15] tests/unit/iothread: update AioContext ref/put helpers Date: Sun, 23 Aug 2026 05:33:38 +0800 Message-ID: <20260822213343.661939-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260822213343.661939-1-zhangckid@gmail.com> References: <20260822213343.661939-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::632; envelope-from=zhangckid@gmail.com; helo=mail-pl1-x632.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: 1787434535626158500 Content-Type: text/plain; charset="utf-8" Update the unit-test IOThread stubs and callers to use iothread_ref_and_get_aio_context() together with the matching iothread_unref_and_put_aio_context(). Signed-off-by: Zhang Chen --- tests/unit/iothread.c | 18 ++++++++++++------ tests/unit/iothread.h | 7 ++++++- tests/unit/test-aio-multithread.c | 5 ++++- tests/unit/test-bdrv-drain.c | 18 +++++++++++++----- tests/unit/test-block-iothread.c | 21 ++++++++++++++------- 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/tests/unit/iothread.c b/tests/unit/iothread.c index a363bf8f70..790cd2dce7 100644 --- a/tests/unit/iothread.c +++ b/tests/unit/iothread.c @@ -30,12 +30,23 @@ struct IOThread { bool stopping; }; =20 +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + IOThreadHolder *holder) +{ + return iothread->ctx; +} + +void iothread_unref_and_put_aio_context(IOThread *iothread, + IOThreadHolder *holder) +{ +} + static void iothread_init_gcontext(IOThread *iothread) { GSource *source; =20 iothread->worker_context =3D g_main_context_new(); - source =3D aio_get_g_source(iothread_get_aio_context(iothread)); + source =3D aio_get_g_source(iothread->ctx); g_source_attach(source, iothread->worker_context); g_source_unref(source); iothread->main_loop =3D g_main_loop_new(iothread->worker_context, TRUE= ); @@ -113,8 +124,3 @@ IOThread *iothread_new(void) qemu_mutex_unlock(&iothread->init_done_lock); return iothread; } - -AioContext *iothread_get_aio_context(IOThread *iothread) -{ - return iothread->ctx; -} diff --git a/tests/unit/iothread.h b/tests/unit/iothread.h index eb4d0c77f8..9bdac074c0 100644 --- a/tests/unit/iothread.h +++ b/tests/unit/iothread.h @@ -17,9 +17,14 @@ #include "qemu/thread.h" =20 typedef struct IOThread IOThread; +typedef struct IOThreadHolder IOThreadHolder; + +AioContext *iothread_ref_and_get_aio_context(IOThread *iothread, + IOThreadHolder *holder); +void iothread_unref_and_put_aio_context(IOThread *iothread, + IOThreadHolder *holder); =20 IOThread *iothread_new(void); void iothread_join(IOThread *iothread); -AioContext *iothread_get_aio_context(IOThread *iothread); =20 #endif diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multit= hread.c index 9179cdc6a3..66ba5a466b 100644 --- a/tests/unit/test-aio-multithread.c +++ b/tests/unit/test-aio-multithread.c @@ -69,7 +69,7 @@ static void create_aio_contexts(void) =20 for (i =3D 0; i < NUM_CONTEXTS; i++) { threads[i] =3D iothread_new(); - ctx[i] =3D iothread_get_aio_context(threads[i]); + ctx[i] =3D iothread_ref_and_get_aio_context(threads[i], NULL); } =20 qemu_event_init(&done_event, false); @@ -87,6 +87,9 @@ static void join_aio_contexts(void) for (i =3D 0; i < NUM_CONTEXTS; i++) { aio_context_ref(ctx[i]); } + for (i =3D 0; i < NUM_CONTEXTS; i++) { + iothread_unref_and_put_aio_context(threads[i], NULL); + } for (i =3D 0; i < NUM_CONTEXTS; i++) { iothread_join(threads[i]); } diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 43b0ba8648..05c31ffca8 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -537,8 +537,8 @@ static void test_iothread_common(enum drain_type drain_= type, int drain_thread) =20 IOThread *a =3D iothread_new(); IOThread *b =3D iothread_new(); - AioContext *ctx_a =3D iothread_get_aio_context(a); - AioContext *ctx_b =3D iothread_get_aio_context(b); + AioContext *ctx_a =3D iothread_ref_and_get_aio_context(a, NULL); + AioContext *ctx_b =3D iothread_ref_and_get_aio_context(b, NULL); =20 QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 @@ -612,6 +612,8 @@ static void test_iothread_common(enum drain_type drain_= type, int drain_thread) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(a, NULL); + iothread_unref_and_put_aio_context(b, NULL); =20 out: iothread_join(a); @@ -762,7 +764,7 @@ static void test_blockjob_common_drain_node(enum drain_= type drain_type, AioContext *ctx; =20 iothread =3D iothread_new(); - ctx =3D iothread_get_aio_context(iothread); + ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); blk_set_aio_context(blk_src, ctx, &error_abort); } =20 @@ -892,6 +894,10 @@ static void test_blockjob_common_drain_node(enum drain= _type drain_type, bdrv_unref(src_overlay); bdrv_unref(target); =20 + if (use_iothread) { + iothread_unref_and_put_aio_context(iothread, NULL); + } + if (iothread) { iothread_join(iothread); } @@ -1398,8 +1404,8 @@ static void test_set_aio_context(void) BlockDriverState *bs; IOThread *a =3D iothread_new(); IOThread *b =3D iothread_new(); - AioContext *ctx_a =3D iothread_get_aio_context(a); - AioContext *ctx_b =3D iothread_get_aio_context(b); + AioContext *ctx_a =3D iothread_ref_and_get_aio_context(a, NULL); + AioContext *ctx_b =3D iothread_ref_and_get_aio_context(b, NULL); =20 bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, &error_abort); @@ -1410,6 +1416,8 @@ static void test_set_aio_context(void) bdrv_try_change_aio_context(bs, qemu_get_aio_context(), NULL, &error_a= bort); =20 bdrv_unref(bs); + iothread_unref_and_put_aio_context(a, NULL); + iothread_unref_and_put_aio_context(b, NULL); iothread_join(a); iothread_join(b); } diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 5273ff235a..fc9735d056 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -466,7 +466,7 @@ static void test_sync_op(const void *opaque) { const SyncOpTest *t =3D opaque; IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; BdrvChild *c; @@ -493,6 +493,7 @@ static void test_sync_op(const void *opaque) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 typedef struct TestBlockJob { @@ -549,7 +550,7 @@ BlockJobDriver test_job_driver =3D { static void test_attach_blockjob(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; TestBlockJob *tjob; @@ -595,6 +596,7 @@ static void test_attach_blockjob(void) =20 bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 /* @@ -612,7 +614,7 @@ static void test_attach_blockjob(void) static void test_propagate_basic(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_verify; @@ -658,6 +660,7 @@ static void test_propagate_basic(void) bdrv_unref(bs_b); bdrv_unref(bs_a); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 /* @@ -676,7 +679,7 @@ static void test_propagate_basic(void) static void test_propagate_diamond(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx; BlockBackend *blk; BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify; @@ -736,12 +739,13 @@ static void test_propagate_diamond(void) bdrv_unref(bs_c); bdrv_unref(bs_b); bdrv_unref(bs_a); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_propagate_mirror(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx =3D qemu_get_aio_context(); BlockDriverState *src, *target, *filter; BlockBackend *blk; @@ -807,12 +811,13 @@ static void test_propagate_mirror(void) blk_unref(blk); bdrv_unref(src); bdrv_unref(target); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_attach_second_node(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); AioContext *main_ctx =3D qemu_get_aio_context(); BlockBackend *blk; BlockDriverState *bs, *filter; @@ -840,12 +845,13 @@ static void test_attach_second_node(void) bdrv_unref(filter); bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 static void test_attach_preserve_blk_ctx(void) { IOThread *iothread =3D iothread_new(); - AioContext *ctx =3D iothread_get_aio_context(iothread); + AioContext *ctx =3D iothread_ref_and_get_aio_context(iothread, NULL); BlockBackend *blk; BlockDriverState *bs; =20 @@ -871,6 +877,7 @@ static void test_attach_preserve_blk_ctx(void) blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); bdrv_unref(bs); blk_unref(blk); + iothread_unref_and_put_aio_context(iothread, NULL); } =20 int main(int argc, char **argv) --=20 2.55.0