From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhLNQ-0003rD-Li for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhLN1-0000d2-Vw for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:32:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhLN1-0000Yv-M1 for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:31:43 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAFFVg2K032528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Nov 2013 10:31:43 -0500 Message-ID: <52863E65.9020900@redhat.com> Date: Fri, 15 Nov 2013 16:31:49 +0100 From: Max Reitz MIME-Version: 1.0 References: <1384420220-9244-1-git-send-email-famz@redhat.com> <1384420220-9244-4-git-send-email-famz@redhat.com> In-Reply-To: <1384420220-9244-4-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 3/4] qemu-iotest: Add pause_drive and resume_drive methods List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com On 14.11.2013 10:10, Fam Zheng wrote: > They wrap blkdebug "break" and "remove_break". > > Add optional argument "resume" to cancel_and_wait(). > > Signed-off-by: Fam Zheng > --- > tests/qemu-iotests/iotests.py | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index fb10ff4..a483865 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -107,6 +107,18 @@ class VM(object): > self._num_drives += 1 > return self > > + def pause_drive(self, drive, event=""): > + '''Pause drive r/w operations''' > + if not event: > + self.pause_drive(drive, "read_aio") > + self.pause_drive(drive, "write_aio") > + self.qmp('human-monitor-command', > + command_line='qemu-io %s "break %s bp_%s"' % (drive, event, drive)) In the default event="" case (on, say, "drive0"), you'll execute the three HMP commands 'qemu-io drive0 "break read_aio bp_drive0"', 'qemu-io drive0 "break write_aio bp_drive0"', 'qemu-io drive0 "break bp_drive0"', that is, this code will issue three HMP commands with the last one having an empty string as the event (which is probably not what you want and will probably result in a silently ignored error from the break command). Also, I'd propose using something like None instead of "" for the default event. > + > + 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 +234,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=""): > '''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) > + I'd propose using a bool as the resume value (i.e., resume=False as default). In the next patch, it looks like the parameter should be the drive name, although it actually doesn't matter at all what string it contains (as long as it isn't empty). Thus, a boolean value is probably more appropriate. Max > cancelled = False > result = None > while not cancelled: