From 9ffa9f42dd630e01a507905b60cc7f45d8326327 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 30 Nov 2017 16:17:47 +0100 Subject: [PATCH 08/36] block: don't add 'driver' to options when referring to backing via node name RH-Author: Kevin Wolf Message-id: <20171130161747.18388-2-kwolf@redhat.com> Patchwork-id: 78023 O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH 1/1] block: don't add 'driver' to options when referring to backing via node name Bugzilla: 1505701 RH-Acked-by: Jeffrey Cody RH-Acked-by: Max Reitz RH-Acked-by: John Snow From: Peter Krempa When referring to a backing file of an image via node name bdrv_open_backing_file would add the 'driver' option to the option list filling it with the backing format driver. This breaks construction of the backing chain via -blockdev, as bdrv_open_inherit reports an error if both 'reference' and 'options' are provided. $ qemu-img create -f raw /tmp/backing.raw 64M $ qemu-img create -f qcow2 -F raw -b /tmp/backing.raw /tmp/test.qcow2 $ qemu-system-x86_64 \ -blockdev driver=file,filename=/tmp/backing.raw,node-name=backing \ -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing qemu-system-x86_64: -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing: Could not open backing file: Cannot reference an existing block device with additional options or a new filename Signed-off-by: Peter Krempa Signed-off-by: Kevin Wolf (cherry picked from commit 6bff597bf6580ecc691258e849f652911dbdda7c) Signed-off-by: Miroslav Rezanina --- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 3308814..6fb4e98 100644 --- a/block.c +++ b/block.c @@ -2178,7 +2178,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, goto free_exit; } - if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { + if (!reference && + bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { qdict_put_str(options, "driver", bs->backing_format); } -- 1.8.3.1