[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/37] block/export: Add query-block-exports
From: |
Kevin Wolf |
Subject: |
[PULL 28/37] block/export: Add query-block-exports |
Date: |
Fri, 2 Oct 2020 16:43:36 +0200 |
This adds a simple QMP command to query the list of block exports.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200924152717.287415-25-kwolf@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qapi/block-export.json | 32 ++++++++++++++++++++++++++++++++
block/export/export.c | 23 +++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/qapi/block-export.json b/qapi/block-export.json
index 76e014c406..91b042b453 100644
--- a/qapi/block-export.json
+++ b/qapi/block-export.json
@@ -245,3 +245,35 @@
##
{ 'event': 'BLOCK_EXPORT_DELETED',
'data': { 'id': 'str' } }
+
+##
+# @BlockExportInfo:
+#
+# Information about a single block export.
+#
+# @id: The unique identifier for the block export
+#
+# @type: The block export type
+#
+# @node-name: The node name of the block node that is exported
+#
+# @shutting-down: True if the export is shutting down (e.g. after a
+# block-export-del command, but before the shutdown has
+# completed)
+#
+# Since: 5.2
+##
+{ 'struct': 'BlockExportInfo',
+ 'data': { 'id': 'str',
+ 'type': 'BlockExportType',
+ 'node-name': 'str',
+ 'shutting-down': 'bool' } }
+
+##
+# @query-block-exports:
+#
+# Returns: A list of BlockExportInfo describing all block exports
+#
+# Since: 5.2
+##
+{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] }
diff --git a/block/export/export.c b/block/export/export.c
index 8702c233f3..657bb58b51 100644
--- a/block/export/export.c
+++ b/block/export/export.c
@@ -286,3 +286,26 @@ void qmp_block_export_del(const char *id,
blk_exp_request_shutdown(exp);
}
+
+BlockExportInfoList *qmp_query_block_exports(Error **errp)
+{
+ BlockExportInfoList *head = NULL, **p_next = &head;
+ BlockExport *exp;
+
+ QLIST_FOREACH(exp, &block_exports, next) {
+ BlockExportInfoList *entry = g_new0(BlockExportInfoList, 1);
+ BlockExportInfo *info = g_new(BlockExportInfo, 1);
+ *info = (BlockExportInfo) {
+ .id = g_strdup(exp->id),
+ .type = exp->drv->type,
+ .node_name = g_strdup(bdrv_get_node_name(blk_bs(exp->blk))),
+ .shutting_down = !exp->user_owned,
+ };
+
+ entry->value = info;
+ *p_next = entry;
+ p_next = &entry->next;
+ }
+
+ return head;
+}
--
2.25.4
- [PULL 19/37] block/export: Add node-name to BlockExportOptions, (continued)
- [PULL 19/37] block/export: Add node-name to BlockExportOptions, Kevin Wolf, 2020/10/02
- [PULL 21/37] block/export: Add blk_exp_close_all(_type), Kevin Wolf, 2020/10/02
- [PULL 20/37] block/export: Allocate BlockExport in blk_exp_add(), Kevin Wolf, 2020/10/02
- [PULL 22/37] block/export: Add 'id' option to block-export-add, Kevin Wolf, 2020/10/02
- [PULL 24/37] block/export: Add block-export-del, Kevin Wolf, 2020/10/02
- [PULL 23/37] block/export: Move strong user reference to block_exports, Kevin Wolf, 2020/10/02
- [PULL 25/37] block/export: Add BLOCK_EXPORT_DELETED event, Kevin Wolf, 2020/10/02
- [PULL 26/37] block/export: Move blk to BlockExport, Kevin Wolf, 2020/10/02
- [PULL 30/37] nbd: Merge nbd_export_new() and nbd_export_create(), Kevin Wolf, 2020/10/02
- [PULL 29/37] block/export: Move writable to BlockExportOptions, Kevin Wolf, 2020/10/02
- [PULL 28/37] block/export: Add query-block-exports,
Kevin Wolf <=
- [PULL 31/37] nbd: Deprecate nbd-server-add/remove, Kevin Wolf, 2020/10/02
- [PULL 27/37] block/export: Create BlockBackend in blk_exp_add(), Kevin Wolf, 2020/10/02
- [PULL 33/37] iotests: Introduce qemu_nbd_list_log(), Kevin Wolf, 2020/10/02
- [PULL 36/37] qemu-storage-daemon: Fix help line for --export, Kevin Wolf, 2020/10/02
- [PULL 32/37] iotests: Factor out qemu_tool_pipe_and_status(), Kevin Wolf, 2020/10/02
- [PULL 37/37] qcow2: Use L1E_SIZE in qcow2_write_l1_entry(), Kevin Wolf, 2020/10/02
- [PULL 34/37] iotests: Allow supported and unsupported formats at the same time, Kevin Wolf, 2020/10/02
- [PULL 35/37] iotests: Test block-export-* QMP interface, Kevin Wolf, 2020/10/02
- Re: [PULL 00/37] Block layer patches, Peter Maydell, 2020/10/02