111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto backing quick 3f700ceaeSMax Reitz# 4f700ceaeSMax Reitz# Test case for mirroring with dataplane 5f700ceaeSMax Reitz# 6f700ceaeSMax Reitz# Copyright (C) 2017 Red Hat, Inc. 7f700ceaeSMax Reitz# 8f700ceaeSMax Reitz# This program is free software; you can redistribute it and/or modify 9f700ceaeSMax Reitz# it under the terms of the GNU General Public License as published by 10f700ceaeSMax Reitz# the Free Software Foundation; either version 2 of the License, or 11f700ceaeSMax Reitz# (at your option) any later version. 12f700ceaeSMax Reitz# 13f700ceaeSMax Reitz# This program is distributed in the hope that it will be useful, 14f700ceaeSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 15f700ceaeSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16f700ceaeSMax Reitz# GNU General Public License for more details. 17f700ceaeSMax Reitz# 18f700ceaeSMax Reitz# You should have received a copy of the GNU General Public License 19f700ceaeSMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 20f700ceaeSMax Reitz# 21f700ceaeSMax Reitz 22f700ceaeSMax Reitz# creator 23*42a5009dSJohn Snowowner=hreitz@redhat.com 24f700ceaeSMax Reitz 25f700ceaeSMax Reitzseq=$(basename $0) 26f700ceaeSMax Reitzecho "QA output created by $seq" 27f700ceaeSMax Reitz 28f700ceaeSMax Reitzstatus=1 # failure is the default! 29f700ceaeSMax Reitz 30f700ceaeSMax Reitz_cleanup() 31f700ceaeSMax Reitz{ 32f700ceaeSMax Reitz _cleanup_qemu 33f700ceaeSMax Reitz _cleanup_test_img 34f700ceaeSMax Reitz _rm_test_img "$TEST_IMG.overlay0" 35f700ceaeSMax Reitz _rm_test_img "$TEST_IMG.overlay1" 36f700ceaeSMax Reitz} 37f700ceaeSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 38f700ceaeSMax Reitz 39f700ceaeSMax Reitz# get standard environment, filters and qemu instance handling 40f700ceaeSMax Reitz. ./common.rc 41f700ceaeSMax Reitz. ./common.filter 42f700ceaeSMax Reitz. ./common.qemu 43f700ceaeSMax Reitz 44f700ceaeSMax Reitz_supported_fmt qcow2 4557284d2aSMax Reitz_supported_proto file fuse 46f700ceaeSMax Reitz 47359a8562SLaurent Vivier_require_devices scsi-hd 48359a8562SLaurent Vivier_require_one_device_of virtio-scsi-pci virtio-scsi-ccw 499bdabfbeSThomas Huth 50f700ceaeSMax ReitzIMG_SIZE=64K 51f700ceaeSMax Reitz 52f700ceaeSMax Reitz_make_test_img $IMG_SIZE 53b66ff2c2SEric BlakeTEST_IMG="$TEST_IMG.overlay0" _make_test_img -b "$TEST_IMG" -F $IMGFMT $IMG_SIZE 54b66ff2c2SEric BlakeTEST_IMG="$TEST_IMG.overlay1" _make_test_img -b "$TEST_IMG" -F $IMGFMT $IMG_SIZE 55f700ceaeSMax Reitz 56f700ceaeSMax Reitz# So that we actually have something to mirror and the job does not return 57f700ceaeSMax Reitz# immediately (which may be bad because then we cannot know whether the 58f700ceaeSMax Reitz# 'return' or the 'BLOCK_JOB_READY' comes first). 59f700ceaeSMax Reitz$QEMU_IO -c 'write 0 42' "$TEST_IMG.overlay0" | _filter_qemu_io 60f700ceaeSMax Reitz 61f700ceaeSMax Reitz# We cannot use virtio-blk here because that does not actually set the attached 62f700ceaeSMax Reitz# BB's AioContext in qtest mode 63f700ceaeSMax Reitz_launch_qemu \ 64f700ceaeSMax Reitz -object iothread,id=iothr \ 65f700ceaeSMax Reitz -blockdev node-name=source,driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG.overlay0" \ 66f700ceaeSMax Reitz -device virtio-scsi,id=scsi-bus,iothread=iothr \ 67f700ceaeSMax Reitz -device scsi-hd,bus=scsi-bus.0,drive=source 68f700ceaeSMax Reitz 69f700ceaeSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 70f700ceaeSMax Reitz "{ 'execute': 'qmp_capabilities' }" \ 71f700ceaeSMax Reitz 'return' 72f700ceaeSMax Reitz 73f700ceaeSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 74f700ceaeSMax Reitz "{ 'execute': 'drive-mirror', 75f700ceaeSMax Reitz 'arguments': { 76f700ceaeSMax Reitz 'job-id': 'mirror', 77f700ceaeSMax Reitz 'device': 'source', 78f700ceaeSMax Reitz 'target': '$TEST_IMG.overlay1', 79f700ceaeSMax Reitz 'mode': 'existing', 80f700ceaeSMax Reitz 'sync': 'top' 81f700ceaeSMax Reitz } }" \ 82f700ceaeSMax Reitz 'BLOCK_JOB_READY' 83f700ceaeSMax Reitz 84f700ceaeSMax Reitz# The backing BDS should be assigned the overlay's AioContext 85f700ceaeSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 86f700ceaeSMax Reitz "{ 'execute': 'block-job-complete', 87f700ceaeSMax Reitz 'arguments': { 'device': 'mirror' } }" \ 88f700ceaeSMax Reitz 'BLOCK_JOB_COMPLETED' 89f700ceaeSMax Reitz 90f700ceaeSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 91f700ceaeSMax Reitz "{ 'execute': 'quit' }" \ 92f700ceaeSMax Reitz 'return' 93f700ceaeSMax Reitz 94f700ceaeSMax Reitzwait=yes _cleanup_qemu 95f700ceaeSMax Reitz 96f700ceaeSMax Reitz# success, all done 97f700ceaeSMax Reitzecho '*** done' 98f700ceaeSMax Reitzrm -f $seq.full 99f700ceaeSMax Reitzstatus=0 100