Received: from eggs.gnu.org ([2001:4830:134:3::10]:55542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYue7-0007cH-3c for qemu-devel@nongnu.org; Mon, 07 Sep 2015 07:31:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYue3-0003h9-U8 for qemu-devel@nongnu.org; Mon, 07 Sep 2015 07:31:35 -0400 From: Alberto Garcia In-Reply-To: <55E9ADC9.3000404@redhat.com> References: <55E9ADC9.3000404@redhat.com> Date: Mon, 07 Sep 2015 13:31:13 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz On Fri 04 Sep 2015 04:42:17 PM CEST, Eric Blake wrote: >> + if (snapshot_ref) { >> + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) { >> error_propagate(errp, local_err); >> return; >> } >> } > > Shouldn't you also check that snapshot_ref does not currently have a > backing BDS (as it is the act of creating the snapshot that sets the > current device as the backing of the snapshot_ref BDS before altering > the BB to point to snapshot_ref as its new BDS)? Wait, I actually think that it should have a backing BDS. This new command is roughly equivalent to the 'existing' mode of the 'blockdev-snapshot-sync' command, so the new image must be created externally in both cases having the current image as its backing file. The difference is that 'blockdev-snapshot-sync' will open the new image and not its backing chain (using the BDRV_O_NO_BACKING flag), but in 'blockdev-snapshot' the image must be opened previously with 'blockdev-add', which will open the whole chain. So I think that we should expect a backing image and we have to unref it during the 'commit' part of the transaction (before bdrv_append()). Berto