summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Garcia2015-10-26 13:27:15 +0100
committerKevin Wolf2015-11-11 16:25:47 +0100
commit3e8c2e57056614933fc5eb022e1d6d0f28071b44 (patch)
tree2a3b6968a1406c4ac4c0e096dcaf7f9c2ab562b9
parentblock: rename BlockdevSnapshot to BlockdevSnapshotSync (diff)
downloadqemu-3e8c2e57056614933fc5eb022e1d6d0f28071b44.tar.gz
qemu-3e8c2e57056614933fc5eb022e1d6d0f28071b44.tar.xz
qemu-3e8c2e57056614933fc5eb022e1d6d0f28071b44.zip
block: support passing 'backing': '' to 'blockdev-add'
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 <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block.c b/block.c
index a99e6d8509..34935015dd 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);