1e6c79647SMax Reitz#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw 3e6c79647SMax Reitz# 4e6c79647SMax Reitz# Test FUSE exports (in ways that are not captured by the generic 5e6c79647SMax Reitz# tests) 6e6c79647SMax Reitz# 7e6c79647SMax Reitz# Copyright (C) 2020 Red Hat, Inc. 8e6c79647SMax Reitz# 9e6c79647SMax Reitz# This program is free software; you can redistribute it and/or modify 10e6c79647SMax Reitz# it under the terms of the GNU General Public License as published by 11e6c79647SMax Reitz# the Free Software Foundation; either version 2 of the License, or 12e6c79647SMax Reitz# (at your option) any later version. 13e6c79647SMax Reitz# 14e6c79647SMax Reitz# This program is distributed in the hope that it will be useful, 15e6c79647SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 16e6c79647SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17e6c79647SMax Reitz# GNU General Public License for more details. 18e6c79647SMax Reitz# 19e6c79647SMax Reitz# You should have received a copy of the GNU General Public License 20e6c79647SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 21e6c79647SMax Reitz# 22e6c79647SMax Reitz 23e6c79647SMax Reitzseq=$(basename "$0") 24e6c79647SMax Reitzecho "QA output created by $seq" 25e6c79647SMax Reitz 26e6c79647SMax Reitzstatus=1 # failure is the default! 27e6c79647SMax Reitz 28e6c79647SMax Reitz_cleanup() 29e6c79647SMax Reitz{ 30e6c79647SMax Reitz _cleanup_qemu 31e6c79647SMax Reitz _cleanup_test_img 32e6c79647SMax Reitz rmdir "$EXT_MP" 2>/dev/null 33e6c79647SMax Reitz rm -f "$EXT_MP" 34e6c79647SMax Reitz rm -f "$COPIED_IMG" 35e6c79647SMax Reitz} 36e6c79647SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 37e6c79647SMax Reitz 38e6c79647SMax Reitz# get standard environment, filters and checks 39e6c79647SMax Reitz. ./common.rc 40e6c79647SMax Reitz. ./common.filter 41e6c79647SMax Reitz. ./common.qemu 42e6c79647SMax Reitz 43e6c79647SMax Reitz# Generic format, but needs a plain filename 44e6c79647SMax Reitz_supported_fmt generic 45e6c79647SMax Reitzif [ "$IMGOPTSSYNTAX" = "true" ]; then 46e6c79647SMax Reitz _unsupported_fmt $IMGFMT 47e6c79647SMax Reitzfi 48e6c79647SMax Reitz# We need the image to have exactly the specified size, and VPC does 49e6c79647SMax Reitz# not allow that by default 50e6c79647SMax Reitz_unsupported_fmt vpc 51e6c79647SMax Reitz 52e6c79647SMax Reitz_supported_proto file # We create the FUSE export manually 53e6c79647SMax Reitz_supported_os Linux # We need /dev/urandom 54e6c79647SMax Reitz 55e6c79647SMax Reitz# $1: Export ID 56e6c79647SMax Reitz# $2: Options (beyond the node-name and ID) 57e6c79647SMax Reitz# $3: Expected return value (defaults to 'return') 58e6c79647SMax Reitz# $4: Node to export (defaults to 'node-format') 59e6c79647SMax Reitzfuse_export_add() 60e6c79647SMax Reitz{ 618fc54f94SMax Reitz # The grep -v is a filter for errors when /etc/fuse.conf does not contain 628fc54f94SMax Reitz # user_allow_other. (The error is benign, but it is printed by fusermount 638fc54f94SMax Reitz # on the first mount attempt, so our export code cannot hide it.) 64e6c79647SMax Reitz _send_qemu_cmd $QEMU_HANDLE \ 65e6c79647SMax Reitz "{'execute': 'block-export-add', 66e6c79647SMax Reitz 'arguments': { 67e6c79647SMax Reitz 'type': 'fuse', 68e6c79647SMax Reitz 'id': '$1', 69e6c79647SMax Reitz 'node-name': '${4:-node-format}', 70e6c79647SMax Reitz $2 71e6c79647SMax Reitz } }" \ 72e6c79647SMax Reitz "${3:-return}" \ 738fc54f94SMax Reitz | _filter_imgfmt \ 748fc54f94SMax Reitz | grep -v 'option allow_other only allowed if' 75e6c79647SMax Reitz} 76e6c79647SMax Reitz 77e6c79647SMax Reitz# $1: Export ID 78e6c79647SMax Reitzfuse_export_del() 79e6c79647SMax Reitz{ 80*f389309dSStefan Hajnoczi capture_events="BLOCK_EXPORT_DELETED" \ 81e6c79647SMax Reitz _send_qemu_cmd $QEMU_HANDLE \ 82e6c79647SMax Reitz "{'execute': 'block-export-del', 83e6c79647SMax Reitz 'arguments': { 84e6c79647SMax Reitz 'id': '$1' 85e6c79647SMax Reitz } }" \ 86e6c79647SMax Reitz 'return' 87e6c79647SMax Reitz 88*f389309dSStefan Hajnoczi _wait_event $QEMU_HANDLE \ 89e6c79647SMax Reitz 'BLOCK_EXPORT_DELETED' 90e6c79647SMax Reitz} 91e6c79647SMax Reitz 92e6c79647SMax Reitz# Return the length of the protocol file 93e6c79647SMax Reitz# $1: Protocol node export mount point 94e6c79647SMax Reitz# $2: Original file (to compare) 95e6c79647SMax Reitzget_proto_len() 96e6c79647SMax Reitz{ 97e6c79647SMax Reitz len1=$(stat -c '%s' "$1") 98e6c79647SMax Reitz len2=$(stat -c '%s' "$2") 99e6c79647SMax Reitz 100e6c79647SMax Reitz if [ "$len1" != "$len2" ]; then 101e6c79647SMax Reitz echo 'ERROR: Length of export and original differ:' >&2 102e6c79647SMax Reitz echo "$len1 != $len2" >&2 103e6c79647SMax Reitz else 104e6c79647SMax Reitz echo '(OK: Lengths of export and original are the same)' >&2 105e6c79647SMax Reitz fi 106e6c79647SMax Reitz 107e6c79647SMax Reitz echo "$len1" 108e6c79647SMax Reitz} 109e6c79647SMax Reitz 110e6c79647SMax ReitzCOPIED_IMG="$TEST_IMG.copy" 111e6c79647SMax ReitzEXT_MP="$TEST_IMG.fuse" 112e6c79647SMax Reitz 113e6c79647SMax Reitzecho '=== Set up ===' 114e6c79647SMax Reitz 115e6c79647SMax Reitz# Create image with random data 116e6c79647SMax Reitz_make_test_img 64M 117e6c79647SMax Reitz$QEMU_IO -c 'write -s /dev/urandom 0 64M' "$TEST_IMG" | _filter_qemu_io 118e6c79647SMax Reitz 119e6c79647SMax Reitz_launch_qemu 120e6c79647SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 121e6c79647SMax Reitz "{'execute': 'qmp_capabilities'}" \ 122e6c79647SMax Reitz 'return' 123e6c79647SMax Reitz 124e6c79647SMax Reitz# Separate blockdev-add calls for format and protocol so we can remove 125e6c79647SMax Reitz# the format layer later on 126e6c79647SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 127e6c79647SMax Reitz "{'execute': 'blockdev-add', 128e6c79647SMax Reitz 'arguments': { 129e6c79647SMax Reitz 'driver': 'file', 130e6c79647SMax Reitz 'node-name': 'node-protocol', 131e6c79647SMax Reitz 'filename': '$TEST_IMG' 132e6c79647SMax Reitz } }" \ 133e6c79647SMax Reitz 'return' 134e6c79647SMax Reitz 135e6c79647SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 136e6c79647SMax Reitz "{'execute': 'blockdev-add', 137e6c79647SMax Reitz 'arguments': { 138e6c79647SMax Reitz 'driver': '$IMGFMT', 139e6c79647SMax Reitz 'node-name': 'node-format', 140e6c79647SMax Reitz 'file': 'node-protocol' 141e6c79647SMax Reitz } }" \ 142e6c79647SMax Reitz 'return' 143e6c79647SMax Reitz 144e6c79647SMax Reitzecho 145e6c79647SMax Reitzecho '=== Mountpoint not present ===' 146e6c79647SMax Reitz 147e6c79647SMax Reitzrmdir "$EXT_MP" 2>/dev/null 148e6c79647SMax Reitzrm -f "$EXT_MP" 149e6c79647SMax Reitzoutput=$(fuse_export_add 'export-err' "'mountpoint': '$EXT_MP'" error) 150e6c79647SMax Reitz 151ea29331bSMarkus Armbrusterif echo "$output" | grep -q "Parameter 'type' does not accept value 'fuse'"; then 152e6c79647SMax Reitz _notrun 'No FUSE support' 153e6c79647SMax Reitzfi 154e6c79647SMax Reitz 155e6c79647SMax Reitzecho "$output" 156e6c79647SMax Reitz 157e6c79647SMax Reitzecho 158e6c79647SMax Reitzecho '=== Mountpoint is a directory ===' 159e6c79647SMax Reitz 160e6c79647SMax Reitzmkdir "$EXT_MP" 161e6c79647SMax Reitzfuse_export_add 'export-err' "'mountpoint': '$EXT_MP'" error 162e6c79647SMax Reitzrmdir "$EXT_MP" 163e6c79647SMax Reitz 164e6c79647SMax Reitzecho 165e6c79647SMax Reitzecho '=== Mountpoint is a regular file ===' 166e6c79647SMax Reitz 167e6c79647SMax Reitztouch "$EXT_MP" 168e6c79647SMax Reitzfuse_export_add 'export-mp' "'mountpoint': '$EXT_MP'" 169e6c79647SMax Reitz 170e6c79647SMax Reitz# Check that the export presents the same data as the original image 171e6c79647SMax Reitz$QEMU_IMG compare -f raw -F $IMGFMT -U "$EXT_MP" "$TEST_IMG" 172e6c79647SMax Reitz 173f29add26SMax Reitz# Some quick chmod tests 174f29add26SMax Reitzstat -c 'Permissions pre-chmod: %a' "$EXT_MP" 175f29add26SMax Reitz 176f29add26SMax Reitz# Verify that we cannot set +w 177f29add26SMax Reitzchmod u+w "$EXT_MP" 2>&1 | _filter_testdir | _filter_imgfmt 178f29add26SMax Reitzstat -c 'Permissions post-+w: %a' "$EXT_MP" 179f29add26SMax Reitz 180f29add26SMax Reitz# But that we can set, say, +x (if we are so inclined) 181f29add26SMax Reitzchmod u+x "$EXT_MP" 2>&1 | _filter_testdir | _filter_imgfmt 182f29add26SMax Reitzstat -c 'Permissions post-+x: %a' "$EXT_MP" 183f29add26SMax Reitz 184e6c79647SMax Reitzecho 185e6c79647SMax Reitzecho '=== Mount over existing file ===' 186e6c79647SMax Reitz 187e6c79647SMax Reitz# This is the coolest feature of FUSE exports: You can transparently 188e6c79647SMax Reitz# make images in any format appear as raw images 189e6c79647SMax Reitzfuse_export_add 'export-img' "'mountpoint': '$TEST_IMG'" 190e6c79647SMax Reitz 191e6c79647SMax Reitz# Accesses both exports at the same time, so we get a concurrency test 192e6c79647SMax Reitz$QEMU_IMG compare -f raw -F raw -U "$EXT_MP" "$TEST_IMG" 193e6c79647SMax Reitz 194e6c79647SMax Reitz# Just to be sure, we later want to compare the data offline. Also, 195e6c79647SMax Reitz# this allows us to see that cp works without complaining. 196e6c79647SMax Reitz# (This is not a given, because cp will expect a short read at EOF. 197e6c79647SMax Reitz# Internally, qemu does not allow short reads, so we have to check 198e6c79647SMax Reitz# whether the FUSE export driver lets them work.) 199e6c79647SMax Reitzcp "$TEST_IMG" "$COPIED_IMG" 200e6c79647SMax Reitz 201e6c79647SMax Reitz# $TEST_IMG will be in mode 0400 because it is read-only; we are going 202e6c79647SMax Reitz# to write to the copy, so make it writable 203e6c79647SMax Reitzchmod 0600 "$COPIED_IMG" 204e6c79647SMax Reitz 205e6c79647SMax Reitzecho 206e6c79647SMax Reitzecho '=== Double export ===' 207e6c79647SMax Reitz 208e6c79647SMax Reitz# We have already seen that exporting a node twice works fine, but you 209e6c79647SMax Reitz# cannot export anything twice on the same mount point. The reason is 210e6c79647SMax Reitz# that qemu has to stat the given mount point, and this would have to 211e6c79647SMax Reitz# be answered by the same qemu instance if it already has an export 212e6c79647SMax Reitz# there. However, it cannot answer the stat because it is itself 213e6c79647SMax Reitz# caught up in that same stat. 214e6c79647SMax Reitzfuse_export_add 'export-err' "'mountpoint': '$EXT_MP'" error 215e6c79647SMax Reitz 216e6c79647SMax Reitzecho 217e6c79647SMax Reitzecho '=== Remove export ===' 218e6c79647SMax Reitz 219e6c79647SMax Reitz# Double-check that $EXT_MP appears as a non-empty file (the raw image) 22074163addSHanna Reitz$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' | head -n 1 221e6c79647SMax Reitz 222e6c79647SMax Reitzfuse_export_del 'export-mp' 223e6c79647SMax Reitz 224e6c79647SMax Reitz# See that the file appears empty again 22574163addSHanna Reitz$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' | head -n 1 226e6c79647SMax Reitz 227e6c79647SMax Reitzecho 228e6c79647SMax Reitzecho '=== Writable export ===' 229e6c79647SMax Reitz 230e6c79647SMax Reitzfuse_export_add 'export-mp' "'mountpoint': '$EXT_MP', 'writable': true" 231e6c79647SMax Reitz 232e6c79647SMax Reitz# Check that writing to the read-only export fails 233e2eec281SHanna Reitzoutput=$($QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" 2>&1 \ 234e2eec281SHanna Reitz | _filter_qemu_io | _filter_testdir | _filter_imgfmt) 235e2eec281SHanna Reitz 236e2eec281SHanna Reitz# Expected reference output: Opening the file fails because it has no 237e2eec281SHanna Reitz# write permission 238e2eec281SHanna Reitzreference="Could not open 'TEST_DIR/t.IMGFMT': Permission denied" 239e2eec281SHanna Reitz 240e2eec281SHanna Reitzif echo "$output" | grep -q "$reference"; then 241e2eec281SHanna Reitz echo "Writing to read-only export failed: OK" 242e2eec281SHanna Reitzelif echo "$output" | grep -q "write failed: Permission denied"; then 243e2eec281SHanna Reitz # With CAP_DAC_OVERRIDE (e.g. when running this test as root), the export 244e2eec281SHanna Reitz # can be opened regardless of its file permissions, but writing will then 245e2eec281SHanna Reitz # fail. This is not the result for which we want to test, so count this as 246e2eec281SHanna Reitz # a SKIP. 247e2eec281SHanna Reitz _casenotrun "Opening RO export as R/W succeeded, perhaps because of" \ 248e2eec281SHanna Reitz "CAP_DAC_OVERRIDE" 249e2eec281SHanna Reitz 250e2eec281SHanna Reitz # Still, write this to the reference output to make the test pass 251e2eec281SHanna Reitz echo "Writing to read-only export failed: OK" 252e2eec281SHanna Reitzelse 253e2eec281SHanna Reitz echo "Writing to read-only export failed: ERROR" 254e2eec281SHanna Reitz echo "$output" 255e2eec281SHanna Reitzfi 256e6c79647SMax Reitz 257e6c79647SMax Reitz# But here it should work 258e6c79647SMax Reitz$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$EXT_MP" | _filter_qemu_io 259e6c79647SMax Reitz 260e6c79647SMax Reitz# (Adjust the copy, too) 261e6c79647SMax Reitz$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$COPIED_IMG" | _filter_qemu_io 262e6c79647SMax Reitz 263e6c79647SMax Reitzecho 264e6c79647SMax Reitzecho '=== Resizing exports ===' 265e6c79647SMax Reitz 266e6c79647SMax Reitz# Here, we need to export the protocol node -- the format layer may 267e6c79647SMax Reitz# not be growable, simply because the format does not support it. 268e6c79647SMax Reitz 269e6c79647SMax Reitz# Remove all exports and the format node first so permissions will not 270e6c79647SMax Reitz# get in the way 271e6c79647SMax Reitzfuse_export_del 'export-mp' 272e6c79647SMax Reitzfuse_export_del 'export-img' 273e6c79647SMax Reitz 274e6c79647SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 275e6c79647SMax Reitz "{'execute': 'blockdev-del', 276e6c79647SMax Reitz 'arguments': { 277e6c79647SMax Reitz 'node-name': 'node-format' 278e6c79647SMax Reitz } }" \ 279e6c79647SMax Reitz 'return' 280e6c79647SMax Reitz 281e6c79647SMax Reitz# Now export the protocol node 282e6c79647SMax Reitzfuse_export_add \ 283e6c79647SMax Reitz 'export-mp' \ 284e6c79647SMax Reitz "'mountpoint': '$EXT_MP', 'writable': true" \ 285e6c79647SMax Reitz 'return' \ 286e6c79647SMax Reitz 'node-protocol' 287e6c79647SMax Reitz 288e6c79647SMax Reitzecho 289e6c79647SMax Reitzecho '--- Try growing non-growable export ---' 290e6c79647SMax Reitz 291e6c79647SMax Reitz# Get the current size so we can write beyond the EOF 292e6c79647SMax Reitzorig_len=$(get_proto_len "$EXT_MP" "$TEST_IMG") 293e6c79647SMax Reitzorig_disk_usage=$(stat -c '%b' "$TEST_IMG") 294e6c79647SMax Reitz 295e6c79647SMax Reitz# Should fail (exports are non-growable by default) 296e6c79647SMax Reitz# (Note that qemu-io can never write beyond the EOF, so we have to use 297e6c79647SMax Reitz# dd here) 298e6c79647SMax Reitzdd if=/dev/zero of="$EXT_MP" bs=1 count=64k seek=$orig_len 2>&1 \ 299e6c79647SMax Reitz | _filter_testdir | _filter_imgfmt 300e6c79647SMax Reitz 301e6c79647SMax Reitzecho 302e6c79647SMax Reitzecho '--- Resize export ---' 303e6c79647SMax Reitz 304e6c79647SMax Reitz# But we can truncate it explicitly; even with fallocate 305e6c79647SMax Reitzfallocate -o "$orig_len" -l 64k "$EXT_MP" 306e6c79647SMax Reitz 307e6c79647SMax Reitznew_len=$(get_proto_len "$EXT_MP" "$TEST_IMG") 308e6c79647SMax Reitzif [ "$new_len" != "$((orig_len + 65536))" ]; then 309e6c79647SMax Reitz echo 'ERROR: Unexpected post-truncate image size:' 310e6c79647SMax Reitz echo "$new_len != $((orig_len + 65536))" 311e6c79647SMax Reitzelse 312e6c79647SMax Reitz echo 'OK: Post-truncate image size is as expected' 313e6c79647SMax Reitzfi 314e6c79647SMax Reitz 315e6c79647SMax Reitznew_disk_usage=$(stat -c '%b' "$TEST_IMG") 316e6c79647SMax Reitzif [ "$new_disk_usage" -gt "$orig_disk_usage" ]; then 317e6c79647SMax Reitz echo 'OK: Disk usage grew with fallocate' 318e6c79647SMax Reitzelse 319e6c79647SMax Reitz echo 'ERROR: Disk usage did not grow despite fallocate:' 320e6c79647SMax Reitz echo "$orig_disk_usage => $new_disk_usage" 321e6c79647SMax Reitzfi 322e6c79647SMax Reitz 323e6c79647SMax Reitzecho 324e6c79647SMax Reitzecho '--- Try growing growable export ---' 325e6c79647SMax Reitz 326e6c79647SMax Reitz# Now export as growable 327e6c79647SMax Reitzfuse_export_del 'export-mp' 328e6c79647SMax Reitzfuse_export_add \ 329e6c79647SMax Reitz 'export-mp' \ 330e6c79647SMax Reitz "'mountpoint': '$EXT_MP', 'writable': true, 'growable': true" \ 331e6c79647SMax Reitz 'return' \ 332e6c79647SMax Reitz 'node-protocol' 333e6c79647SMax Reitz 334e6c79647SMax Reitz# Now we should be able to write beyond the EOF 335e6c79647SMax Reitzdd if=/dev/zero of="$EXT_MP" bs=1 count=64k seek=$new_len 2>&1 \ 336e6c79647SMax Reitz | _filter_testdir | _filter_imgfmt 337e6c79647SMax Reitz 338e6c79647SMax Reitznew_len=$(get_proto_len "$EXT_MP" "$TEST_IMG") 339e6c79647SMax Reitzif [ "$new_len" != "$((orig_len + 131072))" ]; then 340e6c79647SMax Reitz echo 'ERROR: Unexpected post-grow image size:' 341e6c79647SMax Reitz echo "$new_len != $((orig_len + 131072))" 342e6c79647SMax Reitzelse 343e6c79647SMax Reitz echo 'OK: Post-grow image size is as expected' 344e6c79647SMax Reitzfi 345e6c79647SMax Reitz 346e6c79647SMax Reitzecho 347e6c79647SMax Reitzecho '--- Shrink export ---' 348e6c79647SMax Reitz 349e6c79647SMax Reitz# Now go back to the original size 350e6c79647SMax Reitztruncate -s "$orig_len" "$EXT_MP" 351e6c79647SMax Reitz 352e6c79647SMax Reitznew_len=$(get_proto_len "$EXT_MP" "$TEST_IMG") 353e6c79647SMax Reitzif [ "$new_len" != "$orig_len" ]; then 354e6c79647SMax Reitz echo 'ERROR: Unexpected post-truncate image size:' 355e6c79647SMax Reitz echo "$new_len != $orig_len" 356e6c79647SMax Reitzelse 357e6c79647SMax Reitz echo 'OK: Post-truncate image size is as expected' 358e6c79647SMax Reitzfi 359e6c79647SMax Reitz 360e6c79647SMax Reitzecho 361e6c79647SMax Reitzecho '=== Tear down ===' 362e6c79647SMax Reitz 363e6c79647SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 364e6c79647SMax Reitz "{'execute': 'quit'}" \ 365e6c79647SMax Reitz 'return' 366e6c79647SMax Reitz 367e6c79647SMax Reitzwait=yes _cleanup_qemu 368e6c79647SMax Reitz 369e6c79647SMax Reitzecho 370e6c79647SMax Reitzecho '=== Compare copy with original ===' 371e6c79647SMax Reitz 372e6c79647SMax Reitz$QEMU_IMG compare -f raw -F $IMGFMT "$COPIED_IMG" "$TEST_IMG" 37327e0d8b5SHanna Czenczek_cleanup_test_img 37427e0d8b5SHanna Czenczek 37527e0d8b5SHanna Czenczekecho 37627e0d8b5SHanna Czenczekecho '=== Writing zeroes while unmapping ===' 37727e0d8b5SHanna Czenczek# Regression test for https://gitlab.com/qemu-project/qemu/-/issues/1507 37827e0d8b5SHanna Czenczek_make_test_img 64M 37927e0d8b5SHanna Czenczek$QEMU_IO -c 'write -s /dev/urandom 0 64M' "$TEST_IMG" | _filter_qemu_io 38027e0d8b5SHanna Czenczek 38127e0d8b5SHanna Czenczek_launch_qemu 38227e0d8b5SHanna Czenczek_send_qemu_cmd $QEMU_HANDLE \ 38327e0d8b5SHanna Czenczek "{'execute': 'qmp_capabilities'}" \ 38427e0d8b5SHanna Czenczek 'return' 38527e0d8b5SHanna Czenczek 38627e0d8b5SHanna Czenczek_send_qemu_cmd $QEMU_HANDLE \ 38727e0d8b5SHanna Czenczek "{'execute': 'blockdev-add', 38827e0d8b5SHanna Czenczek 'arguments': { 38927e0d8b5SHanna Czenczek 'driver': '$IMGFMT', 39027e0d8b5SHanna Czenczek 'node-name': 'node-format', 39127e0d8b5SHanna Czenczek 'file': { 39227e0d8b5SHanna Czenczek 'driver': 'file', 39327e0d8b5SHanna Czenczek 'filename': '$TEST_IMG' 39427e0d8b5SHanna Czenczek } 39527e0d8b5SHanna Czenczek } }" \ 39627e0d8b5SHanna Czenczek 'return' 39727e0d8b5SHanna Czenczek 39827e0d8b5SHanna Czenczekfuse_export_add 'export' "'mountpoint': '$EXT_MP', 'writable': true" 39927e0d8b5SHanna Czenczek 40027e0d8b5SHanna Czenczek# Try writing zeroes by unmapping 40127e0d8b5SHanna Czenczek$QEMU_IO -f raw -c 'write -zu 0 64M' "$EXT_MP" | _filter_qemu_io 40227e0d8b5SHanna Czenczek 40327e0d8b5SHanna Czenczek# Check the result 40427e0d8b5SHanna Czenczek$QEMU_IO -f raw -c 'read -P 0 0 64M' "$EXT_MP" | _filter_qemu_io 40527e0d8b5SHanna Czenczek 40627e0d8b5SHanna Czenczek_send_qemu_cmd $QEMU_HANDLE \ 40727e0d8b5SHanna Czenczek "{'execute': 'quit'}" \ 40827e0d8b5SHanna Czenczek 'return' 40927e0d8b5SHanna Czenczek 41027e0d8b5SHanna Czenczekwait=yes _cleanup_qemu 41127e0d8b5SHanna Czenczek 41227e0d8b5SHanna Czenczek# Check the original image 41327e0d8b5SHanna Czenczek$QEMU_IO -c 'read -P 0 0 64M' "$TEST_IMG" | _filter_qemu_io 41427e0d8b5SHanna Czenczek 41527e0d8b5SHanna Czenczek_cleanup_test_img 416e6c79647SMax Reitz 417e6c79647SMax Reitz# success, all done 418e6c79647SMax Reitzecho "*** done" 419e6c79647SMax Reitzrm -f $seq.full 420e6c79647SMax Reitzstatus=0 421