[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL for-2.1 22/24] block: add helper function to determin
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL for-2.1 22/24] block: add helper function to determine if a BDS is in a chain |
Date: |
Tue, 1 Jul 2014 10:48:55 +0200 |
From: Jeff Cody <address@hidden>
This is a small helper function, to determine if 'base' is in the
chain of BlockDriverState 'top'. It returns true if it is in the chain,
and false otherwise.
If either argument is NULL, it will also return false.
Reviewed-by: Benoit Canet <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 11 +++++++++++
include/block/block.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/block.c b/block.c
index c111c29..f45e63c 100644
--- a/block.c
+++ b/block.c
@@ -3774,6 +3774,17 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
return NULL;
}
+/* If 'base' is in the same chain as 'top', return true. Otherwise,
+ * return false. If either argument is NULL, return false. */
+bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base)
+{
+ while (top && top != base) {
+ top = top->backing_hd;
+ }
+
+ return top != NULL;
+}
+
BlockDriverState *bdrv_next(BlockDriverState *bs)
{
if (!bs) {
diff --git a/include/block/block.h b/include/block/block.h
index 7e92f54..29c9e50 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -403,6 +403,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(void);
BlockDriverState *bdrv_lookup_bs(const char *device,
const char *node_name,
Error **errp);
+bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base);
BlockDriverState *bdrv_next(BlockDriverState *bs);
void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
void *opaque);
--
1.9.3
- [Qemu-devel] [PULL for-2.1 15/24] iotests: Add qemu tests to quick group, (continued)
- [Qemu-devel] [PULL for-2.1 15/24] iotests: Add qemu tests to quick group, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 17/24] block: make 'top' argument to block-commit optional, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 16/24] iotests: Add more tests to quick group, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 18/24] block: simplify bdrv_find_base() and bdrv_find_overlay(), Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 19/24] block/cow: Avoid use of uninitialized cow_bs in error path, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 20/24] qapi: Change back sector-count to sectors-count in quorum QAPI events., Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 21/24] block: add QAPI command to allow live backing file change, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 23/24] block: extend block-commit to accept a string for the backing file, Stefan Hajnoczi, 2014/07/01
- [Qemu-devel] [PULL for-2.1 22/24] block: add helper function to determine if a BDS is in a chain,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL for-2.1 24/24] block: add backing-file option to block-stream, Stefan Hajnoczi, 2014/07/01
- Re: [Qemu-devel] [PULL for-2.1 00/24] Block patches, Peter Maydell, 2014/07/01