1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-01 00:21:59 +03:00

override: Implement bindings for virDomainGetFSInfo as domain.fsInfo

Implement the function which returns a list of tuples, that contains members
of virDomainFSInfo struct.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
This commit is contained in:
Tomoki Sekiyama
2014-11-22 02:28:00 +01:00
committed by Pavel Hrdina
parent 3d1d3fd52a
commit c6def1bf95
4 changed files with 85 additions and 1 deletions

View File

@ -476,6 +476,7 @@ skip_impl = (
'virNetworkGetDHCPLeases', 'virNetworkGetDHCPLeases',
'virDomainBlockCopy', 'virDomainBlockCopy',
'virNodeAllocPages', 'virNodeAllocPages',
'virDomainGetFSInfo',
) )
lxc_skip_impl = ( lxc_skip_impl = (
@ -586,6 +587,7 @@ skip_function = (
'virNetworkDHCPLeaseFree', # only useful in C, python code uses list 'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
'virDomainStatsRecordListFree', # only useful in C, python uses dict 'virDomainStatsRecordListFree', # only useful in C, python uses dict
'virDomainFSInfoFree', # only useful in C, python code uses list
) )
lxc_skip_function = ( lxc_skip_function = (
@ -1107,6 +1109,9 @@ def nameFixup(name, classe, type, file):
elif name[0:20] == "virDomainGetCPUStats": elif name[0:20] == "virDomainGetCPUStats":
func = name[9:] func = name[9:]
func = func[0:1].lower() + func[1:] func = func[0:1].lower() + func[1:]
elif name[0:18] == "virDomainGetFSInfo":
func = name[12:]
func = func[0:2].lower() + func[2:]
elif name[0:12] == "virDomainGet": elif name[0:12] == "virDomainGet":
func = name[12:] func = name[12:]
func = func[0:1].lower() + func[1:] func = func[0:1].lower() + func[1:]

View File

@ -658,5 +658,11 @@
<arg name='flags' type='unsigned int' info='an OR&apos;ed set of virNodeAllocPagesFlags'/> <arg name='flags' type='unsigned int' info='an OR&apos;ed set of virNodeAllocPagesFlags'/>
<return type='int' info='the number of nodes successfully adjusted or -1 in case of an error'/> <return type='int' info='the number of nodes successfully adjusted or -1 in case of an error'/>
</function> </function>
<function name="virDomainGetFSInfo" file='python'>
<info>Get a list of mapping information for each mounted file systems within the specified guest and the disks.</info>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='flags' type='unsigned int' info='unused, pass 0'/>
<return type='char *' info="list of mounted filesystems information"/>
</function>
</symbols> </symbols>
</api> </api>

View File

@ -8266,6 +8266,73 @@ libvirt_virNodeAllocPages(PyObject *self ATTRIBUTE_UNUSED,
} }
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */ #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
#if LIBVIR_CHECK_VERSION(1, 2, 11)
static PyObject *
libvirt_virDomainGetFSInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
virDomainPtr domain;
PyObject *pyobj_domain;
unsigned int flags;
virDomainFSInfoPtr *fsinfo = NULL;
char **dev;
int c_retval, i;
PyObject *py_retval = NULL;
if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainFSInfo",
&pyobj_domain, &flags))
return NULL;
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
LIBVIRT_BEGIN_ALLOW_THREADS;
c_retval = virDomainGetFSInfo(domain, &fsinfo, flags);
LIBVIRT_END_ALLOW_THREADS;
if (c_retval < 0)
goto cleanup;
/* convert to a Python list */
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
for (i = 0; i < c_retval; i++) {
virDomainFSInfoPtr fs = fsinfo[i];
PyObject *info, *alias;
if (fs == NULL)
goto cleanup;
info = PyTuple_New(4);
if (info == NULL)
goto cleanup;
PyList_SetItem(py_retval, i, info);
alias = PyList_New(0);
if (alias == NULL)
goto cleanup;
PyTuple_SetItem(info, 0, libvirt_constcharPtrWrap(fs->mountpoint));
PyTuple_SetItem(info, 1, libvirt_constcharPtrWrap(fs->name));
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(fs->fstype));
PyTuple_SetItem(info, 3, alias);
for (dev = fs->devAlias; dev && *dev; dev++)
if (PyList_Append(alias, libvirt_constcharPtrWrap(*dev)) < 0)
goto cleanup;
}
for (i = 0; i < c_retval; i++)
virDomainFSInfoFree(fsinfo[i]);
VIR_FREE(fsinfo);
return py_retval;
cleanup:
for (i = 0; i < c_retval; i++)
virDomainFSInfoFree(fsinfo[i]);
VIR_FREE(fsinfo);
Py_XDECREF(py_retval);
return VIR_PY_NONE;
}
#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
/************************************************************************ /************************************************************************
* * * *
* The registration stuff * * The registration stuff *
@ -8459,6 +8526,9 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(1, 2, 9) #if LIBVIR_CHECK_VERSION(1, 2, 9)
{(char *) "virNodeAllocPages", libvirt_virNodeAllocPages, METH_VARARGS, NULL}, {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */ #endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
#if LIBVIR_CHECK_VERSION(1, 2, 11)
{(char *) "virDomainGetFSInfo", libvirt_virDomainGetFSInfo, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };

View File

@ -137,6 +137,9 @@ for cname in wantfunctions:
if name[0:28] == "virDomainStatsRecordListFree": if name[0:28] == "virDomainStatsRecordListFree":
continue continue
if name[0:19] == "virDomainFSInfoFree":
continue
if name[0:21] == "virDomainListGetStats": if name[0:21] == "virDomainListGetStats":
name = "virConnectDomainListGetStats" name = "virConnectDomainListGetStats"
@ -269,7 +272,7 @@ for name in sorted(basicklassmap):
func = func[0:1].lower() + func[1:] func = func[0:1].lower() + func[1:]
if func[0:8] == "nWFilter": if func[0:8] == "nWFilter":
func = "nwfilter" + func[8:] func = "nwfilter" + func[8:]
if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw": if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw" or func[0:6] == "fSInfo":
func = "fs" + func[2:] func = "fs" + func[2:]
if klass == "virNetwork": if klass == "virNetwork":