Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Test that temporary backing file overrides (on the command line or in |
| 4 | # blockdev-add) don't replace the original path stored in the image during |
| 5 | # header updates. |
| 6 | # |
| 7 | # Copyright (C) 2015 Red Hat, Inc. |
| 8 | # |
| 9 | # This program is free software; you can redistribute it and/or modify |
| 10 | # it under the terms of the GNU General Public License as published by |
| 11 | # the Free Software Foundation; either version 2 of the License, or |
| 12 | # (at your option) any later version. |
| 13 | # |
| 14 | # This program is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | # GNU General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
| 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | # |
| 22 | |
| 23 | # creator |
| 24 | owner=kwolf@redhat.com |
| 25 | |
| 26 | seq="$(basename $0)" |
| 27 | echo "QA output created by $seq" |
| 28 | |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 29 | status=1 # failure is the default! |
| 30 | |
| 31 | _cleanup() |
| 32 | { |
Jeff Cody | ecfa185 | 2017-04-18 15:42:41 -0400 | [diff] [blame] | 33 | _cleanup_qemu |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 34 | _cleanup_test_img |
| 35 | } |
| 36 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
| 37 | |
| 38 | # get standard environment, filters and checks |
| 39 | . ./common.rc |
| 40 | . ./common.filter |
| 41 | . ./common.qemu |
| 42 | |
| 43 | _supported_fmt qcow2 |
| 44 | _supported_proto generic |
Jeff Cody | a98f49f | 2017-02-14 09:51:42 -0500 | [diff] [blame] | 45 | _unsupported_proto vxhs |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 46 | _supported_os Linux |
Max Reitz | 94254c9 | 2018-01-17 10:54:20 -0600 | [diff] [blame] | 47 | # We are going to use lazy-refcounts |
| 48 | _unsupported_imgopts 'compat=0.10' |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 49 | |
| 50 | qemu_comm_method="monitor" |
| 51 | |
| 52 | |
| 53 | TEST_IMG="$TEST_IMG.orig" _make_test_img 64M |
| 54 | TEST_IMG="$TEST_IMG.base" _make_test_img 64M |
| 55 | _make_test_img 64M |
| 56 | _img_info | _filter_img_info |
| 57 | |
| 58 | echo |
| 59 | echo "=== HMP commit ===" |
| 60 | echo |
| 61 | # bdrv_make_empty() involves a header update for qcow2 |
| 62 | |
| 63 | # Test that a backing file isn't written |
Bo Tu | 137a905 | 2015-07-03 15:28:50 +0800 | [diff] [blame] | 64 | _launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base" |
| 65 | _send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 66 | _send_qemu_cmd $QEMU_HANDLE '' '(qemu)' |
| 67 | _cleanup_qemu |
| 68 | _img_info | _filter_img_info |
| 69 | |
| 70 | # Make sure that if there was a backing file that was just overridden on the |
| 71 | # command line, that backing file is retained, with the right format |
| 72 | _make_test_img -F raw -b "$TEST_IMG.orig" 64M |
Bo Tu | 137a905 | 2015-07-03 15:28:50 +0800 | [diff] [blame] | 73 | _launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT |
| 74 | _send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" |
Kevin Wolf | e4603fe | 2015-04-07 15:03:16 +0200 | [diff] [blame] | 75 | _send_qemu_cmd $QEMU_HANDLE '' '(qemu)' |
| 76 | _cleanup_qemu |
| 77 | _img_info | _filter_img_info |
| 78 | |
| 79 | echo |
| 80 | echo "=== Marking image dirty (lazy refcounts) ===" |
| 81 | echo |
| 82 | |
| 83 | # Test that a backing file isn't written |
| 84 | _make_test_img 64M |
| 85 | $QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io |
| 86 | _img_info | _filter_img_info |
| 87 | |
| 88 | # Make sure that if there was a backing file that was just overridden on the |
| 89 | # command line, that backing file is retained, with the right format |
| 90 | _make_test_img -F raw -b "$TEST_IMG.orig" 64M |
| 91 | $QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,backing.driver=$IMGFMT,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io |
| 92 | _img_info | _filter_img_info |
| 93 | |
| 94 | # success, all done |
| 95 | echo '*** done' |
| 96 | rm -f $seq.full |
| 97 | status=0 |