diff mbox

[RFC,2/7] block-backend: Introduce blk_root() helper

Message ID 1476971860-20860-3-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang Oct. 20, 2016, 1:57 p.m. UTC
With this helper function, we can get the BdrvChild struct
from BlockBackend

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 block/block-backend.c          | 5 +++++
 include/sysemu/block-backend.h | 1 +
 2 files changed, 6 insertions(+)

Comments

Changlong Xie Oct. 25, 2016, 9:58 a.m. UTC | #1
I know you need blk->root in the next patch, but we strongly don't 
recommend your current solution.  Please refer Kevin's cf2ab8fc

1409     /* XXX Ugly way to get blk->root, but that's a feature, not a 
bug. This
1410      * hack makes it obvious that vhdx_write_header() bypasses the 
BlockBackend
1411      * here, which it really shouldn't be doing. */
1412     child = QLIST_FIRST(&bs->parents);
1413     assert(!QLIST_NEXT(child, next_parent));

Then you can drop this commit.

On 10/20/2016 09:57 PM, zhanghailiang wrote:
> With this helper function, we can get the BdrvChild struct
> from BlockBackend
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>   block/block-backend.c          | 5 +++++
>   include/sysemu/block-backend.h | 1 +
>   2 files changed, 6 insertions(+)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 1a724a8..66387f0 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -389,6 +389,11 @@ BlockDriverState *blk_bs(BlockBackend *blk)
>       return blk->root ? blk->root->bs : NULL;
>   }
>
> +BdrvChild *blk_root(BlockBackend *blk)
> +{
> +    return blk->root;
> +}
> +
>   static BlockBackend *bdrv_first_blk(BlockDriverState *bs)
>   {
>       BdrvChild *child;
> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
> index b07159b..867f9f5 100644
> --- a/include/sysemu/block-backend.h
> +++ b/include/sysemu/block-backend.h
> @@ -99,6 +99,7 @@ void blk_remove_bs(BlockBackend *blk);
>   void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
>   bool bdrv_has_blk(BlockDriverState *bs);
>   bool bdrv_is_root_node(BlockDriverState *bs);
> +BdrvChild *blk_root(BlockBackend *blk);
>
>   void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
>   void blk_iostatus_enable(BlockBackend *blk);
>
Zhanghailiang Dec. 5, 2016, 2:41 a.m. UTC | #2
On 2016/10/25 17:58, Changlong Xie wrote:
> I know you need blk->root in the next patch, but we strongly don't
> recommend your current solution.  Please refer Kevin's cf2ab8fc
>
> 1409     /* XXX Ugly way to get blk->root, but that's a feature, not a
> bug. This
> 1410      * hack makes it obvious that vhdx_write_header() bypasses the
> BlockBackend
> 1411      * here, which it really shouldn't be doing. */
> 1412     child = QLIST_FIRST(&bs->parents);
> 1413     assert(!QLIST_NEXT(child, next_parent));
>
> Then you can drop this commit.
>

OK, got it, I'll drop this patch in next version, thanks.

> On 10/20/2016 09:57 PM, zhanghailiang wrote:
>> With this helper function, we can get the BdrvChild struct
>> from BlockBackend
>>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> ---
>>    block/block-backend.c          | 5 +++++
>>    include/sysemu/block-backend.h | 1 +
>>    2 files changed, 6 insertions(+)
>>
>> diff --git a/block/block-backend.c b/block/block-backend.c
>> index 1a724a8..66387f0 100644
>> --- a/block/block-backend.c
>> +++ b/block/block-backend.c
>> @@ -389,6 +389,11 @@ BlockDriverState *blk_bs(BlockBackend *blk)
>>        return blk->root ? blk->root->bs : NULL;
>>    }
>>
>> +BdrvChild *blk_root(BlockBackend *blk)
>> +{
>> +    return blk->root;
>> +}
>> +
>>    static BlockBackend *bdrv_first_blk(BlockDriverState *bs)
>>    {
>>        BdrvChild *child;
>> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
>> index b07159b..867f9f5 100644
>> --- a/include/sysemu/block-backend.h
>> +++ b/include/sysemu/block-backend.h
>> @@ -99,6 +99,7 @@ void blk_remove_bs(BlockBackend *blk);
>>    void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
>>    bool bdrv_has_blk(BlockDriverState *bs);
>>    bool bdrv_is_root_node(BlockDriverState *bs);
>> +BdrvChild *blk_root(BlockBackend *blk);
>>
>>    void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
>>    void blk_iostatus_enable(BlockBackend *blk);
>>
>
>
>
> .
>
diff mbox

Patch

diff --git a/block/block-backend.c b/block/block-backend.c
index 1a724a8..66387f0 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -389,6 +389,11 @@  BlockDriverState *blk_bs(BlockBackend *blk)
     return blk->root ? blk->root->bs : NULL;
 }
 
+BdrvChild *blk_root(BlockBackend *blk)
+{
+    return blk->root;
+}
+
 static BlockBackend *bdrv_first_blk(BlockDriverState *bs)
 {
     BdrvChild *child;
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index b07159b..867f9f5 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -99,6 +99,7 @@  void blk_remove_bs(BlockBackend *blk);
 void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
 bool bdrv_has_blk(BlockDriverState *bs);
 bool bdrv_is_root_node(BlockDriverState *bs);
+BdrvChild *blk_root(BlockBackend *blk);
 
 void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
 void blk_iostatus_enable(BlockBackend *blk);