Message ID | 1442589793-7105-8-git-send-email-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
On 09/18/2015 09:22 AM, 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 <mreitz@redhat.com> > --- > block.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > Reviewed-by: Eric Blake <eblake@redhat.com>
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 <mreitz@redhat.com> > --- > 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? > - return drv->bdrv_is_inserted(bs); > + QLIST_FOREACH(child, &bs->children, next) { > + if (!bdrv_is_inserted(child->bs)) { > + return false; > + } > + } > + return true; > } Berto
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 <mreitz@redhat.com> >> --- >> 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 >
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); } - return drv->bdrv_is_inserted(bs); + QLIST_FOREACH(child, &bs->children, next) { + if (!bdrv_is_inserted(child->bs)) { + return false; + } + } + return true; } /**
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 <mreitz@redhat.com> --- block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)