From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UujSs-00040M-3L for qemu-devel@nongnu.org; Thu, 04 Jul 2013 09:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UujSq-0004vI-9d for qemu-devel@nongnu.org; Thu, 04 Jul 2013 09:20:50 -0400 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]:58728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UujSq-0004v3-1z for qemu-devel@nongnu.org; Thu, 04 Jul 2013 09:20:48 -0400 Received: by mail-ea0-f180.google.com with SMTP id k10so790828eaj.25 for ; Thu, 04 Jul 2013 06:20:47 -0700 (PDT) Date: Thu, 4 Jul 2013 15:20:44 +0200 From: Stefan Hajnoczi Message-ID: <20130704132044.GH4213@stefanha-thinkpad.redhat.com> References: <1372386525-23155-1-git-send-email-imain@redhat.com> <1372386525-23155-3-git-send-email-imain@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1372386525-23155-3-git-send-email-imain@redhat.com> Subject: Re: [Qemu-devel] [PATCH V1 2/2] Add tests for sync modes 'TOP' and 'NONE' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ian Main Cc: qemu-devel@nongnu.org On Thu, Jun 27, 2013 at 07:28:45PM -0700, Ian Main wrote: > diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 > index c66f8db..6de81ff 100755 > --- a/tests/qemu-iotests/055 > +++ b/tests/qemu-iotests/055 > @@ -23,8 +23,9 @@ > import time > import os > import iotests > -from iotests import qemu_img, qemu_io > +from iotests import qemu_img, qemu_io, create_image > > +backing_img = os.path.join(iotests.test_dir, 'backing.img') > test_img = os.path.join(iotests.test_dir, 'test.img') > target_img = os.path.join(iotests.test_dir, 'target.img') > > @@ -60,6 +61,20 @@ class TestSingleDrive(iotests.QMPTestCase): > event = self.cancel_and_wait() > self.assert_qmp(event, 'data/type', 'backup') > > + def test_cancel_sync_none(self): > + self.assert_no_active_block_jobs() > + > + result = self.vm.qmp('drive-backup', device='drive0', > + sync='none', target=target_img) > + self.assert_qmp(result, 'return', {}) > + time.sleep(1) > + > + # This is generally very hard to test, we would have to > + # have some writing going on in the VM to test and know > + # what the result should be. You can use the qemu-io HMP command to write to the disk from this test case. First take a look at the qemu-io(1) command-line help output. To fill the first sector with 0x5e you would do something like this: $ qemu-io -c 'write -P0x5e 0 512' test.img Kevin recently added an HMP command so you can invoke this from the monitor. It operates on an open drive, see hmp-commands.hx. Finally, you need to use the QMP 'human-monitor-command' to invoke HMP commands from your test case. Basically you need something like: self.vm.qmp('human-monitor-command', command-line='drive0 "write -P0x5e 0 512"') We should probably wrap this in a new method called VM.hmp_qemu_io() in iotests.py, so that tests can simply do: self.vm.hmp_qemu_io('drive0', 'write -P0x5e 0 512') Anyway, this lets you write to the drive. This should be good for testing sync=none.