From patchwork Wed Jun 7 17:50:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 772628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wjblV26HXz9sDC for ; Thu, 8 Jun 2017 03:53:58 +1000 (AEST) Received: from localhost ([::1]:45519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf9Y-0004EP-0O for incoming@patchwork.ozlabs.org; Wed, 07 Jun 2017 13:53:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf6M-00020O-4N for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIf6L-0005x3-1X for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51364) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIf6H-0005vT-9G; Wed, 07 Jun 2017 13:50:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 401E0C0587D4; Wed, 7 Jun 2017 17:50:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 401E0C0587D4 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 401E0C0587D4 Received: from noname.redhat.com (ovpn-117-1.ams2.redhat.com [10.36.117.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E6B67E659; Wed, 7 Jun 2017 17:50:31 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 7 Jun 2017 19:50:17 +0200 Message-Id: <1496857819-12466-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1496857819-12466-1-git-send-email-kwolf@redhat.com> References: <1496857819-12466-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 07 Jun 2017 17:50:32 +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] [PULL 6/8] qemu-iotests: Test automatic commit job cancel on hot unplug 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Kevin Wolf Reviewed-by: John Snow --- tests/qemu-iotests/040 | 35 +++++++++++++++++++++++++++++++++-- tests/qemu-iotests/040.out | 4 ++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 5bdaf3d..9d381d9 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -70,7 +70,9 @@ class ImageCommitTestCase(iotests.QMPTestCase): self.wait_for_complete() class TestSingleDrive(ImageCommitTestCase): - image_len = 1 * 1024 * 1024 + # Need some space after the copied data so that throttling is effective in + # tests that use it rather than just completing the job immediately + image_len = 2 * 1024 * 1024 test_len = 1 * 1024 * 256 def setUp(self): @@ -79,7 +81,9 @@ class TestSingleDrive(ImageCommitTestCase): qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img) qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img) qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', mid_img) - self.vm = iotests.VM().add_drive(test_img) + self.vm = iotests.VM().add_drive(test_img, interface="none") + self.vm.add_device("virtio-scsi-pci") + self.vm.add_device("scsi-hd,id=scsi0,drive=drive0") self.vm.launch() def tearDown(self): @@ -131,6 +135,33 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img) + # When the job is running on a BB that is automatically deleted on hot + # unplug, the job is cancelled when the device disappears + def test_hot_unplug(self): + if self.image_len == 0: + return + + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', device='drive0', top=mid_img, + base=backing_img, speed=(self.image_len / 4)) + self.assert_qmp(result, 'return', {}) + result = self.vm.qmp('device_del', id='scsi0') + self.assert_qmp(result, 'return', {}) + + cancelled = False + deleted = False + while not cancelled or not deleted: + for event in self.vm.get_qmp_events(wait=True): + if event['event'] == 'DEVICE_DELETED': + self.assert_qmp(event, 'data/device', 'scsi0') + deleted = True + elif event['event'] == 'BLOCK_JOB_CANCELLED': + self.assert_qmp(event, 'data/device', 'drive0') + cancelled = True + else: + self.fail("Unexpected event %s" % (event['event'])) + + self.assert_no_active_block_jobs() class TestRelativePaths(ImageCommitTestCase): image_len = 1 * 1024 * 1024 diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index 4fd1c2d..6d9bee1 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -......................... +........................... ---------------------------------------------------------------------- -Ran 25 tests +Ran 27 tests OK