Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > There are several BlockBackend functions which, in theory, cannot fail. > This patch makes them cope with the BlockDriverState pointer being NULL > by making them fall back to some default action like ignoring the value > in setters and returning the default in getters. > > Signed-off-by: Max Reitz <mre...@redhat.com> > Reviewed-by: Eric Blake <ebl...@redhat.com>
Hm, okay, maybe bdrv_drain() belongs here. I just reviewed the end result for completeness and didn't check which patch did what. > int blk_enable_write_cache(BlockBackend *blk) > { > + if (!blk->bs) { > + return 0; > + } > + > return bdrv_enable_write_cache(blk->bs); > } > > void blk_set_enable_write_cache(BlockBackend *blk, bool wce) > { > - bdrv_set_enable_write_cache(blk->bs, wce); > + if (blk->bs) { > + bdrv_set_enable_write_cache(blk->bs, wce); > + } > } WCE is part of the open_flags in BlockBackendRootState. The root state doesn't seem to be used yet, and I wrote about my concerns about it in reply to an earlier patch, but as long as we have it, should this query/modify the root state if no BDS is attached? Kevin