1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 28f7acbe6SKevin Wolf# 38f7acbe6SKevin Wolf# Test for configuring cache modes of arbitrary nodes (requires O_DIRECT) 48f7acbe6SKevin Wolf# 58f7acbe6SKevin Wolf# Copyright (C) 2015 Red Hat, Inc. 68f7acbe6SKevin Wolf# 78f7acbe6SKevin Wolf# This program is free software; you can redistribute it and/or modify 88f7acbe6SKevin Wolf# it under the terms of the GNU General Public License as published by 98f7acbe6SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 108f7acbe6SKevin Wolf# (at your option) any later version. 118f7acbe6SKevin Wolf# 128f7acbe6SKevin Wolf# This program is distributed in the hope that it will be useful, 138f7acbe6SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 148f7acbe6SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 158f7acbe6SKevin Wolf# GNU General Public License for more details. 168f7acbe6SKevin Wolf# 178f7acbe6SKevin Wolf# You should have received a copy of the GNU General Public License 188f7acbe6SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 198f7acbe6SKevin Wolf# 208f7acbe6SKevin Wolf 218f7acbe6SKevin Wolf# creator 228f7acbe6SKevin Wolfowner=kwolf@redhat.com 238f7acbe6SKevin Wolf 248f7acbe6SKevin Wolfseq=`basename $0` 258f7acbe6SKevin Wolfecho "QA output created by $seq" 268f7acbe6SKevin Wolf 278f7acbe6SKevin Wolfstatus=1 # failure is the default! 288f7acbe6SKevin Wolf 298f7acbe6SKevin Wolf_cleanup() 308f7acbe6SKevin Wolf{ 318f7acbe6SKevin Wolf _cleanup_test_img 328f7acbe6SKevin Wolf rm -f $TEST_IMG.snap 338f7acbe6SKevin Wolf} 348f7acbe6SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 358f7acbe6SKevin Wolf 368f7acbe6SKevin Wolf# get standard environment, filters and checks 378f7acbe6SKevin Wolf. ./common.rc 388f7acbe6SKevin Wolf. ./common.filter 398f7acbe6SKevin Wolf 408f7acbe6SKevin Wolf_supported_fmt qcow2 418f7acbe6SKevin Wolf_supported_proto file 428f7acbe6SKevin Wolf_supported_os Linux 438f7acbe6SKevin Wolf 448f7acbe6SKevin Wolf# We test all cache modes anyway, but O_DIRECT needs to be supported 458f7acbe6SKevin Wolf_default_cache_mode none 468f7acbe6SKevin Wolf_supported_cache_modes none directsync 478f7acbe6SKevin Wolf 488cedcffdSEric Blakedo_run_qemu() 498f7acbe6SKevin Wolf{ 508f7acbe6SKevin Wolf echo Testing: "$@" 518f7acbe6SKevin Wolf ( 528f7acbe6SKevin Wolf if ! test -t 0; then 538f7acbe6SKevin Wolf while read cmd; do 548f7acbe6SKevin Wolf echo $cmd 558f7acbe6SKevin Wolf done 568f7acbe6SKevin Wolf fi 578f7acbe6SKevin Wolf echo quit 588f7acbe6SKevin Wolf ) | $QEMU -nographic -monitor stdio -nodefaults "$@" 598f7acbe6SKevin Wolf echo 608f7acbe6SKevin Wolf} 618f7acbe6SKevin Wolf 628cedcffdSEric Blakerun_qemu() 638f7acbe6SKevin Wolf{ 6469404d9eSKevin Wolf do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp 658f7acbe6SKevin Wolf} 668f7acbe6SKevin Wolf 678f7acbe6SKevin Wolfsize=128M 688f7acbe6SKevin Wolf 698f7acbe6SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img $size 708f7acbe6SKevin WolfTEST_IMG="$TEST_IMG.snap" _make_test_img $size 718f7acbe6SKevin Wolf_make_test_img -b "$TEST_IMG.base" $size 728f7acbe6SKevin Wolf 738f7acbe6SKevin Wolfecho 748f7acbe6SKevin Wolfecho === Simple test for all cache modes === 758f7acbe6SKevin Wolfecho 768f7acbe6SKevin Wolf 778f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=none 788f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=directsync 798f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=writeback 808f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=writethrough 818f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=unsafe 828f7acbe6SKevin Wolfrun_qemu -drive file="$TEST_IMG",cache=invalid_value 838f7acbe6SKevin Wolf 848f7acbe6SKevin Wolfecho 858f7acbe6SKevin Wolfecho === Check inheritance of cache modes === 868f7acbe6SKevin Wolfecho 878f7acbe6SKevin Wolf 888f7acbe6SKevin Wolffiles="if=none,file=$TEST_IMG,backing.file.filename=$TEST_IMG.base" 898f7acbe6SKevin Wolfids="node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file" 908f7acbe6SKevin Wolf 918cedcffdSEric Blakecheck_cache_all() 928f7acbe6SKevin Wolf{ 938f7acbe6SKevin Wolf # cache.direct is supposed to be inherited by both bs->file and 948f7acbe6SKevin Wolf # bs->backing 958f7acbe6SKevin Wolf 96b43671f8SEric Blake printf "cache.direct=on on none0\n" 9773ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't" 98b43671f8SEric Blake printf "\ncache.direct=on on file\n" 9973ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't" 100b43671f8SEric Blake printf "\ncache.direct=on on backing\n" 10173ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't" 102b43671f8SEric Blake printf "\ncache.direct=on on backing-file\n" 10373ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't" 1048f7acbe6SKevin Wolf 1058f7acbe6SKevin Wolf # cache.writeback is supposed to be inherited by bs->backing; bs->file 1068f7acbe6SKevin Wolf # always gets cache.writeback=on 1078f7acbe6SKevin Wolf 108b43671f8SEric Blake printf "\n\ncache.writeback=off on none0\n" 10973ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 110b43671f8SEric Blake printf "\ncache.writeback=off on file\n" 11161de4c68SKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.writeback=off | grep -e "doesn't" -e "does not" 112b43671f8SEric Blake printf "\ncache.writeback=off on backing\n" 11361de4c68SKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.writeback=off | grep -e "doesn't" -e "does not" 114b43671f8SEric Blake printf "\ncache.writeback=off on backing-file\n" 11561de4c68SKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.writeback=off | grep -e "doesn't" -e "does not" 1168f7acbe6SKevin Wolf 1178f7acbe6SKevin Wolf # cache.no-flush is supposed to be inherited by both bs->file and bs->backing 1188f7acbe6SKevin Wolf 119b43671f8SEric Blake printf "\n\ncache.no-flush=on on none0\n" 12073ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 121b43671f8SEric Blake printf "\ncache.no-flush=on on file\n" 12273ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 123b43671f8SEric Blake printf "\ncache.no-flush=on on backing\n" 12473ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 125b43671f8SEric Blake printf "\ncache.no-flush=on on backing-file\n" 12673ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 1278f7acbe6SKevin Wolf} 1288f7acbe6SKevin Wolf 1298f7acbe6SKevin Wolfecho 1308f7acbe6SKevin Wolfecho "--- Configure cache modes on the command line ---" 1318f7acbe6SKevin Wolfecho 1328f7acbe6SKevin Wolf 1338f7acbe6SKevin Wolf# First check the inherited cache mode after opening the image. 1348f7acbe6SKevin Wolf 135c83f9fbaSKevin Wolfhmp_cmds="info block none0 136c83f9fbaSKevin Wolfinfo block image 1378f7acbe6SKevin Wolfinfo block file 1388f7acbe6SKevin Wolfinfo block backing 1398f7acbe6SKevin Wolfinfo block backing-file" 1408f7acbe6SKevin Wolf 1418f7acbe6SKevin Wolfcheck_cache_all 1428f7acbe6SKevin Wolf 1438f7acbe6SKevin Wolfecho 1448f7acbe6SKevin Wolfecho "--- Cache modes after reopen (live snapshot) ---" 1458f7acbe6SKevin Wolfecho 1468f7acbe6SKevin Wolf 1478f7acbe6SKevin Wolf# Then trigger a reopen and check that the cache modes are still the same. 1488f7acbe6SKevin Wolf 1498f7acbe6SKevin Wolfhmp_cmds="snapshot_blkdev -n none0 $TEST_IMG.snap $IMGFMT 1508f7acbe6SKevin Wolfinfo block 1518f7acbe6SKevin Wolfinfo block image 1528f7acbe6SKevin Wolfinfo block file 1538f7acbe6SKevin Wolfinfo block backing 1548f7acbe6SKevin Wolfinfo block backing-file" 1558f7acbe6SKevin Wolf 1568f7acbe6SKevin Wolfcheck_cache_all 1578f7acbe6SKevin Wolf 1588f7acbe6SKevin Wolfecho 1598f7acbe6SKevin Wolfecho "--- Change cache modes with reopen (qemu-io command, flags) ---" 1608f7acbe6SKevin Wolfecho 1618f7acbe6SKevin Wolf 1628f7acbe6SKevin Wolf# This one actually changes the cache mode with the reopen. For this test, the 1638f7acbe6SKevin Wolf# new cache mode is specified in the flags, not as an option. 1648f7acbe6SKevin Wolf 1658f7acbe6SKevin Wolfhmp_cmds='qemu-io none0 "reopen -c none" 166c83f9fbaSKevin Wolfinfo block none0 1678f7acbe6SKevin Wolfinfo block image 1688f7acbe6SKevin Wolfinfo block file 1698f7acbe6SKevin Wolfinfo block backing 1708f7acbe6SKevin Wolfinfo block backing-file' 1718f7acbe6SKevin Wolf 1728f7acbe6SKevin Wolfcheck_cache_all 1738f7acbe6SKevin Wolf 1748f7acbe6SKevin Wolfecho 1758f7acbe6SKevin Wolfecho "--- Change cache modes with reopen (qemu-io command, options) ---" 1768f7acbe6SKevin Wolfecho 1778f7acbe6SKevin Wolf 1788f7acbe6SKevin Wolf# This one actually changes the cache mode with the reopen. For this test, the 1798f7acbe6SKevin Wolf# new cache mode is specified as an option, not in the flags. 1808f7acbe6SKevin Wolf 1818f7acbe6SKevin Wolfhmp_cmds='qemu-io none0 "reopen -o cache.direct=on" 182c83f9fbaSKevin Wolfinfo block none0 1838f7acbe6SKevin Wolfinfo block image 1848f7acbe6SKevin Wolfinfo block file 1858f7acbe6SKevin Wolfinfo block backing 1868f7acbe6SKevin Wolfinfo block backing-file' 1878f7acbe6SKevin Wolf 1888f7acbe6SKevin Wolfcheck_cache_all 1898f7acbe6SKevin Wolf 1908f7acbe6SKevin Wolfecho 1918f7acbe6SKevin Wolfecho "--- Change cache modes after snapshot ---" 1928f7acbe6SKevin Wolfecho 1938f7acbe6SKevin Wolf 1948f7acbe6SKevin Wolf# This checks that the original image doesn't inherit from the snapshot 1958f7acbe6SKevin Wolf 1968f7acbe6SKevin Wolfhmp_cmds="snapshot_blkdev -n none0 $TEST_IMG.snap $IMGFMT 1978f7acbe6SKevin Wolfqemu-io none0 \"reopen -c none\" 1988f7acbe6SKevin Wolfinfo block none0 1998f7acbe6SKevin Wolfinfo block image 2008f7acbe6SKevin Wolfinfo block file 2018f7acbe6SKevin Wolfinfo block backing 2028f7acbe6SKevin Wolfinfo block backing-file" 2038f7acbe6SKevin Wolf 2048f7acbe6SKevin Wolfcheck_cache_all 2058f7acbe6SKevin Wolf 2068f7acbe6SKevin Wolfecho 2078f7acbe6SKevin Wolfecho "--- Change cache mode in parent, child has explicit option in JSON ---" 2088f7acbe6SKevin Wolfecho 2098f7acbe6SKevin Wolf 2108f7acbe6SKevin Wolf# This checks that children with options explicitly set by the json: 2118f7acbe6SKevin Wolf# pseudo-protocol don't inherit these options from their parents. 2128f7acbe6SKevin Wolf# 2138f7acbe6SKevin Wolf# Yes, blkdebug::json:... is criminal, but I can't see another way to have a 2148f7acbe6SKevin Wolf# BDS initialised with the json: pseudo-protocol, but still have it inherit 2158f7acbe6SKevin Wolf# options from its parent node. 2168f7acbe6SKevin Wolf 21719dbecdcSKevin Wolfhmp_cmds="qemu-io none0 \"reopen -o cache.direct=on,cache.no-flush=on\" 218c83f9fbaSKevin Wolfinfo block none0 2198f7acbe6SKevin Wolfinfo block image 2208f7acbe6SKevin Wolfinfo block blkdebug 2218f7acbe6SKevin Wolfinfo block file" 2228f7acbe6SKevin Wolf 22373ac451fSKevin Wolfecho "$hmp_cmds" | run_qemu -drive if=none,file="blkdebug::json:{\"filename\":\"$TEST_IMG\",,\"cache\":{\"direct\":false}}",node-name=image,file.node-name=blkdebug,file.image.node-name=file | grep "Cache" 2248f7acbe6SKevin Wolf 2258f7acbe6SKevin Wolfecho 2268f7acbe6SKevin Wolfecho "=== Check that referenced BDSes don't inherit ===" 2278f7acbe6SKevin Wolfecho 2288f7acbe6SKevin Wolf 2298f7acbe6SKevin Wolfdrv_bkfile="if=none,driver=file,filename=$TEST_IMG.base,node-name=backing-file" 2308f7acbe6SKevin Wolfdrv_bk="if=none,file=json:{'driver':'$IMGFMT',,'file':'backing-file',,'node-name':'backing'}" 2318f7acbe6SKevin Wolfdrv_file="if=none,driver=file,filename=$TEST_IMG,node-name=file" 2328f7acbe6SKevin Wolfdrv_img="if=none,id=blk,file=json:{'driver':'$IMGFMT',,'file':'file',,'backing':'backing',,'node-name':'image'}" 2338f7acbe6SKevin Wolf 2348cedcffdSEric Blakecheck_cache_all_separate() 2358f7acbe6SKevin Wolf{ 2368f7acbe6SKevin Wolf # Check cache.direct 2378f7acbe6SKevin Wolf 238b43671f8SEric Blake printf "cache.direct=on on blk\n" 23973ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.direct=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 240b43671f8SEric Blake printf "\ncache.direct=on on file\n" 24173ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.direct=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 242b43671f8SEric Blake printf "\ncache.direct=on on backing\n" 24373ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.direct=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 244b43671f8SEric Blake printf "\ncache.direct=on on backing-file\n" 24573ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.direct=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 2468f7acbe6SKevin Wolf 2478f7acbe6SKevin Wolf # Check cache.writeback 2488f7acbe6SKevin Wolf 249b43671f8SEric Blake printf "\n\ncache.writeback=off on blk\n" 25073ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 251b43671f8SEric Blake printf "\ncache.writeback=off on file\n" 25273ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.writeback=off -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 253b43671f8SEric Blake printf "\ncache.writeback=off on backing\n" 25473ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.writeback=off -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 255b43671f8SEric Blake printf "\ncache.writeback=off on backing-file\n" 25673ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.writeback=off -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 2578f7acbe6SKevin Wolf 2588f7acbe6SKevin Wolf # Check cache.no-flush 2598f7acbe6SKevin Wolf 260b43671f8SEric Blake printf "\n\ncache.no-flush=on on blk\n" 26173ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 262b43671f8SEric Blake printf "\ncache.no-flush=on on file\n" 26373ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.no-flush=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 264b43671f8SEric Blake printf "\ncache.no-flush=on on backing\n" 26573ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.no-flush=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 266b43671f8SEric Blake printf "\ncache.no-flush=on on backing-file\n" 26773ac451fSKevin Wolf echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.no-flush=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't" 2688f7acbe6SKevin Wolf} 2698f7acbe6SKevin Wolf 2708f7acbe6SKevin Wolfecho 2718f7acbe6SKevin Wolfecho "--- Configure cache modes on the command line ---" 2728f7acbe6SKevin Wolfecho 2738f7acbe6SKevin Wolf 2748f7acbe6SKevin Wolf# First check the inherited cache mode after opening the image. 2758f7acbe6SKevin Wolf 2768f7acbe6SKevin Wolfhmp_cmds="info block image 2778f7acbe6SKevin Wolfinfo block file 2788f7acbe6SKevin Wolfinfo block backing 2798f7acbe6SKevin Wolfinfo block backing-file" 2808f7acbe6SKevin Wolf 2818f7acbe6SKevin Wolfcheck_cache_all_separate 2828f7acbe6SKevin Wolf 2838f7acbe6SKevin Wolfecho 2848f7acbe6SKevin Wolfecho "--- Cache modes after reopen (live snapshot) ---" 2858f7acbe6SKevin Wolfecho 2868f7acbe6SKevin Wolf 2878f7acbe6SKevin Wolf# Then trigger a reopen and check that the cache modes are still the same. 2888f7acbe6SKevin Wolf 2898f7acbe6SKevin Wolfhmp_cmds="snapshot_blkdev -n blk $TEST_IMG.snap $IMGFMT 2908f7acbe6SKevin Wolfinfo block blk 2918f7acbe6SKevin Wolfinfo block image 2928f7acbe6SKevin Wolfinfo block file 2938f7acbe6SKevin Wolfinfo block backing 2948f7acbe6SKevin Wolfinfo block backing-file" 2958f7acbe6SKevin Wolf 2968f7acbe6SKevin Wolfcheck_cache_all_separate 2978f7acbe6SKevin Wolf 2988f7acbe6SKevin Wolfecho 2998f7acbe6SKevin Wolfecho "--- Change cache modes with reopen (qemu-io command, flags) ---" 3008f7acbe6SKevin Wolfecho 3018f7acbe6SKevin Wolf 3028f7acbe6SKevin Wolf# This one actually changes the cache mode with the reopen. For this test, the 3038f7acbe6SKevin Wolf# new cache mode is specified as flags, not as option. 3048f7acbe6SKevin Wolf 3058f7acbe6SKevin Wolfhmp_cmds='qemu-io blk "reopen -c none" 3068f7acbe6SKevin Wolfinfo block image 3078f7acbe6SKevin Wolfinfo block file 3088f7acbe6SKevin Wolfinfo block backing 3098f7acbe6SKevin Wolfinfo block backing-file' 3108f7acbe6SKevin Wolf 3118f7acbe6SKevin Wolfcheck_cache_all_separate 3128f7acbe6SKevin Wolf 3138f7acbe6SKevin Wolf 3148f7acbe6SKevin Wolfecho 3158f7acbe6SKevin Wolfecho "=== Reopening children instead of the root ===" 3168f7acbe6SKevin Wolfecho 3178f7acbe6SKevin Wolf 3188f7acbe6SKevin Wolffiles="if=none,file=$TEST_IMG,backing.file.filename=$TEST_IMG.base" 3198f7acbe6SKevin Wolfids="node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file" 3208f7acbe6SKevin Wolf 3218f7acbe6SKevin Wolfecho 3228f7acbe6SKevin Wolfecho "--- Basic reopen ---" 3238f7acbe6SKevin Wolfecho 3248f7acbe6SKevin Wolf 3258f7acbe6SKevin Wolfhmp_cmds='qemu-io none0 "reopen -o backing.cache.direct=on" 326c83f9fbaSKevin Wolfinfo block none0 3278f7acbe6SKevin Wolfinfo block image 3288f7acbe6SKevin Wolfinfo block file 3298f7acbe6SKevin Wolfinfo block backing 3308f7acbe6SKevin Wolfinfo block backing-file' 3318f7acbe6SKevin Wolf 3328f7acbe6SKevin Wolfcheck_cache_all 3338f7acbe6SKevin Wolf 3348f7acbe6SKevin Wolfecho 3358f7acbe6SKevin Wolfecho "--- Change cache mode after reopening child ---" 3368f7acbe6SKevin Wolfecho 3378f7acbe6SKevin Wolf 3388f7acbe6SKevin Wolf# This checks that children with options explicitly set with reopen don't 3398f7acbe6SKevin Wolf# inherit these options from their parents any more 3408f7acbe6SKevin Wolf 3418f7acbe6SKevin Wolf# TODO Implement node-name support for 'qemu-io' HMP command for -c 3428f7acbe6SKevin Wolf# Can use only -o to access child node options for now 3438f7acbe6SKevin Wolf 344bfd18d1eSKevin Wolfhmp_cmds="qemu-io none0 \"reopen -o file.cache.direct=off,file.cache.no-flush=off\" 345bfd18d1eSKevin Wolfqemu-io none0 \"reopen -o backing.file.cache.direct=off,backing.file.cache.no-flush=on\" 3468f7acbe6SKevin Wolfqemu-io none0 \"reopen -c none\" 3478f7acbe6SKevin Wolfinfo block image 3488f7acbe6SKevin Wolfinfo block file 3498f7acbe6SKevin Wolfinfo block backing 3508f7acbe6SKevin Wolfinfo block backing-file" 3518f7acbe6SKevin Wolf 3528f7acbe6SKevin Wolfecho "$hmp_cmds" | run_qemu -drive "$files","$ids" | grep "Cache" 3538f7acbe6SKevin Wolf 3548f7acbe6SKevin Wolf# success, all done 3558f7acbe6SKevin Wolfecho "*** done" 3568f7acbe6SKevin Wolfrm -f $seq.full 3578f7acbe6SKevin Wolfstatus=0 358