Skip to content

Commit

Permalink
qemu-iotest: Add pause_drive and resume_drive methods
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fam Zheng authored and kevmw committed Nov 29, 2013
1 parent 4cc70e9 commit 3cf53c7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/qemu-iotests/iotests.py
Expand Up @@ -107,6 +107,19 @@ def add_drive(self, path, opts=''):
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',
Expand Down Expand Up @@ -222,11 +235,14 @@ def assert_no_active_block_jobs(self):
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:
Expand Down

0 comments on commit 3cf53c7

Please sign in to comment.