From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 1/8] iotests/257: add Pattern class
Date: Tue, 9 Jul 2019 21:05:49 -0400 [thread overview]
Message-ID: <20190710010556.32365-2-jsnow@redhat.com> (raw)
In-Reply-To: <20190710010556.32365-1-jsnow@redhat.com>
Just kidding, this is easier to manage with a full class instead of a
namedtuple.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qemu-iotests/257 | 58 +++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
index 75a651c7c3..f576a35a5c 100755
--- a/tests/qemu-iotests/257
+++ b/tests/qemu-iotests/257
@@ -19,7 +19,6 @@
#
# owner=jsnow@redhat.com
-from collections import namedtuple
import math
import os
@@ -29,10 +28,18 @@ from iotests import log, qemu_img
SIZE = 64 * 1024 * 1024
GRANULARITY = 64 * 1024
-Pattern = namedtuple('Pattern', ['byte', 'offset', 'size'])
-def mkpattern(byte, offset, size=GRANULARITY):
- """Constructor for Pattern() with default size"""
- return Pattern(byte, offset, size)
+
+class Pattern:
+ def __init__(self, byte, offset, size=GRANULARITY):
+ self.byte = byte
+ self.offset = offset
+ self.size = size
+
+ def bits(self, granularity):
+ lower = math.floor(self.offset / granularity)
+ upper = math.floor((self.offset + self.size - 1) / granularity)
+ return set(range(lower, upper + 1))
+
class PatternGroup:
"""Grouping of Pattern objects. Initialize with an iterable of Patterns."""
@@ -43,40 +50,39 @@ class PatternGroup:
"""Calculate the unique bits dirtied by this pattern grouping"""
res = set()
for pattern in self.patterns:
- lower = math.floor(pattern.offset / granularity)
- upper = math.floor((pattern.offset + pattern.size - 1) / granularity)
- res = res | set(range(lower, upper + 1))
+ res = res | pattern.bits(granularity)
return res
+
GROUPS = [
PatternGroup([
# Batch 0: 4 clusters
- mkpattern('0x49', 0x0000000),
- mkpattern('0x6c', 0x0100000), # 1M
- mkpattern('0x6f', 0x2000000), # 32M
- mkpattern('0x76', 0x3ff0000)]), # 64M - 64K
+ Pattern('0x49', 0x0000000),
+ Pattern('0x6c', 0x0100000), # 1M
+ Pattern('0x6f', 0x2000000), # 32M
+ Pattern('0x76', 0x3ff0000)]), # 64M - 64K
PatternGroup([
# Batch 1: 6 clusters (3 new)
- mkpattern('0x65', 0x0000000), # Full overwrite
- mkpattern('0x77', 0x00f8000), # Partial-left (1M-32K)
- mkpattern('0x72', 0x2008000), # Partial-right (32M+32K)
- mkpattern('0x69', 0x3fe0000)]), # Adjacent-left (64M - 128K)
+ Pattern('0x65', 0x0000000), # Full overwrite
+ Pattern('0x77', 0x00f8000), # Partial-left (1M-32K)
+ Pattern('0x72', 0x2008000), # Partial-right (32M+32K)
+ Pattern('0x69', 0x3fe0000)]), # Adjacent-left (64M - 128K)
PatternGroup([
# Batch 2: 7 clusters (3 new)
- mkpattern('0x74', 0x0010000), # Adjacent-right
- mkpattern('0x69', 0x00e8000), # Partial-left (1M-96K)
- mkpattern('0x6e', 0x2018000), # Partial-right (32M+96K)
- mkpattern('0x67', 0x3fe0000,
- 2*GRANULARITY)]), # Overwrite [(64M-128K)-64M)
+ Pattern('0x74', 0x0010000), # Adjacent-right
+ Pattern('0x69', 0x00e8000), # Partial-left (1M-96K)
+ Pattern('0x6e', 0x2018000), # Partial-right (32M+96K)
+ Pattern('0x67', 0x3fe0000,
+ 2*GRANULARITY)]), # Overwrite [(64M-128K)-64M)
PatternGroup([
# Batch 3: 8 clusters (5 new)
# Carefully chosen such that nothing re-dirties the one cluster
# that copies out successfully before failure in Group #1.
- mkpattern('0xaa', 0x0010000,
- 3*GRANULARITY), # Overwrite and 2x Adjacent-right
- mkpattern('0xbb', 0x00d8000), # Partial-left (1M-160K)
- mkpattern('0xcc', 0x2028000), # Partial-right (32M+160K)
- mkpattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right
+ Pattern('0xaa', 0x0010000,
+ 3*GRANULARITY), # Overwrite and 2x Adjacent-right
+ Pattern('0xbb', 0x00d8000), # Partial-left (1M-160K)
+ Pattern('0xcc', 0x2028000), # Partial-right (32M+160K)
+ Pattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right
]
class Drive:
--
2.21.0
next prev parent reply other threads:[~2019-07-10 1:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 1:05 [Qemu-devel] [PATCH 0/8] bitmaps: allow bitmaps to be used with full and top John Snow
2019-07-10 1:05 ` John Snow [this message]
2019-07-10 15:10 ` [Qemu-devel] [PATCH 1/8] iotests/257: add Pattern class Max Reitz
2019-07-10 16:26 ` Max Reitz
2019-07-10 17:34 ` John Snow
2019-07-10 1:05 ` [Qemu-devel] [PATCH 2/8] iotests/257: add EmulatedBitmap class John Snow
2019-07-10 15:47 ` Max Reitz
2019-07-10 17:36 ` John Snow
2019-07-10 1:05 ` [Qemu-devel] [PATCH 3/8] iotests/257: Refactor backup helpers John Snow
2019-07-10 16:04 ` Max Reitz
2019-07-10 17:52 ` John Snow
2019-07-10 20:17 ` Max Reitz
2019-07-10 1:05 ` [Qemu-devel] [PATCH 4/8] block/backup: hoist bitmap check into QMP interface John Snow
2019-07-10 16:11 ` Max Reitz
2019-07-10 17:57 ` John Snow
2019-07-10 20:19 ` Max Reitz
2019-07-10 1:05 ` [Qemu-devel] [PATCH 5/8] iotests/257: test API failures John Snow
2019-07-10 16:22 ` Max Reitz
2019-07-10 18:00 ` John Snow
2019-07-10 1:05 ` [Qemu-devel] [PATCH 6/8] block/backup: issue progress updates for skipped regions John Snow
2019-07-10 16:36 ` Max Reitz
2019-07-10 18:20 ` John Snow
2019-07-10 20:30 ` Max Reitz
2019-07-10 20:47 ` John Snow
2019-07-10 20:53 ` Max Reitz
2019-07-10 1:05 ` [Qemu-devel] [PATCH 7/8] block/backup: support bitmap sync modes for non-bitmap backups John Snow
2019-07-10 16:48 ` Max Reitz
2019-07-10 18:32 ` John Snow
2019-07-10 20:39 ` Max Reitz
2019-07-10 1:05 ` [Qemu-devel] [PATCH 8/8] iotests/257: test traditional sync modes John Snow
2019-07-10 17:14 ` Max Reitz
2019-07-10 19:00 ` John Snow
2019-07-10 20:46 ` Max Reitz
[not found] ` <2f221513-f173-8d9f-a3b2-d790ef6f6f51@redhat.com>
2019-07-11 12:37 ` Max Reitz
2019-07-11 17:58 ` John Snow
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=20190710010556.32365-2-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@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 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).