111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick 3d551cd50SStefan Hajnoczi# 412ac6d3dSKevin Wolf# Test qcow2 feature bits 5d551cd50SStefan Hajnoczi# 6d551cd50SStefan Hajnoczi# Copyright (C) 2011 Red Hat, Inc. 7d551cd50SStefan Hajnoczi# Copyright IBM, Corp. 2010 8d551cd50SStefan Hajnoczi# 9d551cd50SStefan Hajnoczi# Based on test 031. 10d551cd50SStefan Hajnoczi# 11d551cd50SStefan Hajnoczi# This program is free software; you can redistribute it and/or modify 12d551cd50SStefan Hajnoczi# it under the terms of the GNU General Public License as published by 13d551cd50SStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or 14d551cd50SStefan Hajnoczi# (at your option) any later version. 15d551cd50SStefan Hajnoczi# 16d551cd50SStefan Hajnoczi# This program is distributed in the hope that it will be useful, 17d551cd50SStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of 18d551cd50SStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19d551cd50SStefan Hajnoczi# GNU General Public License for more details. 20d551cd50SStefan Hajnoczi# 21d551cd50SStefan Hajnoczi# You should have received a copy of the GNU General Public License 22d551cd50SStefan Hajnoczi# along with this program. If not, see <http://www.gnu.org/licenses/>. 23d551cd50SStefan Hajnoczi# 24d551cd50SStefan Hajnoczi 25d551cd50SStefan Hajnoczi# creator 26*42a5009dSJohn Snowowner=stefanha@redhat.com 27d551cd50SStefan Hajnoczi 28d551cd50SStefan Hajnocziseq=`basename $0` 29d551cd50SStefan Hajnocziecho "QA output created by $seq" 30d551cd50SStefan Hajnoczi 31d551cd50SStefan Hajnoczistatus=1 # failure is the default! 32d551cd50SStefan Hajnoczi 33d551cd50SStefan Hajnoczi_cleanup() 34d551cd50SStefan Hajnoczi{ 35d551cd50SStefan Hajnoczi _cleanup_test_img 36d551cd50SStefan Hajnoczi} 37d551cd50SStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15 38d551cd50SStefan Hajnoczi 39d551cd50SStefan Hajnoczi# get standard environment, filters and checks 40d551cd50SStefan Hajnoczi. ./common.rc 41d551cd50SStefan Hajnoczi. ./common.filter 42d551cd50SStefan Hajnoczi. ./common.pattern 43d551cd50SStefan Hajnoczi 44d551cd50SStefan Hajnoczi# This tests qcow2-specific low-level functionality 45d551cd50SStefan Hajnoczi_supported_fmt qcow2 4657284d2aSMax Reitz_supported_proto file fuse 473be2024aSMax Reitz# Only qcow2v3 and later supports feature bits; 48e7be13adSEric Blake# qcow2.py does not support external data files; 49e7be13adSEric Blake# this test requires a cluster size large enough for the feature table 50e7be13adSEric Blake_unsupported_imgopts 'compat=0.10' data_file \ 51e7be13adSEric Blake 'cluster_size=\(512\|1024\|2048\|4096\)' 52d551cd50SStefan Hajnoczi 5312ac6d3dSKevin Wolfecho 5412ac6d3dSKevin Wolfecho === Image with unknown incompatible feature bit === 5512ac6d3dSKevin Wolfecho 5612ac6d3dSKevin Wolf_make_test_img 64M 5712ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 5812ac6d3dSKevin Wolf 5912ac6d3dSKevin Wolf# Without feature table 60b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 61984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep features 627ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts 6312ac6d3dSKevin Wolf_img_info 6412ac6d3dSKevin Wolf 6512ac6d3dSKevin Wolf# With feature table containing bit 63 6612ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 6712ac6d3dSKevin Wolf_img_info 6812ac6d3dSKevin Wolf 6912ac6d3dSKevin Wolfecho 7012ac6d3dSKevin Wolfecho === Image with multiple incompatible feature bits === 7112ac6d3dSKevin Wolfecho 7212ac6d3dSKevin Wolf_make_test_img 64M 7312ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 61 7412ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 62 7512ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 7612ac6d3dSKevin Wolf 7712ac6d3dSKevin Wolf# Without feature table 78b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 7912ac6d3dSKevin Wolf_img_info 8012ac6d3dSKevin Wolf 8112ac6d3dSKevin Wolf# With feature table containing bit 63 8212ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 8312ac6d3dSKevin Wolf_img_info 8412ac6d3dSKevin Wolf 8512ac6d3dSKevin Wolf# With feature table containing bit 61 8612ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 8712ac6d3dSKevin Wolfprintf "\x00\x3d%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 8812ac6d3dSKevin Wolf_img_info 8912ac6d3dSKevin Wolf 9012ac6d3dSKevin Wolf# With feature table containing bits 61 and 62 9112ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 9212ac6d3dSKevin Wolfprintf "\x00\x3d%s\x00%40s\x00\x3e%s\x00%40s" "test1" "" "test2" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 9312ac6d3dSKevin Wolf_img_info 9412ac6d3dSKevin Wolf 9512ac6d3dSKevin Wolf# With feature table containing all bits 9612ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 9712ac6d3dSKevin 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 9812ac6d3dSKevin Wolf_img_info 9912ac6d3dSKevin Wolf 10012ac6d3dSKevin Wolf# With feature table containing unrelated bits, including compatible/autoclear 10112ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 10212ac6d3dSKevin 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 10312ac6d3dSKevin Wolf_img_info 10412ac6d3dSKevin Wolf 10512ac6d3dSKevin Wolf 106d551cd50SStefan Hajnocziecho === Create image with unknown autoclear feature bit === 107d551cd50SStefan Hajnocziecho 108d551cd50SStefan Hajnoczi_make_test_img 64M 109ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 110984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep features 1117ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts 112d551cd50SStefan Hajnoczi 113d551cd50SStefan Hajnocziecho 114d551cd50SStefan Hajnocziecho === Repair image === 115d551cd50SStefan Hajnocziecho 116c6bb9ad1SFederico Simoncelli_check_test_img -r all 117c6bb9ad1SFederico Simoncelli 118984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep features 1197ab2a258SMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header-exts 120d551cd50SStefan Hajnoczi 121d551cd50SStefan Hajnoczi# success, all done 122d551cd50SStefan Hajnocziecho "*** done" 123d551cd50SStefan Hajnoczirm -f $seq.full 124d551cd50SStefan Hajnoczistatus=0 125