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 "typewrappers.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_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1567 PyObject
*py_retval
;
1568 unsigned char uuid
[VIR_UUID_BUFLEN
];
1569 virSecretPtr secret
;
1570 PyObject
*pyobj_secret
;
1573 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
1575 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
1579 LIBVIRT_BEGIN_ALLOW_THREADS
;
1580 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
1581 LIBVIRT_END_ALLOW_THREADS
;
1585 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
1591 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
1593 PyObject
*py_retval
;
1594 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
1596 PyObject
*pyobj_dom
;
1599 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
1602 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
1606 LIBVIRT_BEGIN_ALLOW_THREADS
;
1607 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
1608 LIBVIRT_END_ALLOW_THREADS
;
1613 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
1618 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1619 PyObject
*py_retval
;
1620 virSecretPtr c_retval
;
1622 PyObject
*pyobj_conn
;
1623 unsigned char * uuid
;
1626 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn
, &uuid
, &len
))
1628 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1630 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
1633 LIBVIRT_BEGIN_ALLOW_THREADS
;
1634 c_retval
= virSecretLookupByUUID(conn
, uuid
);
1635 LIBVIRT_END_ALLOW_THREADS
;
1636 py_retval
= libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
1642 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
1644 PyObject
*py_retval
;
1645 char **uuids
= NULL
;
1648 PyObject
*pyobj_conn
;
1650 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
1652 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1654 LIBVIRT_BEGIN_ALLOW_THREADS
;
1655 c_retval
= virConnectNumOfSecrets(conn
);
1656 LIBVIRT_END_ALLOW_THREADS
;
1661 uuids
= malloc(sizeof(*uuids
) * c_retval
);
1664 LIBVIRT_BEGIN_ALLOW_THREADS
;
1665 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
1666 LIBVIRT_END_ALLOW_THREADS
;
1672 py_retval
= PyList_New(c_retval
);
1675 for (i
= 0;i
< c_retval
;i
++) {
1676 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
1686 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
1688 PyObject
*py_retval
;
1689 unsigned char *c_retval
;
1691 virSecretPtr secret
;
1692 PyObject
*pyobj_secret
;
1695 if (!PyArg_ParseTuple(args
, (char *)"Oi:virSecretGetValue", &pyobj_secret
,
1698 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
1700 LIBVIRT_BEGIN_ALLOW_THREADS
;
1701 c_retval
= virSecretGetValue(secret
, &size
, flags
);
1702 LIBVIRT_END_ALLOW_THREADS
;
1704 if (c_retval
== NULL
)
1707 py_retval
= PyString_FromStringAndSize((const char *)c_retval
, size
);
1708 memset(c_retval
, 0, size
);
1715 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
1717 PyObject
*py_retval
;
1719 virSecretPtr secret
;
1720 PyObject
*pyobj_secret
;
1725 if (!PyArg_ParseTuple(args
, (char *)"Oz#i:virSecretSetValue", &pyobj_secret
,
1726 &value
, &size
, &flags
))
1728 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
1730 LIBVIRT_BEGIN_ALLOW_THREADS
;
1731 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
1733 LIBVIRT_END_ALLOW_THREADS
;
1735 py_retval
= libvirt_intWrap(c_retval
);
1739 /*******************************************
1740 * Helper functions to avoid importing modules
1741 * for every callback
1742 *******************************************/
1743 static PyObject
*libvirt_module
= NULL
;
1744 static PyObject
*libvirt_dict
= NULL
;
1745 static PyObject
*libvirt_dom_class
= NULL
;
1748 getLibvirtModuleObject (void) {
1750 return libvirt_module
;
1752 // PyImport_ImportModule returns a new reference
1753 /* Bogus (char *) cast for RHEL-5 python API brokenness */
1754 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
1755 if(!libvirt_module
) {
1757 printf("%s Error importing libvirt module\n", __FUNCTION__
);
1763 return libvirt_module
;
1767 getLibvirtDictObject (void) {
1769 return libvirt_dict
;
1771 // PyModule_GetDict returns a borrowed reference
1772 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
1775 printf("%s Error importing libvirt dictionary\n", __FUNCTION__
);
1781 Py_INCREF(libvirt_dict
);
1782 return libvirt_dict
;
1786 getLibvirtDomainClassObject (void) {
1787 if(libvirt_dom_class
)
1788 return libvirt_dom_class
;
1790 // PyDict_GetItemString returns a borrowed reference
1791 libvirt_dom_class
= PyDict_GetItemString(getLibvirtDictObject(),
1793 if(!libvirt_dom_class
) {
1795 printf("%s Error importing virDomain class\n", __FUNCTION__
);
1801 Py_INCREF(libvirt_dom_class
);
1802 return libvirt_dom_class
;
1804 /*******************************************
1806 *******************************************/
1809 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
1815 PyObject
*pyobj_ret
;
1817 PyObject
*pyobj_conn_inst
= (PyObject
*)opaque
;
1818 PyObject
*pyobj_dom
;
1820 PyObject
*pyobj_dom_args
;
1821 PyObject
*pyobj_dom_inst
;
1823 PyObject
*dom_class
;
1826 LIBVIRT_ENSURE_THREAD_STATE
;
1828 /* Create a python instance of this virDomainPtr */
1830 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
1831 pyobj_dom_args
= PyTuple_New(2);
1832 if(PyTuple_SetItem(pyobj_dom_args
, 0, pyobj_conn_inst
)!=0) {
1834 printf("%s error creating tuple",__FUNCTION__
);
1838 if(PyTuple_SetItem(pyobj_dom_args
, 1, pyobj_dom
)!=0) {
1840 printf("%s error creating tuple",__FUNCTION__
);
1844 Py_INCREF(pyobj_conn_inst
);
1846 dom_class
= getLibvirtDomainClassObject();
1847 if(!PyClass_Check(dom_class
)) {
1849 printf("%s dom_class is not a class!\n", __FUNCTION__
);
1854 pyobj_dom_inst
= PyInstance_New(dom_class
,
1858 Py_DECREF(pyobj_dom_args
);
1860 if(!pyobj_dom_inst
) {
1862 printf("%s Error creating a python instance of virDomain\n", __FUNCTION__
);
1868 /* Call the Callback Dispatcher */
1869 pyobj_ret
= PyObject_CallMethod(pyobj_conn_inst
,
1870 (char*)"dispatchDomainEventCallbacks",
1876 Py_DECREF(pyobj_dom_inst
);
1880 printf("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
1884 Py_DECREF(pyobj_ret
);
1890 LIBVIRT_RELEASE_THREAD_STATE
;
1895 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
* self
,
1898 PyObject
*py_retval
; /* return value */
1899 PyObject
*pyobj_conn
; /* virConnectPtr */
1900 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
1905 if (!PyArg_ParseTuple
1906 (args
, (char *) "OO:virConnectDomainEventRegister",
1907 &pyobj_conn
, &pyobj_conn_inst
)) {
1909 printf("%s failed parsing tuple\n", __FUNCTION__
);
1911 return VIR_PY_INT_FAIL
;
1915 printf("libvirt_virConnectDomainEventRegister(%p %p) called\n",
1916 pyobj_conn
, pyobj_conn_inst
);
1918 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1920 Py_INCREF(pyobj_conn_inst
);
1922 LIBVIRT_BEGIN_ALLOW_THREADS
;
1924 ret
= virConnectDomainEventRegister(conn
,
1925 libvirt_virConnectDomainEventCallback
,
1926 (void *)pyobj_conn_inst
, NULL
);
1928 LIBVIRT_END_ALLOW_THREADS
;
1930 py_retval
= libvirt_intWrap(ret
);
1935 libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject
* self
,
1938 PyObject
*py_retval
;
1939 PyObject
*pyobj_conn
;
1940 PyObject
*pyobj_conn_inst
;
1945 if (!PyArg_ParseTuple
1946 (args
, (char *) "OO:virConnectDomainEventDeregister",
1947 &pyobj_conn
, &pyobj_conn_inst
))
1951 printf("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
1954 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1956 LIBVIRT_BEGIN_ALLOW_THREADS
;
1958 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
1960 LIBVIRT_END_ALLOW_THREADS
;
1962 Py_DECREF(pyobj_conn_inst
);
1963 py_retval
= libvirt_intWrap(ret
);
1967 /*******************************************
1969 *******************************************/
1970 static PyObject
*addHandleObj
= NULL
;
1971 static char *addHandleName
= NULL
;
1972 static PyObject
*updateHandleObj
= NULL
;
1973 static char *updateHandleName
= NULL
;
1974 static PyObject
*removeHandleObj
= NULL
;
1975 static char *removeHandleName
= NULL
;
1976 static PyObject
*addTimeoutObj
= NULL
;
1977 static char *addTimeoutName
= NULL
;
1978 static PyObject
*updateTimeoutObj
= NULL
;
1979 static char *updateTimeoutName
= NULL
;
1980 static PyObject
*removeTimeoutObj
= NULL
;
1981 static char *removeTimeoutName
= NULL
;
1983 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
1986 libvirt_virEventAddHandleFunc (int fd
,
1988 virEventHandleCallback cb
,
1993 PyObject
*python_cb
;
1996 PyObject
*opaque_obj
;
1998 PyObject
*pyobj_args
;
2001 LIBVIRT_ENSURE_THREAD_STATE
;
2003 /* Lookup the python callback */
2004 python_cb
= PyDict_GetItemString(getLibvirtDictObject(),
2005 "eventInvokeHandleCallback");
2008 printf("%s: Error finding eventInvokeHandleCallback\n", __FUNCTION__
);
2014 if (!PyCallable_Check(python_cb
)) {
2016 char *name
= py_str(python_cb
);
2017 printf("%s: %s is not callable\n", __FUNCTION__
,
2018 name
? name
: "libvirt.eventInvokeHandleCallback");
2023 Py_INCREF(python_cb
);
2025 /* create tuple for cb */
2026 cb_obj
= libvirt_virEventHandleCallbackWrap(cb
);
2027 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
2028 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
2030 cb_args
= PyTuple_New(3);
2031 PyTuple_SetItem(cb_args
, 0, cb_obj
);
2032 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
2033 PyTuple_SetItem(cb_args
, 2, ff_obj
);
2035 pyobj_args
= PyTuple_New(4);
2036 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(fd
));
2037 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
2038 PyTuple_SetItem(pyobj_args
, 2, python_cb
);
2039 PyTuple_SetItem(pyobj_args
, 3, cb_args
);
2041 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
2045 } else if (!PyInt_Check(result
)) {
2047 printf("%s: %s should return an int\n", __FUNCTION__
, NAME(addHandle
));
2050 retval
= (int)PyInt_AsLong(result
);
2054 Py_DECREF(pyobj_args
);
2057 LIBVIRT_RELEASE_THREAD_STATE
;
2063 libvirt_virEventUpdateHandleFunc(int watch
, int event
)
2066 PyObject
*pyobj_args
;
2068 LIBVIRT_ENSURE_THREAD_STATE
;
2070 pyobj_args
= PyTuple_New(2);
2071 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
2072 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
2074 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
2081 Py_DECREF(pyobj_args
);
2083 LIBVIRT_RELEASE_THREAD_STATE
;
2088 libvirt_virEventRemoveHandleFunc(int watch
)
2091 PyObject
*pyobj_args
;
2095 virFreeCallback cff
;
2097 LIBVIRT_ENSURE_THREAD_STATE
;
2099 pyobj_args
= PyTuple_New(1);
2100 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
2102 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
2106 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
2108 printf("%s: %s must return opaque obj registered with %s"
2109 "to avoid leaking libvirt memory\n",
2110 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
2113 opaque
= PyTuple_GetItem(result
, 1);
2114 ff
= PyTuple_GetItem(result
, 2);
2115 cff
= PyvirFreeCallback_Get(ff
);
2117 (*cff
)(PyvirVoidPtr_Get(opaque
));
2122 Py_DECREF(pyobj_args
);
2124 LIBVIRT_RELEASE_THREAD_STATE
;
2130 libvirt_virEventAddTimeoutFunc(int timeout
,
2131 virEventTimeoutCallback cb
,
2137 PyObject
*python_cb
;
2141 PyObject
*opaque_obj
;
2143 PyObject
*pyobj_args
;
2146 LIBVIRT_ENSURE_THREAD_STATE
;
2148 /* Lookup the python callback */
2149 python_cb
= PyDict_GetItemString(getLibvirtDictObject(),
2150 "eventInvokeTimeoutCallback");
2153 printf("%s: Error finding eventInvokeTimeoutCallback\n", __FUNCTION__
);
2159 if (!PyCallable_Check(python_cb
)) {
2161 char *name
= py_str(python_cb
);
2162 printf("%s: %s is not callable\n", __FUNCTION__
,
2163 name
? name
: "libvirt.eventInvokeTimeoutCallback");
2168 Py_INCREF(python_cb
);
2170 /* create tuple for cb */
2171 cb_obj
= libvirt_virEventTimeoutCallbackWrap(cb
);
2172 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
2173 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
2175 cb_args
= PyTuple_New(3);
2176 PyTuple_SetItem(cb_args
, 0, cb_obj
);
2177 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
2178 PyTuple_SetItem(cb_args
, 2, ff_obj
);
2180 pyobj_args
= PyTuple_New(3);
2182 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timeout
));
2183 PyTuple_SetItem(pyobj_args
, 1, python_cb
);
2184 PyTuple_SetItem(pyobj_args
, 2, cb_args
);
2186 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
2190 } else if (!PyInt_Check(result
)) {
2192 printf("%s: %s should return an int\n", __FUNCTION__
, NAME(addTimeout
));
2195 retval
= (int)PyInt_AsLong(result
);
2199 Py_DECREF(pyobj_args
);
2202 LIBVIRT_RELEASE_THREAD_STATE
;
2207 libvirt_virEventUpdateTimeoutFunc(int timer
, int timeout
)
2209 PyObject
*result
= NULL
;
2210 PyObject
*pyobj_args
;
2212 LIBVIRT_ENSURE_THREAD_STATE
;
2214 pyobj_args
= PyTuple_New(2);
2215 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
2216 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(timeout
));
2218 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
2225 Py_DECREF(pyobj_args
);
2227 LIBVIRT_RELEASE_THREAD_STATE
;
2231 libvirt_virEventRemoveTimeoutFunc(int timer
)
2233 PyObject
*result
= NULL
;
2234 PyObject
*pyobj_args
;
2238 virFreeCallback cff
;
2240 LIBVIRT_ENSURE_THREAD_STATE
;
2242 pyobj_args
= PyTuple_New(1);
2243 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
2245 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
2249 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
2251 printf("%s: %s must return opaque obj registered with %s"
2252 "to avoid leaking libvirt memory\n",
2253 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
2256 opaque
= PyTuple_GetItem(result
, 1);
2257 ff
= PyTuple_GetItem(result
, 2);
2258 cff
= PyvirFreeCallback_Get(ff
);
2260 (*cff
)(PyvirVoidPtr_Get(opaque
));
2265 Py_DECREF(pyobj_args
);
2267 LIBVIRT_RELEASE_THREAD_STATE
;
2273 libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject
* self
,
2276 /* Unref the previously-registered impl (if any) */
2277 Py_XDECREF(addHandleObj
);
2278 free(addHandleName
);
2279 Py_XDECREF(updateHandleObj
);
2280 free(updateHandleName
);
2281 Py_XDECREF(removeHandleObj
);
2282 free(removeHandleName
);
2283 Py_XDECREF(addTimeoutObj
);
2284 free(addTimeoutName
);
2285 Py_XDECREF(updateTimeoutObj
);
2286 free(updateTimeoutName
);
2287 Py_XDECREF(removeTimeoutObj
);
2288 free(removeTimeoutName
);
2290 /* Parse and check arguments */
2291 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
2292 &addHandleObj
, &updateHandleObj
,
2293 &removeHandleObj
, &addTimeoutObj
,
2294 &updateTimeoutObj
, &removeTimeoutObj
) ||
2295 !PyCallable_Check(addHandleObj
) ||
2296 !PyCallable_Check(updateHandleObj
) ||
2297 !PyCallable_Check(removeHandleObj
) ||
2298 !PyCallable_Check(addTimeoutObj
) ||
2299 !PyCallable_Check(updateTimeoutObj
) ||
2300 !PyCallable_Check(removeTimeoutObj
))
2301 return VIR_PY_INT_FAIL
;
2303 /* Get argument string representations (for error reporting) */
2304 addHandleName
= py_str(addTimeoutObj
);
2305 updateHandleName
= py_str(updateHandleObj
);
2306 removeHandleName
= py_str(removeHandleObj
);
2307 addTimeoutName
= py_str(addTimeoutObj
);
2308 updateTimeoutName
= py_str(updateTimeoutObj
);
2309 removeTimeoutName
= py_str(removeTimeoutObj
);
2311 /* Inc refs since we're holding onto these objects until
2312 * the next call (if any) to this function.
2314 Py_INCREF(addHandleObj
);
2315 Py_INCREF(updateHandleObj
);
2316 Py_INCREF(removeHandleObj
);
2317 Py_INCREF(addTimeoutObj
);
2318 Py_INCREF(updateTimeoutObj
);
2319 Py_INCREF(removeTimeoutObj
);
2321 LIBVIRT_BEGIN_ALLOW_THREADS
;
2323 /* Now register our C EventImpl, which will dispatch
2324 * to the Python callbacks passed in as args.
2326 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
2327 libvirt_virEventUpdateHandleFunc
,
2328 libvirt_virEventRemoveHandleFunc
,
2329 libvirt_virEventAddTimeoutFunc
,
2330 libvirt_virEventUpdateTimeoutFunc
,
2331 libvirt_virEventRemoveTimeoutFunc
);
2333 LIBVIRT_END_ALLOW_THREADS
;
2335 return VIR_PY_INT_SUCCESS
;
2339 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
2342 int watch
, fd
, event
;
2344 PyObject
*py_opaque
;
2345 virEventHandleCallback cb
;
2348 if (!PyArg_ParseTuple
2349 (args
, (char *) "iiiOO:virEventInvokeHandleCallback",
2350 &watch
, &fd
, &event
, &py_f
, &py_opaque
2352 return VIR_PY_INT_FAIL
;
2354 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
2355 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
2358 cb (watch
, fd
, event
, opaque
);
2360 return VIR_PY_INT_SUCCESS
;
2364 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
2369 PyObject
*py_opaque
;
2370 virEventTimeoutCallback cb
;
2373 if (!PyArg_ParseTuple
2374 (args
, (char *) "iOO:virEventInvokeTimeoutCallback",
2375 &timer
, &py_f
, &py_opaque
2377 return VIR_PY_INT_FAIL
;
2379 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
2380 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
2384 return VIR_PY_INT_SUCCESS
;
2387 /************************************************************************
2389 * The registration stuff *
2391 ************************************************************************/
2392 static PyMethodDef libvirtMethods
[] = {
2393 #include "libvirt-export.c"
2394 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
2395 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
2396 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
2397 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
2398 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
2399 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
2400 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
2401 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
2402 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
2403 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
2404 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
2405 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
2406 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
2407 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
2408 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
2409 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
2410 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
2411 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
2412 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
2413 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
2414 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
2415 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
2416 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
2417 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
2418 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
2419 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
2420 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
2421 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
2422 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
2423 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
2424 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
2425 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
2426 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
2427 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
2428 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
2429 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
2430 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
2431 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
2432 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
2433 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
2434 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
2435 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
2436 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
2437 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
2438 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
2439 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
2440 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
2441 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
2442 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
2443 {NULL
, NULL
, 0, NULL
}
2454 static int initialized
= 0;
2456 if (initialized
!= 0)
2461 /* initialize the python extension module */
2462 Py_InitModule((char *)