Received: from eggs.gnu.org ([2001:4830:134:3::10]:37063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3Cv-0004ZE-Bq for qemu-devel@nongnu.org; Sat, 06 Feb 2016 08:47:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS3Cu-0005Xv-FU for qemu-devel@nongnu.org; Sat, 06 Feb 2016 08:47:25 -0500 Date: Sat, 6 Feb 2016 13:47:17 +0000 From: Alyssa Milburn Message-ID: <20160206134717.GM9530@li141-249.members.linode.com> References: <20160204173639.GA5772@li141-249.members.linode.com> <56B5EF57.2080301@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56B5EF57.2080301@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] blockdev: Unset temporary flag when changing medium. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org, Markus Armbruster On Sat, Feb 06, 2016 at 02:04:23PM +0100, Max Reitz wrote: > On 04.02.2016 18:36, Alyssa Milburn wrote: > > This avoids a 'change' command from the monitor unlink()ing the new > > file if the bdrv was previously snapshotted. > > > > Signed-off-by: Alyssa Milburn > > --- > > blockdev.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/blockdev.c b/blockdev.c > > index be4ca44..d39c2e6 100644 > > --- a/blockdev.c > > +++ b/blockdev.c > > @@ -2514,6 +2514,7 @@ void qmp_blockdev_change_medium(const char *device, const char *filename, > > } > > > > bdrv_flags = blk_get_open_flags_from_root_state(blk); > > + bdrv_flags &= ~BDRV_O_TEMPORARY; > > > > if (!has_read_only) { > > read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; > > > > This patch is correct (thanks!), but I think we want to unset even more > flags, namely BDRV_O_SNAPSHOT, BDRV_O_NO_BACKING, and BDRV_O_PROTOCOL. Thanks. I posted an updated patch with this change (but of course, this is a trivial patch anyway). It's not entirely clear to me which flags should(n't) be preserved and where to do that. Since the snapshotted file is part of a chain (and the original flags are "correct") I wondered if this might not be the ideal fix, but it seems safe/sane to do it here. - Alyssa