If set to true, the image will be opened with the BDRV_O_NO_BACKING flag. 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 <be...@igalia.com> --- block.c | 5 +++++ qapi/block-core.json | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 22d3b0e..4be32fb 100644 --- a/block.c +++ b/block.c @@ -1469,6 +1469,11 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + if (qdict_get_try_bool(options, "ignore-backing", false)) { + flags |= BDRV_O_NO_BACKING; + } + qdict_del(options, "ignore-backing"); + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); diff --git a/qapi/block-core.json b/qapi/block-core.json index ec50f06..0f797d7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1498,11 +1498,15 @@ # allowed to pass an empty string here in order to disable the # default backing file. # +# @ignore-backing: #optional if true, no backing file will be +# opened. Defaults to false (Since 2.5) +# # Since: 1.7 ## { 'struct': 'BlockdevOptionsGenericCOWFormat', 'base': 'BlockdevOptionsGenericFormat', - 'data': { '*backing': 'BlockdevRef' } } + 'data': { '*backing': 'BlockdevRef', + '*ignore-backing': 'bool' } } ## # @Qcow2OverlapCheckMode -- 2.5.1