From: Stefan Hajnoczi <stefanha@gmail.com>
To: Peter Xu <peterx@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] iotests: fix wait_until_completed()
Date: Wed, 4 Apr 2018 15:24:05 +0100 [thread overview]
Message-ID: <20180404142405.GU4467@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180404014241.GG26441@xz-mi>
[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]
On Wed, Apr 04, 2018 at 09:42:41AM +0800, Peter Xu wrote:
> On Tue, Apr 03, 2018 at 01:59:18PM +0100, Stefan Hajnoczi wrote:
> > On Tue, Mar 27, 2018 at 10:21:55AM +0800, Peter Xu wrote:
> > > On Mon, Mar 26, 2018 at 12:47:39PM +0200, Kevin Wolf wrote:
> > > > Am 26.03.2018 um 08:11 hat Peter Xu geschrieben:
> > > The patch fixes the other case when there
> > > are two events: one JOB_COMPLETED plus another (e.g., RESUME) event.
> > > When that happens, logically we should return one JOB_COMPLETED event,
> > > but the old code will return the other event (e.g., RESUME).
> > >
> > > >
> > > > Wouldn't it be much easier to just add a 'break'?
> > >
> > > Yes, it's the same. But IMHO those logics (e.g., the completed
> > > variable) are not really needed at all. This one is simpler.
> >
> > No, the outer loop is needed so that the function waits until
> > BLOCK_JOB_COMPLETED is received. It's not possible to do it with a
> > single for loop.
>
> Indeed. But then I would still slightly prefer removing the
> "completed" var:
>
> def wait_until_completed(self, drive='drive0', check_offset=True):
> '''Wait for a block job to finish, returning the event'''
> while True:
> for event in self.vm.get_qmp_events(wait=True):
> if event['event'] == 'BLOCK_JOB_COMPLETED':
> self.assert_qmp(event, 'data/device', drive)
> self.assert_qmp_absent(event, 'data/error')
> if check_offset:
> self.assert_qmp(event, 'data/offset', event['data']['len'])
> self.assert_no_active_block_jobs()
> return event
>
> Or a single break would work too. Do either of you have any
> preference? I can repost in either way. Thanks,
Looks good to me!
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2018-04-04 14:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 6:11 [Qemu-devel] [PATCH] iotests: fix wait_until_completed() Peter Xu
2018-03-26 10:47 ` Kevin Wolf
2018-03-27 2:21 ` Peter Xu
2018-04-03 12:59 ` Stefan Hajnoczi
2018-04-04 1:42 ` Peter Xu
2018-04-04 14:24 ` 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=20180404142405.GU4467@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=peterx@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).