[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 2/7] block/export: add blk_by_export_id()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v7 2/7] block/export: add blk_by_export_id() |
Date: |
Fri, 21 Apr 2023 14:40:57 +0300 |
We need it for further blockdev-replace functionality.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
block/export/export.c | 18 ++++++++++++++++++
include/sysemu/block-backend-global-state.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/block/export/export.c b/block/export/export.c
index 28a91c9c42..016943860c 100644
--- a/block/export/export.c
+++ b/block/export/export.c
@@ -368,3 +368,21 @@ BlockExportInfoList *qmp_query_block_exports(Error **errp)
return head;
}
+
+BlockBackend *blk_by_export_id(const char *id, Error **errp)
+{
+ BlockExport *exp;
+
+ exp = blk_exp_find(id);
+ if (exp == NULL) {
+ error_setg(errp, "Export '%s' not found", id);
+ return NULL;
+ }
+
+ if (!exp->blk) {
+ error_setg(errp, "Export '%s' is empty", id);
+ return NULL;
+ }
+
+ return exp->blk;
+}
diff --git a/include/sysemu/block-backend-global-state.h
b/include/sysemu/block-backend-global-state.h
index 5db83ed8cb..b9dc81c34d 100644
--- a/include/sysemu/block-backend-global-state.h
+++ b/include/sysemu/block-backend-global-state.h
@@ -71,6 +71,7 @@ void blk_detach_dev(BlockBackend *blk, DeviceState *dev);
DeviceState *blk_get_attached_dev(BlockBackend *blk);
BlockBackend *blk_by_dev(void *dev);
BlockBackend *blk_by_qdev_id(const char *id, Error **errp);
+BlockBackend *blk_by_export_id(const char *id, Error **errp);
void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque);
void blk_activate(BlockBackend *blk, Error **errp);
--
2.34.1
- [PATCH v7 0/7] blockdev-replace, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 1/7] block-backend: blk_root(): drop const specifier on return type, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 3/7] block: make bdrv_find_child() function public, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 4/7] qapi: add x-blockdev-replace command, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 7/7] iotests: add filter-insertion, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 6/7] iotests.py: introduce VM.assert_edges_list() method, Vladimir Sementsov-Ogievskiy, 2023/04/21
- [PATCH v7 2/7] block/export: add blk_by_export_id(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH v7 5/7] block: bdrv_get_xdbg_block_graph(): report export ids, Vladimir Sementsov-Ogievskiy, 2023/04/21