From dbf231d7b40ebc2dfd9a7c31c46dad6011d9c308 Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Sat, 26 Oct 2019 13:12:21 +0300 Subject: [PATCH 1/4] qemu-iotests/iotests.py: improve assert_qmp message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the two values compared, make it obvious which is found at path, and which is expected. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 075f4739da..6a248472b9 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -731,8 +731,8 @@ class QMPTestCase(unittest.TestCase): self.fail('no match for "%s" in %s' % (str(result), str(value))) else: self.assertEqual(result, value, - 'values not equal "%s" and "%s"' - % (str(result), str(value))) + '"%s" is "%s", expected "%s"' + % (path, str(result), str(value))) def assert_no_active_block_jobs(self): result = self.vm.qmp('query-block-jobs') From d44abcc0f71a08e5777f8d4fe92902dc2eaaa468 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 8 Nov 2019 09:03:59 +0100 Subject: [PATCH 2/4] iotests: Fix "no qualified output" error path The variable for error messages to be displayed is $results, not $reason. Fix 'check' to print the "no qualified output" error message again instead of having a failure without any message telling the user why it failed. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 71fe38834e..90970b0549 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -887,7 +887,7 @@ do if [ ! -f "$reference" ] then status="fail" - reason="no qualified output" + results="no qualified output" err=true else if diff -w "$reference" $tmp.out >/dev/null 2>&1 From ae0f57f0aa03571045a3accc0b22d91a4775e63c Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 8 Nov 2019 09:36:35 +0100 Subject: [PATCH 3/4] block: Remove 'backing': null from bs->{explicit_,}options bs->options and bs->explicit_options shouldn't contain any options for child nodes. bdrv_open_inherited() takes care to remove any options that match a child name after opening the image and the same is done when reopening. However, we miss the case of 'backing': null, which is a child option, but results in no child being created. This means that a 'backing': null remains in bs->options and bs->explicit_options. A typical use for 'backing': null is in live snapshots: blockdev-add for the qcow2 overlay makes sure not to open the backing file (because it is already opened and blockdev-snapshot will attach it). After doing a blockdev-snapshot, bs->options and bs->explicit_options become inconsistent with the actual state (bs has a backing file now, but the options still say null). On the next occasion that the image is reopened, e.g. switching it from read-write to read-only when another snapshot is taken, the option will take effect again and the node incorrectly loses its backing file. Fix bdrv_open_inherited() to remove the 'backing' option from bs->options and bs->explicit_options even for the case where it specifies that no backing file is wanted. Reported-by: Peter Krempa Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Tested-by: Peter Krempa --- block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block.c b/block.c index 4cffc2bc35..473eb6eeaa 100644 --- a/block.c +++ b/block.c @@ -3019,6 +3019,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, "use \"backing\": null instead"); } flags |= BDRV_O_NO_BACKING; + qdict_del(bs->explicit_options, "backing"); + qdict_del(bs->options, "backing"); qdict_del(options, "backing"); } From b1f6a8e180367c945b67c6c9bbcec5c856be3779 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 8 Nov 2019 09:46:03 +0100 Subject: [PATCH 4/4] iotests: Test multiple blockdev-snapshot calls Test that doing a second blockdev-snapshot doesn't make the first overlay's backing file go away. Signed-off-by: Kevin Wolf Reviewed-by: Peter Krempa --- tests/qemu-iotests/273 | 76 +++++++++ tests/qemu-iotests/273.out | 337 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 414 insertions(+) create mode 100755 tests/qemu-iotests/273 create mode 100644 tests/qemu-iotests/273.out diff --git a/tests/qemu-iotests/273 b/tests/qemu-iotests/273 new file mode 100755 index 0000000000..98a672516d --- /dev/null +++ b/tests/qemu-iotests/273 @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# +# Test multiple blockdev-snapshot calls with 'backing': null +# +# Copyright (C) 2019 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +seq=$(basename "$0") +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This is a qcow2 regression test +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +do_run_qemu() +{ + echo Testing: "$@" + $QEMU -nographic -qmp-pretty stdio -nodefaults "$@" + echo +} + +run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | + _filter_generated_node_ids | _filter_imgfmt | _filter_actual_image_size +} + +TEST_IMG="$TEST_IMG.base" _make_test_img 64M +TEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base" +_make_test_img -b "$TEST_IMG.mid" + +run_qemu \ + -blockdev file,node-name=base,filename="$TEST_IMG.base" \ + -blockdev file,node-name=midf,filename="$TEST_IMG.mid" \ + -blockdev '{"driver":"qcow2","node-name":"mid","file":"midf","backing":null}' \ + -blockdev file,node-name=topf,filename="$TEST_IMG" \ + -blockdev '{"driver":"qcow2","file":"topf","node-name":"top","backing":null}' \ +<