147e5df21SKevin Wolf#!/bin/bash 247e5df21SKevin Wolf# 347e5df21SKevin Wolf# Test command line configuration of block devices and driver-specific options 447e5df21SKevin Wolf# 547e5df21SKevin Wolf# Copyright (C) 2013 Red Hat, Inc. 647e5df21SKevin Wolf# 747e5df21SKevin Wolf# This program is free software; you can redistribute it and/or modify 847e5df21SKevin Wolf# it under the terms of the GNU General Public License as published by 947e5df21SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 1047e5df21SKevin Wolf# (at your option) any later version. 1147e5df21SKevin Wolf# 1247e5df21SKevin Wolf# This program is distributed in the hope that it will be useful, 1347e5df21SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 1447e5df21SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1547e5df21SKevin Wolf# GNU General Public License for more details. 1647e5df21SKevin Wolf# 1747e5df21SKevin Wolf# You should have received a copy of the GNU General Public License 1847e5df21SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 1947e5df21SKevin Wolf# 2047e5df21SKevin Wolf 2147e5df21SKevin Wolf# creator 2247e5df21SKevin Wolfowner=kwolf@redhat.com 2347e5df21SKevin Wolf 2447e5df21SKevin Wolfseq=`basename $0` 2547e5df21SKevin Wolfecho "QA output created by $seq" 2647e5df21SKevin Wolf 2747e5df21SKevin Wolfhere=`pwd` 2847e5df21SKevin Wolftmp=/tmp/$$ 2947e5df21SKevin Wolfstatus=1 # failure is the default! 3047e5df21SKevin Wolf 3147e5df21SKevin Wolf_cleanup() 3247e5df21SKevin Wolf{ 3347e5df21SKevin Wolf _cleanup_test_img 3447e5df21SKevin Wolf} 3547e5df21SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 3647e5df21SKevin Wolf 3747e5df21SKevin Wolf# get standard environment, filters and checks 3847e5df21SKevin Wolf. ./common.rc 3947e5df21SKevin Wolf. ./common.filter 4047e5df21SKevin Wolf 4147e5df21SKevin Wolf_supported_fmt qcow2 4247e5df21SKevin Wolf_supported_proto file 4347e5df21SKevin Wolf_supported_os Linux 4447e5df21SKevin Wolf 4547e5df21SKevin Wolffunction do_run_qemu() 4647e5df21SKevin Wolf{ 4747e5df21SKevin Wolf echo Testing: "$@" 4847e5df21SKevin Wolf echo quit | $QEMU -nographic -monitor stdio -serial none "$@" 4947e5df21SKevin Wolf echo 5047e5df21SKevin Wolf} 5147e5df21SKevin Wolf 5247e5df21SKevin Wolffunction run_qemu() 5347e5df21SKevin Wolf{ 54*c09b437bSStefan Hajnoczi do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu 5547e5df21SKevin Wolf} 5647e5df21SKevin Wolf 5747e5df21SKevin Wolfsize=128M 5847e5df21SKevin Wolf 5947e5df21SKevin Wolf_make_test_img $size 6047e5df21SKevin Wolf 6147e5df21SKevin Wolfecho 6247e5df21SKevin Wolfecho === Unknown option === 6347e5df21SKevin Wolfecho 6447e5df21SKevin Wolf 6547e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt= 6647e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=on 6747e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=1234 6847e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=foo 6947e5df21SKevin Wolf 7047e5df21SKevin Wolf 7147e5df21SKevin Wolfecho 7247e5df21SKevin Wolfecho === Enable and disable lazy refcounting on the command line, plus some invalid values === 7347e5df21SKevin Wolfecho 7447e5df21SKevin Wolf 7547e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=on 7647e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=off 7747e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts= 7847e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=42 7947e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=foo 8047e5df21SKevin Wolf 8147e5df21SKevin Wolf 8247e5df21SKevin Wolfecho 8347e5df21SKevin Wolfecho === With version 2 images enabling lazy refcounts must fail === 8447e5df21SKevin Wolfecho 8547e5df21SKevin Wolf 8647e5df21SKevin Wolf_make_test_img -ocompat=0.10 $size 8747e5df21SKevin Wolf 8847e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=on 8947e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=off 9047e5df21SKevin Wolf 9147e5df21SKevin Wolfecho 9247e5df21SKevin Wolfecho === No medium === 9347e5df21SKevin Wolfecho 9447e5df21SKevin Wolf 9547e5df21SKevin Wolfrun_qemu -drive if=floppy 9647e5df21SKevin Wolfrun_qemu -drive if=ide,media=cdrom 9747e5df21SKevin Wolfrun_qemu -drive if=scsi,media=cdrom 9847e5df21SKevin Wolf 9947e5df21SKevin Wolfrun_qemu -drive if=ide 10047e5df21SKevin Wolfrun_qemu -drive if=virtio 10147e5df21SKevin Wolfrun_qemu -drive if=scsi 10247e5df21SKevin Wolf 10347e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-cd,drive=disk 10447e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-cd,drive=disk 10547e5df21SKevin Wolf 10647e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-drive,drive=disk 10747e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-hd,drive=disk 10847e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk 10947e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk 11047e5df21SKevin Wolf 11147e5df21SKevin Wolfecho 11247e5df21SKevin Wolfecho === Read-only === 11347e5df21SKevin Wolfecho 11447e5df21SKevin Wolf 11547e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=floppy,readonly=on 11647e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=ide,media=cdrom,readonly=on 11747e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=scsi,media=cdrom,readonly=on 11847e5df21SKevin Wolf 11947e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=ide,readonly=on 12047e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=virtio,readonly=on 12147e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=scsi,readonly=on 12247e5df21SKevin Wolf 12347e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-cd,drive=disk 12447e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-cd,drive=disk 12547e5df21SKevin Wolf 12647e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-drive,drive=disk 12747e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-hd,drive=disk 12847e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk 12947e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-hd,drive=disk 13047e5df21SKevin Wolf 13147e5df21SKevin Wolfecho 13247e5df21SKevin Wolfecho === Cache modes === 13347e5df21SKevin Wolfecho 13447e5df21SKevin Wolf 13547e5df21SKevin Wolf# Cannot use the test image because cache=none might not work on the host FS 13647e5df21SKevin Wolf# Use cdrom so that we won't get errors about missing media 13747e5df21SKevin Wolf 13847e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=none 13947e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=directsync 14047e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=writeback 14147e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=writethrough 14247e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=unsafe 14347e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=invalid_value 14447e5df21SKevin Wolf 14547e5df21SKevin Wolf# success, all done 14647e5df21SKevin Wolfecho "*** done" 14747e5df21SKevin Wolfrm -f $seq.full 14847e5df21SKevin Wolfstatus=0 149