Re: [PATCH] python: Expose blockPeek and memoryPeek in Python binding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/14/2011 06:16 AM, Osier Yang wrote:
> An simple example to show to use it:
> 
> \#! /usr/bin/python
> 
> import os
> import sys
> import libvirt
> 
> disk = "/var/lib/libvirt/images/test.img"
> 
> conn = libvirt.open(None)
> dom = conn.lookupByName('test')
> 
> mem_contents = dom.memoryPeek(0, 128, libvirt.VIR_MEMORY_VIRTUAL);
> sys.stdout.write(mem_contents)

That does indeed help review.

>      </function>
> +    <function name='virDomainBlockPeek' file='python'>
> +      <info>Read the contents of domain's disk device</info>
> +      <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
> +      <arg name='disk' type='const char *' info='disk name'/>
> +      <arg name='offset' type='unsigned long long' info='offset within block device'/>
> +      <arg name='size' type='size_t' info='size to read'/>
> +      <arg name='flags' type='unsigned int' info='unused, always passed 0'/>

s/passed/pass/

> +
> +cleanup:
> +    memset(buf, 0, size);
> +    free(buf);

Drop the memset().  Since you are free()ing buf anyways, it's a waste of
time to zero the memory before it goes out of scope.  (both instances).

ACK with those fixes, plus the ones you pointed out in your commit message.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]