From nobody Wed Nov 5 05:16:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153270118740495.11855206284076; Fri, 27 Jul 2018 07:19:47 -0700 (PDT) Received: from localhost ([::1]:41535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3as-0007gV-CO for importer@patchew.org; Fri, 27 Jul 2018 10:19:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3XE-0005LW-AR for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fj3XD-00038k-9I for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:16:00 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41342 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fj3X9-0002vr-OK; Fri, 27 Jul 2018 10:15:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55F4740216E7; Fri, 27 Jul 2018 14:15:55 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-112.ams2.redhat.com [10.36.117.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BAF01121301; Fri, 27 Jul 2018 14:15:54 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 27 Jul 2018 16:15:37 +0200 Message-Id: <20180727141539.506-2-kwolf@redhat.com> In-Reply-To: <20180727141539.506-1-kwolf@redhat.com> References: <20180727141539.506-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 27 Jul 2018 14:15:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 27 Jul 2018 14:15:55 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 1/3] block/qapi: Add 'qdev' field to query-blockstats result X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Like for query-block, the client needs to identify which BlockBackend the returned data is for. Anonymous BlockBackends are identified by the device model they are attached to. Add a 'qdev' field that contains the qdev ID or QOM path of the attached device model. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- qapi/block-core.json | 5 ++++- block/qapi.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index d40d5ecc3b..3f09f62fa1 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -866,6 +866,9 @@ # # @node-name: The node name of the device. (Since 2.3) # +# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block +# device. (since 3.0) +# # @stats: A @BlockDeviceStats for the device. # # @parent: This describes the file block device if it has one. @@ -879,7 +882,7 @@ # Since: 0.14.0 ## { 'struct': 'BlockStats', - 'data': {'*device': 'str', '*node-name': 'str', + 'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str', 'stats': 'BlockDeviceStats', '*parent': 'BlockStats', '*backing': 'BlockStats'} } diff --git a/block/qapi.c b/block/qapi.c index e12968fec8..50f867d634 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -597,11 +597,21 @@ BlockStatsList *qmp_query_blockstats(bool has_query_n= odes, BlockStatsList *info =3D g_malloc0(sizeof(*info)); AioContext *ctx =3D blk_get_aio_context(blk); BlockStats *s; + char *qdev; =20 aio_context_acquire(ctx); s =3D bdrv_query_bds_stats(blk_bs(blk), true); s->has_device =3D true; s->device =3D g_strdup(blk_name(blk)); + + qdev =3D blk_get_attached_dev_id(blk); + if (qdev && *qdev) { + s->has_qdev =3D true; + s->qdev =3D qdev; + } else { + g_free(qdev); + } + bdrv_query_blk_stats(s->stats, blk); aio_context_release(ctx); =20 --=20 2.13.6