Received: from eggs.gnu.org ([2001:4830:134:3::10]:43264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpELk-00014u-GH for qemu-devel@nongnu.org; Thu, 22 Oct 2015 07:48:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpELj-00026z-Iw for qemu-devel@nongnu.org; Thu, 22 Oct 2015 07:48:04 -0400 Date: Thu, 22 Oct 2015 13:47:53 +0200 From: Kevin Wolf Message-ID: <20151022114753.GH3941@noname.redhat.com> References: <20151019112745.GB5408@noname.redhat.com> <20151019150450.GG5408@noname.redhat.com> <20151022103824.GE3941@noname.redhat.com> <20151022112505.GG3941@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 0/3] Add 'blockdev-del' command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia Cc: qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Am 22.10.2015 um 13:31 hat Alberto Garcia geschrieben: > On Thu 22 Oct 2015 01:25:05 PM CEST, Kevin Wolf wrote: > >> But there's this case that is not so obvious. It involves the new > >> 'blockdev-snapshot' command I'm working on: > >> > >> - blockdev-add id=drive0 node-name=node0 file=hd0.qcow2 > >> - qemu-img create -f qcow2 -b hd0.qcow2 overlay0.qcow2 > >> - blockdev-add node-name=overlay0 file=overlay0.qcow2 > >> - blockdev-snapshot node=hd0 overlay=overlay0 > >> > >> At this point you have drive0 with overlay0 inserted, and hd0 as its > >> backing image. All these operation will fail: > >> > >> - blockdev-del id=drive0 because overlay0 has two references > >> (monitor and block backend) > >> - blockdev-del node=overlay0 for the same reason > >> - blockdev-del node=hd0 because it's a backing image > >> > >> In order to delete all this you need to: > >> > >> - eject device=drive0 overlay0 has one reference left > >> - blockdev-del id=drive0 > >> - blockdev-del node=overlay0 this deletes hd0 as well > >> > >> Does this make sense, or do we need to rethink the semantics a bit more? > > > > Well, it's consistent with what you described above. > > > > The confusing part might be that you could blockdev-del id=drive0 > > originally, but after taking the snapshot it doesn't work any > > more. The only way I can see to remove this effect is that you always > > need to eject the BDS first, even if its only reference is from the BB > > that is going to be deleted. > > > > I guess that would be even clearer rules, but of course it also means > > that it's a bit more cumbersome to use. If it helps avoiding bugs in > > management tools, it might be worth it. > > That would be a good reason to force the user to eject the media > first. Note however that in this case you would still need to delete > overlay0 manually, as it would still have the monitor reference. Yes, but I think that's expected because you had a separate blockdev-add. > However if the snapshot is created using blockdev-snapshot-sync that > problem does not exist because that extra reference is not there. Hm... Actually I see a good question here. It's not clear to me that a BDS created with blockdev-snapshot-sync shouldn't be considered explicit, especially if a node-name was passed. I guess you can bring up good arguments for either behaviour. Kevin