xref: /qemu/tests/qemu-iotests/036 (revision 3be2024aefe0024ada2fb5044c230c867ef59c67)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2d551cd50SStefan Hajnoczi#
312ac6d3dSKevin Wolf# Test qcow2 feature bits
4d551cd50SStefan Hajnoczi#
5d551cd50SStefan Hajnoczi# Copyright (C) 2011 Red Hat, Inc.
6d551cd50SStefan Hajnoczi# Copyright IBM, Corp. 2010
7d551cd50SStefan Hajnoczi#
8d551cd50SStefan Hajnoczi# Based on test 031.
9d551cd50SStefan Hajnoczi#
10d551cd50SStefan Hajnoczi# This program is free software; you can redistribute it and/or modify
11d551cd50SStefan Hajnoczi# it under the terms of the GNU General Public License as published by
12d551cd50SStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or
13d551cd50SStefan Hajnoczi# (at your option) any later version.
14d551cd50SStefan Hajnoczi#
15d551cd50SStefan Hajnoczi# This program is distributed in the hope that it will be useful,
16d551cd50SStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of
17d551cd50SStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18d551cd50SStefan Hajnoczi# GNU General Public License for more details.
19d551cd50SStefan Hajnoczi#
20d551cd50SStefan Hajnoczi# You should have received a copy of the GNU General Public License
21d551cd50SStefan Hajnoczi# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22d551cd50SStefan Hajnoczi#
23d551cd50SStefan Hajnoczi
24d551cd50SStefan Hajnoczi# creator
25d551cd50SStefan Hajnocziowner=stefanha@linux.vnet.ibm.com
26d551cd50SStefan Hajnoczi
27d551cd50SStefan Hajnocziseq=`basename $0`
28d551cd50SStefan Hajnocziecho "QA output created by $seq"
29d551cd50SStefan Hajnoczi
30d551cd50SStefan Hajnoczistatus=1	# failure is the default!
31d551cd50SStefan Hajnoczi
32d551cd50SStefan Hajnoczi_cleanup()
33d551cd50SStefan Hajnoczi{
34d551cd50SStefan Hajnoczi	_cleanup_test_img
35d551cd50SStefan Hajnoczi}
36d551cd50SStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15
37d551cd50SStefan Hajnoczi
38d551cd50SStefan Hajnoczi# get standard environment, filters and checks
39d551cd50SStefan Hajnoczi. ./common.rc
40d551cd50SStefan Hajnoczi. ./common.filter
41d551cd50SStefan Hajnoczi. ./common.pattern
42d551cd50SStefan Hajnoczi
43d551cd50SStefan Hajnoczi# This tests qcow2-specific low-level functionality
44d551cd50SStefan Hajnoczi_supported_fmt qcow2
451f7bf7d0SPeter Lieven_supported_proto file
46*3be2024aSMax Reitz# Only qcow2v3 and later supports feature bits;
47*3be2024aSMax Reitz# qcow2.py does not support external data files
48*3be2024aSMax Reitz_unsupported_imgopts 'compat=0.10' data_file
49d551cd50SStefan Hajnoczi
5012ac6d3dSKevin Wolfecho
5112ac6d3dSKevin Wolfecho === Image with unknown incompatible feature bit ===
5212ac6d3dSKevin Wolfecho
5312ac6d3dSKevin Wolf_make_test_img 64M
5412ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
5512ac6d3dSKevin Wolf
5612ac6d3dSKevin Wolf# Without feature table
57b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
587ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
597ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
6012ac6d3dSKevin Wolf_img_info
6112ac6d3dSKevin Wolf
6212ac6d3dSKevin Wolf# With feature table containing bit 63
6312ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
6412ac6d3dSKevin Wolf_img_info
6512ac6d3dSKevin Wolf
6612ac6d3dSKevin Wolfecho
6712ac6d3dSKevin Wolfecho === Image with multiple incompatible feature bits ===
6812ac6d3dSKevin Wolfecho
6912ac6d3dSKevin Wolf_make_test_img 64M
7012ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 61
7112ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 62
7212ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
7312ac6d3dSKevin Wolf
7412ac6d3dSKevin Wolf# Without feature table
75b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
7612ac6d3dSKevin Wolf_img_info
7712ac6d3dSKevin Wolf
7812ac6d3dSKevin Wolf# With feature table containing bit 63
7912ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
8012ac6d3dSKevin Wolf_img_info
8112ac6d3dSKevin Wolf
8212ac6d3dSKevin Wolf# With feature table containing bit 61
8312ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
8412ac6d3dSKevin Wolfprintf "\x00\x3d%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
8512ac6d3dSKevin Wolf_img_info
8612ac6d3dSKevin Wolf
8712ac6d3dSKevin Wolf# With feature table containing bits 61 and 62
8812ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
8912ac6d3dSKevin Wolfprintf "\x00\x3d%s\x00%40s\x00\x3e%s\x00%40s" "test1" "" "test2" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
9012ac6d3dSKevin Wolf_img_info
9112ac6d3dSKevin Wolf
9212ac6d3dSKevin Wolf# With feature table containing all bits
9312ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
9412ac6d3dSKevin Wolfprintf "\x00\x3d%s\x00%40s\x00\x3e%s\x00%40s\x00\x3f%s\x00%40s" "test1" "" "test2" "" "test3" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
9512ac6d3dSKevin Wolf_img_info
9612ac6d3dSKevin Wolf
9712ac6d3dSKevin Wolf# With feature table containing unrelated bits, including compatible/autoclear
9812ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
9912ac6d3dSKevin Wolfprintf "\x01\x3d%s\x00%40s\x00\x3e%s\x00%40s\x02\x3f%s\x00%40s\x00\x3c%s\x00%40s" "test1" "" "test2" "" "test3" "" "test4" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857
10012ac6d3dSKevin Wolf_img_info
10112ac6d3dSKevin Wolf
10212ac6d3dSKevin Wolf
103d551cd50SStefan Hajnocziecho === Create image with unknown autoclear feature bit ===
104d551cd50SStefan Hajnocziecho
105d551cd50SStefan Hajnoczi_make_test_img 64M
106ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63
1077ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
1087ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
109d551cd50SStefan Hajnoczi
110d551cd50SStefan Hajnocziecho
111d551cd50SStefan Hajnocziecho === Repair image ===
112d551cd50SStefan Hajnocziecho
113c6bb9ad1SFederico Simoncelli_check_test_img -r all
114c6bb9ad1SFederico Simoncelli
1157ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
1167ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
117d551cd50SStefan Hajnoczi
118d551cd50SStefan Hajnoczi# success, all done
119d551cd50SStefan Hajnocziecho "*** done"
120d551cd50SStefan Hajnoczirm -f $seq.full
121d551cd50SStefan Hajnoczistatus=0
122