On Mon 19 Oct 2015 05:04:50 PM CEST, Kevin Wolf <kw...@redhat.com> wrote: >> > So we seem to have two criteria to distinguish BDSes: >> > >> > 1. Does/Doesn't have a BlockBackend on top. >> > In the future, multiple BlockBackends are possible, too. >> >> One single BDS attached to multiple BlockBackends at the same time? >> What's the use case? > > For having multiple users of the BDS, e.g. a guest device and an NBD > server. > > Or sometimes maybe just because it's the logical thing to happen: > Imagine an image B with a backing file A. Both have a BlockBackend on > them. Do a live commit of B into A. On completion, the BDS B is > deleted and both BBs point to A.
Can you have a BlockBackend on a BDS that is being used as a backing file? What is that for? And can you even write to it? >> > I haven't thought about it enough yet, but it seems to me that we >> > can't do the BDS/BB aliasing with blockdev-del, but need to interpret >> > node-name as BDS and id as BB. Perhaps we also shouldn't use a single >> > 'device' option then, but a union of 'node-name' and 'id' (just like >> > the same devices were created in blockdev-add). >> >> Having two separate options could make things more clear, indeed. > > Note that it doesn't improve things with your generalised rule (if I got > it right anyway). > > So I think these are the options we have: > > a) blockdev-del only works on a BDS or empty BB without any references. > Before deleting a BDS, it must be ejected from the BB; before > deleting a BB, its BDS must be ejected. > > b) Your rule: Same as a), but treating BB and BDS as a unit if the BDS > is only referenced by the BB. > > c) No aliasing. You explicitly refer to a BB or to a BDS. The difference > from A is that it works without an explicit eject: When a BDS is > deleted, it is automatically ejected from the BB; and when the BB is > deleted, the BDS stays around if it still has other references. I'm currently thinking about d), which tries to maintain the symmetry with blockdev-add: - blockdev-del would have two parameters, 'id' and 'node-name', and only one of them can be set, so you must choose whether you want to delete a backend or a BDS. - blockdev-add can either create a backend with a BDS, or a BDS alone, so: - If you created a backend and you try to delete it you can do it (along with its BDS) as long as neither the backend nor the BDS are being used (no extra references, no parents). This means that the operation will fail if there's a BDS that has been created separately and manually attached to the the backend. - If you created a BDS alone and you try to delete it you can do it as long as no one else is using it. This would delete the BDS and only the BDS (because that's what you create with blockdev-add). If it's currently attached to a backend then the operation fails. I think this is what best mirrors blockdev-add. It however has the following consequence: blockdev-add id=drive0 node-name=node0 ... blockdev-del node-name=node0 <-- This fails, node0 is used by drive0 blockdev-del id=drive0 <-- This works and removes drive0 and node0 Berto