On 2011年12月13日 21:32, Osier Yang wrote: > --- > python/generator.py | 1 + > python/libvirt-override-api.xml | 9 +++++++++ > python/libvirt-override.c | 35 +++++++++++++++++++++++++++++++++++ > 3 files changed, 45 insertions(+), 0 deletions(-) > > diff --git a/python/generator.py b/python/generator.py > index 88c52b9..1657f4f 100755 > --- a/python/generator.py > +++ b/python/generator.py > @@ -262,6 +262,7 @@ py_types = { > 'unsigned char *': ('z', None, "charPtr", "char *"), > 'char *': ('z', None, "charPtr", "char *"), > 'const char *': ('z', None, "charPtrConst", "const char *"), > + 'size_t': ('n', None, "size_t", "size_t"), > > 'virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"), > 'const virDomainPtr': ('O', "virDomain", "virDomainPtr", > "virDomainPtr"), > diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml > index 7c18763..87db67b 100644 > --- a/python/libvirt-override-api.xml > +++ b/python/libvirt-override-api.xml > @@ -405,5 +405,14 @@ > <arg name='flags' type='unsigned int' info='an OR'ed set of > virDomainModificationImpact'/> > <return type='int' info='0 in case of success, -1 in case of > failure'/> > </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'/> > +<return type='char *' info='the returned buffer or None in case of error'/> > +</function> > </symbols> > </api> > diff --git a/python/libvirt-override.c b/python/libvirt-override.c > index 9e98918..4839e08 100644 > --- a/python/libvirt-override.c > +++ b/python/libvirt-override.c > @@ -5017,6 +5017,40 @@ libvirt_virDomainMigrateGetMaxSpeed(PyObject *self > ATTRIBUTE_UNUSED, PyObject *a > return(py_retval); > } > > +static PyObject * > +libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED, > + PyObject *args) { > + PyObject *py_retval; > + int c_retval; > + virDomainPtr domain; > + PyObject *pyobj_domain; > + const char *disk; > + unsigned long long offset; > + size_t size; > + char *buf; > + unsigned int flags; > + int i;
Please ignore this unused "i". I will clean it up when pushing. > + > + if (!PyArg_ParseTuple(args, (char > *)"OzLni:virDomainBlockPeek",&pyobj_domain, > +&disk,&offset,&size,&flags)) > + return(NULL); > + > + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); > + > + if ((buf = malloc(size)) == NULL) > + return VIR_PY_NONE; > + > + LIBVIRT_BEGIN_ALLOW_THREADS; > + c_retval = virDomainBlockPeek(domain, disk, offset, size, buf, flags); > + LIBVIRT_END_ALLOW_THREADS; > + > + if (c_retval< 0) > + return VIR_PY_NONE; > + > + py_retval = libvirt_charPtrWrap(buf); > + return py_retval; > +} > + > /************************************************************************ > * * > * The registration stuff * > @@ -5112,6 +5146,7 @@ static PyMethodDef libvirtMethods[] = { > {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune, > METH_VARARGS, NULL}, > {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, > NULL}, > {(char *) "virDomainMigrateGetMaxSpeed", > libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, > + {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, > METH_VARARGS, NULL}, > {NULL, NULL, 0, NULL} > }; > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list