summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf2020-09-24 17:27:10 +0200
committerKevin Wolf2020-10-02 15:46:40 +0200
commit8cade320c8838952b5f589c6df26b2e62dd099d7 (patch)
tree2e74e9fd7d86a18a4e18c916c5b81adf83a82c0d /block
parentblock/export: Create BlockBackend in blk_exp_add() (diff)
downloadqemu-8cade320c8838952b5f589c6df26b2e62dd099d7.tar.gz
qemu-8cade320c8838952b5f589c6df26b2e62dd099d7.tar.xz
qemu-8cade320c8838952b5f589c6df26b2e62dd099d7.zip
block/export: Add query-block-exports
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>
Diffstat (limited to 'block')
-rw-r--r--block/export/export.c23
1 files changed, 23 insertions, 0 deletions
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;
+}