[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 2/8] iotests/257: add EmulatedBitmap class
From: |
John Snow |
Subject: |
Re: [Qemu-block] [PATCH 2/8] iotests/257: add EmulatedBitmap class |
Date: |
Wed, 10 Jul 2019 13:36:08 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 |
On 7/10/19 11:47 AM, Max Reitz wrote:
> 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 <address@hidden>
>> ---
>> 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 <address@hidden>
>
It's okay. I forget which shorthand operators Python has for which types
sometimes.
>>> a = {'a', 'b', 'c'}
>>> a -= {'c'}
>>> a
{'b', 'a'}
Well, apparently it does. I'll change it.
--js
[Qemu-block] [PATCH 4/8] block/backup: hoist bitmap check into QMP interface, John Snow, 2019/07/09