1d551cd50SStefan Hajnoczi#!/bin/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 Hajnoczihere=`pwd` 31d551cd50SStefan Hajnoczitmp=/tmp/$$ 32d551cd50SStefan Hajnoczistatus=1 # failure is the default! 33d551cd50SStefan Hajnoczi 34d551cd50SStefan Hajnoczi_cleanup() 35d551cd50SStefan Hajnoczi{ 36d551cd50SStefan Hajnoczi _cleanup_test_img 37d551cd50SStefan Hajnoczi} 38d551cd50SStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15 39d551cd50SStefan Hajnoczi 40d551cd50SStefan Hajnoczi# get standard environment, filters and checks 41d551cd50SStefan Hajnoczi. ./common.rc 42d551cd50SStefan Hajnoczi. ./common.filter 43d551cd50SStefan Hajnoczi. ./common.pattern 44d551cd50SStefan Hajnoczi 45d551cd50SStefan Hajnoczi# This tests qcow2-specific low-level functionality 46d551cd50SStefan Hajnoczi_supported_fmt qcow2 471f7bf7d0SPeter Lieven_supported_proto file 48d551cd50SStefan Hajnoczi_supported_os Linux 49d551cd50SStefan Hajnoczi 50d551cd50SStefan Hajnoczi# Only qcow2v3 and later supports feature bits 51d551cd50SStefan HajnocziIMGOPTS="compat=1.1" 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 60*b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 6112ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" dump-header 6212ac6d3dSKevin Wolf_img_info 6312ac6d3dSKevin Wolf 6412ac6d3dSKevin Wolf# With feature table containing bit 63 6512ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 6612ac6d3dSKevin Wolf_img_info 6712ac6d3dSKevin Wolf 6812ac6d3dSKevin Wolfecho 6912ac6d3dSKevin Wolfecho === Image with multiple incompatible feature bits === 7012ac6d3dSKevin Wolfecho 7112ac6d3dSKevin Wolf_make_test_img 64M 7212ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 61 7312ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 62 7412ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 7512ac6d3dSKevin Wolf 7612ac6d3dSKevin Wolf# Without feature table 77*b527c9b3SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 7812ac6d3dSKevin Wolf_img_info 7912ac6d3dSKevin Wolf 8012ac6d3dSKevin Wolf# With feature table containing bit 63 8112ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 8212ac6d3dSKevin Wolf_img_info 8312ac6d3dSKevin Wolf 8412ac6d3dSKevin Wolf# With feature table containing bit 61 8512ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 8612ac6d3dSKevin Wolfprintf "\x00\x3d%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 8712ac6d3dSKevin Wolf_img_info 8812ac6d3dSKevin Wolf 8912ac6d3dSKevin Wolf# With feature table containing bits 61 and 62 9012ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 9112ac6d3dSKevin Wolfprintf "\x00\x3d%s\x00%40s\x00\x3e%s\x00%40s" "test1" "" "test2" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 9212ac6d3dSKevin Wolf_img_info 9312ac6d3dSKevin Wolf 9412ac6d3dSKevin Wolf# With feature table containing all bits 9512ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 9612ac6d3dSKevin 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 9712ac6d3dSKevin Wolf_img_info 9812ac6d3dSKevin Wolf 9912ac6d3dSKevin Wolf# With feature table containing unrelated bits, including compatible/autoclear 10012ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 10112ac6d3dSKevin 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 10212ac6d3dSKevin Wolf_img_info 10312ac6d3dSKevin Wolf 10412ac6d3dSKevin Wolf 105d551cd50SStefan Hajnocziecho === Create image with unknown autoclear feature bit === 106d551cd50SStefan Hajnocziecho 107d551cd50SStefan Hajnoczi_make_test_img 64M 108ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 109ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header 110d551cd50SStefan Hajnoczi 111d551cd50SStefan Hajnocziecho 112d551cd50SStefan Hajnocziecho === Repair image === 113d551cd50SStefan Hajnocziecho 114c6bb9ad1SFederico Simoncelli_check_test_img -r all 115c6bb9ad1SFederico Simoncelli 116ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header 117d551cd50SStefan Hajnoczi 118d551cd50SStefan Hajnoczi# success, all done 119d551cd50SStefan Hajnocziecho "*** done" 120d551cd50SStefan Hajnoczirm -f $seq.full 121d551cd50SStefan Hajnoczistatus=0 122