From nobody Sat Apr 11 18:38:38 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=1775833614; cv=none; d=zohomail.com; s=zohoarc; b=iAcwtTpAq8sadfHB1j16WGHg6RkKojePbTq8LZdkYwm1yYFy+5sOdIbqOSd3LJyOEtbyK/xzrqKEVRz7tSe3rIFcJkhPQsHIQ+bFiKm3NLA57ef/7D6hRSiSO1p936zK0isNdRhBPxnJCxjdDM/y6gEW2DppsgdBCmb/pQ5ivSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775833614; 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=a1Kh3XSHSeM1ZEixAaGnsOegNSycBCR3GL6VS/B2SVg=; b=mv1rstVZA+lKRyr4IReo2xgMuqeZY49DAlMOoRS3Ej6v0B//mLU23uDOp96iANol71yvuOlExWZwfaM7ocTDmCuNx7VjxQKgbBVDnNn/LuhL20B3jtI1GNPrxNWBCiNZAHmTa8Q4MxERXwd1Lzq//l5PvxScKPUwCKb7AdfUYl8= 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 lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775833614946543.1835136021532; Fri, 10 Apr 2026 08:06:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wBDQZ-0007AA-QH; Fri, 10 Apr 2026 11:05: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 1wBDQY-00079j-Ey for qemu-devel@nongnu.org; Fri, 10 Apr 2026 11:05:46 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wBDQX-0002Y1-0s for qemu-devel@nongnu.org; Fri, 10 Apr 2026 11:05:46 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-35c238f1063so1608781a91.1 for ; Fri, 10 Apr 2026 08:05:44 -0700 (PDT) Received: from ZBMac-LWN10QXKQ0.taila0cd24.ts.net ([104.168.88.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35e4131cfacsm3565785a91.10.2026.04.10.08.05.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Apr 2026 08:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775833543; x=1776438343; 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; bh=a1Kh3XSHSeM1ZEixAaGnsOegNSycBCR3GL6VS/B2SVg=; b=DdL5ohiIU1IvTFomJgwbItORplh48Q4AGjuD0lDDPFPfI6BKwKIrC6vpArhMldJVrW EaoMqpOipG81p1c80M7kQT1xaqYV1dt71xn7RoXCRcFawQWKEtBAvct0VQ8HVDh7T7bA jsWnid5zVx+XMF2JTcGgFT+NL+SB5MF4OWRDa6vi09ecKuoyG39c3Dhm+EEZ0xd2XzMz LundSR+si0PCy5w3N2psXo1rfhETKY7XjwK6u68eYy/I/TXuY7rtZOh4iHgBYg6nFyro 3bdIOCN94WtILAiOsNDliQ7nbwcctYu7nZORxpbfp0wr+a2vlDFJW5i0js0c4aXD7gR1 U/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775833543; x=1776438343; 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; bh=a1Kh3XSHSeM1ZEixAaGnsOegNSycBCR3GL6VS/B2SVg=; b=gyGMtQj4CJyEutV8lECrUDE4lUWhFMcfw/ocsomrAyIMwxakieokugdEwb7h5BHJrM vrpl05RbRtJV7CzLIrD9P/EkG+9CxwTGrPiPBFgdousVG7UYaHVRJ/bQbmsbhbYOqmEo QRkzFawel7d1sJqgh/sZlv1EYrc5HjvmPnbgUcmM/fCYBeW77ppBfN7YcM1cEXGse14Q Jfdlf6tW6uxlgSOuTn7l5Yn7UHIZxdjZ7ET1uLfiEivS84cYa4fRyu57mWvuqVPJDdNm I+pdkmuZ+RfcwVy1E3/q5QxnoTppzugAuSb5bkTYS6SH3XOCp48MhowNQWzrs3LWa9SW iIZw== X-Gm-Message-State: AOJu0YyE7q+iFt8idBZXEaHgJFINm7llExH4vN8V29Dcd7zQjr1/PqJL S/rIjpLvfO65X6BxNBFv0oZPHjuXmjH66WZNM92eRxtKI/iLdUUrv43hF9U4QMMz X-Gm-Gg: AeBDieuvx6kV1s8+AXo/h634XJXzMXs2eY1K01tKm6dGFN5Glx6MsFwvz4Ykjh0Xn4z fkzq5n31cfYRJFnV4ZGoAlYbkiO3yzU6e3cUfFjD/htC66zZnosjMQOKUkR2j71Nyi77hXkKqyM qDb4A7R478TTuhwFllMwAkNz9Wxlg8eoQWaVE8tRmi/uCRUKUo2lThD/Sq6xDL79j6J+SXA9JID zkR9UQoqCpWVn94ETeV4UEtVT/ZDWEQCn5kNC9LXWm79WuEzT8l6gfEcNElFMzoQpPKMH1rPbkT 7Pt0uCFZPHIM574/26UP/sHT5QL2ZQE69dXdsZm/lK7SGD7Samfl8wi5WxoPXplFlWUjhxfWFvj p+PEUymPAZ2CUAgeZn5GM0SWATcO2+Ylg9H5zVQpLoq3lPrZWvdGFNXy5MwpnDRt30bCfpaZilu w4abo6424l88GyfPFjiVGLzrhay0cNRDsWXzEKRiV3nh2AlGliTY10 X-Received: by 2002:a17:90b:2e8c:b0:35b:a7be:ae47 with SMTP id 98e67ed59e1d1-35e428321d5mr3767159a91.21.1775833543121; Fri, 10 Apr 2026 08:05:43 -0700 (PDT) From: Zhang Chen To: qemu-devel , "Dr . David Alan Gilbert" , Eric Blake , Markus Armbruster , "Michael S . Tsirkin" , Stefan Hajnoczi Cc: Zhang Chen Subject: [PATCH V6 09/14] net/colo: track IOThread references using path-based holder Date: Fri, 10 Apr 2026 23:04:52 +0800 Message-ID: <20260410150457.85190-10-zhangckid@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260410150457.85190-1-zhangckid@gmail.com> References: <20260410150457.85190-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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=zhangckid@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: 1775833615589158500 Content-Type: text/plain; charset="utf-8" Convert colo-compare to use the iothread_ref_and_get_aio_context() and iothread_put_aio_context() APIs. This ensures that IOThread references are tracked using the COLO object's canonical QOM path as the holder ID. This refactoring improves IOThread lifecycle traceability and aligns the code with modern QEMU iothread reference management patterns. Signed-off-by: Zhang Chen --- net/colo-compare.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index c356419d6a..f3231257d2 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 @@ -926,9 +927,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) + @@ -968,8 +967,10 @@ 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)); + AioContext *ctx =3D iothread_ref_and_get_aio_context(s->iothread, path= ); + + 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, @@ -1408,6 +1409,7 @@ static void colo_compare_finalize(Object *obj) { CompareState *s =3D COLO_COMPARE(obj); CompareState *tmp =3D NULL; + g_autofree char *path =3D object_get_canonical_path(OBJECT(s)); =20 qemu_mutex_lock(&colo_compare_mutex); QTAILQ_FOREACH(tmp, &net_compares, next) { @@ -1434,11 +1436,11 @@ static void colo_compare_finalize(Object *obj) =20 qemu_bh_delete(s->event_bh); =20 - 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); } + iothread_put_aio_context(s->iothread, path); =20 /* Release all unhandled packets after compare thead exited */ g_queue_foreach(&s->conn_list, colo_flush_packets, s); --=20 2.49.0