Blame SOURCES/kvm-block-qapi-Add-qdev-field-to-query-blockstats-result.patch

1bdc94
From 95bfd60b406ed4cce708b5981d4bc3a007d0cec9 Mon Sep 17 00:00:00 2001
1bdc94
From: Kevin Wolf <kwolf@redhat.com>
1bdc94
Date: Tue, 7 Aug 2018 14:03:59 +0200
1bdc94
Subject: [PATCH 06/13] block/qapi: Add 'qdev' field to query-blockstats result
1bdc94
1bdc94
RH-Author: Kevin Wolf <kwolf@redhat.com>
1bdc94
Message-id: <20180807140401.23995-2-kwolf@redhat.com>
1bdc94
Patchwork-id: 81666
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/3] block/qapi: Add 'qdev' field to query-blockstats result
1bdc94
Bugzilla: 1612114
1bdc94
RH-Acked-by: John Snow <jsnow@redhat.com>
1bdc94
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
1bdc94
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
1bdc94
1bdc94
Like for query-block, the client needs to identify which BlockBackend
1bdc94
the returned data is for. Anonymous BlockBackends are identified by the
1bdc94
device model they are attached to. Add a 'qdev' field that contains the
1bdc94
qdev ID or QOM path of the attached device model.
1bdc94
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Reviewed-by: Eric Blake <eblake@redhat.com>
1bdc94
(cherry picked from commit 5a9cb5a97f1e519f249d9ec482d498b78296b51d)
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 block/qapi.c         | 10 ++++++++++
1bdc94
 qapi/block-core.json | 14 ++++++++++----
1bdc94
 2 files changed, 20 insertions(+), 4 deletions(-)
1bdc94
1bdc94
diff --git a/block/qapi.c b/block/qapi.c
1bdc94
index e12968f..50f867d 100644
1bdc94
--- a/block/qapi.c
1bdc94
+++ b/block/qapi.c
1bdc94
@@ -597,11 +597,21 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
1bdc94
             BlockStatsList *info = g_malloc0(sizeof(*info));
1bdc94
             AioContext *ctx = blk_get_aio_context(blk);
1bdc94
             BlockStats *s;
1bdc94
+            char *qdev;
1bdc94
 
1bdc94
             aio_context_acquire(ctx);
1bdc94
             s = bdrv_query_bds_stats(blk_bs(blk), true);
1bdc94
             s->has_device = true;
1bdc94
             s->device = g_strdup(blk_name(blk));
1bdc94
+
1bdc94
+            qdev = blk_get_attached_dev_id(blk);
1bdc94
+            if (qdev && *qdev) {
1bdc94
+                s->has_qdev = true;
1bdc94
+                s->qdev = qdev;
1bdc94
+            } else {
1bdc94
+                g_free(qdev);
1bdc94
+            }
1bdc94
+
1bdc94
             bdrv_query_blk_stats(s->stats, blk);
1bdc94
             aio_context_release(ctx);
1bdc94
 
1bdc94
diff --git a/qapi/block-core.json b/qapi/block-core.json
1bdc94
index 8a00bec..c6b42eb 100644
1bdc94
--- a/qapi/block-core.json
1bdc94
+++ b/qapi/block-core.json
1bdc94
@@ -867,6 +867,9 @@
1bdc94
 #
1bdc94
 # @node-name: The node name of the device. (Since 2.3)
1bdc94
 #
1bdc94
+# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block
1bdc94
+#        device. (since 3.0)
1bdc94
+#
1bdc94
 # @stats:  A @BlockDeviceStats for the device.
1bdc94
 #
1bdc94
 # @parent: This describes the file block device if it has one.
1bdc94
@@ -880,7 +883,7 @@
1bdc94
 # Since: 0.14.0
1bdc94
 ##
1bdc94
 { 'struct': 'BlockStats',
1bdc94
-  'data': {'*device': 'str', '*node-name': 'str',
1bdc94
+  'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str',
1bdc94
            'stats': 'BlockDeviceStats',
1bdc94
            '*parent': 'BlockStats',
1bdc94
            '*backing': 'BlockStats'} }
1bdc94
@@ -942,7 +945,8 @@
1bdc94
 #                "idle_time_ns":2953431879,
1bdc94
 #                "account_invalid":true,
1bdc94
 #                "account_failed":false
1bdc94
-#             }
1bdc94
+#             },
1bdc94
+#             "qdev": "/machine/unattached/device[23]"
1bdc94
 #          },
1bdc94
 #          {
1bdc94
 #             "device":"ide1-cd0",
1bdc94
@@ -960,7 +964,8 @@
1bdc94
 #                "wr_merged":0,
1bdc94
 #                "account_invalid":false,
1bdc94
 #                "account_failed":false
1bdc94
-#             }
1bdc94
+#             },
1bdc94
+#             "qdev": "/machine/unattached/device[24]"
1bdc94
 #          },
1bdc94
 #          {
1bdc94
 #             "device":"floppy0",
1bdc94
@@ -978,7 +983,8 @@
1bdc94
 #                "wr_merged":0,
1bdc94
 #                "account_invalid":false,
1bdc94
 #                "account_failed":false
1bdc94
-#             }
1bdc94
+#             },
1bdc94
+#             "qdev": "/machine/unattached/device[16]"
1bdc94
 #          },
1bdc94
 #          {
1bdc94
 #             "device":"sd0",
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94