From patchwork Thu Apr 12 12:01:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 152061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0CD1AB706B for ; Thu, 12 Apr 2012 23:19:23 +1000 (EST) Received: from localhost ([::1]:58438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIJvk-0003SX-ON for incoming@patchwork.ozlabs.org; Thu, 12 Apr 2012 09:19:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIIk0-0006j6-Jz for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:03:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIIjt-00063A-MA for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:03:08 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:65466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIIjt-0005p8-EI for qemu-devel@nongnu.org; Thu, 12 Apr 2012 08:03:01 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so2694743pbc.4 for ; Thu, 12 Apr 2012 05:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=/kydNYaLxx91o2U4SvuVFrNE6XsOPqErDeVblsjU5xA=; b=j62NMp0r7OzaOM8x+qfBoTxweJf96Nj+L5Ms9xQDnMt04aZjCCAwbE85pe2UgpaC08 RS2MQAUvjbx603acHqGNjfIRcY/lbpFD1x34obJiiCfHI9PrcnO6P9NeFWHOUy61uZbL GR5jCh/X31Dtsca9eRVZ+8zcpo6hEkvRGFeXVRcUyYRLuQV9x7DmqmKiK5kqvGyU+fft 6vRF3yNETEdktfBZfP/Sivk34mM5HO31Ym6uUtceJtIwQiP1y3MdY+tfA3GpOwoiGG1c uCn8fARwYWi7IjABTk4rmxkkhiI7JXwyynMTzrmGbdXkVT8vCmY7f00RpZms1bGjtStB b3Vw== Received: by 10.68.201.6 with SMTP id jw6mr2562417pbc.92.1334232180573; Thu, 12 Apr 2012 05:03:00 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id qu5sm5515368pbc.45.2012.04.12.05.02.57 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Apr 2012 05:02:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 12 Apr 2012 14:01:09 +0200 Message-Id: <1334232076-19018-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334232076-19018-1-git-send-email-pbonzini@redhat.com> References: <1334232076-19018-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 19/26] stream: add testcase for partial streaming X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- tests/qemu-iotests/030 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 3efb6cd..9c74dd2 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -23,6 +23,7 @@ import iotests from iotests import qemu_img, qemu_io backing_img = os.path.join(iotests.test_dir, 'backing.img') +mid_img = os.path.join(iotests.test_dir, 'mid.img') test_img = os.path.join(iotests.test_dir, 'test.img') class ImageStreamingTestCase(iotests.QMPTestCase): @@ -37,7 +38,8 @@ class TestSingleDrive(ImageStreamingTestCase): def setUp(self): qemu_img('create', backing_img, str(TestSingleDrive.image_len)) - qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img) self.vm = iotests.VM().add_drive(test_img) self.vm.launch() @@ -68,6 +70,29 @@ class TestSingleDrive(ImageStreamingTestCase): self.assertFalse('sectors not allocated' in qemu_io('-c', 'map', test_img), 'image file not fully populated after streaming') + def test_stream_partial(self): + self.assert_no_active_streams() + + result = self.vm.qmp('block_stream', device='drive0', base=mid_img) + self.assert_qmp(result, 'return', {}) + + completed = False + while not completed: + for event in self.vm.get_qmp_events(wait=True): + if event['event'] == 'BLOCK_JOB_COMPLETED': + self.assert_qmp(event, 'data/type', 'stream') + self.assert_qmp(event, 'data/device', 'drive0') + self.assert_qmp(event, 'data/offset', self.image_len) + self.assert_qmp(event, 'data/len', self.image_len) + completed = True + + self.assert_no_active_streams() + self.vm.shutdown() + + self.assertEqual(qemu_io('-c', 'map', mid_img), + qemu_io('-c', 'map', test_img), + 'image file map does not match backing file after streaming') + def test_device_not_found(self): result = self.vm.qmp('block_stream', device='nonexistent') self.assert_qmp(result, 'error/class', 'DeviceNotFound')