From patchwork Wed Jun 13 17:44:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10462763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 497B760348 for ; Wed, 13 Jun 2018 17:52:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3417528FA7 for ; Wed, 13 Jun 2018 17:52:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B64828F74; Wed, 13 Jun 2018 17:52:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4976B28FE4 for ; Wed, 13 Jun 2018 17:52:38 +0000 (UTC) Received: from localhost ([::1]:36008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT9wj-00018O-3t for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Jun 2018 13:52:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT9pO-0003Ry-3b for qemu-devel@nongnu.org; Wed, 13 Jun 2018 13:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fT9pK-0007P4-NH for qemu-devel@nongnu.org; Wed, 13 Jun 2018 13:45:02 -0400 Received: from mail-eopbgr10099.outbound.protection.outlook.com ([40.107.1.99]:57531 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fT9pJ-0007HZ-I0; Wed, 13 Jun 2018 13:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2kQGGprKNVvOrTdWVeK3+scRV0O1n3Yrgf/Ot/GrTlE=; b=iBwUZ4w+akgtFDLwankUeE0I08UPYJPvvBoUxQv7BrZ9ns1A+U4j6JM78M329vmn/kwr2uTIdUVr0dy1jOCEYuRCpKlSbqGtnGdgNmU0WV7NSmpH7OioNMLWzSyuAAAIWOviwp9YjdeO89lgtgpP4S/7WX2rMwa1whLHHqO3d3s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.16; Wed, 13 Jun 2018 17:44:54 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Wed, 13 Jun 2018 20:44:26 +0300 Message-Id: <1528911866-37489-9-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528911866-37489-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1528911866-37489-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0902CA0023.eurprd09.prod.outlook.com (2603:10a6:3:e5::33) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42633b20-4c20-42cc-a836-08d5d1555fa5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3347; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 3:FDmvTJ2XrWm5kZUUS6MT2acNw+2ZemOLb7rCf47Y3jZgbtrxtS5h/w8vJQkyn+O1cOruZNgPLS5ZbntcD5h8ypb2/E3NYnxFvDbuMg/Ch6OwV+pn+TVxUPI13JD5mrj2IwQXqy7oc4ehT9VQJUj8ufru4iD2HJ3H8+BcgSVwWEg/aOJXaIFgcW94Ah7IP99/+xSL/2nE5rBK9NHJ5vuSgZTyfkEduFwqe145jroIZohRIbaz7Yo2ep6T0uB7Mcx/; 25:6g+2l/p8DjtGlP5hFYjYq0La6X9SAf6lXLCN1G4eea7mxWmgZPjgEOM2DB9fLuauF/w2M14ZFU8dVlYbrf0LnO5WIK9WkS25hGmPe9wwWHlkC36fTivnfi3hAAT0/KVY/OxPeSwInVgGLLzYDHHCFRZovmb+UxnaXzixXKqzltmN+arKoImkENkVjpxO8P4MXj1OZEG08+2X5Ntwq0RxGb0vAm8hWD6+5f3mPr3qmskUmi/jSu8mBUANaC5LTDAGANh4MCTpKMScvSClFpfmWMF41ytF0uN4FxqiYAn3WPW9fY6uCmk4upm8RANAt4SjtDhyR2JgzA3MaV89diPgwQ==; 31:zEFWCBB/V8LBa+tG5AOCcsqIU1w+B9iAhD6An1IaqnIpiaHaprK09LFMxO8tz79KfF7McTXbpnzeaRZkyO1u/Cx/++Z2P0YtyFgSGj1SlGy3uPeC+eTS4Oxv9N+21fnEsVQw+4Okv3hePMgkZiF5eFTZFTPCqmFsN6v480fJQPkJu7L6bvUEHq2PH95xRtghdtNQuuCtj98lMy7ZIrVAf3mcaF5hMPc1Jl4grFkf6A0= X-MS-TrafficTypeDiagnostic: AM0PR08MB3347: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:Ynp+05rWxiWcdtkNbb9dfcBOvHY8smOxBYqiLdlynZId25p0EZMNIyjM6rFzZdZ6+jgxQ5pcDkMV7Rnc5aQv0ZuUNqueYZmgWLdUgrKt8bYkq+G5xke0h9G65N+WTW6svv7Jld7tgzXrrqbrsSL2SUFlpX04uwpPkHOsFhfsYfcdUM8nbNPC/++DNV3VQajF6+aWtl3CcqklM0EwqELG+zpCS8/xAFik3zcFGMFAF370MEVyDDEff5O6W3cnbzkSP+uPI/b0zDtYianN8Dl/ENRtY5i1bdvzr3rfRZobQZku9E56NtEoI2G5Euhyg+JGHxmSURb0o98YEAzEk82G19y6tH1GBBZcXbf8io8jbpDS7GBuE3BYNj6wTFYky3Lcg2igtHODKzKfTVkG0zwivNX3S9SRFQW1ehSJAtnBdoQkEu1IeOwnUO6eDErq//x1DXeGdC07tUuxrIamlydd5tqgxU51bLiPA4AEzoV7RPqfMGz+bO6izJzQeLcyXSQg; 4:4fQjxZT6gdjeaAhpTzBN7h4FZhp+RO8OW1CJuDxiKR85KDIrBV9g/GPByAD1Hiy7MydtkeT881yro9sreydWqFxJHZNH66THHUQx7UZ+ivg72FBxfEXJNU0cHDj3wHDbSKpLSxbU6EMa1YjclSP4hCxCw4R5VUp1UDm7VpjQMEJE9HKVApVYIE1eNFACU1IDLopen65s53jWQz+7LxSc7OM98O4iXVAmTpgvhUZm7WV9cDba1hZH40cyuwo3MDDnqnkGtQkMCkLEn3an7ClbGfWxxP7/KetyD8QCYRvysul77UEk96d7ozTxH3a8a+zc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:AM0PR08MB3347; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3347; X-Forefront-PRVS: 07025866F6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(346002)(376002)(39850400004)(366004)(39380400002)(199004)(189003)(50466002)(2351001)(386003)(4326008)(2361001)(59450400001)(6512007)(52116002)(105586002)(486006)(478600001)(106356001)(44832011)(53416004)(107886003)(51416003)(53936002)(76176011)(11346002)(956004)(446003)(2616005)(476003)(69596002)(6486002)(48376002)(16526019)(6506007)(7736002)(97736004)(186003)(5660300001)(6666003)(25786009)(6916009)(305945005)(8936002)(6116002)(3846002)(50226002)(66066001)(36756003)(8676002)(86362001)(47776003)(55236004)(68736007)(316002)(2906002)(16586007)(81166006)(26005)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3347; H:xantnef-ws.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR08MB3347; 23:3y4BYq/Um1i+3/ffgmxUfLakX2Us8FehXGoo4d/T/?= =?us-ascii?Q?Mn6JwG3pZxE8tLln8lweskaaEirJZBNW+GMqJ5bLJE/JOQ5qJI4snECz+1rh?= =?us-ascii?Q?6GA9tVfobwhT+tlfK26WE2uE2aMzLEdZXyR7nU2l1HH6Rq6IYSLtxub6lqVB?= =?us-ascii?Q?tFQFEXqd5EPb/aD1q9B5JXIdTCNhqpGhP293QWbOeWrxcbrCnqjCKB/9iicv?= =?us-ascii?Q?JXuUqExbGDJmiOenjP4eYN2HGu1MzSwHWsx9EHoB+D6Tzc/eUJL0vLE4vmv8?= =?us-ascii?Q?LZmBDxfxjsd8pnTGUg7Ge8Bd9BKJ2ZQwJOGyyfIm48GgYwVpO8hVhK2wZDie?= =?us-ascii?Q?wobkUzzgRgD++6/ouxvvoEx+7sEtAJMd73p3UYykfoTMnYNtUWWU2TJ8fKtl?= =?us-ascii?Q?xcr3ZZdjBR8nNE3+8hTSzsOp6gITrPAwm9rwzt1lQvboClRbMl8hdDzNgDLI?= =?us-ascii?Q?+H0vlfqckhGXwO8nCLKOjsjOpFN3OMATsR8BHcl5bciLSi6pI+prPFHa/BIg?= =?us-ascii?Q?v2VxwyU2g30sgFNkKENJ84L79/O2fq7ctiExMXYyB3kVpcpF0jyZve7ygiQ3?= =?us-ascii?Q?xHYIikge566GS8kwZcY99l9KQ3rRhBb4mAawsPZK2elXpRzi5OJisqXaYjVi?= =?us-ascii?Q?w/F/Snx/ejCSOqY/SOWujhbhfXRTNDsV1yXKZEDmvz/prdqlhKdRHyHRNeq4?= =?us-ascii?Q?LalaZBYBSAY3C5Uu8jh4Ha1M1XFWQYwD+SUz6zER/yxiqMWhkFf39039XWl+?= =?us-ascii?Q?0I9RzciPssgaYsMqP6idgnMhuxlrgAX3yViuxa0LDLzxHb97qJ7KjeLSTVjK?= =?us-ascii?Q?klgYBar8lQurLhVKgwGOOurg0vpMC5xISw4976DDpxQr9HtsB9u92WPDi5Rz?= =?us-ascii?Q?hfOQqHnE7wPeDIuGj/olI5dfmz8ERX7fIvg3DdcXZ22oIF2F6xbduWM0vlqp?= =?us-ascii?Q?k0MtArMrw89yhgETqYBd8JrQlTkZ0f5T883TkKJdfjMZGCprXiSHXwEpQcik?= =?us-ascii?Q?XDfq8tUjvjHy2sVRuFQppWfzLF6R64w/2LjqZYY/7dROaXvoJK7Z8Xj7qhD8?= =?us-ascii?Q?j/1pNNShZ0oHuZpkVez8UIfXZpqD4KB4IWRNJ0EQ3eTXsylOcNcQcF1nOO9U?= =?us-ascii?Q?Z+WQJLhrnb2lPlTJhvnFJIsdUVNYFpb0lZNkOyaXxzbk8FiTQPeEDKsrtPoA?= =?us-ascii?Q?mriJDJ5R/PZoIj9SuYIPlzraV+udmAic1QYQu6VW77uF2MWHIwLihTNkH4bL?= =?us-ascii?Q?5WLYqohrK2KnqHZ4ihGHzYiSg8PEnbYp4WlKk7kypahFdPZKWgAD/xLf0fhI?= =?us-ascii?Q?PHdRp6RTBb3tlqAhKsVhJzoDhhAJwOxLkz6ExNCU1s2/tm4hmjU2fUGsaBGH?= =?us-ascii?Q?kkSfw=3D=3D?= X-Microsoft-Antispam-Message-Info: V3wgT1veNVJI4AYYDrE2yLOQTw1ZMPbLS5mCj1swkftEbdDUIMa3bEH2w1Aq/tdi75JCARDr60LFHfLeXxu9dGopUc5WZaarepTqP7fz/FnXEl7EglCrQriatKM9pCjYm1C0uwAtfU2qR2sQOJvFGYf0RkyIlhsDEqLgwIfL2mdNzfKcI+eW4FW4ASZWVFD3 X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 6:2pALjL0iMBZIXA/0h5udue/t9y8yB/7/aH5mEp/+xtyoM9XbwPllyxeb5Tpci3XejCng3sJmRFdemVnVqrSYYd8YnAHpW+ir/ES4N2JPlxKMXj4Ok25Z1C5CWZGcKJazYOQfspsgaCNkROS7SpXcetjIfdHTGofeOqXuCI/+jkFXO1NL6qAuEB3pSw0fddcBiaA4acSh2CrdkgLHjpfI0MbnGK1JJLK4hdX5lc1zUh30lmb6X6gmY5OHyc+dqrk+18wdIor2iA4N/HPE/d8nwGrG8498aZoFxGvBz2ufptZAVyGzxA+iJtJivyrAOVw7WEnvgpazIERD1hnEZeCn/drzgdd8DyIQDBr66Dw45bIpdDcY9uDEW4EUhsJsxnge59cG0YIzDK12YpPIFYmOO+EsYvgy0ycLX+H3naGThczUU4f+AjnRArbL293+DM1AUFPr+LilaYeEVlhUG80w6w==; 5:HBhpMqJ43p28Wy9Bxbtici59rEMyx7xpW/c5YN4o/JKWHeDHkacGYiuICt8OYPML6d5j3Q4iXCMlozTB0ESVLdjFh4Ijb5RForjvHHdvVH2MP7EUBh92Y11ojnz6nBBZJ2t8j90rvqKHURY0LTUaMQrq0VKbr9u2Me+qEjZ3atQ=; 24:kahIW/t1gLVhN5XCHiDgyjkNhEjZXZ9EavUf2SblSRk60xcyCmIGPz3EFqwOZbt7VROlO/Ye6cz+mwWagEqWW5hIpkCNbNv1tKRAVeM24Bs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 7:meS5OLUk+3bWboOzVUbz6kcovUzPeJaXxgpwZRgZsNpfx1fhhn38TaVPnokK16aZ0AQ3dxsirv0iu+hF3j/mEW0+6mS2Lc9ZsXDhj3acl5UtdfN9DAz/RDgh2sy06Gcp6O4DLKdPMRXIvzOLO7Ho1hp8NFkLF/OBqMrsVrQxYGyE4W+dpXBiG4G6oanWv/lONLpZ1WS33yYCnrJSdqDYQ7Wd6cw15QKo2rk1/O8PFKwHzHY8Kl63uNUio5kvzq92; 20:4zGNEV8BF3Z2o2fqh3D9Uhj7812jlMCrIRstpVtMnVZ0PPKnY+Bw1pX9A1O+blWICjbyeenuCCRuO0ioRco7+4g0gXGkrnvKrHDgX0XGswxL3ko9H2VDawUNB7bknnrMnvDAomTf700XDwBfQqNi6oLXsnpKHTF+xuSdZkxeTx4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2018 17:44:54.2395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42633b20-4c20-42cc-a836-08d5d1555fa5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3347 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.99 Subject: [Qemu-devel] [PATCH v3 8/8] qapi: query-blockstat: add driver specific file-posix stats 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, Anton Nefedov , berto@igalia.com, den@virtuozzo.com, qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A block driver can provide a callback to report driver-specific statistics. file-posix driver now reports discard statistics Signed-off-by: Anton Nefedov --- qapi/block-core.json | 39 +++++++++++++++++++++++++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++++++ block/file-posix.c | 17 +++++++++++++++++ block/qapi.c | 5 +++++ 6 files changed, 72 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index a859011..800cf2c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -886,6 +886,42 @@ '*x_flush_latency_histogram': 'BlockLatencyHistogramInfo' } } ## +# @BlockStatsSpecificFile: +# +# File driver statistics +# +# @discard-nb-ok: The number of succeeded discard operations performed by +# the driver. +# +# @discard-nb-failed: The number of failed discard operations performed by +# the driver. +# +# @discard-bytes-ok: The number of bytes discarded by the driver. +# +# Since 3.0 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'int', + 'discard-nb-failed': 'int', + 'discard-bytes-ok': 'int' + } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 3.0 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile' + } } + +## # @BlockStats: # # Statistics of a virtual block device or a block backing device. @@ -897,6 +933,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 3.0) +# # @parent: This describes the file block device if it has one. # Contains recursively the statistics of the underlying # protocol (e.g. the host file for a qcow2 image). If there is @@ -910,6 +948,7 @@ { 'struct': 'BlockStats', 'data': {'*device': 'str', '*node-name': 'str', 'stats': 'BlockDeviceStats', + '*driver-specific': 'BlockStatsSpecific', '*parent': 'BlockStats', '*backing': 'BlockStats'} } diff --git a/include/block/block.h b/include/block/block.h index e677080..b263d8a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -445,6 +445,7 @@ const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs); void bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *cluster_offset, diff --git a/include/block/block_int.h b/include/block/block_int.h index 327e478..2456723 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -317,6 +317,7 @@ struct BlockDriver { Error **errp); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs); + BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs); int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, diff --git a/block.c b/block.c index 5088708..46c91c8 100644 --- a/block.c +++ b/block.c @@ -4172,6 +4172,15 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs) return NULL; } +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (!drv || !drv->bdrv_get_specific_stats) { + return NULL; + } + return drv->bdrv_get_specific_stats(bs); +} + void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event) { if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { diff --git a/block/file-posix.c b/block/file-posix.c index 4a2e394..0bc2cb6 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2518,6 +2518,21 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_FILE; + stats->u.file = (BlockStatsSpecificFile){ + .discard_nb_ok = s->stats.discard_nb_ok, + .discard_nb_failed = s->stats.discard_nb_failed, + .discard_bytes_ok = s->stats.discard_bytes_ok, + }; + + return stats; +} + static QemuOptsList raw_create_opts = { .name = "raw-create-opts", .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2623,6 +2638,7 @@ BlockDriver bdrv_file = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = raw_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, @@ -3104,6 +3120,7 @@ static BlockDriver bdrv_host_device = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = raw_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, diff --git a/block/qapi.c b/block/qapi.c index 2ee90d4..29b7898 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -535,6 +535,11 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset); + s->driver_specific = bdrv_get_specific_stats(bs); + if (s->driver_specific) { + s->has_driver_specific = true; + } + if (bs->file) { s->has_parent = true; s->parent = bdrv_query_bds_stats(bs->file->bs, blk_level);