All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "eblake@redhat.com" <eblake@redhat.com>,
	"fam@euphon.net" <fam@euphon.net>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	"kwolf@redhat.com" <kwolf@redhat.com>,
	"jsnow@redhat.com" <jsnow@redhat.com>,
	Denis Lunev <den@virtuozzo.com>
Subject: Re: [Qemu-devel] [PATCH v11 3/3] qemu-img info: bitmaps extension new test 239
Date: Fri, 1 Feb 2019 15:57:05 +0000	[thread overview]
Message-ID: <252495f5-8ade-336a-658f-9f6e979bda4c@virtuozzo.com> (raw)
In-Reply-To: <1548942405-760115-4-git-send-email-andrey.shinkevich@virtuozzo.com>

31.01.2019 16:46, Andrey Shinkevich wrote:
> A new test file 239 added to the qemu-iotests set. It checks
> the output format of 'qemu-img info' for bitmaps extension of
> qcow2 specific information.
> 
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> ---
>   tests/qemu-iotests/239     |  74 ++++++++++++++++++++++++++
>   tests/qemu-iotests/239.out | 130 +++++++++++++++++++++++++++++++++++++++++++++
>   tests/qemu-iotests/group   |   1 +
>   3 files changed, 205 insertions(+)
>   create mode 100755 tests/qemu-iotests/239
>   create mode 100644 tests/qemu-iotests/239.out
> 
> diff --git a/tests/qemu-iotests/239 b/tests/qemu-iotests/239
> new file mode 100755
> index 0000000..bee7943
> --- /dev/null
> +++ b/tests/qemu-iotests/239
> @@ -0,0 +1,74 @@
> +#!/usr/bin/env python
> +#
> +# Test for qcow2 bitmap printed information
> +#
> +# Copyright (c) 2018 Virtuozzo International GmbH
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +import iotests
> +import json
> +from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
> +                    file_path, log
> +
> +iotests.verify_image_format(supported_fmts=['qcow2'])
> +
> +disk = file_path('disk')
> +chunk = 256
> +
> +def print_bitmap():
> +    log('qemu-img info dump:\n')
> +    iotests.img_info_log(disk, extra_args=['--force-share'])
> +    result = json.loads(qemu_img_pipe('info', '--force-share',
> +                                      '--output=json', disk))
> +    if 'bitmaps' in result['format-specific']['data']:
> +        bitmaps = result['format-specific']['data']['bitmaps']
> +        log('The same bitmaps in JSON format:')
> +        log(bitmaps, indent=2)
> +    else:
> +        log('No bitmap in JSON format output')
> +
> +def add_bitmap(bitmap_number, persistent, disabled):
> +    granularity = 2**(13 + bitmap_number)
> +    bitmap_name = 'bitmap-' + str(bitmap_number-1)
> +    vm = iotests.VM().add_drive(disk)
> +    vm.launch()
> +    vm.qmp_log('block-dirty-bitmap-add', node='drive0', name=bitmap_name,
> +               granularity=granularity, persistent=persistent,
> +               disabled=disabled)
> +    vm.shutdown()
> +
> +def write_to_disk(offset, size):
> +    write = 'write {} {}K'.format(offset, size)

I think, you meant {}K {}K. On the other hand, if you want to work with 256K chunks,
I think, better is to define chunk as
chunk = 256 * 1024

> +    qemu_io('-f', iotests.imgfmt, '-c', write, disk)

Hmm, interesting, it's a common preactice to give -f iotests.imgfmt to qemu_io(),
but in reality it's not needed, as qemu_io() automatically set this flag, this
parameter will be passed twice. So, it would be good to fix it in all iotests,
handle '-f' properly in qemu_io(), and I think, in qemu-io utility too, forbid
multiple -f option.

So, here let's use
qemu_io('-c', write, disk)

> +    log('Write ' + str(size) + 'K to disk at offset ' + str(hex(offset)))

hmm, you just do qemu-io output by hand. better log() what qemu_io() returns
with appropriate filters, look in iotest 149

> +
> +
> +qemu_img_create('-f', iotests.imgfmt, disk, '1M')
> +
> +for num in range(1, 4):

good to log('Test {}'.format(num)) here

> +    disabled = False
> +    if num == 2:
> +        disabled = True
> +    add_bitmap(num, bool(num-1), disabled)

more clear: num > 1

> +    write_to_disk((num-1)*chunk, chunk)

Hm, actually this don't change test output, as we don't see dirty bits through
new API. However, it make sense anyway, to be closer to real-life.

> +    print_bitmap()
> +    log('')
> +
> +vm = iotests.VM().add_drive(disk)
> +vm.launch()
> +log('Checking \"in-use\" flag...')

don't back-slash double quotes, it's not needed, as you are inside single quotes.

> +print_bitmap()

I'd prefere to use '--force-share' only for this case, when it's really needed.

> +vm.shutdown()
> diff --git a/tests/qemu-iotests/239.out b/tests/qemu-iotests/239.out



-- 
Best regards,
Vladimir

  reply	other threads:[~2019-02-01 15:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 13:46 [Qemu-devel] [PATCH v11 0/3] qemu-img info lists bitmap directory entries Andrey Shinkevich
2019-01-31 13:46 ` [Qemu-devel] [PATCH v11 1/3] bdrv_query_image_info Error parameter added Andrey Shinkevich
2019-02-01 14:42   ` Vladimir Sementsov-Ogievskiy
2019-02-01 14:46     ` Daniel P. Berrangé
2019-02-01 17:13   ` Kevin Wolf
2019-01-31 13:46 ` [Qemu-devel] [PATCH v11 2/3] qemu-img info lists bitmap directory entries Andrey Shinkevich
2019-02-01 15:19   ` Vladimir Sementsov-Ogievskiy
2019-02-01 17:08   ` Eric Blake
2019-02-01 17:19   ` Kevin Wolf
2019-02-01 18:39   ` Markus Armbruster
2019-02-01 19:04     ` Eric Blake
2019-02-01 19:23       ` Markus Armbruster
2019-02-01 19:28         ` Eric Blake
2019-02-04 13:05           ` Markus Armbruster
2019-02-04 16:03             ` Vladimir Sementsov-Ogievskiy
2019-02-04 16:24               ` Eric Blake
2019-02-04 16:35                 ` Vladimir Sementsov-Ogievskiy
2019-02-04 16:46                   ` Vladimir Sementsov-Ogievskiy
2019-02-04 17:33                     ` Eric Blake
2019-02-04 17:37                       ` Eric Blake
2019-02-04  7:49     ` Vladimir Sementsov-Ogievskiy
2019-02-04 15:23       ` Eric Blake
2019-02-04  9:46     ` Kevin Wolf
2019-02-04 13:45       ` Markus Armbruster
2019-02-04 15:36         ` Vladimir Sementsov-Ogievskiy
2019-02-05 10:00           ` Kevin Wolf
2019-02-05 13:16             ` Vladimir Sementsov-Ogievskiy
2019-02-05 14:28               ` Kevin Wolf
2019-02-05 14:38                 ` Eric Blake
2019-01-31 13:46 ` [Qemu-devel] [PATCH v11 3/3] qemu-img info: bitmaps extension new test 239 Andrey Shinkevich
2019-02-01 15:57   ` Vladimir Sementsov-Ogievskiy [this message]
2019-02-01 17:14   ` Kevin Wolf
2019-02-04  7:53     ` Vladimir Sementsov-Ogievskiy
2019-02-04  9:36       ` Kevin Wolf
2019-02-01 17:23   ` Eric Blake
2019-02-01 17:34     ` Kevin Wolf
2019-02-03 15:28 ` [Qemu-devel] [PATCH v11 0/3] qemu-img info lists bitmap directory entries no-reply

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=252495f5-8ade-336a-658f-9f6e979bda4c@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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.