On 10.07.19 03:05, John Snow wrote: > Represent a bitmap with an object that we can mark and clear bits in. > This makes it easier to manage partial writes when we don't write a > full group's worth of patterns before an error. > > Signed-off-by: John Snow > --- > tests/qemu-iotests/257 | 125 +++++++++++++++++++++++++---------------- > 1 file changed, 76 insertions(+), 49 deletions(-) > > diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 > index f576a35a5c..2ff4aa8695 100755 > --- a/tests/qemu-iotests/257 > +++ b/tests/qemu-iotests/257 > @@ -85,6 +85,60 @@ GROUPS = [ > Pattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right > ] > > + > +class EmulatedBitmap: > + def __init__(self, granularity=GRANULARITY): > + self._bits = set() > + self.groups = set() > + self.granularity = granularity > + > + def dirty_bits(self, bits): > + self._bits |= set(bits) > + > + def dirty_group(self, n): > + self.dirty_bits(GROUPS[n].bits(self.granularity)) > + > + def clear(self): > + self._bits = set() > + > + def clear_bits(self, bits): > + self._bits = self._bits - set(bits) Does -= not work here? No real complaints. Sorry. Reviewed-by: Max Reitz