From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuP7P-0001oU-Us for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:18:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuP7P-0005vO-2w for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:18:39 -0500 From: Kevin Wolf Date: Thu, 5 Nov 2015 19:17:47 +0100 Message-Id: <1446747485-6562-20-git-send-email-kwolf@redhat.com> In-Reply-To: <1446747485-6562-1-git-send-email-kwolf@redhat.com> References: <1446747485-6562-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 19/37] block: support passing 'backing': '' to 'blockdev-add' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Alberto Garcia Passing an empty string allows opening an image but not its backing file. This was already described in the API documentation, only the implementation was missing. This is useful for creating snapshots using images opened with blockdev-add, since they are not supposed to have a backing image before the operation. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Reviewed-by: Jeff Cody Signed-off-by: Kevin Wolf --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index a99e6d8..3493501 100644 --- a/block.c +++ b/block.c @@ -1393,6 +1393,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, BlockDriverState *bs; BlockDriver *drv = NULL; const char *drvname; + const char *backing; Error *local_err = NULL; int snapshot_flags = 0; @@ -1460,6 +1461,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + backing = qdict_get_try_str(options, "backing"); + if (backing && *backing == '\0') { + flags |= BDRV_O_NO_BACKING; + qdict_del(options, "backing"); + } + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); -- 1.8.3.1