xref: /qemu/tests/qemu-iotests/051 (revision 75f02ed53a0dd7fff641de5c73566ee9abe4cf94)
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 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
4247e5df21SKevin Wolf_supported_os Linux
435262caa7SMax Reitz# A compat=0.10 image is created in this test which does not support anything
445262caa7SMax Reitz# other than refcount_bits=16
455262caa7SMax Reitz_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
4647e5df21SKevin Wolf
4747e5df21SKevin Wolffunction do_run_qemu()
4847e5df21SKevin Wolf{
4947e5df21SKevin Wolf    echo Testing: "$@"
504db9c980SFam Zheng    (
514db9c980SFam Zheng        if ! test -t 0; then
524db9c980SFam Zheng            while read cmd; do
534db9c980SFam Zheng                echo $cmd
544db9c980SFam Zheng            done
554db9c980SFam Zheng        fi
564db9c980SFam Zheng        echo quit
574db9c980SFam Zheng    ) | $QEMU -nographic -monitor stdio -serial none "$@"
5847e5df21SKevin Wolf    echo
5947e5df21SKevin Wolf}
6047e5df21SKevin Wolf
6147e5df21SKevin Wolffunction run_qemu()
6247e5df21SKevin Wolf{
6369404d9eSKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu |
6469404d9eSKevin Wolf        _filter_generated_node_ids | _filter_hmp
6547e5df21SKevin Wolf}
6647e5df21SKevin Wolf
6747e5df21SKevin Wolfsize=128M
68dd87de06SBo Tudevice_id="drive0"
6947e5df21SKevin Wolf
7047e5df21SKevin Wolf_make_test_img $size
711ab39193SJeff Codycp "$TEST_IMG" "$TEST_IMG.orig"
721ab39193SJeff Codymv "$TEST_IMG" "$TEST_IMG.base"
731ab39193SJeff Cody_make_test_img -b "$TEST_IMG.base" $size
7447e5df21SKevin Wolf
7547e5df21SKevin Wolfecho
7647e5df21SKevin Wolfecho === Unknown option ===
7747e5df21SKevin Wolfecho
7847e5df21SKevin Wolf
79dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=,if=none,id=$device_id
80dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=on,if=none,id=$device_id
81dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=1234,if=none,id=$device_id
82dd87de06SBo Turun_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=foo,if=none,id=$device_id
8347e5df21SKevin Wolf
844db9c980SFam Zhengecho
85eb909c7fSKevin Wolfecho === Unknown protocol option ===
86eb909c7fSKevin Wolfecho
87eb909c7fSKevin Wolf
88eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=
89eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=on
90eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=1234
91eb909c7fSKevin Wolfrun_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=foo
92eb909c7fSKevin Wolf
93eb909c7fSKevin Wolfecho
9406d22aa3SKevin Wolfecho === Invalid format ===
9506d22aa3SKevin Wolfecho
9606d22aa3SKevin Wolf
9706d22aa3SKevin Wolfrun_qemu -drive file="$TEST_IMG",format=foo
9806d22aa3SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=foo
9917b005f1SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=raw,format=qcow2
10080495fdfSMax Reitzrun_qemu -drive file="$TEST_IMG",driver=qcow2,format=qcow2
10106d22aa3SKevin Wolf
10206d22aa3SKevin Wolfecho
103354483e5SChristian Borntraegerecho === Device without drive ===
104354483e5SChristian Borntraegerecho
105354483e5SChristian Borntraeger
106*75f02ed5SCornelia Huckcase "$QEMU_DEFAULT_MACHINE" in
107*75f02ed5SCornelia Huck  s390-ccw-virtio)
108*75f02ed5SCornelia Huck      virtio_scsi=virtio-scsi-ccw
109*75f02ed5SCornelia Huck      ;;
110*75f02ed5SCornelia Huck  *)
111*75f02ed5SCornelia Huck      virtio_scsi=virtio-scsi-pci
112*75f02ed5SCornelia Huck      ;;
113*75f02ed5SCornelia Huckesac
114*75f02ed5SCornelia Huck
115*75f02ed5SCornelia Huckrun_qemu -device $virtio_scsi -device scsi-hd |
116*75f02ed5SCornelia Huck    sed -e "s/$virtio_scsi/VIRTIO_SCSI/"
117354483e5SChristian Borntraeger
118354483e5SChristian Borntraegerecho
1194db9c980SFam Zhengecho === Overriding backing file ===
1204db9c980SFam Zhengecho
1214db9c980SFam Zheng
122dd87de06SBo Tuecho "info block" | run_qemu -drive file="$TEST_IMG",driver=qcow2,backing.file.filename="$TEST_IMG.orig",if=none,id=$device_id -nodefaults\
12315489c76SJeff Cody                  | _filter_generated_node_ids
12447e5df21SKevin Wolf
1258ee79e70SKevin Wolf# Drivers that don't support backing files
1268ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",driver=raw,backing.file.filename="$TEST_IMG.orig"
1278ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",file.backing.driver=file,file.backing.filename="$TEST_IMG.orig"
1288ee79e70SKevin Wolfrun_qemu -drive file="$TEST_IMG",file.backing.driver=qcow2,file.backing.file.filename="$TEST_IMG.orig"
1298ee79e70SKevin Wolf
13047e5df21SKevin Wolfecho
13147e5df21SKevin Wolfecho === Enable and disable lazy refcounting on the command line, plus some invalid values ===
13247e5df21SKevin Wolfecho
13347e5df21SKevin Wolf
134fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on
135fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off
136fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=
137fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=42
138fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=foo
13947e5df21SKevin Wolf
14047e5df21SKevin Wolf
14147e5df21SKevin Wolfecho
14247e5df21SKevin Wolfecho === With version 2 images enabling lazy refcounts must fail ===
14347e5df21SKevin Wolfecho
14447e5df21SKevin Wolf
14547e5df21SKevin Wolf_make_test_img -ocompat=0.10 $size
14647e5df21SKevin Wolf
147fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on
148fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off
14947e5df21SKevin Wolf
15047e5df21SKevin Wolfecho
15147e5df21SKevin Wolfecho === No medium ===
15247e5df21SKevin Wolfecho
15347e5df21SKevin Wolf
154dd87de06SBo Tucase "$QEMU_DEFAULT_MACHINE" in
155dd87de06SBo Tu    pc)
15647e5df21SKevin Wolf        run_qemu -drive if=floppy
15747e5df21SKevin Wolf        run_qemu -drive if=ide,media=cdrom
15847e5df21SKevin Wolf        run_qemu -drive if=scsi,media=cdrom
15947e5df21SKevin Wolf        run_qemu -drive if=ide
16047e5df21SKevin Wolf        run_qemu -drive if=scsi
161dd87de06SBo Tu        ;;
162dd87de06SBo Tu     *)
163dd87de06SBo Tu        ;;
164dd87de06SBo Tuesac
165dd87de06SBo Tu
166dd87de06SBo Turun_qemu -drive if=virtio
16747e5df21SKevin Wolf
168289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in
169289f3ebaSBo Tu    pc)
17047e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device ide-cd,drive=disk
17147e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-cd,drive=disk
17247e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device ide-drive,drive=disk
17347e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device ide-hd,drive=disk
17447e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk
17547e5df21SKevin Wolf        run_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk
176289f3ebaSBo Tu        ;;
177289f3ebaSBo Tu     *)
178289f3ebaSBo Tu        ;;
179289f3ebaSBo Tuesac
18047e5df21SKevin Wolf
18147e5df21SKevin Wolfecho
18247e5df21SKevin Wolfecho === Read-only ===
18347e5df21SKevin Wolfecho
18447e5df21SKevin Wolf
185289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in
186289f3ebaSBo Tu    pc)
187fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=floppy,readonly=on
188fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=ide,media=cdrom,readonly=on
189fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=scsi,media=cdrom,readonly=on
190fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=ide,readonly=on
191dd87de06SBo Tu        run_qemu -drive file="$TEST_IMG",if=scsi,readonly=on
192289f3ebaSBo Tu        ;;
193289f3ebaSBo Tu     *)
194289f3ebaSBo Tu        ;;
195289f3ebaSBo Tuesac
196289f3ebaSBo Tu
197fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",if=virtio,readonly=on
19847e5df21SKevin Wolf
199289f3ebaSBo Tucase "$QEMU_DEFAULT_MACHINE" in
200289f3ebaSBo Tu    pc)
201fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device ide-cd,drive=disk
202fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device lsi53c895a -device scsi-cd,drive=disk
203fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device ide-drive,drive=disk
204fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device ide-hd,drive=disk
205fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk
206fef9c191SJeff Cody        run_qemu -drive file="$TEST_IMG",if=none,id=disk,readonly=on -device lsi53c895a -device scsi-hd,drive=disk
207289f3ebaSBo Tu        ;;
208289f3ebaSBo Tu     *)
209289f3ebaSBo Tu        ;;
210289f3ebaSBo Tuesac
21147e5df21SKevin Wolf
21247e5df21SKevin Wolfecho
21347e5df21SKevin Wolfecho === Cache modes ===
21447e5df21SKevin Wolfecho
21547e5df21SKevin Wolf
21647e5df21SKevin Wolf# Cannot use the test image because cache=none might not work on the host FS
21747e5df21SKevin Wolf# Use cdrom so that we won't get errors about missing media
21847e5df21SKevin Wolf
219fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=none
220fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=directsync
221fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=writeback
222fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=writethrough
223fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=unsafe
224fc17c259SKevin Wolfrun_qemu -drive driver=null-co,cache=invalid_value
22547e5df21SKevin Wolf
226768ee459SKevin Wolf# Can't test direct=on here because O_DIRECT might not be supported on this FS
227768ee459SKevin Wolf# Test 142 checks the direct=on cases
228768ee459SKevin Wolf
229768ee459SKevin Wolffor cache in writeback writethrough unsafe invalid_value; do
230b43671f8SEric Blake    printf "info block %s\n" '' file backing backing-file | \
23161de4c68SKevin 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
232768ee459SKevin Wolfdone
233768ee459SKevin Wolf
2342af5ef70SKevin Wolfecho
2352af5ef70SKevin Wolfecho === Specifying the protocol layer ===
2362af5ef70SKevin Wolfecho
2372af5ef70SKevin Wolf
238fef9c191SJeff Codyrun_qemu -drive file="$TEST_IMG",file.driver=file
2392af5ef70SKevin Wolf
24098289620SKevin Wolfecho
241765003dbSKevin Wolfecho === Leaving out required options ===
242765003dbSKevin Wolfecho
243765003dbSKevin Wolf
244765003dbSKevin Wolfrun_qemu -drive driver=file
24542dc10f1SMax Reitzrun_qemu -drive driver=file,filename=
246765003dbSKevin Wolfrun_qemu -drive driver=nbd
247765003dbSKevin Wolfrun_qemu -drive driver=raw
248765003dbSKevin Wolfrun_qemu -drive file.driver=file
249765003dbSKevin Wolfrun_qemu -drive file.driver=nbd
250765003dbSKevin Wolfrun_qemu -drive file.driver=raw
251765003dbSKevin Wolfrun_qemu -drive foo=bar
252765003dbSKevin Wolf
253765003dbSKevin Wolfecho
2545abbf0eeSKevin Wolfecho === Specifying both an option and its legacy alias ===
2555abbf0eeSKevin Wolfecho
2565abbf0eeSKevin Wolf
2575abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops=1234,throttling.iops-total=5678
2585abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_rd=1234,throttling.iops-read=5678
2595abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_wr=1234,throttling.iops-write=5678
2605abbf0eeSKevin Wolf
2615abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps=1234,throttling.bps-total=5678
2625abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_rd=1234,throttling.bps-read=5678
2635abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_wr=1234,throttling.bps-write=5678
2645abbf0eeSKevin Wolf
2655abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_max=1234,throttling.iops-total-max=5678
2665abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_rd_max=1234,throttling.iops-read-max=5678
2675abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_wr_max=1234,throttling.iops-write-max=5678
2685abbf0eeSKevin Wolf
2695abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_max=1234,throttling.bps-total-max=5678
2705abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_rd_max=1234,throttling.bps-read-max=5678
2715abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",bps_wr_max=1234,throttling.bps-write-max=5678
2725abbf0eeSKevin Wolf
2735abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",iops_size=1234,throttling.iops-size=5678
2745abbf0eeSKevin Wolfrun_qemu -drive file="$TEST_IMG",readonly=on,read-only=off
2755abbf0eeSKevin Wolf
2765abbf0eeSKevin Wolfecho
277e9b15550SFam Zhengecho === Catching negative/large throttling values ===
278e9b15550SFam Zhengecho
279e9b15550SFam Zheng
280e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",iops=-1
281e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=-2
282e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps_rd=-3
283e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps_rd_max=-3
284e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",throttling.iops-total=-4
285e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",throttling.bps-total=-5
286e9b15550SFam Zheng# These are accepted
287e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=0
288e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1
289e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1000000000000000
290e9b15550SFam Zheng# While these are not
291e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=1000000000000001
292e9b15550SFam Zhengrun_qemu -drive file="$TEST_IMG",bps=9999999999999999
293e9b15550SFam Zheng
294e9b15550SFam Zhengecho
29598289620SKevin Wolfecho === Parsing protocol from file name ===
29698289620SKevin Wolfecho
29798289620SKevin Wolf
29898289620SKevin Wolf# Protocol strings are supposed to be parsed from traditional option strings,
29998289620SKevin Wolf# but not when using driver-specific options. We can distinguish them by the
30098289620SKevin Wolf# error message for non-existing files.
30198289620SKevin Wolf
30298289620SKevin Wolfrun_qemu -hda foo:bar
30398289620SKevin Wolfrun_qemu -drive file=foo:bar
30498289620SKevin Wolfrun_qemu -drive file.filename=foo:bar
30598289620SKevin Wolf
306e3fa4bfaSKevin Wolfrun_qemu -hda "file:$TEST_IMG"
307e3fa4bfaSKevin Wolfrun_qemu -drive file="file:$TEST_IMG"
308e3fa4bfaSKevin Wolfrun_qemu -drive file.filename="file:$TEST_IMG"
309e3fa4bfaSKevin Wolf
310f32f988cSKevin Wolfecho
311f32f988cSKevin Wolfecho === Snapshot mode ===
312f32f988cSKevin Wolfecho
313f32f988cSKevin Wolf
314f32f988cSKevin Wolf$QEMU_IO -c "write -P 0x11 0 4k" "$TEST_IMG" | _filter_qemu_io
315f32f988cSKevin Wolf
316289f3ebaSBo Tu
317289f3ebaSBo 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
318289f3ebaSBo 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
319289f3ebaSBo 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\
320289f3ebaSBo Tu                                                 | _filter_qemu_io
321289f3ebaSBo 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\
322289f3ebaSBo Tu                                                 | _filter_qemu_io
323289f3ebaSBo 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
324289f3ebaSBo 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
325b998875dSKevin Wolf
326b998875dSKevin Wolf# Opening a read-only file r/w with snapshot=on
327b998875dSKevin Wolfchmod u-w "$TEST_IMG"
328289f3ebaSBo 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
329289f3ebaSBo 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
330b998875dSKevin Wolfchmod u+w "$TEST_IMG"
331f32f988cSKevin Wolf
332f32f988cSKevin Wolf$QEMU_IO -c "read -P 0x11 0 4k" "$TEST_IMG" | _filter_qemu_io
333f32f988cSKevin Wolf
334289f3ebaSBo 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
335f32f988cSKevin Wolf
336f32f988cSKevin Wolf$QEMU_IO -c "read -P 0x22 0 4k" "$TEST_IMG" | _filter_qemu_io
337f32f988cSKevin Wolf
338b43671f8SEric Blakeprintf %b "qemu-io $device_id \"write -P 0x33 0 4k\"\ncommit $device_id\n" |
339b43671f8SEric Blake    run_qemu -drive file="$TEST_IMG",snapshot=on,if=none,id=$device_id |
340b43671f8SEric Blake    _filter_qemu_io
341b1e6fc08SKevin Wolf
342b1e6fc08SKevin Wolf$QEMU_IO -c "read -P 0x33 0 4k" "$TEST_IMG" | _filter_qemu_io
343b1e6fc08SKevin Wolf
34447e5df21SKevin Wolf# success, all done
34547e5df21SKevin Wolfecho "*** done"
34647e5df21SKevin Wolfrm -f $seq.full
34747e5df21SKevin Wolfstatus=0
348