On 01/27/2015 12:45 PM, Max Reitz wrote: > If there is no BlockDriverState in a BlockBackend or if the tray of the > guest device is open, fail all requests (where that is possible) with > -ENOMEDIUM. > > The reason the status of the guest device is taken into account is > because once the guest device's tray is opened, any request on the same > BlockBackend as the guest uses should fail. If the BDS tree is supposed > to be usable even after ejecting it from the guest, a different > BlockBackend must be used. > > Signed-off-by: Max Reitz > --- > block/block-backend.c | 43 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > @@ -635,6 +635,10 @@ int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count) > > int64_t blk_getlength(BlockBackend *blk) > { > + if (!blk_is_available(blk)) { > + return -ENOMEDIUM; > + } > + > return bdrv_getlength(blk->bs); > } If you add blk_nb_sectors, it will probably need the same treatment. Reviewed-by: Eric Blake -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org