[libvirt] [PATCH] python: Expose blockPeek and memoryPeek in Python binding
Eric Blake
eblake at redhat.com
Wed Dec 14 13:43:27 UTC 2011
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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111214/ef86ea33/attachment-0001.sig>
More information about the libvir-list
mailing list