111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick 321c7f3f7SMax Reitz# 48382ba61SFam Zheng# Test case for drive-mirror to NBD 521c7f3f7SMax Reitz# 621c7f3f7SMax Reitz# Copyright (C) 2015 Red Hat, Inc. 721c7f3f7SMax Reitz# 821c7f3f7SMax Reitz# This program is free software; you can redistribute it and/or modify 921c7f3f7SMax Reitz# it under the terms of the GNU General Public License as published by 1021c7f3f7SMax Reitz# the Free Software Foundation; either version 2 of the License, or 1121c7f3f7SMax Reitz# (at your option) any later version. 1221c7f3f7SMax Reitz# 1321c7f3f7SMax Reitz# This program is distributed in the hope that it will be useful, 1421c7f3f7SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 1521c7f3f7SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1621c7f3f7SMax Reitz# GNU General Public License for more details. 1721c7f3f7SMax Reitz# 1821c7f3f7SMax Reitz# You should have received a copy of the GNU General Public License 1921c7f3f7SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 2021c7f3f7SMax Reitz# 2121c7f3f7SMax Reitz 2221c7f3f7SMax Reitz# creator 23*42a5009dSJohn Snowowner=hreitz@redhat.com 2421c7f3f7SMax Reitz 2521c7f3f7SMax Reitzseq="$(basename $0)" 2621c7f3f7SMax Reitzecho "QA output created by $seq" 2721c7f3f7SMax Reitz 2821c7f3f7SMax Reitzstatus=1 # failure is the default! 2921c7f3f7SMax Reitz 30ecfa1854SJeff Cody_cleanup() 31ecfa1854SJeff Cody{ 32ecfa1854SJeff Cody _cleanup_qemu 33ecfa1854SJeff Cody _cleanup_test_img 34f91ecbd7SMax Reitz _rm_test_img "$TEST_DIR/source.$IMGFMT" 35ecfa1854SJeff Cody} 36ecfa1854SJeff Cody 37ecfa1854SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 3821c7f3f7SMax Reitz 3921c7f3f7SMax Reitz# get standard environment, filters and checks 4021c7f3f7SMax Reitz. ./common.rc 4121c7f3f7SMax Reitz. ./common.filter 4221c7f3f7SMax Reitz. ./common.qemu 4321c7f3f7SMax Reitz 4421c7f3f7SMax Reitz_supported_fmt generic 4521c7f3f7SMax Reitz_supported_proto nbd 4621c7f3f7SMax Reitz_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" 4721c7f3f7SMax Reitz 4821c7f3f7SMax Reitz_make_test_img 64M 4952a97b5aSMax ReitzTEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M 5021c7f3f7SMax Reitz 5121c7f3f7SMax Reitz_launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ 5221c7f3f7SMax Reitz -nodefaults 5321c7f3f7SMax Reitz 5421c7f3f7SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 5521c7f3f7SMax Reitz "{'execute': 'qmp_capabilities'}" \ 5621c7f3f7SMax Reitz 'return' 5721c7f3f7SMax Reitz 588382ba61SFam Zheng# 'format': 'nbd' is not actually "correct", but this was the only way to 598382ba61SFam Zheng# test the bug fixed in commit f53a829. Though the bug's related code 608382ba61SFam Zheng# bdrv_swap() was replaced later, let's make sure we don't fall in the same 618382ba61SFam Zheng# pit again. 6221c7f3f7SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 6321c7f3f7SMax Reitz "{'execute': 'drive-mirror', 6421c7f3f7SMax Reitz 'arguments': {'device': 'src', 6521c7f3f7SMax Reitz 'target': '$TEST_IMG', 6621c7f3f7SMax Reitz 'format': 'nbd', 6721c7f3f7SMax Reitz 'sync':'full', 6821c7f3f7SMax Reitz 'mode':'existing'}}" \ 6921c7f3f7SMax Reitz 'BLOCK_JOB_READY' 7021c7f3f7SMax Reitz 7121c7f3f7SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 7221c7f3f7SMax Reitz "{'execute': 'block-job-complete', 7321c7f3f7SMax Reitz 'arguments': {'device': 'src'}}" \ 7421c7f3f7SMax Reitz 'BLOCK_JOB_COMPLETE' 7521c7f3f7SMax Reitz 7621c7f3f7SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 7721c7f3f7SMax Reitz "{'execute': 'quit'}" \ 7821c7f3f7SMax Reitz 'return' 7921c7f3f7SMax Reitz 8021c7f3f7SMax Reitzwait=1 _cleanup_qemu 8121c7f3f7SMax Reitz 8221c7f3f7SMax Reitz 8321c7f3f7SMax Reitz# success, all done 8421c7f3f7SMax Reitzecho '*** done' 8521c7f3f7SMax Reitzrm -f $seq.full 8621c7f3f7SMax Reitzstatus=0 87