1d551cd50SStefan Hajnoczi#!/bin/bash 2d551cd50SStefan Hajnoczi# 3*12ac6d3dSKevin 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 53*12ac6d3dSKevin Wolfecho 54*12ac6d3dSKevin Wolfecho === Image with unknown incompatible feature bit === 55*12ac6d3dSKevin Wolfecho 56*12ac6d3dSKevin Wolf_make_test_img 64M 57*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 58*12ac6d3dSKevin Wolf 59*12ac6d3dSKevin Wolf# Without feature table 60*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" dump-header 61*12ac6d3dSKevin Wolf_img_info 62*12ac6d3dSKevin Wolf 63*12ac6d3dSKevin Wolf# With feature table containing bit 63 64*12ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 65*12ac6d3dSKevin Wolf_img_info 66*12ac6d3dSKevin Wolf 67*12ac6d3dSKevin Wolfecho 68*12ac6d3dSKevin Wolfecho === Image with multiple incompatible feature bits === 69*12ac6d3dSKevin Wolfecho 70*12ac6d3dSKevin Wolf_make_test_img 64M 71*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 61 72*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 62 73*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 74*12ac6d3dSKevin Wolf 75*12ac6d3dSKevin Wolf# Without feature table 76*12ac6d3dSKevin Wolf_img_info 77*12ac6d3dSKevin Wolf 78*12ac6d3dSKevin Wolf# With feature table containing bit 63 79*12ac6d3dSKevin Wolfprintf "\x00\x3f%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 80*12ac6d3dSKevin Wolf_img_info 81*12ac6d3dSKevin Wolf 82*12ac6d3dSKevin Wolf# With feature table containing bit 61 83*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 84*12ac6d3dSKevin Wolfprintf "\x00\x3d%s" "Test feature" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 85*12ac6d3dSKevin Wolf_img_info 86*12ac6d3dSKevin Wolf 87*12ac6d3dSKevin Wolf# With feature table containing bits 61 and 62 88*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 89*12ac6d3dSKevin Wolfprintf "\x00\x3d%s\x00%40s\x00\x3e%s\x00%40s" "test1" "" "test2" "" | $PYTHON qcow2.py "$TEST_IMG" add-header-ext-stdio 0x6803f857 90*12ac6d3dSKevin Wolf_img_info 91*12ac6d3dSKevin Wolf 92*12ac6d3dSKevin Wolf# With feature table containing all bits 93*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 94*12ac6d3dSKevin 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 95*12ac6d3dSKevin Wolf_img_info 96*12ac6d3dSKevin Wolf 97*12ac6d3dSKevin Wolf# With feature table containing unrelated bits, including compatible/autoclear 98*12ac6d3dSKevin Wolf$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 99*12ac6d3dSKevin 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 100*12ac6d3dSKevin Wolf_img_info 101*12ac6d3dSKevin Wolf 102*12ac6d3dSKevin 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 107ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header 108d551cd50SStefan Hajnoczi 109d551cd50SStefan Hajnocziecho 110d551cd50SStefan Hajnocziecho === Repair image === 111d551cd50SStefan Hajnocziecho 112c6bb9ad1SFederico Simoncelli_check_test_img -r all 113c6bb9ad1SFederico Simoncelli 114ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header 115d551cd50SStefan Hajnoczi 116d551cd50SStefan Hajnoczi# success, all done 117d551cd50SStefan Hajnocziecho "*** done" 118d551cd50SStefan Hajnoczirm -f $seq.full 119d551cd50SStefan Hajnoczistatus=0 120