On Mon 05 Oct 2015 05:58:14 PM CEST, Kevin Wolf wrote:
> What I recall is that the desired semantics for blockdev-del is that it
> only works if the monitor reference is the only remaining reference and
> that the name blockdev-del is therefore actually not too bad.
>
> The reason why we want this restriction is that otherwise images could
> stay in use without the user even noticing, which is rather dangerous.
> Explicit monitor commands for adding and for removing an image seem to
> be much easier to handle than images disappearing after e.g. a block job
> decided to drop its reference (without any user interaction).
One thing that is new is that we'll soon have the ability to create
BDSs without a BlockBackend using blockdev-add, therefore blockdev-del
could
a) destroy the BlockDriverState if it doesn't have a BlockBackend
and the monitor reference is the only remaining one.
b) remove the BlockDriverState from the backend (that would be
essentially 'blockdev-remove-medium') and destroy the
backend. That would require that the backend is also unused.
blk_get_attached_dev() doesn't seem to be enough because others
can also hold a reference to the backend (e.g. the NBD server).
c) it could also happen that the device name passed to blockdev-del
is that of a BlockBackend that has no BDS attached. In that case
it would simply destroy the BlockBackend as described in b).
Does that sound right?
Berto