From nobody Wed Nov 5 16:15:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497009135407950.2411661746494; Fri, 9 Jun 2017 04:52:15 -0700 (PDT) Received: from localhost ([::1]:54046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJISc-00082t-1n for importer@patchew.org; Fri, 09 Jun 2017 07:52:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJIQk-0006uE-Qd for qemu-devel@nongnu.org; Fri, 09 Jun 2017 07:50:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJIQj-00022H-5R for qemu-devel@nongnu.org; Fri, 09 Jun 2017 07:50:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJIQe-0001vF-36; Fri, 09 Jun 2017 07:50:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14E3DC0587DB; Fri, 9 Jun 2017 11:50:11 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-130.ams2.redhat.com [10.36.117.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B4931879D; Fri, 9 Jun 2017 11:50:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 14E3DC0587DB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 14E3DC0587DB From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 9 Jun 2017 13:50:03 +0200 Message-Id: <1497009003-25794-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1497009003-25794-1-git-send-email-kwolf@redhat.com> References: <1497009003-25794-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 09 Jun 2017 11:50:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] qemu-iotests: Test exiting qemu with running job X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When qemu is exited, all running jobs should be cancelled successfully. This adds a test for this for all types of block jobs that currently exist in qemu. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/qemu-iotests/185 | 189 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/185.out | 59 ++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 249 insertions(+) create mode 100755 tests/qemu-iotests/185 create mode 100644 tests/qemu-iotests/185.out diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185 new file mode 100755 index 0000000..645ec9a --- /dev/null +++ b/tests/qemu-iotests/185 @@ -0,0 +1,189 @@ +#!/bin/bash +# +# Test exiting qemu while jobs are still running +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +MIG_SOCKET=3D"${TEST_DIR}/migrate" + +_cleanup() +{ + rm -f "${TEST_IMG}.mid" + rm -f "${TEST_IMG}.copy" + _cleanup_test_img + _cleanup_qemu +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 raw +_supported_proto file +_supported_os Linux + +size=3D64M +TEST_IMG=3D"${TEST_IMG}.base" _make_test_img $size + +echo +echo =3D=3D=3D Starting VM =3D=3D=3D +echo + +qemu_comm_method=3D"qmp" + +_launch_qemu \ + -drive file=3D"${TEST_IMG}.base",cache=3D$CACHEMODE,driver=3D$IMGFMT,i= d=3Ddisk +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +echo +echo =3D=3D=3D Creating backing chain =3D=3D=3D +echo + +_send_qemu_cmd $h \ + "{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'disk', + 'snapshot-file': '$TEST_IMG.mid', + 'format': '$IMGFMT', + 'mode': 'absolute-paths' } }" \ + "return" + +_send_qemu_cmd $h \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk \"write 0 4M\"' } }" \ + "return" + +_send_qemu_cmd $h \ + "{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'disk', + 'snapshot-file': '$TEST_IMG', + 'format': '$IMGFMT', + 'mode': 'absolute-paths' } }" \ + "return" + +echo +echo =3D=3D=3D Start commit job and exit qemu =3D=3D=3D +echo + +_send_qemu_cmd $h \ + "{ 'execute': 'block-commit', + 'arguments': { 'device': 'disk', + 'base':'$TEST_IMG.base', + 'top': '$TEST_IMG.mid', + 'speed': 65536 } }" \ + "return" + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "return" +wait=3D1 _cleanup_qemu + +echo +echo =3D=3D=3D Start active commit job and exit qemu =3D=3D=3D +echo + +_launch_qemu \ + -drive file=3D"${TEST_IMG}",cache=3D$CACHEMODE,driver=3D$IMGFMT,id=3Dd= isk +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +_send_qemu_cmd $h \ + "{ 'execute': 'block-commit', + 'arguments': { 'device': 'disk', + 'base':'$TEST_IMG.base', + 'speed': 65536 } }" \ + "return" + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "return" +wait=3D1 _cleanup_qemu + +echo +echo =3D=3D=3D Start mirror job and exit qemu =3D=3D=3D +echo + +_launch_qemu \ + -drive file=3D"${TEST_IMG}",cache=3D$CACHEMODE,driver=3D$IMGFMT,id=3Dd= isk +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +_send_qemu_cmd $h \ + "{ 'execute': 'drive-mirror', + 'arguments': { 'device': 'disk', + 'target': '$TEST_IMG.copy', + 'format': '$IMGFMT', + 'sync': 'full', + 'speed': 65536 } }" \ + "return" + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "return" +wait=3D1 _cleanup_qemu + +echo +echo =3D=3D=3D Start backup job and exit qemu =3D=3D=3D +echo + +_launch_qemu \ + -drive file=3D"${TEST_IMG}",cache=3D$CACHEMODE,driver=3D$IMGFMT,id=3Dd= isk +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +_send_qemu_cmd $h \ + "{ 'execute': 'drive-backup', + 'arguments': { 'device': 'disk', + 'target': '$TEST_IMG.copy', + 'format': '$IMGFMT', + 'sync': 'full', + 'speed': 65536 } }" \ + "return" + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "return" +wait=3D1 _cleanup_qemu + +echo +echo =3D=3D=3D Start streaming job and exit qemu =3D=3D=3D +echo + +_launch_qemu \ + -drive file=3D"${TEST_IMG}",cache=3D$CACHEMODE,driver=3D$IMGFMT,id=3Dd= isk +h=3D$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +_send_qemu_cmd $h \ + "{ 'execute': 'block-stream', + 'arguments': { 'device': 'disk', + 'speed': 65536 } }" \ + "return" + +_send_qemu_cmd $h "{ 'execute': 'quit' }" "return" +wait=3D1 _cleanup_qemu + +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out new file mode 100644 index 0000000..45bc7cb --- /dev/null +++ b/tests/qemu-iotests/185.out @@ -0,0 +1,59 @@ +QA output created by 185 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 + +=3D=3D=3D Starting VM =3D=3D=3D + +{"return": {}} + +=3D=3D=3D Creating backing chain =3D=3D=3D + +Formatting 'TEST_DIR/t.qcow2.mid', fmt=3Dqcow2 size=3D67108864 backing_fil= e=3DTEST_DIR/t.qcow2.base backing_fmt=3Dqcow2 encryption=3Doff cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +{"return": {}} +wrote 4194304/4194304 bytes at offset 0 +4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{"return": ""} +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 backing_file=3D= TEST_DIR/t.qcow2.mid backing_fmt=3Dqcow2 encryption=3Doff cluster_size=3D65= 536 lazy_refcounts=3Doff refcount_bits=3D16 +{"return": {}} + +=3D=3D=3D Start commit job and exit qemu =3D=3D=3D + +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offse= t": 524288, "speed": 65536, "type": "commit"}} + +=3D=3D=3D Start active commit job and exit qemu =3D=3D=3D + +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset= ": 4194304, "speed": 65536, "type": "commit"}} + +=3D=3D=3D Start mirror job and exit qemu =3D=3D=3D + +{"return": {}} +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 encryption= =3Doff cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset= ": 4194304, "speed": 65536, "type": "mirror"}} + +=3D=3D=3D Start backup job and exit qemu =3D=3D=3D + +{"return": {}} +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 encryption= =3Doff cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offse= t": 65536, "speed": 65536, "type": "backup"}} + +=3D=3D=3D Start streaming job and exit qemu =3D=3D=3D + +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offse= t": 524288, "speed": 65536, "type": "stream"}} +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index a6acaff..318ae74 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -175,3 +175,4 @@ 181 rw auto migration 182 rw auto quick 183 rw auto migration +185 rw auto --=20 1.8.3.1