mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
python: Add binding for virDomainGetDiskErrors
This commit is contained in:
parent
e08d2a9ad8
commit
7bceae0fa6
@ -421,5 +421,11 @@
|
||||
<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>
|
||||
<function name='virDomainGetDiskErrors' file='python'>
|
||||
<info>Extract errors on disk devices.</info>
|
||||
<return type='virDomainDiskErrorPtr' info='dictionary of disks and their errors or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='unused, always pass 0'/>
|
||||
</function>
|
||||
</symbols>
|
||||
</api>
|
||||
|
@ -3484,6 +3484,59 @@ libvirt_virDomainGetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
|
||||
return(pyreply);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args)
|
||||
{
|
||||
PyObject *py_retval = VIR_PY_NONE;
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain;
|
||||
unsigned int flags;
|
||||
virDomainDiskErrorPtr disks = NULL;
|
||||
unsigned int ndisks;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetDiskErrors",
|
||||
&pyobj_domain, &flags))
|
||||
return NULL;
|
||||
|
||||
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||
|
||||
if ((count = virDomainGetDiskErrors(domain, NULL, 0, 0)) < 0)
|
||||
return VIR_PY_NONE;
|
||||
ndisks = count;
|
||||
|
||||
if (ndisks) {
|
||||
if (!(disks = malloc(sizeof(*disks) * ndisks)))
|
||||
return VIR_PY_NONE;
|
||||
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
count = virDomainGetDiskErrors(domain, disks, ndisks, 0);
|
||||
LIBVIRT_END_ALLOW_THREADS;
|
||||
|
||||
if (count < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(py_retval = PyDict_New()))
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
PyDict_SetItem(py_retval,
|
||||
libvirt_constcharPtrWrap(disks[i].disk),
|
||||
libvirt_intWrap(disks[i].error));
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (disks) {
|
||||
for (i = 0; i < count; i++)
|
||||
free(disks[i].disk);
|
||||
free(disks);
|
||||
}
|
||||
return py_retval;
|
||||
}
|
||||
|
||||
/*******************************************
|
||||
* Helper functions to avoid importing modules
|
||||
* for every callback
|
||||
@ -5206,6 +5259,7 @@ static PyMethodDef libvirtMethods[] = {
|
||||
{(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
|
||||
{(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
|
||||
{(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
|
||||
{(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user