aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2013-11-20 10:01:55 +0800
committerKevin Wolf <kwolf@redhat.com>2013-11-29 13:40:37 +0100
commit3cf53c771406ad360117f30e61b24635df0e9b50 (patch)
tree0000e388e23a92ed43dd219cabd49b2760658995 /tests
parent4cc70e933731ebf4309e1f1ce90973a0de04f28f (diff)
qemu-iotest: Add pause_drive and resume_drive methods
They wrap blkdebug "break" and "remove_break". Add optional argument "resume" to cancel_and_wait(). Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/iotests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index fb10ff43a7..10c9a99e3a 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -107,6 +107,19 @@ class VM(object):
self._num_drives += 1
return self
+ def pause_drive(self, drive, event=None):
+ '''Pause drive r/w operations'''
+ if not event:
+ self.pause_drive(drive, "read_aio")
+ self.pause_drive(drive, "write_aio")
+ return
+ self.qmp('human-monitor-command',
+ command_line='qemu-io %s "break %s bp_%s"' % (drive, event, drive))
+
+ def resume_drive(self, drive):
+ self.qmp('human-monitor-command',
+ command_line='qemu-io %s "remove_break bp_%s"' % (drive, drive))
+
def hmp_qemu_io(self, drive, cmd):
'''Write to a given drive using an HMP command'''
return self.qmp('human-monitor-command',
@@ -222,11 +235,14 @@ class QMPTestCase(unittest.TestCase):
result = self.vm.qmp('query-block-jobs')
self.assert_qmp(result, 'return', [])
- def cancel_and_wait(self, drive='drive0', force=False):
+ def cancel_and_wait(self, drive='drive0', force=False, resume=False):
'''Cancel a block job and wait for it to finish, returning the event'''
result = self.vm.qmp('block-job-cancel', device=drive, force=force)
self.assert_qmp(result, 'return', {})
+ if resume:
+ self.vm.resume_drive(drive)
+
cancelled = False
result = None
while not cancelled: