[et-mgmt-tools] [patch] virt-convert add disk signature into virt-image format export

Joey Boggs jboggs at redhat.com
Wed Oct 1 21:15:17 UTC 2008


Here's what I've got, moved the hexdigest() out of the loop, cleanup and 
more testing to verify each scenario outputs the right xml configuration 
data.

Hope this is the final revision :)






Joey Boggs wrote:
> That's one thing I forgot to move out of the loop before I sent it. I 
> was still working on the handling of m2 missing prior to that and put 
> it inside the loop for testing. Once moved should that be good to go?
>
> Daniel P. Berrange wrote:
>> On Wed, Oct 01, 2008 at 12:27:46PM -0400, Joey Boggs wrote:
>>  
>>> Here's an update, will this work best or any other suggestions?
>>>
>>>            try:
>>>                import hashlib
>>>                m1 = hashlib.md5(path)
>>>                m2 = hashlib.sha256(path)
>>>            except:
>>>                import md5
>>>                m1 = md5.new(path)
>>>                m2 = None
>>>
>>>            f = open(path,"r")
>>>            while 1:
>>>                chunk = f.read(65536)
>>>                if not chunk:
>>>                    break
>>>                m1.update(chunk)
>>>                md5checksum = m1.hexdigest()
>>>
>>>                if m2:
>>>                   m2.update(chunk)
>>>                   shachecksum = m2.hexdigest()
>>>     
>>
>> hexdigest() should only be called at end, outside
>> the loop. As it stands you're computing a checksum
>> for each chunk & resetting it
>>
>> Daniel
>>   
>
> _______________________________________________
> et-mgmt-tools mailing list
> et-mgmt-tools at redhat.com
> https://www.redhat.com/mailman/listinfo/et-mgmt-tools

-------------- next part --------------
A non-text attachment was scrubbed...
Name: virt-convert-disk-signature-virtimage-10-1-1712.patch
Type: text/x-patch
Size: 3004 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/et-mgmt-tools/attachments/20081001/ca78f996/attachment.bin>


More information about the et-mgmt-tools mailing list