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

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