From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, qemu-devel@nongnu.org,
mreitz@redhat.com
Subject: Re: [PATCH v12 01/11] iotests: add test for QCOW2 header dump
Date: Wed, 5 Aug 2020 15:10:36 +0300 [thread overview]
Message-ID: <5f6fd94a-173a-48e3-bc48-369f7f947c30@virtuozzo.com> (raw)
In-Reply-To: <a7b1f113-a3b0-2026-b087-5d9865b183fd@virtuozzo.com>
On 05.08.2020 14:23, Vladimir Sementsov-Ogievskiy wrote:
> 30.07.2020 17:15, Andrey Shinkevich wrote:
>> The simple script creates a QCOW2 image and fills it with some data.
>> Two bitmaps are created as well. Then the script reads the image header
>> with extensions from the disk by running the script qcow2.py and dumps
>> the information to the output. Other entities, such as snapshots, may
>> be added to the test later.
>>
>> Suggested-by: Eric Blake <eblake@redhat.com>
>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>> ---
>> tests/qemu-iotests/303 | 59
>> ++++++++++++++++++++++++++++++++++++++++++
>> tests/qemu-iotests/303.out | 64
>> ++++++++++++++++++++++++++++++++++++++++++++++
>> tests/qemu-iotests/group | 1 +
>> 3 files changed, 124 insertions(+)
>> create mode 100755 tests/qemu-iotests/303
>> create mode 100644 tests/qemu-iotests/303.out
>>
>> diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
>> new file mode 100755
>> index 0000000..3c7a611
>> --- /dev/null
>> +++ b/tests/qemu-iotests/303
>> @@ -0,0 +1,59 @@
>> +#!/usr/bin/env python3
>> +#
>> +# Test for dumping of qcow2 image metadata
>> +#
>> +# Copyright (c) 2020 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 subprocess
>> +from iotests import qemu_img_create, qemu_io, file_path, log,
>> filter_qemu_io
>> +
>> +iotests.script_initialize(supported_fmts=['qcow2'])
>> +
>> +disk = file_path('disk')
>> +chunk = 1024 * 1024
>> +
>> +
>> +def create_bitmap(bitmap_number, disabled):
>> + granularity = 1 << (14 + bitmap_number)
>> + bitmap_name = 'bitmap-' + str(bitmap_number)
>> + vm = iotests.VM().add_drive(disk)
>> + vm.launch()
>> + vm.qmp_log('block-dirty-bitmap-add', node='drive0',
>> name=bitmap_name,
>> + granularity=granularity, persistent=True,
>> disabled=disabled)
>> + vm.shutdown()
>> +
>> +
>> +def write_to_disk(offset, size):
>> + write = f'write {offset} {size}'
>> + log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
>> +
>> +
>> +def add_bitmap(num, begin, end, disabled):
>> + log(f'Add bitmap {num}')
>> + create_bitmap(num, disabled)
>> + for i in range(begin, end):
>> + write_to_disk((i-1) * chunk, chunk)
>
> a bit unusual to count chunks starting from "1"..
>
> also, any difference with just
>
> write_to_disk((i-1) * chunk, (end-begin) * chunk)
>
> ?
>
QEMU-IMG limits the maximum number of bytes written with one command by
... 2M, if I am not wrong.
Andrey
>> + log('')
>> +
>> +
>> +qemu_img_create('-f', iotests.imgfmt, disk, '10M')
>> +
>> +add_bitmap(1, 1, 7, False)
>> +add_bitmap(2, 7, 9, True)
>> +dump = ['qcow2.py', f'{disk}', 'dump-header']
>
> No reason to put disk into f-string, it's a string anyway: f'{disk}'
> is equal to just disk.
Thanks
>
>> +subprocess.run(dump)
>
>
> And you may use just
>
> subprocess.run(['qcow2.py', disk, 'dump-header'])
>
> without additional variable.
Yes, but further adding the '-j' key to the list looks more elegant to me ))
Andrey
>
>
> Still, I'm OK with it as is:
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
>
next prev parent reply other threads:[~2020-08-05 12:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-30 14:15 [PATCH v12 00/11] iotests: Dump QCOW2 dirty bitmaps metadata Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 01/11] iotests: add test for QCOW2 header dump Andrey Shinkevich
2020-07-30 19:05 ` Eric Blake
2020-07-31 7:28 ` Andrey Shinkevich
2020-08-05 11:23 ` Vladimir Sementsov-Ogievskiy
2020-08-05 12:10 ` Andrey Shinkevich [this message]
2020-07-30 14:15 ` [PATCH v12 02/11] qcow2_format.py: make printable data an extension class member Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 03/11] qcow2_format.py: change Qcow2BitmapExt initialization method Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 04/11] qcow2_format.py: dump bitmap flags in human readable way Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 05/11] qcow2_format.py: Dump bitmap directory information Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 06/11] qcow2_format.py: pass cluster size to substructures Andrey Shinkevich
2020-07-30 14:15 ` [PATCH v12 07/11] qcow2_format.py: Dump bitmap table serialized entries Andrey Shinkevich
2020-08-05 15:57 ` Vladimir Sementsov-Ogievskiy
2020-07-30 14:15 ` [PATCH v12 08/11] qcow2.py: Introduce '-j' key to dump in JSON format Andrey Shinkevich
2020-08-05 16:12 ` Vladimir Sementsov-Ogievskiy
2020-07-30 14:15 ` [PATCH v12 09/11] qcow2_format.py: collect fields " Andrey Shinkevich
2020-08-05 16:58 ` Vladimir Sementsov-Ogievskiy
2020-08-06 9:08 ` Andrey Shinkevich
2020-08-06 9:18 ` Vladimir Sementsov-Ogievskiy
2020-07-30 14:15 ` [PATCH v12 10/11] qcow2_format.py: support dumping metadata " Andrey Shinkevich
2020-08-05 17:04 ` Vladimir Sementsov-Ogievskiy
2020-07-30 14:15 ` [PATCH v12 11/11] iotests: dump QCOW2 header in JSON in #303 Andrey Shinkevich
2020-08-05 17:08 ` Vladimir Sementsov-Ogievskiy
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=5f6fd94a-173a-48e3-bc48-369f7f947c30@virtuozzo.com \
--to=andrey.shinkevich@virtuozzo.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).