111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw 347e5df21SKevin Wolf# 447e5df21SKevin Wolf# Test command line configuration of block devices and driver-specific options 547e5df21SKevin Wolf# 647e5df21SKevin Wolf# Copyright (C) 2013 Red Hat, Inc. 747e5df21SKevin Wolf# 847e5df21SKevin Wolf# This program is free software; you can redistribute it and/or modify 947e5df21SKevin Wolf# it under the terms of the GNU General Public License as published by 1047e5df21SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 1147e5df21SKevin Wolf# (at your option) any later version. 1247e5df21SKevin Wolf# 1347e5df21SKevin Wolf# This program is distributed in the hope that it will be useful, 1447e5df21SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 1547e5df21SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1647e5df21SKevin Wolf# GNU General Public License for more details. 1747e5df21SKevin Wolf# 1847e5df21SKevin Wolf# You should have received a copy of the GNU General Public License 1947e5df21SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 2047e5df21SKevin Wolf# 2147e5df21SKevin Wolf 2247e5df21SKevin Wolf# creator 2347e5df21SKevin Wolfowner=kwolf@redhat.com 2447e5df21SKevin Wolf 2547e5df21SKevin Wolfseq=`basename $0` 2647e5df21SKevin Wolfecho "QA output created by $seq" 2747e5df21SKevin Wolf 2847e5df21SKevin Wolfstatus=1 # failure is the default! 2947e5df21SKevin Wolf 3047e5df21SKevin Wolf_cleanup() 3147e5df21SKevin Wolf{ 3247e5df21SKevin Wolf _cleanup_test_img 3347e5df21SKevin Wolf} 3447e5df21SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 3547e5df21SKevin Wolf 3647e5df21SKevin Wolf# get standard environment, filters and checks 3747e5df21SKevin Wolf. ./common.rc 3847e5df21SKevin Wolf. ./common.filter 3947e5df21SKevin Wolf 4047e5df21SKevin Wolf_supported_fmt qcow2 4147e5df21SKevin Wolf_supported_proto file 425262caa7SMax Reitz# A compat=0.10 image is created in this test which does not support anything 433be2024aSMax Reitz# other than refcount_bits=16; 44e287a351SVladimir Sementsov-Ogievskiy# it also will not support an external data file and compression type 45e287a351SVladimir Sementsov-Ogievskiy_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file \ 46e287a351SVladimir Sementsov-Ogievskiy compression_type 47c85c6d9eSThomas Huth_require_drivers nbd 4847e5df21SKevin Wolf 490c83471bSThomas Huthif [ "$QEMU_DEFAULT_MACHINE" = "pc" ]; then 500c83471bSThomas Huth _require_devices lsi53c895a 510c83471bSThomas Huthfi 520c83471bSThomas Huth 538cedcffdSEric Blakedo_run_qemu() 5447e5df21SKevin Wolf{ 5547e5df21SKevin Wolf echo Testing: "$@" 564db9c980SFam Zheng ( 574db9c980SFam Zheng if ! test -t 0; then 584db9c980SFam Zheng while read cmd; do 594db9c980SFam Zheng echo $cmd 604db9c980SFam Zheng done 614db9c980SFam Zheng fi 624db9c980SFam Zheng echo quit 634db9c980SFam Zheng ) | $QEMU -nographic -monitor stdio -serial none "$@" 6447e5df21SKevin Wolf echo 6547e5df21SKevin Wolf} 6647e5df21SKevin Wolf 678cedcffdSEric Blakerun_qemu() 6847e5df21SKevin Wolf{ 6969404d9eSKevin Wolf do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | 7069404d9eSKevin Wolf _filter_generated_node_ids | _filter_hmp 7147e5df21SKevin Wolf} 7247e5df21SKevin Wolf 7347e5df21SKevin Wolfsize=128M 74dd87de06SBo Tudevice_id="drive0" 7547e5df21SKevin Wolf 7647e5df21SKevin Wolf_make_test_img $size 771ab39193SJeff Codycp "$TEST_IMG" "$TEST_IMG.orig" 781ab39193SJeff Codymv "$TEST_IMG" "$TEST_IMG.base" 79b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size 8047e5df21SKevin Wolf 8147e5df21SKevin Wolfecho 8247e5df21SKevin Wolfecho === Unknown option === 8347e5df21SKevin Wolfecho 8447e5df21SKevin Wolf 85dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=,if=none,id=$device_id 86dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=on,if=none,id=$device_id 87dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=1234,if=none,id=$device_id 88dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=foo,if=none,id=$device_id 8947e5df21SKevin Wolf 904db9c980SFam Zhengecho 91eb909c7fSKevin Wolfecho === Unknown protocol option === 92eb909c7fSKevin Wolfecho 93eb909c7fSKevin Wolf 94eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt= 95eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=on 96eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=1234 97eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=foo 98eb909c7fSKevin Wolf 99eb909c7fSKevin Wolfecho 10006d22aa3SKevin Wolfecho === Invalid format === 10106d22aa3SKevin Wolfecho 10206d22aa3SKevin Wolf 10306d22aa3SKevin Wolfrun_qemu -drive file="$TEST_IMG",format=foo 10406d22aa3SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=foo 10517b005f1SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=raw,format=qcow2 10680495fdfSMax Reitzrun_qemu -drive file="$TEST_IMG",driver=qcow2,format=qcow2 10706d22aa3SKevin Wolf 10806d22aa3SKevin Wolfecho 109824808ddSKevin Wolfecho === Node names === 110824808ddSKevin Wolfecho 111824808ddSKevin Wolf 112824808ddSKevin Wolf# Maximum length: 31 characters 113824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=x123456789012345678901234567890 114824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=x1234567890123456789012345678901 115824808ddSKevin Wolf 116824808ddSKevin Wolf# First character must be alphabetic 117824808ddSKevin Wolf# Following characters alphanumeric or -._ 118824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=All-Types.of_all0wed_chars 119824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=123foo 120824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=_foo 121824808ddSKevin Wolfrun_qemu -drive file="$TEST_IMG",node-name=foo#12 122824808ddSKevin Wolf 123824808ddSKevin Wolfecho 124354483e5SChristian Borntraegerecho === Device without drive === 125354483e5SChristian Borntraegerecho 126354483e5SChristian Borntraeger 12722329f0dSLaurent Vivierrun_qemu -device virtio-scsi -device scsi-hd 128354483e5SChristian Borntraeger 129354483e5SChristian Borntraegerecho 1304db9c980SFam Zhengecho === Overriding backing file === 1314db9c980SFam Zhengecho 1324db9c980SFam Zheng 133dd87de06SBo Tuecho "info block" | run_qemu -drive file="$TEST_IMG",driver=qcow2,backing.file.filename="$TEST_IMG.orig",if=none,id=$device_id -nodefaults\ 13415489c76SJeff Cody | _filter_generated_node_ids 13547e5df21SKevin Wolf 1368ee79e70SKevin Wolf# Drivers that don't support backing files 1378ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=raw,backing.file.filename="$TEST_IMG.orig" 1388ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",file.backing.driver=file,file.backing.filename="$TEST_IMG.orig" 1398ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",file.backing.driver=qcow2,file.backing.file.filename="$TEST_IMG.orig" 1408ee79e70SKevin Wolf 14147e5df21SKevin Wolfecho 14247e5df21SKevin Wolfecho === Enable and disable lazy refcounting on the command line, plus some invalid values === 14347e5df21SKevin Wolfecho 14447e5df21SKevin Wolf 1457e0db6f4SMax Reitz_make_test_img -o compat=1.1 "$size" 1467e0db6f4SMax Reitz 147fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on 148fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off 149fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts= 150fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=42 151fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=foo 15247e5df21SKevin Wolf 15347e5df21SKevin Wolf 15447e5df21SKevin Wolfecho 15547e5df21SKevin Wolfecho === With version 2 images enabling lazy refcounts must fail === 15647e5df21SKevin Wolfecho 15747e5df21SKevin Wolf 15847e5df21SKevin Wolf_make_test_img -o compat=0.10 $size 15947e5df21SKevin Wolf 160fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on 161fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off 16247e5df21SKevin Wolf 16347e5df21SKevin Wolfecho 16447e5df21SKevin Wolfecho === No medium === 16547e5df21SKevin Wolfecho 16647e5df21SKevin Wolf 167dd87de06SBo Tucase "$QEMU_DEFAULT_MACHINE" in 168dd87de06SBo Tu pc) 16947e5df21SKevin Wolf run_qemu -drive if=floppy 17047e5df21SKevin Wolf run_qemu -drive if=ide,media=cdrom 17147e5df21SKevin Wolf run_qemu -drive if=ide 172dd87de06SBo Tu ;; 173dd87de06SBo Tu *) 174dd87de06SBo Tu ;; 175dd87de06SBo Tuesac 176dd87de06SBo Tu 177dd87de06SBo Turun_qemu -drive if=virtio 17847e5df21SKevin Wolf 179289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in 180289f3ebaSBo Tu pc) 18147e5df21SKevin Wolf run_qemu -drive if=none,id=disk -device ide-cd,drive=disk 18247e5df21SKevin Wolf run_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-cd,drive=disk 18347e5df21SKevin Wolf run_qemu -drive if=none,id=disk -device ide-hd,drive=disk 18447e5df21SKevin Wolf run_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk 185289f3ebaSBo Tu ;; 186289f3ebaSBo Tu *) 187289f3ebaSBo Tu ;; 188289f3ebaSBo Tuesac 18947e5df21SKevin Wolf 19047e5df21SKevin Wolfecho 1916c870535SKevin Wolfecho === Attach to node in non-default iothread === 1926c870535SKevin Wolfecho 1936c870535SKevin Wolf 1946c870535SKevin Wolfcase "$QEMU_DEFAULT_MACHINE" in 1956c870535SKevin Wolf pc) 1966c870535SKevin Wolf iothread="-drive file=$TEST_IMG,if=none,node-name=disk -object iothread,id=thread0 -device virtio-scsi,iothread=thread0,id=virtio-scsi0 -device scsi-hd,bus=virtio-scsi0.0,drive=disk,share-rw=on" 1976c870535SKevin Wolf 1986c870535SKevin Wolf # Can't add a device in the main thread while virtio-scsi0 uses the node 1996c870535SKevin Wolf run_qemu $iothread -device ide-hd,drive=disk,share-rw=on 2006c870535SKevin Wolf run_qemu $iothread -device virtio-blk-pci,drive=disk,share-rw=on 2016c870535SKevin Wolf run_qemu $iothread -device lsi53c895a,id=lsi0 -device scsi-hd,bus=lsi0.0,drive=disk,share-rw=on 2026c870535SKevin Wolf run_qemu $iothread -device virtio-scsi,id=virtio-scsi1 -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on 2036c870535SKevin Wolf 2046c870535SKevin Wolf # virtio-blk enables the iothread only when the driver initialises the 2056c870535SKevin Wolf # device, so a second virtio-blk device can't be added even with the 2066c870535SKevin Wolf # same iothread. virtio-scsi allows this. 207af6400afSKevin Wolf run_qemu $iothread -device virtio-blk-pci,drive=disk,iothread=thread0,share-rw=on 2086c870535SKevin Wolf run_qemu $iothread -device virtio-scsi,id=virtio-scsi1,iothread=thread0 -device scsi-hd,bus=virtio-scsi1.0,drive=disk,share-rw=on 2096c870535SKevin Wolf ;; 2106c870535SKevin Wolf *) 2116c870535SKevin Wolf ;; 2126c870535SKevin Wolfesac 2136c870535SKevin Wolf 2146c870535SKevin Wolfecho 21547e5df21SKevin Wolfecho === Read-only === 21647e5df21SKevin Wolfecho 21747e5df21SKevin Wolf 218289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in 219289f3ebaSBo Tu pc) 220fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=floppy,readonly=on 221fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=ide,media=cdrom,readonly=on 222fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=ide,readonly=on 223289f3ebaSBo Tu ;; 224289f3ebaSBo Tu *) 225289f3ebaSBo Tu ;; 226289f3ebaSBo Tuesac 227289f3ebaSBo Tu 228fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",if=virtio,readonly=on 22947e5df21SKevin Wolf 230289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in 231289f3ebaSBo Tu pc) 232fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device ide-cd,drive=disk 233fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device lsi53c895a -device scsi-cd,drive=disk 234fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device ide-hd,drive=disk 235fef9c191SJeff Cody run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device lsi53c895a -device scsi-hd,drive=disk 236289f3ebaSBo Tu ;; 237289f3ebaSBo Tu *) 238289f3ebaSBo Tu ;; 239289f3ebaSBo Tuesac 24047e5df21SKevin Wolf 24147e5df21SKevin Wolfecho 24247e5df21SKevin Wolfecho === Cache modes === 24347e5df21SKevin Wolfecho 24447e5df21SKevin Wolf 24547e5df21SKevin Wolf# Cannot use the test image because cache=none might not work on the host FS 24647e5df21SKevin Wolf# Use cdrom so that we won't get errors about missing media 24747e5df21SKevin Wolf 248a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,cache=none 249a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,cache=directsync 250a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,cache=writeback 251a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,cache=writethrough 252a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,cache=unsafe 253fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=invalid_value 25447e5df21SKevin Wolf 255768ee459SKevin Wolf# Can't test direct=on here because O_DIRECT might not be supported on this FS 256768ee459SKevin Wolf# Test 142 checks the direct=on cases 257768ee459SKevin Wolf 258768ee459SKevin Wolffor cache in writeback writethrough unsafe invalid_value; do 259b43671f8SEric Blake printf "info block %s\n" '' file backing backing-file | \ 26061de4c68SKevin Wolf run_qemu -drive file="$TEST_IMG",cache=$cache,backing.file.filename="$TEST_IMG.base",backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=$device_id -nodefaults 261768ee459SKevin Wolfdone 262768ee459SKevin Wolf 2632af5ef70SKevin Wolfecho 2642af5ef70SKevin Wolfecho === Specifying the protocol layer === 2652af5ef70SKevin Wolfecho 2662af5ef70SKevin Wolf 267fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",file.driver=file 2682af5ef70SKevin Wolf 26998289620SKevin Wolfecho 270765003dbSKevin Wolfecho === Leaving out required options === 271765003dbSKevin Wolfecho 272765003dbSKevin Wolf 273765003dbSKevin Wolfrun_qemu -drive driver=file 27442dc10f1SMax Reitzrun_qemu -drive driver=file,filename= 275765003dbSKevin Wolfrun_qemu -drive driver=nbd 276765003dbSKevin Wolfrun_qemu -drive driver=raw 277765003dbSKevin Wolfrun_qemu -drive file.driver=file 278765003dbSKevin Wolfrun_qemu -drive file.driver=nbd 279765003dbSKevin Wolfrun_qemu -drive file.driver=raw 280765003dbSKevin Wolfrun_qemu -drive foo=bar 281765003dbSKevin Wolf 282765003dbSKevin Wolfecho 2835abbf0eeSKevin Wolfecho === Specifying both an option and its legacy alias === 2845abbf0eeSKevin Wolfecho 2855abbf0eeSKevin Wolf 2865abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops=1234,throttling.iops-total=5678 2875abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_rd=1234,throttling.iops-read=5678 2885abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_wr=1234,throttling.iops-write=5678 2895abbf0eeSKevin Wolf 2905abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps=1234,throttling.bps-total=5678 2915abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_rd=1234,throttling.bps-read=5678 2925abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_wr=1234,throttling.bps-write=5678 2935abbf0eeSKevin Wolf 2945abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_max=1234,throttling.iops-total-max=5678 2955abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_rd_max=1234,throttling.iops-read-max=5678 2965abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_wr_max=1234,throttling.iops-write-max=5678 2975abbf0eeSKevin Wolf 2985abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_max=1234,throttling.bps-total-max=5678 2995abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_rd_max=1234,throttling.bps-read-max=5678 3005abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_wr_max=1234,throttling.bps-write-max=5678 3015abbf0eeSKevin Wolf 3025abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_size=1234,throttling.iops-size=5678 3035abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",readonly=on,read-only=off 3045abbf0eeSKevin Wolf 3055abbf0eeSKevin Wolfecho 306e9b15550SFam Zhengecho === Catching negative/large throttling values === 307e9b15550SFam Zhengecho 308e9b15550SFam Zheng 309e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",iops=-1 310e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=-2 311e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps_rd=-3 312e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps_rd_max=-3 313e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",throttling.iops-total=-4 314e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",throttling.bps-total=-5 315e9b15550SFam Zheng# These are accepted 316e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=0 317e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1 318e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1000000000000000 319e9b15550SFam Zheng# While these are not 320e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1000000000000001 321e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=9999999999999999 322e9b15550SFam Zheng 323e9b15550SFam Zhengecho 32498289620SKevin Wolfecho === Parsing protocol from file name === 32598289620SKevin Wolfecho 32698289620SKevin Wolf 32798289620SKevin Wolf# Protocol strings are supposed to be parsed from traditional option strings, 32898289620SKevin Wolf# but not when using driver-specific options. We can distinguish them by the 32998289620SKevin Wolf# error message for non-existing files. 33098289620SKevin Wolf 33198289620SKevin Wolfrun_qemu -hda foo:bar 33298289620SKevin Wolfrun_qemu -drive file=foo:bar 33398289620SKevin Wolfrun_qemu -drive file.filename=foo:bar 33498289620SKevin Wolf 335e3fa4bfaSKevin Wolfrun_qemu -hda "file:$TEST_IMG" 336e3fa4bfaSKevin Wolfrun_qemu -drive file="file:$TEST_IMG" 337e3fa4bfaSKevin Wolfrun_qemu -drive file.filename="file:$TEST_IMG" 338e3fa4bfaSKevin Wolf 339f32f988cSKevin Wolfecho 340f32f988cSKevin Wolfecho === Snapshot mode === 341f32f988cSKevin Wolfecho 342f32f988cSKevin Wolf 343f32f988cSKevin Wolf$QEMU_IO -c "write -P 0x11 0 4k" "$TEST_IMG" | _filter_qemu_io 344f32f988cSKevin Wolf 345289f3ebaSBo Tu 346289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="$TEST_IMG",if=none,id=$device_id -snapshot | _filter_qemu_io 347289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="$TEST_IMG",snapshot=on,if=none,id=$device_id | _filter_qemu_io 348289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file.filename="$TEST_IMG",driver=qcow2,snapshot=on,if=none,id=$device_id\ 349289f3ebaSBo Tu | _filter_qemu_io 350289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file.filename="$TEST_IMG",driver=qcow2,if=none,id=$device_id -snapshot\ 351289f3ebaSBo Tu | _filter_qemu_io 352289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="file:$TEST_IMG",if=none,id=$device_id -snapshot | _filter_qemu_io 353289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="file:$TEST_IMG",snapshot=on,if=none,id=$device_id | _filter_qemu_io 354b998875dSKevin Wolf 355b998875dSKevin Wolf# Opening a read-only file r/w with snapshot=on 356b998875dSKevin Wolfchmod u-w "$TEST_IMG" 357289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="$TEST_IMG",if=none,id=$device_id -snapshot | _filter_qemu_io 358289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="$TEST_IMG",snapshot=on,if=none,id=$device_id | _filter_qemu_io 359b998875dSKevin Wolfchmod u+w "$TEST_IMG" 360f32f988cSKevin Wolf 361f32f988cSKevin Wolf$QEMU_IO -c "read -P 0x11 0 4k" "$TEST_IMG" | _filter_qemu_io 362f32f988cSKevin Wolf 363289f3ebaSBo Tuecho "qemu-io $device_id \"write -P 0x22 0 4k\"" | run_qemu -drive file="$TEST_IMG",snapshot=off,if=none,id=$device_id | _filter_qemu_io 364f32f988cSKevin Wolf 365f32f988cSKevin Wolf$QEMU_IO -c "read -P 0x22 0 4k" "$TEST_IMG" | _filter_qemu_io 366f32f988cSKevin Wolf 367b43671f8SEric Blakeprintf %b "qemu-io $device_id \"write -P 0x33 0 4k\"\ncommit $device_id\n" | 368b43671f8SEric Blake run_qemu -drive file="$TEST_IMG",snapshot=on,if=none,id=$device_id | 369b43671f8SEric Blake _filter_qemu_io 370b1e6fc08SKevin Wolf 371b1e6fc08SKevin Wolf$QEMU_IO -c "read -P 0x33 0 4k" "$TEST_IMG" | _filter_qemu_io 372b1e6fc08SKevin Wolf 3736a7014efSAlberto Garcia# Using snapshot=on with a non-existent TMPDIR 374ad20319aSAndrey Shinkevichif [ "${VALGRIND_QEMU_VM}" == "y" ]; then 375ad20319aSAndrey Shinkevich _casenotrun "Valgrind needs a valid TMPDIR for itself" 376ad20319aSAndrey Shinkevichfi 377ad20319aSAndrey ShinkevichVALGRIND_QEMU_VM= \ 378*69fbfff9SBin MengTMPDIR=/nonexistent run_qemu -drive driver=null-co,snapshot=on | 379*69fbfff9SBin Meng sed -e "s#'[^']*/vl\.[A-Za-z0-9]\{6\}'#SNAPSHOT_PATH#g" 3806a7014efSAlberto Garcia 38130855137SKevin Wolf# Using snapshot=on together with read-only=on 38230855137SKevin Wolfecho "info block" | 38330855137SKevin Wolf run_qemu -drive file="$TEST_IMG",snapshot=on,read-only=on,if=none,id=$device_id | 38430855137SKevin Wolf _filter_qemu_io | 38559fba0aaSLukáš Doktor sed -e 's#"[^"]*/vl\.[A-Za-z0-9]\{6\}"#SNAPSHOT_PATH#g' 38630855137SKevin Wolf 38730855137SKevin Wolf 38847e5df21SKevin Wolf# success, all done 38947e5df21SKevin Wolfecho "*** done" 39047e5df21SKevin Wolfrm -f $seq.full 39147e5df21SKevin Wolfstatus=0 392