From: Stefan Hajnoczi <stefanha@gmail.com>
To: Ian Main <imain@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V1 2/2] Add tests for sync modes 'TOP' and 'NONE'
Date: Thu, 4 Jul 2013 15:20:44 +0200 [thread overview]
Message-ID: <20130704132044.GH4213@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1372386525-23155-3-git-send-email-imain@redhat.com>
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.
prev parent reply other threads:[~2013-07-04 13:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 2:28 [Qemu-devel] [PATCH V1 0/2] Implement sync modes for drive-backup Ian Main
2013-06-28 2:28 ` [Qemu-devel] [PATCH V1 1/2] " Ian Main
2013-07-01 12:16 ` Paolo Bonzini
2013-07-03 18:14 ` Ian Main
2013-07-04 7:45 ` Paolo Bonzini
2013-07-08 9:21 ` Fam Zheng
2013-07-15 10:50 ` Paolo Bonzini
2013-07-15 17:49 ` Ian Main
2013-07-15 20:47 ` Paolo Bonzini
2013-07-16 18:17 ` Ian Main
2013-06-28 2:28 ` [Qemu-devel] [PATCH V1 2/2] Add tests for sync modes 'TOP' and 'NONE' Ian Main
2013-07-04 13:20 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130704132044.GH4213@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=imain@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).