qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/4] qemu-iotests: make cancel_and_wait() common
Date: Wed, 29 May 2013 13:02:17 +0200	[thread overview]
Message-ID: <20130529110217.GA6932@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20130529095456.GD3521@dhcp-200-207.str.redhat.com>

On Wed, May 29, 2013 at 11:54:56AM +0200, Kevin Wolf wrote:
> Am 28.05.2013 um 17:11 hat Stefan Hajnoczi geschrieben:
> > -    def cancel_and_wait(self, drive='drive0', wait_ready=True):
> > -        '''Cancel a block job and wait for it to finish'''
> > -        if wait_ready:
> > -            ready = False
> > -            while not ready:
> > -                for event in self.vm.get_qmp_events(wait=True):
> > -                    if event['event'] == 'BLOCK_JOB_READY':
> > -                        self.assert_qmp(event, 'data/type', 'mirror')
> > -                        self.assert_qmp(event, 'data/device', drive)
> > -                        ready = True
> > -
> > -        result = self.vm.qmp('block-job-cancel', device=drive,
> > -                             force=not wait_ready)
> > -        self.assert_qmp(result, 'return', {})
> > -
> > -        cancelled = False
> > -        while not cancelled:
> > +    def wait_ready(self, drive='drive0'):
> > +        '''Wait until a block job BLOCK_JOB_READY event'''
> > +        ready = False
> > +        while not ready:
> >              for event in self.vm.get_qmp_events(wait=True):
> > -                if event['event'] == 'BLOCK_JOB_COMPLETED' or \
> > -                   event['event'] == 'BLOCK_JOB_CANCELLED':
> > +                if event['event'] == 'BLOCK_JOB_READY':
> >                      self.assert_qmp(event, 'data/type', 'mirror')
> >                      self.assert_qmp(event, 'data/device', drive)
> > -                    if wait_ready:
> > -                        self.assertEquals(event['event'], 'BLOCK_JOB_COMPLETED')
> > -                        self.assert_qmp(event, 'data/offset', self.image_len)
> > -                        self.assert_qmp(event, 'data/len', self.image_len)
> > -                    cancelled = True
> > +                    ready = True
> 
> Why don't you just move the whole function including the wait_ready
> parameter? It doesn't do any harm to other callers that don't need the
> feature, and will likely be useful for other test cases later.

The BLOCK_JOB_READY and block-job-complete concepts are used by
mirroring only.  Plus the mirroring test cases perform additional checks
on the event object which aren't common.

I figured the cleanest solution is the patch I posted.

Stefan

  reply	other threads:[~2013-05-29 11:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 15:11 [Qemu-devel] [PATCH 0/4] qemu-iotests: reduce iotests.py code duplication Stefan Hajnoczi
2013-05-28 15:11 ` [Qemu-devel] [PATCH 1/4] qemu-iotests: make assert_no_active_block_jobs() common Stefan Hajnoczi
2013-05-28 15:11 ` [Qemu-devel] [PATCH 2/4] qemu-iotests: make cancel_and_wait() common Stefan Hajnoczi
2013-05-29  9:54   ` Kevin Wolf
2013-05-29 11:02     ` Stefan Hajnoczi [this message]
2013-05-28 15:11 ` [Qemu-devel] [PATCH 3/4] qemu-iotests: make compare_images() common Stefan Hajnoczi
2013-05-28 15:11 ` [Qemu-devel] [PATCH 4/4] qemu-iotests: make create_image() common Stefan Hajnoczi
2013-05-29  5:29 ` [Qemu-devel] [PATCH 0/4] qemu-iotests: reduce iotests.py code duplication Fam Zheng
2013-05-29  7:51   ` Stefan Hajnoczi
2013-05-29 10:04 ` Kevin Wolf
2013-05-29 11:56 ` Kevin Wolf

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=20130529110217.GA6932@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=kwolf@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).