All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, jsnow@redhat.com, eblake@redhat.com,
	pkrempa@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/14] qemu-iotests: Rewrite 206 for blockdev-create job
Date: Tue, 29 May 2018 20:49:04 +0200	[thread overview]
Message-ID: <20180529184904.GJ4756@localhost.localdomain> (raw)
In-Reply-To: <8b64d45f-0e9c-107f-a55a-bb3880c60eb6@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 6965 bytes --]

Am 29.05.2018 um 14:27 hat Max Reitz geschrieben:
> On 2018-05-25 18:33, Kevin Wolf wrote:
> > This rewrites the test case 206 to work with the new x-blockdev-create
> > job rather than the old synchronous version of the command.
> > 
> > All of the test cases stay the same as before, but in order to be able
> > to implement proper job handling, the test case is rewritten in Python.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  tests/qemu-iotests/206        | 705 +++++++++++++++++-------------------------
> >  tests/qemu-iotests/206.out    | 241 +++++++++------
> >  tests/qemu-iotests/group      |   2 +-
> >  tests/qemu-iotests/iotests.py |  15 +
> >  4 files changed, 448 insertions(+), 515 deletions(-)
> > 
> > diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
> > index 0a18b2b19a..9a305302d1 100755
> > --- a/tests/qemu-iotests/206
> > +++ b/tests/qemu-iotests/206
> 
> [...]
> 
> > +import iotests
> > +from iotests import imgfmt
> > +
> > +iotests.verify_image_format(supported_fmts=['qcow2'])
> > +
> > +def blockdev_create(vm, options):
> > +    result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options)
> > +
> > +    if 'return' in result:
> > +        assert result['return'] == {}
> > +        vm.run_job('job0')
> > +    iotests.log("")
> > +
> > +with iotests.FilePath('t.qcow2') as disk_path, \
> > +     iotests.FilePath('t.qcow2.base') as backing_path, \
> > +     iotests.VM() as vm:
> > +
> > +    vm.add_object('secret,id=keysec0,data="foo"')
> 
> I don't know how subprocess.Popen() works, but are you sure you aren't
> encrypting with '"foo"' now?  (i.e. literally that key, including quotes)

That's correct. Anything wrong with it?

(Okay, you're right. I did fix it in 210, but forgot it here...)

> > +
> > +    #
> > +    # Successful image creation (defaults)
> > +    #
> > +    iotests.log("=== Successful image creation (defaults) ===")
> 
> OK, the comment makes sense for visual separation.  But so would leaving
> three empty lines.  *cough*

I tried vertical spacing first, but it didn't work well for me. What
made the difference is the syntax highlighting of comments vs. code.
YMMV.

> > +    iotests.log("")
> > +
> > +    size = 128 * 1024 * 1024
> > +
> > +    vm.launch()
> > +    blockdev_create(vm, { 'driver': 'file',
> > +                          'filename': disk_path,
> > +                          'size': 0 })
> > +
> > +    vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
> > +               node_name='imgfile')
> > +
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': 'imgfile',
> > +                          'size': size })
> > +    vm.shutdown()
> > +
> > +    iotests.img_info_log(disk_path)
> > +
> 
> [...]
> 
> > +    #
> > +    # Successful image creation (v2 non-default options)
> > +    #
> > +    iotests.log("=== Successful image creation (v2 non-default options) ===")
> > +    iotests.log("")
> > +
> > +    vm.launch()
> > +    blockdev_create(vm, { 'driver': 'file',
> > +                          'filename': disk_path,
> > +                          'size': 0 })
> > +
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': {
> > +                              'driver': 'file',
> > +                              'filename': disk_path,
> > +                          },
> > +                          'size': size,
> > +                          'backing-file': backing_path,
> 
> Change from the bash version: backing_path does not exist here.  Not
> sure if that was intentional.

No, it was not. It's actually a good test case, though. Creating an
image at backing_path would be easy enough, but maybe we should just
leave it?

> > +                          'backing-fmt': 'qcow2',
> > +                          'version': 'v2',
> > +                          'cluster-size': 512 })
> > +    vm.shutdown()
> > +
> > +    iotests.img_info_log(disk_path)
> 
> [...]
> 
> > +    #
> > +    # Invalid sizes
> > +    #
> > +    iotests.log("=== Invalid sizes ===")
> > +
> > +    # TODO Negative image sizes aren't handled correctly, but this is a problem
> > +    # with QAPI's implementation of the 'size' type and affects other commands
> > +    # as well. Once this is fixed, we may want to add a test case here.
> > +    #
> > +    # 1. Misaligned image size
> > +    # 2. 2^64 - 512
> > +    # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
> > +    # 4. 2^63 - 512 (generally valid, but qcow2 can't handle images this size)
> > +
> > +    vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
> > +
> > +    vm.launch()
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': 'node0',
> > +                          'size': 1234  })
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': 'node0',
> > +                          'size': 18446744073709551104 })
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': 'node0',
> > +                          'size': 9223372036854775808 })
> > +    blockdev_create(vm, { 'driver': imgfmt,
> > +                          'file': 'node0',
> > +                          'size': 9223372036854775296})
> 
> Missing space before the closing fancy bracket, critical!
> 
> [...]
> 
> > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> > index 20ce5a0cf0..f0f4ef32f0 100644
> > --- a/tests/qemu-iotests/iotests.py
> > +++ b/tests/qemu-iotests/iotests.py
> > @@ -416,6 +416,21 @@ class VM(qtest.QEMUQtestMachine):
> >          log(result)
> >          return result
> >  
> > +    def run_job(self, job):
> 
> Is there any reason this function did not get its own patch?
> 
> Also, this is a function specifically for jobs that need a manual
> dismiss but have auto-finalize.  That should be noted somewhere (ideally
> in the function's name, but spontaneously I don't know how).

If you want me to move it into a separate patch, maybe just make it more
reusable with parameters auto_finalize=True, auto_dismiss=false.

> > +        while True:
> > +            for ev in self.get_qmp_events_filtered(wait=True):
> > +                if ev['event'] == 'JOB_STATUS_CHANGE':
> > +                    if ev['data']['status'] == 'aborting':
> > +                        result = self.qmp('query-jobs')
> > +                        for j in result['return']:
> > +                            log('Job failed: %s' % (j.get('error', None)))
> 
> I can understand that you didn't want to use just result['return'][0],
> but if you do iterate, you should probably emit the job ID as well.

If you have multiple jobs running, it doesn't work correctly anyway. :-)

Kevin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2018-05-29 18:49 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:33 [Qemu-devel] [PATCH 00/14] block: Make blockdev-create a job and stable API Kevin Wolf
2018-05-25 16:33 ` [Qemu-devel] [PATCH 01/14] vdi: Fix vdi_co_do_create() return value Kevin Wolf
2018-05-29 10:38   ` Max Reitz
2018-05-29 14:45   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:33 ` [Qemu-devel] [PATCH 02/14] vhdx: Fix vhdx_co_create() " Kevin Wolf
2018-05-29 10:40   ` Max Reitz
2018-05-29 14:44   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:33 ` [Qemu-devel] [PATCH 03/14] job: Add error message for failing jobs Kevin Wolf
2018-05-29 11:01   ` Max Reitz
2018-05-29 14:43   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-29 19:54     ` Kevin Wolf
2018-05-25 16:33 ` [Qemu-devel] [PATCH 04/14] block/create: Make x-blockdev-create a job Kevin Wolf
2018-05-29 11:38   ` Max Reitz
2018-05-29 15:27   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-29 15:40     ` Kevin Wolf
2018-05-25 16:33 ` [Qemu-devel] [PATCH 05/14] qemu-iotests: Add VM.get_qmp_events_filtered() Kevin Wolf
2018-05-29 11:41   ` Max Reitz
2018-05-25 16:33 ` [Qemu-devel] [PATCH 06/14] qemu-iotests: Add VM.qmp_log() Kevin Wolf
2018-05-29 11:48   ` Max Reitz
2018-05-29 12:12     ` Kevin Wolf
2018-05-29 12:15       ` Max Reitz
2018-05-29 12:39         ` Kevin Wolf
2018-05-29 12:41           ` Max Reitz
2018-05-29 18:31   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:33 ` [Qemu-devel] [PATCH 07/14] qemu-iotests: Add iotests.img_info_log() Kevin Wolf
2018-05-29 11:56   ` Max Reitz
2018-05-25 16:33 ` [Qemu-devel] [PATCH 08/14] qemu-iotests: Rewrite 206 for blockdev-create job Kevin Wolf
2018-05-29 12:27   ` Max Reitz
2018-05-29 18:49     ` Kevin Wolf [this message]
2018-05-25 16:33 ` [Qemu-devel] [PATCH 09/14] qemu-iotests: Rewrite 207 " Kevin Wolf
2018-05-29 12:44   ` Max Reitz
2018-05-29 12:47   ` Max Reitz
2018-05-29 17:52   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:33 ` [Qemu-devel] [PATCH 10/14] qemu-iotests: Rewrite 210 " Kevin Wolf
2018-05-29 13:02   ` Max Reitz
2018-05-29 18:23   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:33 ` [Qemu-devel] [PATCH 11/14] qemu-iotests: Rewrite 211 " Kevin Wolf
2018-05-29 13:12   ` Max Reitz
2018-05-25 16:33 ` [Qemu-devel] [PATCH 12/14] qemu-iotests: Rewrite 212 " Kevin Wolf
2018-05-29 13:21   ` Max Reitz
2018-05-25 16:33 ` [Qemu-devel] [PATCH 13/14] qemu-iotests: Rewrite 213 " Kevin Wolf
2018-05-29 13:27   ` Max Reitz
2018-05-25 16:33 ` [Qemu-devel] [PATCH 14/14] block/create: Mark blockdev-create stable Kevin Wolf
2018-05-29 13:30   ` Max Reitz
2018-05-29 18:25   ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-25 16:52 ` [Qemu-devel] [PATCH 00/14] block: Make blockdev-create a job and stable API no-reply
2018-05-25 18:13 ` Eric Blake
2018-05-28  8:42   ` 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=20180529184904.GJ4756@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.