[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursi
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursive |
Date: |
Wed, 30 Sep 2015 16:32:36 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 29.09.2015 11:15, Alberto Garcia wrote:
> On Fri 18 Sep 2015 05:22:42 PM CEST, Max Reitz wrote:
>> If bdrv_is_inserted() is called on the top level BDS, it should make
>> sure all nodes in the BDS tree are actually inserted.
>>
>> Signed-off-by: Max Reitz <address@hidden>
>> ---
>> block.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index 4a089e6..c4fa299 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -3247,14 +3247,20 @@ void bdrv_invalidate_cache_all(Error **errp)
>> bool bdrv_is_inserted(BlockDriverState *bs)
>> {
>> BlockDriver *drv = bs->drv;
>> + BdrvChild *child;
>>
>> if (!drv) {
>> return false;
>> }
>> - if (!drv->bdrv_is_inserted) {
>> - return true;
>> + if (drv->bdrv_is_inserted) {
>> + return drv->bdrv_is_inserted(bs);
>> }
>
> If there's drv->bdrv_is_inserted then this code stops here and does not
> iterate the children, is this correct?
Yes, that is how it's supposed to be.
Max
>> - return drv->bdrv_is_inserted(bs);
>> + QLIST_FOREACH(child, &bs->children, next) {
>> + if (!bdrv_is_inserted(child->bs)) {
>> + return false;
>> + }
>> + }
>> + return true;
>> }
>
> Berto
>
signature.asc
Description: OpenPGP digital signature