2 * libvir.c: this modules implements the main part of the glue of the
3 * libvir library and the Python interpreter. It provides the
4 * entry points where an automatically generated stub is
7 * Copyright (C) 2005, 2007-2009 Red Hat, Inc.
9 * Daniel Veillard <veillard@redhat.com>
14 /* Horrible kludge to work around even more horrible name-space pollution
15 via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
16 which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
20 #include "libvirt/libvirt.h"
21 #include "libvirt/virterror.h"
22 #include "libvirt_wrap.h"
23 #include "libvirt-py.h"
26 extern void initlibvirtmod(void);
28 extern void initcygvirtmod(void);
31 /* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
32 is so common that we encapsulate it here. Now, each use is simply
33 return VIR_PY_NONE; */
34 #define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
35 #define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
36 #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
38 static char *py_str(PyObject
*obj
)
40 PyObject
*str
= PyObject_Str(obj
);
46 return PyString_AsString(str
);
50 /************************************************************************
54 ************************************************************************/
57 libvirt_virDomainBlockStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
59 PyObject
*pyobj_domain
;
62 virDomainBlockStatsStruct stats
;
65 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainBlockStats",
68 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
70 c_retval
= virDomainBlockStats(domain
, path
, &stats
, sizeof(stats
));
74 /* convert to a Python tuple of long objects */
75 if ((info
= PyTuple_New(5)) == NULL
)
77 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rd_req
));
78 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rd_bytes
));
79 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.wr_req
));
80 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.wr_bytes
));
81 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.errs
));
86 libvirt_virDomainInterfaceStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
88 PyObject
*pyobj_domain
;
91 virDomainInterfaceStatsStruct stats
;
94 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainInterfaceStats",
97 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
99 c_retval
= virDomainInterfaceStats(domain
, path
, &stats
, sizeof(stats
));
103 /* convert to a Python tuple of long objects */
104 if ((info
= PyTuple_New(8)) == NULL
)
106 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rx_bytes
));
107 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rx_packets
));
108 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.rx_errs
));
109 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.rx_drop
));
110 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.tx_bytes
));
111 PyTuple_SetItem(info
, 5, PyLong_FromLongLong(stats
.tx_packets
));
112 PyTuple_SetItem(info
, 6, PyLong_FromLongLong(stats
.tx_errs
));
113 PyTuple_SetItem(info
, 7, PyLong_FromLongLong(stats
.tx_drop
));
119 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
122 PyObject
*pyobj_domain
, *info
;
126 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
129 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
131 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
132 if (c_retval
== NULL
)
135 /* convert to a Python tuple of long objects */
136 if ((info
= PyTuple_New(2)) == NULL
) {
141 PyTuple_SetItem(info
, 0, libvirt_constcharPtrWrap(c_retval
));
142 PyTuple_SetItem(info
, 1, PyInt_FromLong((long)nparams
));
148 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
151 PyObject
*pyobj_domain
, *info
;
154 virSchedParameterPtr params
;
156 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
159 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
161 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
162 if (c_retval
== NULL
)
166 if ((params
= malloc(sizeof(*params
)*nparams
)) == NULL
)
169 if (virDomainGetSchedulerParameters(domain
, params
, &nparams
) < 0) {
174 /* convert to a Python tuple of long objects */
175 if ((info
= PyDict_New()) == NULL
) {
179 for (i
= 0 ; i
< nparams
; i
++) {
182 switch (params
[i
].type
) {
183 case VIR_DOMAIN_SCHED_FIELD_INT
:
184 val
= PyInt_FromLong((long)params
[i
].value
.i
);
187 case VIR_DOMAIN_SCHED_FIELD_UINT
:
188 val
= PyInt_FromLong((long)params
[i
].value
.ui
);
191 case VIR_DOMAIN_SCHED_FIELD_LLONG
:
192 val
= PyLong_FromLongLong((long long)params
[i
].value
.l
);
195 case VIR_DOMAIN_SCHED_FIELD_ULLONG
:
196 val
= PyLong_FromLongLong((long long)params
[i
].value
.ul
);
199 case VIR_DOMAIN_SCHED_FIELD_DOUBLE
:
200 val
= PyFloat_FromDouble((double)params
[i
].value
.d
);
203 case VIR_DOMAIN_SCHED_FIELD_BOOLEAN
:
204 val
= PyBool_FromLong((long)params
[i
].value
.b
);
213 key
= libvirt_constcharPtrWrap(params
[i
].field
);
214 PyDict_SetItem(info
, key
, val
);
221 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
224 PyObject
*pyobj_domain
, *info
;
227 virSchedParameterPtr params
;
229 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetScedulerParameters",
230 &pyobj_domain
, &info
))
232 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
234 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
235 if (c_retval
== NULL
)
236 return VIR_PY_INT_FAIL
;
239 if ((params
= malloc(sizeof(*params
)*nparams
)) == NULL
)
240 return VIR_PY_INT_FAIL
;
242 if (virDomainGetSchedulerParameters(domain
, params
, &nparams
) < 0) {
244 return VIR_PY_INT_FAIL
;
247 /* convert to a Python tuple of long objects */
248 for (i
= 0 ; i
< nparams
; i
++) {
250 key
= libvirt_constcharPtrWrap(params
[i
].field
);
251 val
= PyDict_GetItem(info
, key
);
257 switch (params
[i
].type
) {
258 case VIR_DOMAIN_SCHED_FIELD_INT
:
259 params
[i
].value
.i
= (int)PyInt_AS_LONG(val
);
262 case VIR_DOMAIN_SCHED_FIELD_UINT
:
263 params
[i
].value
.ui
= (unsigned int)PyInt_AS_LONG(val
);
266 case VIR_DOMAIN_SCHED_FIELD_LLONG
:
267 params
[i
].value
.l
= (long long)PyLong_AsLongLong(val
);
270 case VIR_DOMAIN_SCHED_FIELD_ULLONG
:
271 params
[i
].value
.ul
= (unsigned long long)PyLong_AsLongLong(val
);
274 case VIR_DOMAIN_SCHED_FIELD_DOUBLE
:
275 params
[i
].value
.d
= (double)PyFloat_AsDouble(val
);
278 case VIR_DOMAIN_SCHED_FIELD_BOOLEAN
:
280 /* Hack - Python's definition of Py_True breaks strict
281 * aliasing rules, so can't directly compare :-(
283 PyObject
*hacktrue
= PyBool_FromLong(1);
284 params
[i
].value
.b
= hacktrue
== val
? 1 : 0;
291 return VIR_PY_INT_FAIL
;
295 if (virDomainSetSchedulerParameters(domain
, params
, nparams
) < 0) {
297 return VIR_PY_INT_FAIL
;
301 return VIR_PY_INT_SUCCESS
;
305 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
308 PyObject
*pyobj_domain
, *pyretval
= NULL
, *pycpuinfo
= NULL
, *pycpumap
= NULL
;
309 virNodeInfo nodeinfo
;
310 virDomainInfo dominfo
;
311 virVcpuInfoPtr cpuinfo
= NULL
;
312 unsigned char *cpumap
= NULL
;
315 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
318 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
320 if (virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
) != 0)
323 if (virDomainGetInfo(domain
, &dominfo
) != 0)
326 if ((cpuinfo
= malloc(sizeof(*cpuinfo
)*dominfo
.nrVirtCpu
)) == NULL
)
329 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
330 if ((cpumap
= malloc(dominfo
.nrVirtCpu
* cpumaplen
)) == NULL
)
333 if (virDomainGetVcpus(domain
,
334 cpuinfo
, dominfo
.nrVirtCpu
,
335 cpumap
, cpumaplen
) < 0)
338 /* convert to a Python tuple of long objects */
339 if ((pyretval
= PyTuple_New(2)) == NULL
)
341 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
343 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
346 for (i
= 0 ; i
< dominfo
.nrVirtCpu
; i
++) {
347 PyObject
*info
= PyTuple_New(4);
350 PyTuple_SetItem(info
, 0, PyInt_FromLong((long)cpuinfo
[i
].number
));
351 PyTuple_SetItem(info
, 1, PyInt_FromLong((long)cpuinfo
[i
].state
));
352 PyTuple_SetItem(info
, 2, PyLong_FromLongLong((long long)cpuinfo
[i
].cpuTime
));
353 PyTuple_SetItem(info
, 3, PyInt_FromLong((long)cpuinfo
[i
].cpu
));
354 PyList_SetItem(pycpuinfo
, i
, info
);
356 for (i
= 0 ; i
< dominfo
.nrVirtCpu
; i
++) {
357 PyObject
*info
= PyTuple_New(VIR_NODEINFO_MAXCPUS(nodeinfo
));
361 for (j
= 0 ; j
< VIR_NODEINFO_MAXCPUS(nodeinfo
) ; j
++) {
362 PyTuple_SetItem(info
, j
, PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
, i
, j
)));
364 PyList_SetItem(pycpumap
, i
, info
);
366 PyTuple_SetItem(pyretval
, 0, pycpuinfo
);
367 PyTuple_SetItem(pyretval
, 1, pycpumap
);
377 /* NB, Py_DECREF is a badly defined macro, so we require
378 * braces here to avoid 'ambiguous else' warnings from
380 * NB. this comment is true at of time of writing wrt to
381 * at least python2.5.
383 if (pyretval
) { Py_DECREF(pyretval
); }
384 if (pycpuinfo
) { Py_DECREF(pycpuinfo
); }
385 if (pycpumap
) { Py_DECREF(pycpumap
); }
391 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
394 PyObject
*pyobj_domain
, *pycpumap
, *truth
;
395 virNodeInfo nodeinfo
;
396 unsigned char *cpumap
;
397 int cpumaplen
, i
, vcpu
;
399 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
400 &pyobj_domain
, &vcpu
, &pycpumap
))
402 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
404 if (virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
) != 0)
405 return VIR_PY_INT_FAIL
;
407 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
408 if ((cpumap
= malloc(cpumaplen
)) == NULL
)
409 return VIR_PY_INT_FAIL
;
410 memset(cpumap
, 0, cpumaplen
);
412 truth
= PyBool_FromLong(1);
413 for (i
= 0 ; i
< VIR_NODEINFO_MAXCPUS(nodeinfo
) ; i
++) {
414 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
416 VIR_USE_CPU(cpumap
, i
);
418 VIR_UNUSE_CPU(cpumap
, i
);
421 virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
425 return VIR_PY_INT_SUCCESS
;
429 /************************************************************************
431 * Global error handler at the Python level *
433 ************************************************************************/
435 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
436 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
439 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args ATTRIBUTE_UNUSED
)
444 if ((err
= virGetLastError()) == NULL
)
447 if ((info
= PyTuple_New(9)) == NULL
)
449 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
450 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
451 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
452 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
453 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
454 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
455 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
456 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
457 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
463 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
468 PyObject
*pyobj_conn
;
470 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
472 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
474 if ((err
= virConnGetLastError(conn
)) == NULL
)
477 if ((info
= PyTuple_New(9)) == NULL
)
479 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
480 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
481 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
482 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
483 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
484 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
485 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
486 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
487 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
493 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
, virErrorPtr err
)
495 PyObject
*list
, *info
;
499 printf("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
503 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
506 LIBVIRT_ENSURE_THREAD_STATE
;
508 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
509 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
510 virDefaultErrorFunc(err
);
512 list
= PyTuple_New(2);
513 info
= PyTuple_New(9);
514 PyTuple_SetItem(list
, 0, libvirt_virPythonErrorFuncCtxt
);
515 PyTuple_SetItem(list
, 1, info
);
516 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
517 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
518 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
519 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
520 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
521 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
522 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
523 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
524 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
525 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
526 /* TODO pass conn and dom if available */
527 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
532 LIBVIRT_RELEASE_THREAD_STATE
;
536 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
* self
,
543 if (!PyArg_ParseTuple
544 (args
, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f
,
549 printf("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
553 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
554 if (libvirt_virPythonErrorFuncHandler
!= NULL
) {
555 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
557 if (libvirt_virPythonErrorFuncCtxt
!= NULL
) {
558 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
561 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
562 libvirt_virPythonErrorFuncHandler
= NULL
;
563 libvirt_virPythonErrorFuncCtxt
= NULL
;
565 Py_XINCREF(pyobj_ctx
);
568 /* TODO: check f is a function ! */
569 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
570 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
573 py_retval
= libvirt_intWrap(1);
577 static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
582 PyObject
*pyauth
= (PyObject
*)cbdata
;
588 LIBVIRT_ENSURE_THREAD_STATE
;
590 pycb
= PyList_GetItem(pyauth
, 1);
591 pycbdata
= PyList_GetItem(pyauth
, 2);
593 list
= PyTuple_New(2);
594 pycred
= PyTuple_New(ncred
);
595 for (i
= 0 ; i
< ncred
; i
++) {
596 PyObject
*pycreditem
;
597 pycreditem
= PyList_New(5);
599 PyTuple_SetItem(pycred
, i
, pycreditem
);
600 PyList_SetItem(pycreditem
, 0, PyInt_FromLong((long) cred
[i
].type
));
601 PyList_SetItem(pycreditem
, 1, PyString_FromString(cred
[i
].prompt
));
602 if (cred
[i
].challenge
) {
603 PyList_SetItem(pycreditem
, 2, PyString_FromString(cred
[i
].challenge
));
606 PyList_SetItem(pycreditem
, 2, Py_None
);
608 if (cred
[i
].defresult
) {
609 PyList_SetItem(pycreditem
, 3, PyString_FromString(cred
[i
].defresult
));
612 PyList_SetItem(pycreditem
, 3, Py_None
);
614 PyList_SetItem(pycreditem
, 4, Py_None
);
617 PyTuple_SetItem(list
, 0, pycred
);
618 Py_XINCREF(pycbdata
);
619 PyTuple_SetItem(list
, 1, pycbdata
);
622 pyret
= PyEval_CallObject(pycb
, list
);
623 if (PyErr_Occurred())
626 ret
= PyLong_AsLong(pyret
);
628 for (i
= 0 ; i
< ncred
; i
++) {
629 PyObject
*pycreditem
;
632 pycreditem
= PyTuple_GetItem(pycred
, i
);
633 pyresult
= PyList_GetItem(pycreditem
, 4);
634 if (pyresult
!= Py_None
)
635 result
= PyString_AsString(pyresult
);
636 if (result
!= NULL
) {
637 cred
[i
].result
= strdup(result
);
638 cred
[i
].resultlen
= strlen(result
);
640 cred
[i
].result
= NULL
;
641 cred
[i
].resultlen
= 0;
650 LIBVIRT_RELEASE_THREAD_STATE
;
657 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
659 virConnectPtr c_retval
;
664 PyObject
*pycredtype
;
667 if (!PyArg_ParseTuple(args
, (char *)"zOi:virConnectOpenAuth", &name
, &pyauth
, &flags
))
670 pycredtype
= PyList_GetItem(pyauth
, 0);
671 pycredcb
= PyList_GetItem(pyauth
, 1);
673 auth
.ncredtype
= PyList_Size(pycredtype
);
674 if (auth
.ncredtype
) {
676 auth
.credtype
= malloc(sizeof(*auth
.credtype
) * auth
.ncredtype
);
677 if (auth
.credtype
== NULL
)
679 for (i
= 0 ; i
< auth
.ncredtype
; i
++) {
681 val
= PyList_GetItem(pycredtype
, i
);
682 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
685 auth
.cb
= pycredcb
? virConnectCredCallbackWrapper
: NULL
;
686 auth
.cbdata
= pyauth
;
688 LIBVIRT_BEGIN_ALLOW_THREADS
;
690 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
691 LIBVIRT_END_ALLOW_THREADS
;
692 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
697 /************************************************************************
699 * Wrappers for functions where generator fails *
701 ************************************************************************/
704 libvirt_virGetVersion (PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
707 unsigned long libVer
, typeVer
= 0;
710 if (!PyArg_ParseTuple (args
, (char *) "|s", &type
))
713 LIBVIRT_BEGIN_ALLOW_THREADS
;
716 c_retval
= virGetVersion (&libVer
, NULL
, NULL
);
718 c_retval
= virGetVersion (&libVer
, type
, &typeVer
);
720 LIBVIRT_END_ALLOW_THREADS
;
726 return PyInt_FromLong (libVer
);
728 return Py_BuildValue ((char *) "kk", libVer
, typeVer
);
733 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
736 int ids
[500], c_retval
, i
;
738 PyObject
*pyobj_conn
;
741 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
743 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
745 LIBVIRT_BEGIN_ALLOW_THREADS
;
746 c_retval
= virConnectListDomains(conn
, &ids
[0], 500);
747 LIBVIRT_END_ALLOW_THREADS
;
750 py_retval
= PyList_New(c_retval
);
751 for (i
= 0;i
< c_retval
;i
++) {
752 PyList_SetItem(py_retval
, i
, libvirt_intWrap(ids
[i
]));
758 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
764 PyObject
*pyobj_conn
;
767 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains", &pyobj_conn
))
769 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
771 c_retval
= virConnectNumOfDefinedDomains(conn
);
776 names
= malloc(sizeof(*names
) * c_retval
);
779 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
785 py_retval
= PyList_New(c_retval
);
788 for (i
= 0;i
< c_retval
;i
++) {
789 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
799 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
803 PyObject
*pyobj_domain
;
806 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
808 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
810 LIBVIRT_BEGIN_ALLOW_THREADS
;
811 c_retval
= virDomainGetInfo(domain
, &info
);
812 LIBVIRT_END_ALLOW_THREADS
;
815 py_retval
= PyList_New(5);
816 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
817 PyList_SetItem(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
));
818 PyList_SetItem(py_retval
, 2, libvirt_ulongWrap(info
.memory
));
819 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.nrVirtCpu
));
820 PyList_SetItem(py_retval
, 4,
821 libvirt_longlongWrap((unsigned long long) info
.cpuTime
));
826 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
830 PyObject
*pyobj_conn
;
833 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_conn
))
835 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
837 LIBVIRT_BEGIN_ALLOW_THREADS
;
838 c_retval
= virNodeGetInfo(conn
, &info
);
839 LIBVIRT_END_ALLOW_THREADS
;
842 py_retval
= PyList_New(8);
843 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&info
.model
[0]));
844 PyList_SetItem(py_retval
, 1, libvirt_longWrap((long) info
.memory
>> 10));
845 PyList_SetItem(py_retval
, 2, libvirt_intWrap((int) info
.cpus
));
846 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.mhz
));
847 PyList_SetItem(py_retval
, 4, libvirt_intWrap((int) info
.nodes
));
848 PyList_SetItem(py_retval
, 5, libvirt_intWrap((int) info
.sockets
));
849 PyList_SetItem(py_retval
, 6, libvirt_intWrap((int) info
.cores
));
850 PyList_SetItem(py_retval
, 7, libvirt_intWrap((int) info
.threads
));
855 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
857 unsigned char uuid
[VIR_UUID_BUFLEN
];
859 PyObject
*pyobj_domain
;
862 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
864 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
868 LIBVIRT_BEGIN_ALLOW_THREADS
;
869 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
870 LIBVIRT_END_ALLOW_THREADS
;
874 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
880 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
883 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
888 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
891 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
895 LIBVIRT_BEGIN_ALLOW_THREADS
;
896 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
897 LIBVIRT_END_ALLOW_THREADS
;
902 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
907 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
909 virDomainPtr c_retval
;
911 PyObject
*pyobj_conn
;
912 unsigned char * uuid
;
915 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn
, &uuid
, &len
))
917 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
919 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
922 LIBVIRT_BEGIN_ALLOW_THREADS
;
923 c_retval
= virDomainLookupByUUID(conn
, uuid
);
924 LIBVIRT_END_ALLOW_THREADS
;
925 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
931 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
937 PyObject
*pyobj_conn
;
940 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks", &pyobj_conn
))
942 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
944 c_retval
= virConnectNumOfNetworks(conn
);
949 names
= malloc(sizeof(*names
) * c_retval
);
952 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
958 py_retval
= PyList_New(c_retval
);
961 for (i
= 0;i
< c_retval
;i
++) {
962 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
973 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
979 PyObject
*pyobj_conn
;
982 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn
))
984 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
986 c_retval
= virConnectNumOfDefinedNetworks(conn
);
991 names
= malloc(sizeof(*names
) * c_retval
);
994 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
1000 py_retval
= PyList_New(c_retval
);
1003 for (i
= 0;i
< c_retval
;i
++) {
1004 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1015 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1016 PyObject
*py_retval
;
1017 unsigned char uuid
[VIR_UUID_BUFLEN
];
1018 virNetworkPtr domain
;
1019 PyObject
*pyobj_domain
;
1022 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
1024 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
1028 LIBVIRT_BEGIN_ALLOW_THREADS
;
1029 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
1030 LIBVIRT_END_ALLOW_THREADS
;
1034 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
1040 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
1042 PyObject
*py_retval
;
1043 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
1045 PyObject
*pyobj_net
;
1048 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
1051 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
1055 LIBVIRT_BEGIN_ALLOW_THREADS
;
1056 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
1057 LIBVIRT_END_ALLOW_THREADS
;
1062 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
1067 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1068 PyObject
*py_retval
;
1069 virNetworkPtr c_retval
;
1071 PyObject
*pyobj_conn
;
1072 unsigned char * uuid
;
1075 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn
, &uuid
, &len
))
1077 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1079 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
1082 LIBVIRT_BEGIN_ALLOW_THREADS
;
1083 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
1084 LIBVIRT_END_ALLOW_THREADS
;
1085 py_retval
= libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
1091 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1092 PyObject
*py_retval
;
1093 int c_retval
, autostart
;
1094 virDomainPtr domain
;
1095 PyObject
*pyobj_domain
;
1097 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart", &pyobj_domain
))
1100 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1102 LIBVIRT_BEGIN_ALLOW_THREADS
;
1103 c_retval
= virDomainGetAutostart(domain
, &autostart
);
1104 LIBVIRT_END_ALLOW_THREADS
;
1107 return VIR_PY_INT_FAIL
;
1108 py_retval
= libvirt_intWrap(autostart
);
1114 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1115 PyObject
*py_retval
;
1116 int c_retval
, autostart
;
1117 virNetworkPtr network
;
1118 PyObject
*pyobj_network
;
1120 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart", &pyobj_network
))
1123 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
1125 LIBVIRT_BEGIN_ALLOW_THREADS
;
1126 c_retval
= virNetworkGetAutostart(network
, &autostart
);
1127 LIBVIRT_END_ALLOW_THREADS
;
1130 return VIR_PY_INT_FAIL
;
1131 py_retval
= libvirt_intWrap(autostart
);
1136 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
1138 PyObject
*py_retval
;
1139 PyObject
*pyobj_conn
;
1140 int startCell
, maxCells
, c_retval
, i
;
1142 unsigned long long *freeMems
;
1144 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn
, &startCell
, &maxCells
))
1147 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
1150 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1152 malloc(maxCells
* sizeof(*freeMems
));
1153 if (freeMems
== NULL
)
1156 LIBVIRT_BEGIN_ALLOW_THREADS
;
1157 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
1158 LIBVIRT_END_ALLOW_THREADS
;
1165 py_retval
= PyList_New(c_retval
);
1166 for (i
= 0;i
< c_retval
;i
++) {
1167 PyList_SetItem(py_retval
, i
,
1168 libvirt_longlongWrap((long long) freeMems
[i
]));
1176 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
1178 PyObject
*py_retval
;
1179 char **names
= NULL
;
1182 PyObject
*pyobj_conn
;
1185 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools", &pyobj_conn
))
1187 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1189 c_retval
= virConnectNumOfStoragePools(conn
);
1194 names
= malloc(sizeof(*names
) * c_retval
);
1197 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
1203 py_retval
= PyList_New(c_retval
);
1204 if (py_retval
== NULL
) {
1206 for (i
= 0;i
< c_retval
;i
++)
1214 for (i
= 0;i
< c_retval
;i
++) {
1215 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1226 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
1228 PyObject
*py_retval
;
1229 char **names
= NULL
;
1232 PyObject
*pyobj_conn
;
1235 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn
))
1237 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1239 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
1244 names
= malloc(sizeof(*names
) * c_retval
);
1247 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
1253 py_retval
= PyList_New(c_retval
);
1254 if (py_retval
== NULL
) {
1256 for (i
= 0;i
< c_retval
;i
++)
1264 for (i
= 0;i
< c_retval
;i
++) {
1265 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1276 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
1278 PyObject
*py_retval
;
1279 char **names
= NULL
;
1281 virStoragePoolPtr pool
;
1282 PyObject
*pyobj_pool
;
1285 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes", &pyobj_pool
))
1287 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
1289 c_retval
= virStoragePoolNumOfVolumes(pool
);
1294 names
= malloc(sizeof(*names
) * c_retval
);
1297 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
1303 py_retval
= PyList_New(c_retval
);
1304 if (py_retval
== NULL
) {
1306 for (i
= 0;i
< c_retval
;i
++)
1314 for (i
= 0;i
< c_retval
;i
++) {
1315 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1325 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1326 PyObject
*py_retval
;
1327 int c_retval
, autostart
;
1328 virStoragePoolPtr pool
;
1329 PyObject
*pyobj_pool
;
1331 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool
))
1334 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
1336 LIBVIRT_BEGIN_ALLOW_THREADS
;
1337 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
1338 LIBVIRT_END_ALLOW_THREADS
;
1343 py_retval
= libvirt_intWrap(autostart
);
1348 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1349 PyObject
*py_retval
;
1351 virStoragePoolPtr pool
;
1352 PyObject
*pyobj_pool
;
1353 virStoragePoolInfo info
;
1355 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
1357 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
1359 LIBVIRT_BEGIN_ALLOW_THREADS
;
1360 c_retval
= virStoragePoolGetInfo(pool
, &info
);
1361 LIBVIRT_END_ALLOW_THREADS
;
1365 if ((py_retval
= PyList_New(4)) == NULL
)
1368 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
1369 PyList_SetItem(py_retval
, 1,
1370 libvirt_longlongWrap((unsigned long long) info
.capacity
));
1371 PyList_SetItem(py_retval
, 2,
1372 libvirt_longlongWrap((unsigned long long) info
.allocation
));
1373 PyList_SetItem(py_retval
, 3,
1374 libvirt_longlongWrap((unsigned long long) info
.available
));
1380 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1381 PyObject
*py_retval
;
1383 virStorageVolPtr pool
;
1384 PyObject
*pyobj_pool
;
1385 virStorageVolInfo info
;
1387 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
1389 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
1391 LIBVIRT_BEGIN_ALLOW_THREADS
;
1392 c_retval
= virStorageVolGetInfo(pool
, &info
);
1393 LIBVIRT_END_ALLOW_THREADS
;
1397 if ((py_retval
= PyList_New(3)) == NULL
)
1399 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
1400 PyList_SetItem(py_retval
, 1,
1401 libvirt_longlongWrap((unsigned long long) info
.capacity
));
1402 PyList_SetItem(py_retval
, 2,
1403 libvirt_longlongWrap((unsigned long long) info
.allocation
));
1408 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1409 PyObject
*py_retval
;
1410 unsigned char uuid
[VIR_UUID_BUFLEN
];
1411 virStoragePoolPtr pool
;
1412 PyObject
*pyobj_pool
;
1415 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
1417 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
1421 LIBVIRT_BEGIN_ALLOW_THREADS
;
1422 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
1423 LIBVIRT_END_ALLOW_THREADS
;
1428 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
1434 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
1436 PyObject
*py_retval
;
1437 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
1438 virStoragePoolPtr pool
;
1439 PyObject
*pyobj_pool
;
1442 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool
))
1444 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
1448 LIBVIRT_BEGIN_ALLOW_THREADS
;
1449 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
1450 LIBVIRT_END_ALLOW_THREADS
;
1455 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
1460 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1461 PyObject
*py_retval
;
1462 virStoragePoolPtr c_retval
;
1464 PyObject
*pyobj_conn
;
1465 unsigned char * uuid
;
1468 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn
, &uuid
, &len
))
1470 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1472 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
1475 LIBVIRT_BEGIN_ALLOW_THREADS
;
1476 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
1477 LIBVIRT_END_ALLOW_THREADS
;
1478 py_retval
= libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
1483 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
1485 PyObject
*py_retval
;
1486 char **names
= NULL
;
1489 PyObject
*pyobj_conn
;
1493 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virNodeListDevices",
1494 &pyobj_conn
, &cap
, &flags
))
1496 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1498 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
1503 names
= malloc(sizeof(*names
) * c_retval
);
1506 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
1512 py_retval
= PyList_New(c_retval
);
1515 for (i
= 0;i
< c_retval
;i
++) {
1516 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1526 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
1528 PyObject
*py_retval
;
1529 char **names
= NULL
;
1531 virNodeDevicePtr dev
;
1532 PyObject
*pyobj_dev
;
1534 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
1536 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
1538 c_retval
= virNodeDeviceNumOfCaps(dev
);
1543 names
= malloc(sizeof(*names
) * c_retval
);
1546 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
1552 py_retval
= PyList_New(c_retval
);
1555 for (i
= 0;i
< c_retval
;i
++) {
1556 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
1566 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
1568 PyObject
*py_retval
;
1569 char **uuids
= NULL
;
1572 PyObject
*pyobj_conn
;
1574 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
1576 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1578 LIBVIRT_BEGIN_ALLOW_THREADS
;
1579 c_retval
= virConnectNumOfSecrets(conn
);
1580 LIBVIRT_END_ALLOW_THREADS
;
1585 uuids
= malloc(sizeof(*uuids
) * c_retval
);
1588 LIBVIRT_BEGIN_ALLOW_THREADS
;
1589 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
1590 LIBVIRT_END_ALLOW_THREADS
;
1596 py_retval
= PyList_New(c_retval
);
1599 for (i
= 0;i
< c_retval
;i
++) {
1600 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
1610 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
1612 PyObject
*py_retval
;
1613 unsigned char *c_retval
;
1615 virSecretPtr secret
;
1616 PyObject
*pyobj_secret
;
1619 if (!PyArg_ParseTuple(args
, (char *)"Oi:virSecretGetValue", &pyobj_secret
,
1622 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
1624 LIBVIRT_BEGIN_ALLOW_THREADS
;
1625 c_retval
= virSecretGetValue(secret
, &size
, flags
);
1626 LIBVIRT_END_ALLOW_THREADS
;
1628 if (c_retval
== NULL
)
1631 py_retval
= PyString_FromStringAndSize((const char *)c_retval
, size
);
1632 memset(c_retval
, 0, size
);
1639 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
1641 PyObject
*py_retval
;
1643 virSecretPtr secret
;
1644 PyObject
*pyobj_secret
;
1649 if (!PyArg_ParseTuple(args
, (char *)"Oz#i:virSecretSetValue", &pyobj_secret
,
1650 &value
, &size
, &flags
))
1652 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
1654 LIBVIRT_BEGIN_ALLOW_THREADS
;
1655 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
1657 LIBVIRT_END_ALLOW_THREADS
;
1659 py_retval
= libvirt_intWrap(c_retval
);
1663 /*******************************************
1664 * Helper functions to avoid importing modules
1665 * for every callback
1666 *******************************************/
1667 static PyObject
*libvirt_module
= NULL
;
1668 static PyObject
*libvirt_dict
= NULL
;
1669 static PyObject
*libvirt_dom_class
= NULL
;
1672 getLibvirtModuleObject (void) {
1674 return libvirt_module
;
1676 // PyImport_ImportModule returns a new reference
1677 /* Bogus (char *) cast for RHEL-5 python API brokenness */
1678 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
1679 if(!libvirt_module
) {
1681 printf("%s Error importing libvirt module\n", __FUNCTION__
);
1687 return libvirt_module
;
1691 getLibvirtDictObject (void) {
1693 return libvirt_dict
;
1695 // PyModule_GetDict returns a borrowed reference
1696 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
1699 printf("%s Error importing libvirt dictionary\n", __FUNCTION__
);
1705 Py_INCREF(libvirt_dict
);
1706 return libvirt_dict
;
1710 getLibvirtDomainClassObject (void) {
1711 if(libvirt_dom_class
)
1712 return libvirt_dom_class
;
1714 // PyDict_GetItemString returns a borrowed reference
1715 libvirt_dom_class
= PyDict_GetItemString(getLibvirtDictObject(),
1717 if(!libvirt_dom_class
) {
1719 printf("%s Error importing virDomain class\n", __FUNCTION__
);
1725 Py_INCREF(libvirt_dom_class
);
1726 return libvirt_dom_class
;
1728 /*******************************************
1730 *******************************************/
1733 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
1739 PyObject
*pyobj_ret
;
1741 PyObject
*pyobj_conn_inst
= (PyObject
*)opaque
;
1742 PyObject
*pyobj_dom
;
1744 PyObject
*pyobj_dom_args
;
1745 PyObject
*pyobj_dom_inst
;
1747 PyObject
*dom_class
;
1750 LIBVIRT_ENSURE_THREAD_STATE
;
1752 /* Create a python instance of this virDomainPtr */
1754 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
1755 pyobj_dom_args
= PyTuple_New(2);
1756 if(PyTuple_SetItem(pyobj_dom_args
, 0, pyobj_conn_inst
)!=0) {
1758 printf("%s error creating tuple",__FUNCTION__
);
1762 if(PyTuple_SetItem(pyobj_dom_args
, 1, pyobj_dom
)!=0) {
1764 printf("%s error creating tuple",__FUNCTION__
);
1768 Py_INCREF(pyobj_conn_inst
);
1770 dom_class
= getLibvirtDomainClassObject();
1771 if(!PyClass_Check(dom_class
)) {
1773 printf("%s dom_class is not a class!\n", __FUNCTION__
);
1778 pyobj_dom_inst
= PyInstance_New(dom_class
,
1782 Py_DECREF(pyobj_dom_args
);
1784 if(!pyobj_dom_inst
) {
1786 printf("%s Error creating a python instance of virDomain\n", __FUNCTION__
);
1792 /* Call the Callback Dispatcher */
1793 pyobj_ret
= PyObject_CallMethod(pyobj_conn_inst
,
1794 (char*)"dispatchDomainEventCallbacks",
1800 Py_DECREF(pyobj_dom_inst
);
1804 printf("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
1808 Py_DECREF(pyobj_ret
);
1814 LIBVIRT_RELEASE_THREAD_STATE
;
1819 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
* self
,
1822 PyObject
*py_retval
; /* return value */
1823 PyObject
*pyobj_conn
; /* virConnectPtr */
1824 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
1829 if (!PyArg_ParseTuple
1830 (args
, (char *) "OO:virConnectDomainEventRegister",
1831 &pyobj_conn
, &pyobj_conn_inst
)) {
1833 printf("%s failed parsing tuple\n", __FUNCTION__
);
1835 return VIR_PY_INT_FAIL
;
1839 printf("libvirt_virConnectDomainEventRegister(%p %p) called\n",
1840 pyobj_conn
, pyobj_conn_inst
);
1842 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1844 Py_INCREF(pyobj_conn_inst
);
1846 LIBVIRT_BEGIN_ALLOW_THREADS
;
1848 ret
= virConnectDomainEventRegister(conn
,
1849 libvirt_virConnectDomainEventCallback
,
1850 (void *)pyobj_conn_inst
, NULL
);
1852 LIBVIRT_END_ALLOW_THREADS
;
1854 py_retval
= libvirt_intWrap(ret
);
1859 libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject
* self
,
1862 PyObject
*py_retval
;
1863 PyObject
*pyobj_conn
;
1864 PyObject
*pyobj_conn_inst
;
1869 if (!PyArg_ParseTuple
1870 (args
, (char *) "OO:virConnectDomainEventDeregister",
1871 &pyobj_conn
, &pyobj_conn_inst
))
1875 printf("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
1878 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1880 LIBVIRT_BEGIN_ALLOW_THREADS
;
1882 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
1884 LIBVIRT_END_ALLOW_THREADS
;
1886 Py_DECREF(pyobj_conn_inst
);
1887 py_retval
= libvirt_intWrap(ret
);
1891 /*******************************************
1893 *******************************************/
1894 static PyObject
*addHandleObj
= NULL
;
1895 static char *addHandleName
= NULL
;
1896 static PyObject
*updateHandleObj
= NULL
;
1897 static char *updateHandleName
= NULL
;
1898 static PyObject
*removeHandleObj
= NULL
;
1899 static char *removeHandleName
= NULL
;
1900 static PyObject
*addTimeoutObj
= NULL
;
1901 static char *addTimeoutName
= NULL
;
1902 static PyObject
*updateTimeoutObj
= NULL
;
1903 static char *updateTimeoutName
= NULL
;
1904 static PyObject
*removeTimeoutObj
= NULL
;
1905 static char *removeTimeoutName
= NULL
;
1907 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
1910 libvirt_virEventAddHandleFunc (int fd
,
1912 virEventHandleCallback cb
,
1917 PyObject
*python_cb
;
1920 PyObject
*opaque_obj
;
1922 PyObject
*pyobj_args
;
1925 LIBVIRT_ENSURE_THREAD_STATE
;
1927 /* Lookup the python callback */
1928 python_cb
= PyDict_GetItemString(getLibvirtDictObject(),
1929 "eventInvokeHandleCallback");
1932 printf("%s: Error finding eventInvokeHandleCallback\n", __FUNCTION__
);
1938 if (!PyCallable_Check(python_cb
)) {
1940 char *name
= py_str(python_cb
);
1941 printf("%s: %s is not callable\n", __FUNCTION__
,
1942 name
? name
: "libvirt.eventInvokeHandleCallback");
1947 Py_INCREF(python_cb
);
1949 /* create tuple for cb */
1950 cb_obj
= libvirt_virEventHandleCallbackWrap(cb
);
1951 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
1952 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
1954 cb_args
= PyTuple_New(3);
1955 PyTuple_SetItem(cb_args
, 0, cb_obj
);
1956 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
1957 PyTuple_SetItem(cb_args
, 2, ff_obj
);
1959 pyobj_args
= PyTuple_New(4);
1960 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(fd
));
1961 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
1962 PyTuple_SetItem(pyobj_args
, 2, python_cb
);
1963 PyTuple_SetItem(pyobj_args
, 3, cb_args
);
1965 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
1969 } else if (!PyInt_Check(result
)) {
1971 printf("%s: %s should return an int\n", __FUNCTION__
, NAME(addHandle
));
1974 retval
= (int)PyInt_AsLong(result
);
1978 Py_DECREF(pyobj_args
);
1981 LIBVIRT_RELEASE_THREAD_STATE
;
1987 libvirt_virEventUpdateHandleFunc(int watch
, int event
)
1990 PyObject
*pyobj_args
;
1992 LIBVIRT_ENSURE_THREAD_STATE
;
1994 pyobj_args
= PyTuple_New(2);
1995 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
1996 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
1998 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
2005 Py_DECREF(pyobj_args
);
2007 LIBVIRT_RELEASE_THREAD_STATE
;
2012 libvirt_virEventRemoveHandleFunc(int watch
)
2015 PyObject
*pyobj_args
;
2019 virFreeCallback cff
;
2021 LIBVIRT_ENSURE_THREAD_STATE
;
2023 pyobj_args
= PyTuple_New(1);
2024 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
2026 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
2030 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
2032 printf("%s: %s must return opaque obj registered with %s"
2033 "to avoid leaking libvirt memory\n",
2034 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
2037 opaque
= PyTuple_GetItem(result
, 1);
2038 ff
= PyTuple_GetItem(result
, 2);
2039 cff
= PyvirFreeCallback_Get(ff
);
2041 (*cff
)(PyvirVoidPtr_Get(opaque
));
2046 Py_DECREF(pyobj_args
);
2048 LIBVIRT_RELEASE_THREAD_STATE
;
2054 libvirt_virEventAddTimeoutFunc(int timeout
,
2055 virEventTimeoutCallback cb
,
2061 PyObject
*python_cb
;
2065 PyObject
*opaque_obj
;
2067 PyObject
*pyobj_args
;
2070 LIBVIRT_ENSURE_THREAD_STATE
;
2072 /* Lookup the python callback */
2073 python_cb
= PyDict_GetItemString(getLibvirtDictObject(),
2074 "eventInvokeTimeoutCallback");
2077 printf("%s: Error finding eventInvokeTimeoutCallback\n", __FUNCTION__
);
2083 if (!PyCallable_Check(python_cb
)) {
2085 char *name
= py_str(python_cb
);
2086 printf("%s: %s is not callable\n", __FUNCTION__
,
2087 name
? name
: "libvirt.eventInvokeTimeoutCallback");
2092 Py_INCREF(python_cb
);
2094 /* create tuple for cb */
2095 cb_obj
= libvirt_virEventTimeoutCallbackWrap(cb
);
2096 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
2097 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
2099 cb_args
= PyTuple_New(3);
2100 PyTuple_SetItem(cb_args
, 0, cb_obj
);
2101 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
2102 PyTuple_SetItem(cb_args
, 2, ff_obj
);
2104 pyobj_args
= PyTuple_New(3);
2106 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timeout
));
2107 PyTuple_SetItem(pyobj_args
, 1, python_cb
);
2108 PyTuple_SetItem(pyobj_args
, 2, cb_args
);
2110 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
2114 } else if (!PyInt_Check(result
)) {
2116 printf("%s: %s should return an int\n", __FUNCTION__
, NAME(addTimeout
));
2119 retval
= (int)PyInt_AsLong(result
);
2123 Py_DECREF(pyobj_args
);
2126 LIBVIRT_RELEASE_THREAD_STATE
;
2131 libvirt_virEventUpdateTimeoutFunc(int timer
, int timeout
)
2133 PyObject
*result
= NULL
;
2134 PyObject
*pyobj_args
;
2136 LIBVIRT_ENSURE_THREAD_STATE
;
2138 pyobj_args
= PyTuple_New(2);
2139 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
2140 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(timeout
));
2142 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
2149 Py_DECREF(pyobj_args
);
2151 LIBVIRT_RELEASE_THREAD_STATE
;
2155 libvirt_virEventRemoveTimeoutFunc(int timer
)
2157 PyObject
*result
= NULL
;
2158 PyObject
*pyobj_args
;
2162 virFreeCallback cff
;
2164 LIBVIRT_ENSURE_THREAD_STATE
;
2166 pyobj_args
= PyTuple_New(1);
2167 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
2169 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
2173 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
2175 printf("%s: %s must return opaque obj registered with %s"
2176 "to avoid leaking libvirt memory\n",
2177 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
2180 opaque
= PyTuple_GetItem(result
, 1);
2181 ff
= PyTuple_GetItem(result
, 2);
2182 cff
= PyvirFreeCallback_Get(ff
);
2184 (*cff
)(PyvirVoidPtr_Get(opaque
));
2189 Py_DECREF(pyobj_args
);
2191 LIBVIRT_RELEASE_THREAD_STATE
;
2197 libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject
* self
,
2200 /* Unref the previously-registered impl (if any) */
2201 Py_XDECREF(addHandleObj
);
2202 free(addHandleName
);
2203 Py_XDECREF(updateHandleObj
);
2204 free(updateHandleName
);
2205 Py_XDECREF(removeHandleObj
);
2206 free(removeHandleName
);
2207 Py_XDECREF(addTimeoutObj
);
2208 free(addTimeoutName
);
2209 Py_XDECREF(updateTimeoutObj
);
2210 free(updateTimeoutName
);
2211 Py_XDECREF(removeTimeoutObj
);
2212 free(removeTimeoutName
);
2214 /* Parse and check arguments */
2215 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
2216 &addHandleObj
, &updateHandleObj
,
2217 &removeHandleObj
, &addTimeoutObj
,
2218 &updateTimeoutObj
, &removeTimeoutObj
) ||
2219 !PyCallable_Check(addHandleObj
) ||
2220 !PyCallable_Check(updateHandleObj
) ||
2221 !PyCallable_Check(removeHandleObj
) ||
2222 !PyCallable_Check(addTimeoutObj
) ||
2223 !PyCallable_Check(updateTimeoutObj
) ||
2224 !PyCallable_Check(removeTimeoutObj
))
2225 return VIR_PY_INT_FAIL
;
2227 /* Get argument string representations (for error reporting) */
2228 addHandleName
= py_str(addTimeoutObj
);
2229 updateHandleName
= py_str(updateHandleObj
);
2230 removeHandleName
= py_str(removeHandleObj
);
2231 addTimeoutName
= py_str(addTimeoutObj
);
2232 updateTimeoutName
= py_str(updateTimeoutObj
);
2233 removeTimeoutName
= py_str(removeTimeoutObj
);
2235 /* Inc refs since we're holding onto these objects until
2236 * the next call (if any) to this function.
2238 Py_INCREF(addHandleObj
);
2239 Py_INCREF(updateHandleObj
);
2240 Py_INCREF(removeHandleObj
);
2241 Py_INCREF(addTimeoutObj
);
2242 Py_INCREF(updateTimeoutObj
);
2243 Py_INCREF(removeTimeoutObj
);
2245 LIBVIRT_BEGIN_ALLOW_THREADS
;
2247 /* Now register our C EventImpl, which will dispatch
2248 * to the Python callbacks passed in as args.
2250 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
2251 libvirt_virEventUpdateHandleFunc
,
2252 libvirt_virEventRemoveHandleFunc
,
2253 libvirt_virEventAddTimeoutFunc
,
2254 libvirt_virEventUpdateTimeoutFunc
,
2255 libvirt_virEventRemoveTimeoutFunc
);
2257 LIBVIRT_END_ALLOW_THREADS
;
2259 return VIR_PY_INT_SUCCESS
;
2263 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
2266 int watch
, fd
, event
;
2268 PyObject
*py_opaque
;
2269 virEventHandleCallback cb
;
2272 if (!PyArg_ParseTuple
2273 (args
, (char *) "iiiOO:virEventInvokeHandleCallback",
2274 &watch
, &fd
, &event
, &py_f
, &py_opaque
2276 return VIR_PY_INT_FAIL
;
2278 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
2279 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
2282 cb (watch
, fd
, event
, opaque
);
2284 return VIR_PY_INT_SUCCESS
;
2288 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
2293 PyObject
*py_opaque
;
2294 virEventTimeoutCallback cb
;
2297 if (!PyArg_ParseTuple
2298 (args
, (char *) "iOO:virEventInvokeTimeoutCallback",
2299 &timer
, &py_f
, &py_opaque
2301 return VIR_PY_INT_FAIL
;
2303 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
2304 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
2308 return VIR_PY_INT_SUCCESS
;
2311 /************************************************************************
2313 * The registration stuff *
2315 ************************************************************************/
2316 static PyMethodDef libvirtMethods
[] = {
2317 #include "libvirt-export.c"
2318 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
2319 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
2320 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
2321 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
2322 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
2323 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
2324 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
2325 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
2326 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
2327 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
2328 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
2329 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
2330 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
2331 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
2332 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
2333 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
2334 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
2335 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
2336 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
2337 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
2338 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
2339 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
2340 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
2341 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
2342 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
2343 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
2344 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
2345 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
2346 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
2347 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
2348 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
2349 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
2350 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
2351 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
2352 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
2353 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
2354 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
2355 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
2356 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
2357 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
2358 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
2359 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
2360 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
2361 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
2362 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
2363 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
2364 {NULL
, NULL
, 0, NULL
}
2375 static int initialized
= 0;
2377 if (initialized
!= 0)
2382 /* initialize the python extension module */
2383 Py_InitModule((char *)