diff options
-rwxr-xr-x | generator.py | 1 | ||||
-rw-r--r-- | libvirt-override-api.xml | 17 | ||||
-rw-r--r-- | libvirt-override.c | 73 |
3 files changed, 91 insertions, 0 deletions
diff --git a/generator.py b/generator.py index 88c52b9..1657f4f 100755 --- a/generator.py +++ b/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/libvirt-override-api.xml b/libvirt-override-api.xml index 7c18763..07e4a78 100644 --- a/libvirt-override-api.xml +++ b/libvirt-override-api.xml @@ -405,5 +405,22 @@ <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 pass 0'/> + <return type='char *' info='the returned buffer or None in case of error'/> + </function> + <function name='virDomainMemoryPeek' file='python'> + <info>Read the contents of domain's memory</info> + <arg name='dom' type='virDomainPtr' info='pointer to the domain'/> + <arg name='start' type='unsigned long long' info='start of memory to peek'/> + <arg name='size' type='size_t' info='size of memory to peek'/> + <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMemoryFlags'/> + <return type='char *' info='the returned buffer or None in case of error'/> + </function> </symbols> </api> diff --git a/libvirt-override.c b/libvirt-override.c index a16a7d1..4aee628 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -5017,6 +5017,77 @@ libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *a return(py_retval); } +static PyObject * +libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval = NULL; + int c_retval; + virDomainPtr domain; + PyObject *pyobj_domain; + const char *disk; + unsigned long long offset; + size_t size; + char *buf; + unsigned int flags; + + 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) + goto cleanup; + + py_retval = PyString_FromStringAndSize(buf, size); + +cleanup: + free(buf); + return py_retval; +} + +static PyObject * +libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval = NULL; + int c_retval; + virDomainPtr domain; + PyObject *pyobj_domain; + unsigned long long start; + size_t size; + char *buf; + unsigned int flags; + + if (!PyArg_ParseTuple(args, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain, + &start, &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 = virDomainMemoryPeek(domain, start, size, buf, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (c_retval < 0) + goto cleanup; + + py_retval = PyString_FromStringAndSize(buf, size); + +cleanup: + free(buf); + return py_retval; +} + /************************************************************************ * * * The registration stuff * @@ -5113,6 +5184,8 @@ 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}, + {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; |