{"id":2222003,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2222003/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260410150457.85190-5-zhangckid@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260410150457.85190-5-zhangckid@gmail.com>","date":"2026-04-10T15:04:47","name":"[V6,04/14] blockdev: Update tracking iothread users with holder name","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"31efd602e1783a2168d30b8be7c3e8bee4002e05","submitter":{"id":72278,"url":"http://patchwork.ozlabs.org/api/1.1/people/72278/?format=json","name":"Zhang Chen","email":"zhangckid@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260410150457.85190-5-zhangckid@gmail.com/mbox/","series":[{"id":499477,"url":"http://patchwork.ozlabs.org/api/1.1/series/499477/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499477","date":"2026-04-10T15:04:43","name":"iothread: Support tracking and querying IOThread holders","version":6,"mbox":"http://patchwork.ozlabs.org/series/499477/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222003/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222003/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=VD2kRAQi;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsgBW2qcTz1yGS\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 01:06:59 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wBDQH-0006jM-KF; Fri, 10 Apr 2026 11:05:29 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zhangckid@gmail.com>)\n id 1wBDQG-0006g4-H3\n for qemu-devel@nongnu.org; Fri, 10 Apr 2026 11:05:28 -0400","from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <zhangckid@gmail.com>)\n id 1wBDQE-0002IH-VG\n for qemu-devel@nongnu.org; Fri, 10 Apr 2026 11:05:28 -0400","by mail-pj1-x102f.google.com with SMTP id\n 98e67ed59e1d1-35d9f68d011so1484103a91.2\n for <qemu-devel@nongnu.org>; Fri, 10 Apr 2026 08:05:25 -0700 (PDT)","from ZBMac-LWN10QXKQ0.taila0cd24.ts.net ([104.168.88.121])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-35e4131cfacsm3565785a91.10.2026.04.10.08.05.20\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Fri, 10 Apr 2026 08:05:22 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775833524; x=1776438324; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=4l9Xr1hbjH1tyACtoEoX12/kjkgfEPIxAbMNxctooNw=;\n b=VD2kRAQicJ2apLSjS3dc9r1RBstwYrOwfswsNIpcjB/n10qQ1JuR76/cU74XEGCDu7\n V8DwxA0sIMBKlv7j9r2q9eSDWwix2lJ3y1RX0qYkx+prWYVTzpO2ofzpOJNPzRELnQMD\n iN2rLZtyr1xy4a9cTunTSoX8ilOvn99rXt7WKgBZvD6jX3tTGHR2riLxMIvB3rpImAVl\n o5/4n6f1gSUn28DamlzgIlXIM5y+l5UMREY1DlrnXRUY+KKw+04XHmSGr9Isc/bpy3/q\n X32NeN2dt+vnhzg9uL8tZ2CoXsNjAz0ugHAZHeyrPb1ipRUe65rdjRYBm9Y0iwxxT19N\n XygQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775833524; x=1776438324;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=4l9Xr1hbjH1tyACtoEoX12/kjkgfEPIxAbMNxctooNw=;\n b=m/ipLvNEXyYgPMlBwS74ns9SeFiVLt893Ydv9Of80FW4cYQqbaZNBKS4TKGRdX3qXh\n AI2b82SnUkkKUgZF5NEFlAmnOCP+DkYHsQXhvLN+9FFeA+4Ep5rm2xvOkvz0+Q5EVJCc\n y8/NCkDqp/5VnQNKYAvwCzbSShnpwSsx4TevkXS/+PE7wUG4pCeKzYtJqDY9SJNYwqLc\n +DXtpvoOJkAsoFRh8ntS5fo+C5nh3KEW4JKXm+9CcxPHoKeujeip056nvD1xb3drhhJc\n c7P0SLAvcP7InJYma97V9ycmAApD7gR/VJHeuKxS3Vxmsrjfh484L/uY+rAdi7yrvOtv\n 4vrA==","X-Gm-Message-State":"AOJu0YzPtMZ2U9YQ4I4WyuQ0KasAKDKZLxCnLBn7/u8H1414cuHeX4la\n ikpTUBRXqdippLKx9VYwxzu+gVSK4kD55rPjXm0B6OQ0ZAbSbhROzrZHaZs6WEaj","X-Gm-Gg":"AeBDievRSwkb8Qmky+IU7b4kkHL9dT61vK9oTIJlNDOMnW1h9dxRWWIMYqjk7VuPbj5\n 07U7SnpYVPsoe9pEtpglIlC/hsBd9Ge8mXh+3ZsUieNK5PBxOHWDrXWJmlWpgoneeIjcA5H3PtH\n Uv6kjzFlU/4Ow5/AMGQ3JOjLeowtq/gJtnzDIvWoL+NId6GTRupDPe87a+2/0whJnPr05LtvOUJ\n 4hBGBFugR3pdRsCa9TgjiqFIKFSqnOYM8R6+mv6d9wht/4XgiG004MiupUYDipkGDUThjUm0A81\n ZRwwTFMoa9D+EjzsBp8ZizFn8m/jdtmBMnfNnNsoofMiqaBhk4vhcLnn+Leq6tSBNqB79c+xLIX\n XtgWlwFuX2ODUK18Tp4CBnaH1UNl1P7W0aUVyZHLCApydQupg8l1akTisbjC/nIhzqArQEX90wk\n 38o8j2kFgmx4tpS/7TiuRKSlOKZpfhrt3R6Zz5GkfVPZ9t8rpLpGWU","X-Received":"by 2002:a17:90b:4d83:b0:359:8a78:569c with SMTP id\n 98e67ed59e1d1-35e42827fd2mr3755164a91.25.1775833523456;\n Fri, 10 Apr 2026 08:05:23 -0700 (PDT)","From":"Zhang Chen <zhangckid@gmail.com>","To":"qemu-devel <qemu-devel@nongnu.org>,\n \"Dr . David Alan Gilbert\" <dave@treblig.org>,\n Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>,\n \"Michael S . Tsirkin\" <mst@redhat.com>,\n Stefan Hajnoczi <stefanha@redhat.com>","Cc":"Zhang Chen <zhangckid@gmail.com>","Subject":"[PATCH V6 04/14] blockdev: Update tracking iothread users with holder\n name","Date":"Fri, 10 Apr 2026 23:04:47 +0800","Message-ID":"<20260410150457.85190-5-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":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::102f;\n envelope-from=zhangckid@gmail.com; helo=mail-pj1-x102f.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Currently, x-blockdev-set-iothread changes the AioContext but does not\ntrack the IOThread object itself within the block layer. This makes it\ndifficult to manage IOThread reference counting (put/get) during\ndynamic context switching.\n\nIntroduce an 'iothread' field to BlockDriverState to store the current\nassigned IOThread. Update qmp_x_blockdev_set_iothread to perform\nproper reference counting using iothread_ref/put when moving nodes\nbetween an IOThread and the main loop.\n\nThis ensures 'info iothreads' (holders) accurately reflects the block\ndevice attachment state after dynamic migrations.\n\nSigned-off-by: Zhang Chen <zhangckid@gmail.com>\n---\n blockdev.c                       | 6 +++++-\n include/block/block_int-common.h | 5 +++++\n 2 files changed, 10 insertions(+), 1 deletion(-)","diff":"diff --git a/blockdev.c b/blockdev.c\nindex 6e86c6262f..6e20579187 100644\n--- a/blockdev.c\n+++ b/blockdev.c\n@@ -3683,8 +3683,12 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,\n             goto out;\n         }\n \n-        new_context = iothread_get_aio_context(obj);\n+        new_context = iothread_ref_and_get_aio_context(obj, node_name);\n+        bs->iothread = obj;\n     } else {\n+        if (bs->iothread) {\n+            iothread_put_aio_context(bs->iothread, node_name);\n+        }\n         new_context = qemu_get_aio_context();\n     }\n \ndiff --git a/include/block/block_int-common.h b/include/block/block_int-common.h\nindex 147c08155f..6edaf53377 100644\n--- a/include/block/block_int-common.h\n+++ b/include/block/block_int-common.h\n@@ -1101,6 +1101,8 @@ typedef struct BdrvBlockStatusCache {\n     int64_t data_end;\n } BdrvBlockStatusCache;\n \n+typedef struct IOThread IOThread;\n+\n struct BlockDriverState {\n     /*\n      * Protected by big QEMU lock or read-only after opening.  No special\n@@ -1289,6 +1291,9 @@ struct BlockDriverState {\n \n     /* array of write pointers' location of each zone in the zoned device. */\n     BlockZoneWps *wps;\n+\n+    /* Track the iothread for detach aio context*/\n+    IOThread *iothread;\n };\n \n struct BlockBackendRootState {\n","prefixes":["V6","04/14"]}