From nobody Wed Nov 5 02:32:12 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 From nobody Wed Nov 5 02:32:12 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 1532701098927968.3625955358117; Fri, 27 Jul 2018 07:18:18 -0700 (PDT) Received: from localhost ([::1]:41527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3ZR-0006Z1-Nz for importer@patchew.org; Fri, 27 Jul 2018 10:18:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3XD-0005Ks-Vh for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fj3XD-00038K-4a for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:15:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41344 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 1fj3XB-0002zB-3y; Fri, 27 Jul 2018 10:15:57 -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 ABE5A40216E7; Fri, 27 Jul 2018 14:15:56 +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 92FEA1121301; Fri, 27 Jul 2018 14:15:55 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 27 Jul 2018 16:15:38 +0200 Message-Id: <20180727141539.506-3-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:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 27 Jul 2018 14:15:56 +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 2/3] block/qapi: Include anonymous BBs in query-blockstats 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" Consistent with query-block, query-blockstats should not only include named BlockBackends, but also those that are anonmyous, but belong to a device model. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/qapi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/qapi.c b/block/qapi.c index 50f867d634..339727f0f4 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -593,12 +593,16 @@ BlockStatsList *qmp_query_blockstats(bool has_query_n= odes, p_next =3D &info->next; } } else { - for (blk =3D blk_next(NULL); blk; blk =3D blk_next(blk)) { + for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { BlockStatsList *info =3D g_malloc0(sizeof(*info)); AioContext *ctx =3D blk_get_aio_context(blk); BlockStats *s; char *qdev; =20 + if (!*blk_name(blk) && !blk_get_attached_dev(blk)) { + continue; + } + aio_context_acquire(ctx); s =3D bdrv_query_bds_stats(blk_bs(blk), true); s->has_device =3D true; --=20 2.13.6 From nobody Wed Nov 5 02:32:12 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 1532701080109162.67486349820717; Fri, 27 Jul 2018 07:18:00 -0700 (PDT) Received: from localhost ([::1]:41526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3Z7-0006Jb-CI for importer@patchew.org; Fri, 27 Jul 2018 10:17:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3XM-0005Ql-PL for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fj3XG-0003Hm-Bz for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:16:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50958 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 1fj3XC-00034r-Dr; Fri, 27 Jul 2018 10:15:58 -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 0DBB07788A; Fri, 27 Jul 2018 14:15:58 +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 E90BC1121301; Fri, 27 Jul 2018 14:15:56 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 27 Jul 2018 16:15:39 +0200 Message-Id: <20180727141539.506-4-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.1]); Fri, 27 Jul 2018 14:15:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 27 Jul 2018 14:15:58 +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 3/3] qemu-iotests: Test query-blockstats with -drive and -blockdev 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" Make sure that query-blockstats returns information for every BlockBackend that is named or attached to a device model (or both). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/qemu-iotests/227 | 101 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/227.out | 42 +++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 144 insertions(+) create mode 100755 tests/qemu-iotests/227 create mode 100644 tests/qemu-iotests/227.out diff --git a/tests/qemu-iotests/227 b/tests/qemu-iotests/227 new file mode 100755 index 0000000000..c840e0915d --- /dev/null +++ b/tests/qemu-iotests/227 @@ -0,0 +1,101 @@ +#!/bin/bash +# +# Test query-blockstats with different ways to create a BB +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D$(basename $0) +echo "QA output created by $seq" + +here=3D$PWD +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" + $QEMU -nographic -qmp stdio -serial none "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ + | _filter_qemu | _filter_imgfmt \ + | _filter_generated_node_ids +} + +echo +echo '=3D=3D=3D blockstats with -drive if=3Dvirtio =3D=3D=3D' +echo + +run_qemu -drive driver=3Dnull-co,if=3Dvirtio <