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-2012 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. */
19 /* We want to see *_LAST enums. */
20 #define VIR_ENUM_SENTINELS
23 #include "libvirt/libvirt.h"
24 #include "libvirt/virterror.h"
25 #include "typewrappers.h"
28 #include "virtypedparam.h"
29 #include "ignore-value.h"
33 extern void initlibvirtmod(void);
35 extern void initcygvirtmod(void);
39 # define DEBUG_ERROR 1
43 # define DEBUG(fmt, ...) \
44 printf(fmt, __VA_ARGS__)
46 # define DEBUG(fmt, ...) \
50 /* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
51 is so common that we encapsulate it here. Now, each use is simply
52 return VIR_PY_NONE; */
53 #define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
54 #define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
55 #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
57 /* We don't want to free() returned value. As written in doc:
58 * PyString_AsString returns pointer to 'internal buffer of string,
59 * not a copy' and 'It must not be deallocated'. */
60 static char *py_str(PyObject
*obj
)
62 PyObject
*str
= PyObject_Str(obj
);
68 return PyString_AsString(str
);
71 /* Helper function to convert a virTypedParameter output array into a
72 * Python dictionary for return to the user. Return NULL on failure,
73 * after raising a python exception. */
75 getPyVirTypedParameter(const virTypedParameterPtr params
, int nparams
)
77 PyObject
*key
, *val
, *info
;
80 if ((info
= PyDict_New()) == NULL
)
83 for (i
= 0 ; i
< nparams
; i
++) {
84 switch (params
[i
].type
) {
85 case VIR_TYPED_PARAM_INT
:
86 val
= PyInt_FromLong(params
[i
].value
.i
);
89 case VIR_TYPED_PARAM_UINT
:
90 val
= PyInt_FromLong(params
[i
].value
.ui
);
93 case VIR_TYPED_PARAM_LLONG
:
94 val
= PyLong_FromLongLong(params
[i
].value
.l
);
97 case VIR_TYPED_PARAM_ULLONG
:
98 val
= PyLong_FromUnsignedLongLong(params
[i
].value
.ul
);
101 case VIR_TYPED_PARAM_DOUBLE
:
102 val
= PyFloat_FromDouble(params
[i
].value
.d
);
105 case VIR_TYPED_PARAM_BOOLEAN
:
106 val
= PyBool_FromLong(params
[i
].value
.b
);
109 case VIR_TYPED_PARAM_STRING
:
110 val
= libvirt_constcharPtrWrap(params
[i
].value
.s
);
114 /* Possible if a newer server has a bug and sent stuff we
115 * don't recognize. */
116 PyErr_Format(PyExc_LookupError
,
117 "Type value \"%d\" not recognized",
123 key
= libvirt_constcharPtrWrap(params
[i
].field
);
127 if (PyDict_SetItem(info
, key
, val
) < 0) {
143 /* Allocate a new typed parameter array with the same contents and
144 * length as info, and using the array params of length nparams as
145 * hints on what types to use when creating the new array. The caller
146 * must NOT clear the array before freeing it, as it points into info
147 * rather than allocated strings. Return NULL on failure, after
148 * raising a python exception. */
149 static virTypedParameterPtr
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
150 setPyVirTypedParameter(PyObject
*info
,
151 const virTypedParameterPtr params
, int nparams
)
153 PyObject
*key
, *value
;
155 virTypedParameterPtr temp
= NULL
, ret
= NULL
;
159 if ((size
= PyDict_Size(info
)) < 0)
162 /* Libvirt APIs use NULL array and 0 size as a special case;
163 * setting should have at least one parameter. */
165 PyErr_Format(PyExc_LookupError
, "Dictionary must not be empty");
169 if (VIR_ALLOC_N(ret
, size
) < 0) {
175 while (PyDict_Next(info
, &pos
, &key
, &value
)) {
178 if ((keystr
= PyString_AsString(key
)) == NULL
)
181 for (i
= 0; i
< nparams
; i
++) {
182 if (STREQ(params
[i
].field
, keystr
))
186 PyErr_Format(PyExc_LookupError
,
187 "Attribute name \"%s\" could not be recognized",
192 ignore_value(virStrcpyStatic(temp
->field
, keystr
));
193 temp
->type
= params
[i
].type
;
195 switch(params
[i
].type
) {
196 case VIR_TYPED_PARAM_INT
:
197 if (libvirt_intUnwrap(value
, &temp
->value
.i
) < 0)
201 case VIR_TYPED_PARAM_UINT
:
202 if (libvirt_uintUnwrap(value
, &temp
->value
.ui
) < 0)
206 case VIR_TYPED_PARAM_LLONG
:
207 if (libvirt_longlongUnwrap(value
, &temp
->value
.l
) < 0)
211 case VIR_TYPED_PARAM_ULLONG
:
212 if (libvirt_ulonglongUnwrap(value
, &temp
->value
.ul
) < 0)
216 case VIR_TYPED_PARAM_DOUBLE
:
217 if (libvirt_doubleUnwrap(value
, &temp
->value
.d
) < 0)
221 case VIR_TYPED_PARAM_BOOLEAN
:
224 if (libvirt_boolUnwrap(value
, &b
) < 0)
229 case VIR_TYPED_PARAM_STRING
:
231 char *string_val
= PyString_AsString(value
);
234 temp
->value
.s
= string_val
;
239 /* Possible if a newer server has a bug and sent stuff we
240 * don't recognize. */
241 PyErr_Format(PyExc_LookupError
,
242 "Type value \"%d\" not recognized",
256 /************************************************************************
260 ************************************************************************/
263 libvirt_virDomainBlockStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
265 PyObject
*pyobj_domain
;
268 virDomainBlockStatsStruct stats
;
271 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainBlockStats",
272 &pyobj_domain
,&path
))
274 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
276 LIBVIRT_BEGIN_ALLOW_THREADS
;
277 c_retval
= virDomainBlockStats(domain
, path
, &stats
, sizeof(stats
));
278 LIBVIRT_END_ALLOW_THREADS
;
283 /* convert to a Python tuple of long objects */
284 if ((info
= PyTuple_New(5)) == NULL
)
286 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rd_req
));
287 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rd_bytes
));
288 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.wr_req
));
289 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.wr_bytes
));
290 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.errs
));
295 libvirt_virDomainBlockStatsFlags(PyObject
*self ATTRIBUTE_UNUSED
,
299 PyObject
*pyobj_domain
;
300 PyObject
*ret
= NULL
;
304 virTypedParameterPtr params
;
307 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainBlockStatsFlags",
308 &pyobj_domain
, &path
, &flags
))
310 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
312 LIBVIRT_BEGIN_ALLOW_THREADS
;
313 i_retval
= virDomainBlockStatsFlags(domain
, path
, NULL
, &nparams
, flags
);
314 LIBVIRT_END_ALLOW_THREADS
;
322 if (VIR_ALLOC_N(params
, nparams
) < 0)
323 return PyErr_NoMemory();
325 LIBVIRT_BEGIN_ALLOW_THREADS
;
326 i_retval
= virDomainBlockStatsFlags(domain
, path
, params
, &nparams
, flags
);
327 LIBVIRT_END_ALLOW_THREADS
;
334 ret
= getPyVirTypedParameter(params
, nparams
);
337 virTypedParameterArrayClear(params
, nparams
);
343 libvirt_virDomainGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
346 PyObject
*pyobj_domain
, *totalbool
;
347 PyObject
*cpu
, *total
;
348 PyObject
*ret
= NULL
;
349 PyObject
*error
= NULL
;
350 int ncpus
= -1, start_cpu
= 0;
351 int sumparams
= 0, nparams
= -1;
355 virTypedParameterPtr params
= NULL
, cpuparams
;
357 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainGetCPUStats",
358 &pyobj_domain
, &totalbool
, &flags
))
360 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
362 if (libvirt_boolUnwrap(totalbool
, &totalflag
) < 0)
365 if ((ret
= PyList_New(0)) == NULL
)
369 LIBVIRT_BEGIN_ALLOW_THREADS
;
370 ncpus
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 0, flags
);
371 LIBVIRT_END_ALLOW_THREADS
;
378 LIBVIRT_BEGIN_ALLOW_THREADS
;
379 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 1, flags
);
380 LIBVIRT_END_ALLOW_THREADS
;
387 sumparams
= nparams
* MIN(ncpus
, 128);
389 if (VIR_ALLOC_N(params
, sumparams
) < 0) {
390 error
= PyErr_NoMemory();
395 int queried_ncpus
= MIN(ncpus
, 128);
398 LIBVIRT_BEGIN_ALLOW_THREADS
;
399 i_retval
= virDomainGetCPUStats(domain
, params
,
400 nparams
, start_cpu
, queried_ncpus
, flags
);
401 LIBVIRT_END_ALLOW_THREADS
;
411 for (i
= 0; i
< queried_ncpus
; i
++) {
412 cpuparams
= ¶ms
[i
* nparams
];
413 if ((cpu
= getPyVirTypedParameter(cpuparams
, i_retval
)) == NULL
) {
417 if (PyList_Append(ret
, cpu
) < 0) {
424 start_cpu
+= queried_ncpus
;
425 ncpus
-= queried_ncpus
;
426 virTypedParameterArrayClear(params
, sumparams
);
429 LIBVIRT_BEGIN_ALLOW_THREADS
;
430 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, -1, 1, flags
);
431 LIBVIRT_END_ALLOW_THREADS
;
441 if (VIR_ALLOC_N(params
, nparams
) < 0) {
442 error
= PyErr_NoMemory();
446 LIBVIRT_BEGIN_ALLOW_THREADS
;
447 i_retval
= virDomainGetCPUStats(domain
, params
, nparams
, -1, 1, flags
);
448 LIBVIRT_END_ALLOW_THREADS
;
458 if ((total
= getPyVirTypedParameter(params
, i_retval
)) == NULL
) {
461 if (PyList_Append(ret
, total
) < 0) {
468 virTypedParameterArrayClear(params
, sumparams
);
473 virTypedParameterArrayClear(params
, sumparams
);
480 libvirt_virDomainInterfaceStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
482 PyObject
*pyobj_domain
;
485 virDomainInterfaceStatsStruct stats
;
488 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainInterfaceStats",
489 &pyobj_domain
,&path
))
491 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
493 LIBVIRT_BEGIN_ALLOW_THREADS
;
494 c_retval
= virDomainInterfaceStats(domain
, path
, &stats
, sizeof(stats
));
495 LIBVIRT_END_ALLOW_THREADS
;
500 /* convert to a Python tuple of long objects */
501 if ((info
= PyTuple_New(8)) == NULL
)
503 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rx_bytes
));
504 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rx_packets
));
505 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.rx_errs
));
506 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.rx_drop
));
507 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.tx_bytes
));
508 PyTuple_SetItem(info
, 5, PyLong_FromLongLong(stats
.tx_packets
));
509 PyTuple_SetItem(info
, 6, PyLong_FromLongLong(stats
.tx_errs
));
510 PyTuple_SetItem(info
, 7, PyLong_FromLongLong(stats
.tx_drop
));
515 libvirt_virDomainMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
517 PyObject
*pyobj_domain
;
518 unsigned int nr_stats
, i
;
519 virDomainMemoryStatStruct stats
[VIR_DOMAIN_MEMORY_STAT_NR
];
522 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainMemoryStats", &pyobj_domain
))
524 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
526 nr_stats
= virDomainMemoryStats(domain
, stats
,
527 VIR_DOMAIN_MEMORY_STAT_NR
, 0);
531 /* convert to a Python dictionary */
532 if ((info
= PyDict_New()) == NULL
)
535 for (i
= 0; i
< nr_stats
; i
++) {
536 if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_SWAP_IN
)
537 PyDict_SetItem(info
, libvirt_constcharPtrWrap("swap_in"),
538 PyLong_FromUnsignedLongLong(stats
[i
].val
));
539 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
)
540 PyDict_SetItem(info
, libvirt_constcharPtrWrap("swap_out"),
541 PyLong_FromUnsignedLongLong(stats
[i
].val
));
542 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
)
543 PyDict_SetItem(info
, libvirt_constcharPtrWrap("major_fault"),
544 PyLong_FromUnsignedLongLong(stats
[i
].val
));
545 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
)
546 PyDict_SetItem(info
, libvirt_constcharPtrWrap("minor_fault"),
547 PyLong_FromUnsignedLongLong(stats
[i
].val
));
548 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_UNUSED
)
549 PyDict_SetItem(info
, libvirt_constcharPtrWrap("unused"),
550 PyLong_FromUnsignedLongLong(stats
[i
].val
));
551 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_AVAILABLE
)
552 PyDict_SetItem(info
, libvirt_constcharPtrWrap("available"),
553 PyLong_FromUnsignedLongLong(stats
[i
].val
));
554 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
)
555 PyDict_SetItem(info
, libvirt_constcharPtrWrap("actual"),
556 PyLong_FromUnsignedLongLong(stats
[i
].val
));
557 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_RSS
)
558 PyDict_SetItem(info
, libvirt_constcharPtrWrap("rss"),
559 PyLong_FromUnsignedLongLong(stats
[i
].val
));
565 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
568 PyObject
*pyobj_domain
, *info
;
572 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
575 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
577 LIBVIRT_BEGIN_ALLOW_THREADS
;
578 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
579 LIBVIRT_END_ALLOW_THREADS
;
580 if (c_retval
== NULL
)
583 /* convert to a Python tuple of long objects */
584 if ((info
= PyTuple_New(2)) == NULL
) {
589 PyTuple_SetItem(info
, 0, libvirt_constcharPtrWrap(c_retval
));
590 PyTuple_SetItem(info
, 1, PyInt_FromLong((long)nparams
));
596 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
600 PyObject
*pyobj_domain
;
601 PyObject
*ret
= NULL
;
605 virTypedParameterPtr params
;
607 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
610 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
612 LIBVIRT_BEGIN_ALLOW_THREADS
;
613 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
614 LIBVIRT_END_ALLOW_THREADS
;
616 if (c_retval
== NULL
)
623 if (VIR_ALLOC_N(params
, nparams
) < 0)
624 return PyErr_NoMemory();
626 LIBVIRT_BEGIN_ALLOW_THREADS
;
627 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
628 LIBVIRT_END_ALLOW_THREADS
;
635 ret
= getPyVirTypedParameter(params
, nparams
);
638 virTypedParameterArrayClear(params
, nparams
);
644 libvirt_virDomainGetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
648 PyObject
*pyobj_domain
;
649 PyObject
*ret
= NULL
;
654 virTypedParameterPtr params
;
656 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetScedulerParametersFlags",
657 &pyobj_domain
, &flags
))
659 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
661 LIBVIRT_BEGIN_ALLOW_THREADS
;
662 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
663 LIBVIRT_END_ALLOW_THREADS
;
665 if (c_retval
== NULL
)
672 if (VIR_ALLOC_N(params
, nparams
) < 0)
673 return PyErr_NoMemory();
675 LIBVIRT_BEGIN_ALLOW_THREADS
;
676 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
677 LIBVIRT_END_ALLOW_THREADS
;
684 ret
= getPyVirTypedParameter(params
, nparams
);
687 virTypedParameterArrayClear(params
, nparams
);
693 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
697 PyObject
*pyobj_domain
, *info
;
698 PyObject
*ret
= NULL
;
703 virTypedParameterPtr params
, new_params
= NULL
;
705 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetScedulerParameters",
706 &pyobj_domain
, &info
))
708 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
710 if ((size
= PyDict_Size(info
)) < 0)
714 PyErr_Format(PyExc_LookupError
,
715 "Need non-empty dictionary to set attributes");
719 LIBVIRT_BEGIN_ALLOW_THREADS
;
720 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
721 LIBVIRT_END_ALLOW_THREADS
;
723 if (c_retval
== NULL
)
724 return VIR_PY_INT_FAIL
;
728 PyErr_Format(PyExc_LookupError
,
729 "Domain has no settable attributes");
733 if (VIR_ALLOC_N(params
, nparams
) < 0)
734 return PyErr_NoMemory();
736 LIBVIRT_BEGIN_ALLOW_THREADS
;
737 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
738 LIBVIRT_END_ALLOW_THREADS
;
741 ret
= VIR_PY_INT_FAIL
;
745 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
749 LIBVIRT_BEGIN_ALLOW_THREADS
;
750 i_retval
= virDomainSetSchedulerParameters(domain
, new_params
, size
);
751 LIBVIRT_END_ALLOW_THREADS
;
754 ret
= VIR_PY_INT_FAIL
;
758 ret
= VIR_PY_INT_SUCCESS
;
761 virTypedParameterArrayClear(params
, nparams
);
763 VIR_FREE(new_params
);
768 libvirt_virDomainSetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
772 PyObject
*pyobj_domain
, *info
;
773 PyObject
*ret
= NULL
;
779 virTypedParameterPtr params
, new_params
;
781 if (!PyArg_ParseTuple(args
,
782 (char *)"OOi:virDomainSetScedulerParametersFlags",
783 &pyobj_domain
, &info
, &flags
))
785 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
787 if ((size
= PyDict_Size(info
)) < 0)
791 PyErr_Format(PyExc_LookupError
,
792 "Need non-empty dictionary to set attributes");
796 LIBVIRT_BEGIN_ALLOW_THREADS
;
797 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
798 LIBVIRT_END_ALLOW_THREADS
;
800 if (c_retval
== NULL
)
801 return VIR_PY_INT_FAIL
;
805 PyErr_Format(PyExc_LookupError
,
806 "Domain has no settable attributes");
810 if (VIR_ALLOC_N(params
, nparams
) < 0)
811 return PyErr_NoMemory();
813 LIBVIRT_BEGIN_ALLOW_THREADS
;
814 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
815 LIBVIRT_END_ALLOW_THREADS
;
818 ret
= VIR_PY_INT_FAIL
;
822 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
826 LIBVIRT_BEGIN_ALLOW_THREADS
;
827 i_retval
= virDomainSetSchedulerParametersFlags(domain
, new_params
, size
, flags
);
828 LIBVIRT_END_ALLOW_THREADS
;
831 ret
= VIR_PY_INT_FAIL
;
835 ret
= VIR_PY_INT_SUCCESS
;
838 virTypedParameterArrayClear(params
, nparams
);
840 VIR_FREE(new_params
);
845 libvirt_virDomainSetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
849 PyObject
*pyobj_domain
, *info
;
850 PyObject
*ret
= NULL
;
855 virTypedParameterPtr params
, new_params
;
857 if (!PyArg_ParseTuple(args
,
858 (char *)"OOi:virDomainSetBlkioParameters",
859 &pyobj_domain
, &info
, &flags
))
861 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
863 if ((size
= PyDict_Size(info
)) < 0)
867 PyErr_Format(PyExc_LookupError
,
868 "Need non-empty dictionary to set attributes");
872 LIBVIRT_BEGIN_ALLOW_THREADS
;
873 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
874 LIBVIRT_END_ALLOW_THREADS
;
877 return VIR_PY_INT_FAIL
;
880 PyErr_Format(PyExc_LookupError
,
881 "Domain has no settable attributes");
885 if (VIR_ALLOC_N(params
, nparams
) < 0)
886 return PyErr_NoMemory();
888 LIBVIRT_BEGIN_ALLOW_THREADS
;
889 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
890 LIBVIRT_END_ALLOW_THREADS
;
893 ret
= VIR_PY_INT_FAIL
;
897 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
901 LIBVIRT_BEGIN_ALLOW_THREADS
;
902 i_retval
= virDomainSetBlkioParameters(domain
, new_params
, size
, flags
);
903 LIBVIRT_END_ALLOW_THREADS
;
906 ret
= VIR_PY_INT_FAIL
;
910 ret
= VIR_PY_INT_SUCCESS
;
913 virTypedParameterArrayClear(params
, nparams
);
915 VIR_FREE(new_params
);
920 libvirt_virDomainGetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
924 PyObject
*pyobj_domain
;
925 PyObject
*ret
= NULL
;
929 virTypedParameterPtr params
;
931 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetBlkioParameters",
932 &pyobj_domain
, &flags
))
934 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
936 LIBVIRT_BEGIN_ALLOW_THREADS
;
937 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
938 LIBVIRT_END_ALLOW_THREADS
;
946 if (VIR_ALLOC_N(params
, nparams
) < 0)
947 return PyErr_NoMemory();
949 LIBVIRT_BEGIN_ALLOW_THREADS
;
950 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
951 LIBVIRT_END_ALLOW_THREADS
;
958 ret
= getPyVirTypedParameter(params
, nparams
);
961 virTypedParameterArrayClear(params
, nparams
);
967 libvirt_virDomainSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
971 PyObject
*pyobj_domain
, *info
;
972 PyObject
*ret
= NULL
;
977 virTypedParameterPtr params
, new_params
;
979 if (!PyArg_ParseTuple(args
,
980 (char *)"OOi:virDomainSetMemoryParameters",
981 &pyobj_domain
, &info
, &flags
))
983 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
985 if ((size
= PyDict_Size(info
)) < 0)
989 PyErr_Format(PyExc_LookupError
,
990 "Need non-empty dictionary to set attributes");
994 LIBVIRT_BEGIN_ALLOW_THREADS
;
995 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
996 LIBVIRT_END_ALLOW_THREADS
;
999 return VIR_PY_INT_FAIL
;
1002 PyErr_Format(PyExc_LookupError
,
1003 "Domain has no settable attributes");
1007 if (VIR_ALLOC_N(params
, nparams
) < 0)
1008 return PyErr_NoMemory();
1010 LIBVIRT_BEGIN_ALLOW_THREADS
;
1011 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1012 LIBVIRT_END_ALLOW_THREADS
;
1015 ret
= VIR_PY_INT_FAIL
;
1019 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1023 LIBVIRT_BEGIN_ALLOW_THREADS
;
1024 i_retval
= virDomainSetMemoryParameters(domain
, new_params
, size
, flags
);
1025 LIBVIRT_END_ALLOW_THREADS
;
1028 ret
= VIR_PY_INT_FAIL
;
1032 ret
= VIR_PY_INT_SUCCESS
;
1035 virTypedParameterArrayClear(params
, nparams
);
1037 VIR_FREE(new_params
);
1042 libvirt_virDomainGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1045 virDomainPtr domain
;
1046 PyObject
*pyobj_domain
;
1047 PyObject
*ret
= NULL
;
1051 virTypedParameterPtr params
;
1053 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetMemoryParameters",
1054 &pyobj_domain
, &flags
))
1056 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1058 LIBVIRT_BEGIN_ALLOW_THREADS
;
1059 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
1060 LIBVIRT_END_ALLOW_THREADS
;
1066 return PyDict_New();
1068 if (VIR_ALLOC_N(params
, nparams
) < 0)
1069 return PyErr_NoMemory();
1071 LIBVIRT_BEGIN_ALLOW_THREADS
;
1072 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1073 LIBVIRT_END_ALLOW_THREADS
;
1080 ret
= getPyVirTypedParameter(params
, nparams
);
1083 virTypedParameterArrayClear(params
, nparams
);
1089 libvirt_virDomainSetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1092 virDomainPtr domain
;
1093 PyObject
*pyobj_domain
, *info
;
1094 PyObject
*ret
= NULL
;
1097 Py_ssize_t size
= 0;
1099 virTypedParameterPtr params
, new_params
;
1101 if (!PyArg_ParseTuple(args
,
1102 (char *)"OOi:virDomainSetNumaParameters",
1103 &pyobj_domain
, &info
, &flags
))
1105 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1107 if ((size
= PyDict_Size(info
)) < 0)
1111 PyErr_Format(PyExc_LookupError
,
1112 "Need non-empty dictionary to set attributes");
1116 LIBVIRT_BEGIN_ALLOW_THREADS
;
1117 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1118 LIBVIRT_END_ALLOW_THREADS
;
1121 return VIR_PY_INT_FAIL
;
1124 PyErr_Format(PyExc_LookupError
,
1125 "Domain has no settable attributes");
1129 if (VIR_ALLOC_N(params
, nparams
) < 0)
1130 return PyErr_NoMemory();
1132 LIBVIRT_BEGIN_ALLOW_THREADS
;
1133 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1134 LIBVIRT_END_ALLOW_THREADS
;
1137 ret
= VIR_PY_INT_FAIL
;
1141 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1145 LIBVIRT_BEGIN_ALLOW_THREADS
;
1146 i_retval
= virDomainSetNumaParameters(domain
, new_params
, size
, flags
);
1147 LIBVIRT_END_ALLOW_THREADS
;
1150 ret
= VIR_PY_INT_FAIL
;
1154 ret
= VIR_PY_INT_SUCCESS
;
1157 virTypedParameterArrayClear(params
, nparams
);
1159 VIR_FREE(new_params
);
1164 libvirt_virDomainGetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1167 virDomainPtr domain
;
1168 PyObject
*pyobj_domain
;
1169 PyObject
*ret
= NULL
;
1173 virTypedParameterPtr params
;
1175 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetNumaParameters",
1176 &pyobj_domain
, &flags
))
1178 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1180 LIBVIRT_BEGIN_ALLOW_THREADS
;
1181 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1182 LIBVIRT_END_ALLOW_THREADS
;
1188 return PyDict_New();
1190 if (VIR_ALLOC_N(params
, nparams
) < 0)
1191 return PyErr_NoMemory();
1193 LIBVIRT_BEGIN_ALLOW_THREADS
;
1194 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1195 LIBVIRT_END_ALLOW_THREADS
;
1202 ret
= getPyVirTypedParameter(params
, nparams
);
1205 virTypedParameterArrayClear(params
, nparams
);
1211 libvirt_virDomainSetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1214 virDomainPtr domain
;
1215 PyObject
*pyobj_domain
, *info
;
1216 PyObject
*ret
= NULL
;
1219 Py_ssize_t size
= 0;
1221 const char *device
= NULL
;
1222 virTypedParameterPtr params
, new_params
;
1224 if (!PyArg_ParseTuple(args
,
1225 (char *)"OzOi:virDomainSetInterfaceParameters",
1226 &pyobj_domain
, &device
, &info
, &flags
))
1228 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1230 if ((size
= PyDict_Size(info
)) < 0)
1234 PyErr_Format(PyExc_LookupError
,
1235 "Need non-empty dictionary to set attributes");
1239 LIBVIRT_BEGIN_ALLOW_THREADS
;
1240 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1241 LIBVIRT_END_ALLOW_THREADS
;
1244 return VIR_PY_INT_FAIL
;
1247 PyErr_Format(PyExc_LookupError
,
1248 "Domain has no settable attributes");
1252 if (VIR_ALLOC_N(params
, nparams
) < 0)
1253 return PyErr_NoMemory();
1255 LIBVIRT_BEGIN_ALLOW_THREADS
;
1256 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1257 LIBVIRT_END_ALLOW_THREADS
;
1260 ret
= VIR_PY_INT_FAIL
;
1264 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1268 LIBVIRT_BEGIN_ALLOW_THREADS
;
1269 i_retval
= virDomainSetInterfaceParameters(domain
, device
, new_params
, size
, flags
);
1270 LIBVIRT_END_ALLOW_THREADS
;
1273 ret
= VIR_PY_INT_FAIL
;
1277 ret
= VIR_PY_INT_SUCCESS
;
1280 virTypedParameterArrayClear(params
, nparams
);
1282 VIR_FREE(new_params
);
1287 libvirt_virDomainGetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1290 virDomainPtr domain
;
1291 PyObject
*pyobj_domain
;
1292 PyObject
*ret
= NULL
;
1296 const char *device
= NULL
;
1297 virTypedParameterPtr params
;
1299 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInterfaceParameters",
1300 &pyobj_domain
, &device
, &flags
))
1302 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1304 LIBVIRT_BEGIN_ALLOW_THREADS
;
1305 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1306 LIBVIRT_END_ALLOW_THREADS
;
1312 return PyDict_New();
1314 if (VIR_ALLOC_N(params
, nparams
) < 0)
1315 return PyErr_NoMemory();
1317 LIBVIRT_BEGIN_ALLOW_THREADS
;
1318 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1319 LIBVIRT_END_ALLOW_THREADS
;
1326 ret
= getPyVirTypedParameter(params
, nparams
);
1329 virTypedParameterArrayClear(params
, nparams
);
1335 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
1337 virDomainPtr domain
;
1338 PyObject
*pyobj_domain
, *pyretval
= NULL
, *pycpuinfo
= NULL
, *pycpumap
= NULL
;
1339 virNodeInfo nodeinfo
;
1340 virDomainInfo dominfo
;
1341 virVcpuInfoPtr cpuinfo
= NULL
;
1342 unsigned char *cpumap
= NULL
;
1343 size_t cpumaplen
, i
;
1346 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
1349 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1351 LIBVIRT_BEGIN_ALLOW_THREADS
;
1352 i_retval
= virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
);
1353 LIBVIRT_END_ALLOW_THREADS
;
1357 LIBVIRT_BEGIN_ALLOW_THREADS
;
1358 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1359 LIBVIRT_END_ALLOW_THREADS
;
1363 if (VIR_ALLOC_N(cpuinfo
, dominfo
.nrVirtCpu
) < 0)
1366 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1367 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1368 VIR_ALLOC_N(cpumap
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1371 LIBVIRT_BEGIN_ALLOW_THREADS
;
1372 i_retval
= virDomainGetVcpus(domain
,
1373 cpuinfo
, dominfo
.nrVirtCpu
,
1375 LIBVIRT_END_ALLOW_THREADS
;
1379 /* convert to a Python tuple of long objects */
1380 if ((pyretval
= PyTuple_New(2)) == NULL
)
1382 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1384 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1387 for (i
= 0 ; i
< dominfo
.nrVirtCpu
; i
++) {
1388 PyObject
*info
= PyTuple_New(4);
1391 PyTuple_SetItem(info
, 0, PyInt_FromLong((long)cpuinfo
[i
].number
));
1392 PyTuple_SetItem(info
, 1, PyInt_FromLong((long)cpuinfo
[i
].state
));
1393 PyTuple_SetItem(info
, 2, PyLong_FromLongLong((long long)cpuinfo
[i
].cpuTime
));
1394 PyTuple_SetItem(info
, 3, PyInt_FromLong((long)cpuinfo
[i
].cpu
));
1395 PyList_SetItem(pycpuinfo
, i
, info
);
1397 for (i
= 0 ; i
< dominfo
.nrVirtCpu
; i
++) {
1398 PyObject
*info
= PyTuple_New(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1402 for (j
= 0 ; j
< VIR_NODEINFO_MAXCPUS(nodeinfo
) ; j
++) {
1403 PyTuple_SetItem(info
, j
, PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
, i
, j
)));
1405 PyList_SetItem(pycpumap
, i
, info
);
1407 PyTuple_SetItem(pyretval
, 0, pycpuinfo
);
1408 PyTuple_SetItem(pyretval
, 1, pycpumap
);
1418 Py_XDECREF(pyretval
);
1419 Py_XDECREF(pycpuinfo
);
1420 Py_XDECREF(pycpumap
);
1426 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
1428 virDomainPtr domain
;
1429 PyObject
*pyobj_domain
, *pycpumap
, *truth
;
1430 virNodeInfo nodeinfo
;
1431 unsigned char *cpumap
;
1432 int cpumaplen
, i
, vcpu
;
1435 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
1436 &pyobj_domain
, &vcpu
, &pycpumap
))
1438 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1440 LIBVIRT_BEGIN_ALLOW_THREADS
;
1441 i_retval
= virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
);
1442 LIBVIRT_END_ALLOW_THREADS
;
1444 return VIR_PY_INT_FAIL
;
1446 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1447 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1448 return VIR_PY_INT_FAIL
;
1450 truth
= PyBool_FromLong(1);
1451 for (i
= 0 ; i
< VIR_NODEINFO_MAXCPUS(nodeinfo
) ; i
++) {
1452 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1454 VIR_USE_CPU(cpumap
, i
);
1456 VIR_UNUSE_CPU(cpumap
, i
);
1459 LIBVIRT_BEGIN_ALLOW_THREADS
;
1460 i_retval
= virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
1461 LIBVIRT_END_ALLOW_THREADS
;
1466 return VIR_PY_INT_FAIL
;
1468 return VIR_PY_INT_SUCCESS
;
1472 libvirt_virDomainPinVcpuFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1474 virDomainPtr domain
;
1475 PyObject
*pyobj_domain
, *pycpumap
, *truth
;
1476 virNodeInfo nodeinfo
;
1477 unsigned char *cpumap
;
1478 int cpumaplen
, i
, vcpu
;
1482 if (!PyArg_ParseTuple(args
, (char *)"OiOi:virDomainPinVcpuFlags",
1483 &pyobj_domain
, &vcpu
, &pycpumap
, &flags
))
1485 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1487 LIBVIRT_BEGIN_ALLOW_THREADS
;
1488 i_retval
= virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
);
1489 LIBVIRT_END_ALLOW_THREADS
;
1491 return VIR_PY_INT_FAIL
;
1493 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1494 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1495 return VIR_PY_INT_FAIL
;
1497 truth
= PyBool_FromLong(1);
1498 for (i
= 0 ; i
< VIR_NODEINFO_MAXCPUS(nodeinfo
) ; i
++) {
1499 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1501 VIR_USE_CPU(cpumap
, i
);
1503 VIR_UNUSE_CPU(cpumap
, i
);
1506 LIBVIRT_BEGIN_ALLOW_THREADS
;
1507 i_retval
= virDomainPinVcpuFlags(domain
, vcpu
, cpumap
, cpumaplen
, flags
);
1508 LIBVIRT_END_ALLOW_THREADS
;
1513 return VIR_PY_INT_FAIL
;
1515 return VIR_PY_INT_SUCCESS
;
1519 libvirt_virDomainGetVcpuPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1521 virDomainPtr domain
;
1522 PyObject
*pyobj_domain
, *pycpumaps
= NULL
;
1523 virNodeInfo nodeinfo
;
1524 virDomainInfo dominfo
;
1525 unsigned char *cpumaps
;
1526 size_t cpumaplen
, vcpu
, pcpu
;
1530 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetVcpuPinInfo",
1531 &pyobj_domain
, &flags
))
1533 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1535 LIBVIRT_BEGIN_ALLOW_THREADS
;
1536 i_retval
= virNodeGetInfo(virDomainGetConnect(domain
), &nodeinfo
);
1537 LIBVIRT_END_ALLOW_THREADS
;
1541 LIBVIRT_BEGIN_ALLOW_THREADS
;
1542 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1543 LIBVIRT_END_ALLOW_THREADS
;
1547 cpumaplen
= VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1548 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1549 VIR_ALLOC_N(cpumaps
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1552 LIBVIRT_BEGIN_ALLOW_THREADS
;
1553 i_retval
= virDomainGetVcpuPinInfo(domain
, dominfo
.nrVirtCpu
,
1554 cpumaps
, cpumaplen
, flags
);
1555 LIBVIRT_END_ALLOW_THREADS
;
1559 if ((pycpumaps
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1562 for (vcpu
= 0; vcpu
< dominfo
.nrVirtCpu
; vcpu
++) {
1563 PyObject
*mapinfo
= PyTuple_New(VIR_NODEINFO_MAXCPUS(nodeinfo
));
1564 if (mapinfo
== NULL
)
1567 for (pcpu
= 0; pcpu
< VIR_NODEINFO_MAXCPUS(nodeinfo
); pcpu
++) {
1568 PyTuple_SetItem(mapinfo
, pcpu
,
1569 PyBool_FromLong(VIR_CPU_USABLE(cpumaps
, cpumaplen
, vcpu
, pcpu
)));
1571 PyList_SetItem(pycpumaps
, vcpu
, mapinfo
);
1581 Py_XDECREF(pycpumaps
);
1586 /************************************************************************
1588 * Global error handler at the Python level *
1590 ************************************************************************/
1592 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
1593 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
1596 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args ATTRIBUTE_UNUSED
)
1601 if ((err
= virGetLastError()) == NULL
)
1604 if ((info
= PyTuple_New(9)) == NULL
)
1606 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
1607 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
1608 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
1609 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
1610 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
1611 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
1612 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
1613 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
1614 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
1620 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
1625 PyObject
*pyobj_conn
;
1627 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
1629 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1631 LIBVIRT_BEGIN_ALLOW_THREADS
;
1632 err
= virConnGetLastError(conn
);
1633 LIBVIRT_END_ALLOW_THREADS
;
1637 if ((info
= PyTuple_New(9)) == NULL
)
1639 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
1640 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
1641 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
1642 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
1643 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
1644 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
1645 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
1646 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
1647 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
1653 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
, virErrorPtr err
)
1655 PyObject
*list
, *info
;
1658 DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
1661 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
1664 LIBVIRT_ENSURE_THREAD_STATE
;
1666 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
1667 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
1668 virDefaultErrorFunc(err
);
1670 list
= PyTuple_New(2);
1671 info
= PyTuple_New(9);
1672 PyTuple_SetItem(list
, 0, libvirt_virPythonErrorFuncCtxt
);
1673 PyTuple_SetItem(list
, 1, info
);
1674 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
1675 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
1676 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
1677 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
1678 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
1679 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
1680 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
1681 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
1682 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
1683 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
1684 /* TODO pass conn and dom if available */
1685 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
1690 LIBVIRT_RELEASE_THREAD_STATE
;
1694 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
* self
,
1697 PyObject
*py_retval
;
1699 PyObject
*pyobj_ctx
;
1701 if (!PyArg_ParseTuple
1702 (args
, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f
,
1706 DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
1709 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
1710 if (libvirt_virPythonErrorFuncHandler
!= NULL
) {
1711 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
1713 if (libvirt_virPythonErrorFuncCtxt
!= NULL
) {
1714 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
1717 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
1718 libvirt_virPythonErrorFuncHandler
= NULL
;
1719 libvirt_virPythonErrorFuncCtxt
= NULL
;
1721 Py_XINCREF(pyobj_ctx
);
1722 Py_XINCREF(pyobj_f
);
1724 /* TODO: check f is a function ! */
1725 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
1726 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
1729 py_retval
= libvirt_intWrap(1);
1733 static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
1738 PyObject
*pyauth
= (PyObject
*)cbdata
;
1744 LIBVIRT_ENSURE_THREAD_STATE
;
1746 pycb
= PyList_GetItem(pyauth
, 1);
1747 pycbdata
= PyList_GetItem(pyauth
, 2);
1749 list
= PyTuple_New(2);
1750 pycred
= PyTuple_New(ncred
);
1751 for (i
= 0 ; i
< ncred
; i
++) {
1752 PyObject
*pycreditem
;
1753 pycreditem
= PyList_New(5);
1755 PyTuple_SetItem(pycred
, i
, pycreditem
);
1756 PyList_SetItem(pycreditem
, 0, PyInt_FromLong((long) cred
[i
].type
));
1757 PyList_SetItem(pycreditem
, 1, PyString_FromString(cred
[i
].prompt
));
1758 if (cred
[i
].challenge
) {
1759 PyList_SetItem(pycreditem
, 2, PyString_FromString(cred
[i
].challenge
));
1762 PyList_SetItem(pycreditem
, 2, Py_None
);
1764 if (cred
[i
].defresult
) {
1765 PyList_SetItem(pycreditem
, 3, PyString_FromString(cred
[i
].defresult
));
1768 PyList_SetItem(pycreditem
, 3, Py_None
);
1770 PyList_SetItem(pycreditem
, 4, Py_None
);
1773 PyTuple_SetItem(list
, 0, pycred
);
1774 Py_XINCREF(pycbdata
);
1775 PyTuple_SetItem(list
, 1, pycbdata
);
1778 pyret
= PyEval_CallObject(pycb
, list
);
1779 if (PyErr_Occurred()) {
1784 ret
= PyLong_AsLong(pyret
);
1786 for (i
= 0 ; i
< ncred
; i
++) {
1787 PyObject
*pycreditem
;
1789 char *result
= NULL
;
1790 pycreditem
= PyTuple_GetItem(pycred
, i
);
1791 pyresult
= PyList_GetItem(pycreditem
, 4);
1792 if (pyresult
!= Py_None
)
1793 result
= PyString_AsString(pyresult
);
1794 if (result
!= NULL
) {
1795 cred
[i
].result
= strdup(result
);
1796 cred
[i
].resultlen
= strlen(result
);
1798 cred
[i
].result
= NULL
;
1799 cred
[i
].resultlen
= 0;
1808 LIBVIRT_RELEASE_THREAD_STATE
;
1815 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
1816 PyObject
*py_retval
;
1817 virConnectPtr c_retval
;
1822 PyObject
*pycredtype
;
1823 virConnectAuth auth
;
1825 memset(&auth
, 0, sizeof(auth
));
1826 if (!PyArg_ParseTuple(args
, (char *)"zOi:virConnectOpenAuth", &name
, &pyauth
, &flags
))
1829 pycredtype
= PyList_GetItem(pyauth
, 0);
1830 pycredcb
= PyList_GetItem(pyauth
, 1);
1832 auth
.ncredtype
= PyList_Size(pycredtype
);
1833 if (auth
.ncredtype
) {
1835 if (VIR_ALLOC_N(auth
.credtype
, auth
.ncredtype
) < 0)
1837 for (i
= 0 ; i
< auth
.ncredtype
; i
++) {
1839 val
= PyList_GetItem(pycredtype
, i
);
1840 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
1843 if (pycredcb
&& pycredcb
!= Py_None
)
1844 auth
.cb
= virConnectCredCallbackWrapper
;
1845 auth
.cbdata
= pyauth
;
1847 LIBVIRT_BEGIN_ALLOW_THREADS
;
1849 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
1850 LIBVIRT_END_ALLOW_THREADS
;
1851 VIR_FREE(auth
.credtype
);
1852 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
1857 /************************************************************************
1859 * Wrappers for functions where generator fails *
1861 ************************************************************************/
1864 libvirt_virGetVersion (PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
1867 unsigned long libVer
, typeVer
= 0;
1870 if (!PyArg_ParseTuple (args
, (char *) "|s", &type
))
1873 LIBVIRT_BEGIN_ALLOW_THREADS
;
1876 c_retval
= virGetVersion (&libVer
, NULL
, NULL
);
1878 c_retval
= virGetVersion (&libVer
, type
, &typeVer
);
1880 LIBVIRT_END_ALLOW_THREADS
;
1886 return PyInt_FromLong (libVer
);
1888 return Py_BuildValue ((char *) "kk", libVer
, typeVer
);
1892 libvirt_virConnectGetVersion (PyObject
*self ATTRIBUTE_UNUSED
,
1895 unsigned long hvVersion
;
1898 PyObject
*pyobj_conn
;
1900 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetVersion",
1903 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1905 LIBVIRT_BEGIN_ALLOW_THREADS
;
1907 c_retval
= virConnectGetVersion(conn
, &hvVersion
);
1909 LIBVIRT_END_ALLOW_THREADS
;
1912 return VIR_PY_INT_FAIL
;
1914 return PyInt_FromLong (hvVersion
);
1918 libvirt_virConnectGetLibVersion (PyObject
*self ATTRIBUTE_UNUSED
,
1921 unsigned long libVer
;
1924 PyObject
*pyobj_conn
;
1926 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetLibVersion",
1929 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1931 LIBVIRT_BEGIN_ALLOW_THREADS
;
1933 c_retval
= virConnectGetLibVersion(conn
, &libVer
);
1935 LIBVIRT_END_ALLOW_THREADS
;
1938 return VIR_PY_INT_FAIL
;
1940 return PyInt_FromLong (libVer
);
1944 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
1946 PyObject
*py_retval
;
1947 int *ids
= NULL
, c_retval
, i
;
1949 PyObject
*pyobj_conn
;
1952 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
1954 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1956 LIBVIRT_BEGIN_ALLOW_THREADS
;
1957 c_retval
= virConnectNumOfDomains(conn
);
1958 LIBVIRT_END_ALLOW_THREADS
;
1963 if (VIR_ALLOC_N(ids
, c_retval
) < 0)
1966 LIBVIRT_BEGIN_ALLOW_THREADS
;
1967 c_retval
= virConnectListDomains(conn
, ids
, c_retval
);
1968 LIBVIRT_END_ALLOW_THREADS
;
1974 py_retval
= PyList_New(c_retval
);
1977 for (i
= 0;i
< c_retval
;i
++) {
1978 PyList_SetItem(py_retval
, i
, libvirt_intWrap(ids
[i
]));
1987 libvirt_virConnectListAllDomains(PyObject
*self ATTRIBUTE_UNUSED
,
1990 PyObject
*pyobj_conn
;
1991 PyObject
*py_retval
= NULL
;
1992 PyObject
*tmp
= NULL
;
1994 virDomainPtr
*doms
= NULL
;
1999 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllDomains",
2000 &pyobj_conn
, &flags
))
2002 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2004 LIBVIRT_BEGIN_ALLOW_THREADS
;
2005 c_retval
= virConnectListAllDomains(conn
, &doms
, flags
);
2006 LIBVIRT_END_ALLOW_THREADS
;
2010 if (!(py_retval
= PyList_New(c_retval
)))
2013 for (i
= 0; i
< c_retval
; i
++) {
2014 if (!(tmp
= libvirt_virDomainPtrWrap(doms
[i
])) ||
2015 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
2017 Py_DECREF(py_retval
);
2021 /* python steals the pointer */
2026 for (i
= 0; i
< c_retval
; i
++)
2028 virDomainFree(doms
[i
]);
2034 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2036 PyObject
*py_retval
;
2037 char **names
= NULL
;
2040 PyObject
*pyobj_conn
;
2043 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains", &pyobj_conn
))
2045 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2047 LIBVIRT_BEGIN_ALLOW_THREADS
;
2048 c_retval
= virConnectNumOfDefinedDomains(conn
);
2049 LIBVIRT_END_ALLOW_THREADS
;
2054 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2056 LIBVIRT_BEGIN_ALLOW_THREADS
;
2057 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
2058 LIBVIRT_END_ALLOW_THREADS
;
2064 py_retval
= PyList_New(c_retval
);
2067 for (i
= 0;i
< c_retval
;i
++) {
2068 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2078 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2081 PyObject
*py_retval
;
2082 char **names
= NULL
;
2085 PyObject
*pyobj_dom
;
2086 PyObject
*pyobj_snap
;
2089 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListNames",
2090 &pyobj_dom
, &flags
))
2092 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2094 LIBVIRT_BEGIN_ALLOW_THREADS
;
2095 c_retval
= virDomainSnapshotNum(dom
, flags
);
2096 LIBVIRT_END_ALLOW_THREADS
;
2101 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2102 return PyErr_NoMemory();
2103 LIBVIRT_BEGIN_ALLOW_THREADS
;
2104 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2105 LIBVIRT_END_ALLOW_THREADS
;
2111 py_retval
= PyList_New(c_retval
);
2115 for (i
= 0; i
< c_retval
; i
++) {
2116 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2117 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2118 Py_XDECREF(pyobj_snap
);
2119 Py_DECREF(py_retval
);
2127 for (i
= 0; i
< c_retval
; i
++)
2134 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2137 PyObject
*py_retval
= NULL
;
2138 virDomainSnapshotPtr
*snaps
= NULL
;
2141 PyObject
*pyobj_dom
;
2143 PyObject
*pyobj_snap
;
2145 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainListAllSnapshots",
2146 &pyobj_dom
, &flags
))
2148 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2150 LIBVIRT_BEGIN_ALLOW_THREADS
;
2151 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2152 LIBVIRT_END_ALLOW_THREADS
;
2156 if (!(py_retval
= PyList_New(c_retval
)))
2159 for (i
= 0; i
< c_retval
; i
++) {
2160 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2161 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2162 Py_XDECREF(pyobj_snap
);
2163 Py_DECREF(py_retval
);
2171 for (i
= 0; i
< c_retval
; i
++)
2173 virDomainSnapshotFree(snaps
[i
]);
2179 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2182 PyObject
*py_retval
;
2183 char **names
= NULL
;
2185 virDomainSnapshotPtr snap
;
2186 PyObject
*pyobj_snap
;
2189 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListChildrenNames",
2190 &pyobj_snap
, &flags
))
2192 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2194 LIBVIRT_BEGIN_ALLOW_THREADS
;
2195 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2196 LIBVIRT_END_ALLOW_THREADS
;
2201 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2202 return PyErr_NoMemory();
2203 LIBVIRT_BEGIN_ALLOW_THREADS
;
2204 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2206 LIBVIRT_END_ALLOW_THREADS
;
2212 py_retval
= PyList_New(c_retval
);
2214 for (i
= 0; i
< c_retval
; i
++) {
2215 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2216 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2217 Py_XDECREF(pyobj_snap
);
2218 Py_DECREF(py_retval
);
2226 for (i
= 0; i
< c_retval
; i
++)
2233 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2236 PyObject
*py_retval
= NULL
;
2237 virDomainSnapshotPtr
*snaps
= NULL
;
2239 virDomainSnapshotPtr parent
;
2240 PyObject
*pyobj_parent
;
2242 PyObject
*pyobj_snap
;
2244 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListAllChildren",
2245 &pyobj_parent
, &flags
))
2247 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2249 LIBVIRT_BEGIN_ALLOW_THREADS
;
2250 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2251 LIBVIRT_END_ALLOW_THREADS
;
2255 if (!(py_retval
= PyList_New(c_retval
)))
2258 for (i
= 0; i
< c_retval
; i
++) {
2259 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2260 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2261 Py_XDECREF(pyobj_snap
);
2262 Py_DECREF(py_retval
);
2270 for (i
= 0; i
< c_retval
; i
++)
2272 virDomainSnapshotFree(snaps
[i
]);
2278 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2281 virDomainSnapshotPtr snap
;
2282 PyObject
*pyobj_snap
;
2283 PyObject
*pyobj_dom
;
2286 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainRevertToSnapshot", &pyobj_dom
, &pyobj_snap
, &flags
))
2288 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2290 LIBVIRT_BEGIN_ALLOW_THREADS
;
2291 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2292 LIBVIRT_END_ALLOW_THREADS
;
2294 return VIR_PY_INT_FAIL
;
2296 return PyInt_FromLong(c_retval
);
2300 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2301 PyObject
*py_retval
;
2303 virDomainPtr domain
;
2304 PyObject
*pyobj_domain
;
2307 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2309 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2311 LIBVIRT_BEGIN_ALLOW_THREADS
;
2312 c_retval
= virDomainGetInfo(domain
, &info
);
2313 LIBVIRT_END_ALLOW_THREADS
;
2316 py_retval
= PyList_New(5);
2317 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
2318 PyList_SetItem(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
));
2319 PyList_SetItem(py_retval
, 2, libvirt_ulongWrap(info
.memory
));
2320 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.nrVirtCpu
));
2321 PyList_SetItem(py_retval
, 4,
2322 libvirt_longlongWrap((unsigned long long) info
.cpuTime
));
2327 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2329 PyObject
*py_retval
;
2331 virDomainPtr domain
;
2332 PyObject
*pyobj_domain
;
2337 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetState",
2338 &pyobj_domain
, &flags
))
2341 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2343 LIBVIRT_BEGIN_ALLOW_THREADS
;
2344 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2345 LIBVIRT_END_ALLOW_THREADS
;
2349 py_retval
= PyList_New(2);
2350 PyList_SetItem(py_retval
, 0, libvirt_intWrap(state
));
2351 PyList_SetItem(py_retval
, 1, libvirt_intWrap(reason
));
2356 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2357 PyObject
*py_retval
;
2359 virDomainPtr domain
;
2360 PyObject
*pyobj_domain
;
2361 virDomainControlInfo info
;
2364 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetControlInfo",
2365 &pyobj_domain
, &flags
))
2367 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2369 LIBVIRT_BEGIN_ALLOW_THREADS
;
2370 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2371 LIBVIRT_END_ALLOW_THREADS
;
2374 py_retval
= PyList_New(3);
2375 PyList_SetItem(py_retval
, 0, libvirt_intWrap(info
.state
));
2376 PyList_SetItem(py_retval
, 1, libvirt_intWrap(info
.details
));
2377 PyList_SetItem(py_retval
, 2, libvirt_longlongWrap(info
.stateTime
));
2382 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2383 PyObject
*py_retval
;
2385 virDomainPtr domain
;
2386 PyObject
*pyobj_domain
;
2387 virDomainBlockInfo info
;
2391 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInfo", &pyobj_domain
, &path
, &flags
))
2393 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2395 LIBVIRT_BEGIN_ALLOW_THREADS
;
2396 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2397 LIBVIRT_END_ALLOW_THREADS
;
2400 py_retval
= PyList_New(3);
2401 PyList_SetItem(py_retval
, 0, libvirt_ulonglongWrap(info
.capacity
));
2402 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.allocation
));
2403 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.physical
));
2408 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2409 PyObject
*py_retval
;
2412 PyObject
*pyobj_conn
;
2415 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_conn
))
2417 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2419 LIBVIRT_BEGIN_ALLOW_THREADS
;
2420 c_retval
= virNodeGetInfo(conn
, &info
);
2421 LIBVIRT_END_ALLOW_THREADS
;
2424 py_retval
= PyList_New(8);
2425 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&info
.model
[0]));
2426 PyList_SetItem(py_retval
, 1, libvirt_longWrap((long) info
.memory
>> 10));
2427 PyList_SetItem(py_retval
, 2, libvirt_intWrap((int) info
.cpus
));
2428 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.mhz
));
2429 PyList_SetItem(py_retval
, 4, libvirt_intWrap((int) info
.nodes
));
2430 PyList_SetItem(py_retval
, 5, libvirt_intWrap((int) info
.sockets
));
2431 PyList_SetItem(py_retval
, 6, libvirt_intWrap((int) info
.cores
));
2432 PyList_SetItem(py_retval
, 7, libvirt_intWrap((int) info
.threads
));
2437 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2438 PyObject
*py_retval
;
2439 unsigned char uuid
[VIR_UUID_BUFLEN
];
2440 virDomainPtr domain
;
2441 PyObject
*pyobj_domain
;
2444 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2446 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2450 LIBVIRT_BEGIN_ALLOW_THREADS
;
2451 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
2452 LIBVIRT_END_ALLOW_THREADS
;
2456 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
2462 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
2464 PyObject
*py_retval
;
2465 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
2467 PyObject
*pyobj_dom
;
2470 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
2473 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2477 LIBVIRT_BEGIN_ALLOW_THREADS
;
2478 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
2479 LIBVIRT_END_ALLOW_THREADS
;
2484 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
2489 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2490 PyObject
*py_retval
;
2491 virDomainPtr c_retval
;
2493 PyObject
*pyobj_conn
;
2494 unsigned char * uuid
;
2497 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn
, &uuid
, &len
))
2499 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2501 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
2504 LIBVIRT_BEGIN_ALLOW_THREADS
;
2505 c_retval
= virDomainLookupByUUID(conn
, uuid
);
2506 LIBVIRT_END_ALLOW_THREADS
;
2507 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
2513 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2515 PyObject
*py_retval
;
2516 char **names
= NULL
;
2519 PyObject
*pyobj_conn
;
2522 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks", &pyobj_conn
))
2524 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2526 LIBVIRT_BEGIN_ALLOW_THREADS
;
2527 c_retval
= virConnectNumOfNetworks(conn
);
2528 LIBVIRT_END_ALLOW_THREADS
;
2533 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2535 LIBVIRT_BEGIN_ALLOW_THREADS
;
2536 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
2537 LIBVIRT_END_ALLOW_THREADS
;
2543 py_retval
= PyList_New(c_retval
);
2546 for (i
= 0;i
< c_retval
;i
++) {
2547 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2558 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2560 PyObject
*py_retval
;
2561 char **names
= NULL
;
2564 PyObject
*pyobj_conn
;
2567 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn
))
2569 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2571 LIBVIRT_BEGIN_ALLOW_THREADS
;
2572 c_retval
= virConnectNumOfDefinedNetworks(conn
);
2573 LIBVIRT_END_ALLOW_THREADS
;
2578 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2580 LIBVIRT_BEGIN_ALLOW_THREADS
;
2581 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
2582 LIBVIRT_END_ALLOW_THREADS
;
2588 py_retval
= PyList_New(c_retval
);
2591 for (i
= 0;i
< c_retval
;i
++) {
2592 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2602 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2605 PyObject
*pyobj_conn
;
2606 PyObject
*py_retval
= NULL
;
2607 PyObject
*tmp
= NULL
;
2609 virNetworkPtr
*nets
= NULL
;
2614 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNetworks",
2615 &pyobj_conn
, &flags
))
2617 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2619 LIBVIRT_BEGIN_ALLOW_THREADS
;
2620 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
2621 LIBVIRT_END_ALLOW_THREADS
;
2625 if (!(py_retval
= PyList_New(c_retval
)))
2628 for (i
= 0; i
< c_retval
; i
++) {
2629 if (!(tmp
= libvirt_virNetworkPtrWrap(nets
[i
])) ||
2630 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
2632 Py_DECREF(py_retval
);
2636 /* python steals the pointer */
2641 for (i
= 0; i
< c_retval
; i
++)
2643 virNetworkFree(nets
[i
]);
2650 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2651 PyObject
*py_retval
;
2652 unsigned char uuid
[VIR_UUID_BUFLEN
];
2653 virNetworkPtr domain
;
2654 PyObject
*pyobj_domain
;
2657 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
2659 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
2663 LIBVIRT_BEGIN_ALLOW_THREADS
;
2664 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
2665 LIBVIRT_END_ALLOW_THREADS
;
2669 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
2675 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
2677 PyObject
*py_retval
;
2678 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
2680 PyObject
*pyobj_net
;
2683 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
2686 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
2690 LIBVIRT_BEGIN_ALLOW_THREADS
;
2691 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
2692 LIBVIRT_END_ALLOW_THREADS
;
2697 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
2702 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2703 PyObject
*py_retval
;
2704 virNetworkPtr c_retval
;
2706 PyObject
*pyobj_conn
;
2707 unsigned char * uuid
;
2710 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn
, &uuid
, &len
))
2712 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2714 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
2717 LIBVIRT_BEGIN_ALLOW_THREADS
;
2718 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
2719 LIBVIRT_END_ALLOW_THREADS
;
2720 py_retval
= libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
2726 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2727 PyObject
*py_retval
;
2728 int c_retval
, autostart
;
2729 virDomainPtr domain
;
2730 PyObject
*pyobj_domain
;
2732 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart", &pyobj_domain
))
2735 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2737 LIBVIRT_BEGIN_ALLOW_THREADS
;
2738 c_retval
= virDomainGetAutostart(domain
, &autostart
);
2739 LIBVIRT_END_ALLOW_THREADS
;
2742 return VIR_PY_INT_FAIL
;
2743 py_retval
= libvirt_intWrap(autostart
);
2749 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2750 PyObject
*py_retval
;
2751 int c_retval
, autostart
;
2752 virNetworkPtr network
;
2753 PyObject
*pyobj_network
;
2755 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart", &pyobj_network
))
2758 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
2760 LIBVIRT_BEGIN_ALLOW_THREADS
;
2761 c_retval
= virNetworkGetAutostart(network
, &autostart
);
2762 LIBVIRT_END_ALLOW_THREADS
;
2765 return VIR_PY_INT_FAIL
;
2766 py_retval
= libvirt_intWrap(autostart
);
2771 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2773 PyObject
*py_retval
;
2774 PyObject
*pyobj_conn
;
2775 int startCell
, maxCells
, c_retval
, i
;
2777 unsigned long long *freeMems
;
2779 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn
, &startCell
, &maxCells
))
2782 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
2785 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2786 if (VIR_ALLOC_N(freeMems
, maxCells
) < 0)
2789 LIBVIRT_BEGIN_ALLOW_THREADS
;
2790 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
2791 LIBVIRT_END_ALLOW_THREADS
;
2797 py_retval
= PyList_New(c_retval
);
2798 for (i
= 0;i
< c_retval
;i
++) {
2799 PyList_SetItem(py_retval
, i
,
2800 libvirt_longlongWrap((long long) freeMems
[i
]));
2807 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2809 PyObject
*ret
= NULL
;
2810 PyObject
*key
= NULL
;
2811 PyObject
*val
= NULL
;
2812 PyObject
*pyobj_conn
;
2815 int cpuNum
, c_retval
, i
;
2817 virNodeCPUStatsPtr stats
= NULL
;
2819 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCPUStats", &pyobj_conn
, &cpuNum
, &flags
))
2821 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
2823 LIBVIRT_BEGIN_ALLOW_THREADS
;
2824 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
2825 LIBVIRT_END_ALLOW_THREADS
;
2830 if (VIR_ALLOC_N(stats
, nparams
) < 0)
2831 return PyErr_NoMemory();
2833 LIBVIRT_BEGIN_ALLOW_THREADS
;
2834 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
2835 LIBVIRT_END_ALLOW_THREADS
;
2842 if (!(ret
= PyDict_New()))
2845 for (i
= 0; i
< nparams
; i
++) {
2846 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
2847 val
= libvirt_ulonglongWrap(stats
[i
].value
);
2849 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
2870 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2872 PyObject
*ret
= NULL
;
2873 PyObject
*key
= NULL
;
2874 PyObject
*val
= NULL
;
2875 PyObject
*pyobj_conn
;
2878 int cellNum
, c_retval
, i
;
2880 virNodeMemoryStatsPtr stats
= NULL
;
2882 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetMemoryStats", &pyobj_conn
, &cellNum
, &flags
))
2884 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
2886 LIBVIRT_BEGIN_ALLOW_THREADS
;
2887 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
2888 LIBVIRT_END_ALLOW_THREADS
;
2893 if (VIR_ALLOC_N(stats
, nparams
) < 0)
2894 return PyErr_NoMemory();
2896 LIBVIRT_BEGIN_ALLOW_THREADS
;
2897 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
2898 LIBVIRT_END_ALLOW_THREADS
;
2905 if (!(ret
= PyDict_New()))
2908 for (i
= 0; i
< nparams
; i
++) {
2909 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
2910 val
= libvirt_ulonglongWrap(stats
[i
].value
);
2912 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
2933 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
2935 PyObject
*py_retval
;
2936 char **names
= NULL
;
2939 PyObject
*pyobj_conn
;
2942 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools", &pyobj_conn
))
2944 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2946 LIBVIRT_BEGIN_ALLOW_THREADS
;
2947 c_retval
= virConnectNumOfStoragePools(conn
);
2948 LIBVIRT_END_ALLOW_THREADS
;
2953 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2955 LIBVIRT_BEGIN_ALLOW_THREADS
;
2956 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
2957 LIBVIRT_END_ALLOW_THREADS
;
2963 py_retval
= PyList_New(c_retval
);
2964 if (py_retval
== NULL
) {
2966 for (i
= 0;i
< c_retval
;i
++)
2974 for (i
= 0;i
< c_retval
;i
++) {
2975 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2986 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
2988 PyObject
*py_retval
;
2989 char **names
= NULL
;
2992 PyObject
*pyobj_conn
;
2995 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn
))
2997 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2999 LIBVIRT_BEGIN_ALLOW_THREADS
;
3000 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3001 LIBVIRT_END_ALLOW_THREADS
;
3006 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3008 LIBVIRT_BEGIN_ALLOW_THREADS
;
3009 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3010 LIBVIRT_END_ALLOW_THREADS
;
3016 py_retval
= PyList_New(c_retval
);
3017 if (py_retval
== NULL
) {
3019 for (i
= 0;i
< c_retval
;i
++)
3027 for (i
= 0;i
< c_retval
;i
++) {
3028 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3038 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3041 PyObject
*pyobj_conn
;
3042 PyObject
*py_retval
= NULL
;
3043 PyObject
*tmp
= NULL
;
3045 virStoragePoolPtr
*pools
= NULL
;
3050 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllStoragePools",
3051 &pyobj_conn
, &flags
))
3053 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3055 LIBVIRT_BEGIN_ALLOW_THREADS
;
3056 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3057 LIBVIRT_END_ALLOW_THREADS
;
3061 if (!(py_retval
= PyList_New(c_retval
)))
3064 for (i
= 0; i
< c_retval
; i
++) {
3065 if (!(tmp
= libvirt_virStoragePoolPtrWrap(pools
[i
])) ||
3066 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3068 Py_DECREF(py_retval
);
3072 /* python steals the pointer */
3077 for (i
= 0; i
< c_retval
; i
++)
3079 virStoragePoolFree(pools
[i
]);
3085 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3087 PyObject
*py_retval
;
3088 char **names
= NULL
;
3090 virStoragePoolPtr pool
;
3091 PyObject
*pyobj_pool
;
3094 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes", &pyobj_pool
))
3096 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3098 LIBVIRT_BEGIN_ALLOW_THREADS
;
3099 c_retval
= virStoragePoolNumOfVolumes(pool
);
3100 LIBVIRT_END_ALLOW_THREADS
;
3105 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3107 LIBVIRT_BEGIN_ALLOW_THREADS
;
3108 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3109 LIBVIRT_END_ALLOW_THREADS
;
3115 py_retval
= PyList_New(c_retval
);
3116 if (py_retval
== NULL
) {
3118 for (i
= 0;i
< c_retval
;i
++)
3126 for (i
= 0;i
< c_retval
;i
++) {
3127 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3137 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3140 PyObject
*py_retval
= NULL
;
3141 PyObject
*tmp
= NULL
;
3142 virStoragePoolPtr pool
;
3143 virStorageVolPtr
*vols
= NULL
;
3147 PyObject
*pyobj_pool
;
3149 if (!PyArg_ParseTuple(args
, (char *)"Oi:virStoragePoolListAllVolumes",
3150 &pyobj_pool
, &flags
))
3153 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3155 LIBVIRT_BEGIN_ALLOW_THREADS
;
3156 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3157 LIBVIRT_END_ALLOW_THREADS
;
3161 if (!(py_retval
= PyList_New(c_retval
)))
3164 for (i
= 0; i
< c_retval
; i
++) {
3165 if (!(tmp
= libvirt_virStorageVolPtrWrap(vols
[i
])) ||
3166 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3168 Py_DECREF(py_retval
);
3172 /* python steals the pointer */
3177 for (i
= 0; i
< c_retval
; i
++)
3179 virStorageVolFree(vols
[i
]);
3186 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3187 PyObject
*py_retval
;
3188 int c_retval
, autostart
;
3189 virStoragePoolPtr pool
;
3190 PyObject
*pyobj_pool
;
3192 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool
))
3195 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3197 LIBVIRT_BEGIN_ALLOW_THREADS
;
3198 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3199 LIBVIRT_END_ALLOW_THREADS
;
3204 py_retval
= libvirt_intWrap(autostart
);
3209 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3210 PyObject
*py_retval
;
3212 virStoragePoolPtr pool
;
3213 PyObject
*pyobj_pool
;
3214 virStoragePoolInfo info
;
3216 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3218 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3220 LIBVIRT_BEGIN_ALLOW_THREADS
;
3221 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3222 LIBVIRT_END_ALLOW_THREADS
;
3226 if ((py_retval
= PyList_New(4)) == NULL
)
3229 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
3230 PyList_SetItem(py_retval
, 1,
3231 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3232 PyList_SetItem(py_retval
, 2,
3233 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3234 PyList_SetItem(py_retval
, 3,
3235 libvirt_longlongWrap((unsigned long long) info
.available
));
3241 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3242 PyObject
*py_retval
;
3244 virStorageVolPtr pool
;
3245 PyObject
*pyobj_pool
;
3246 virStorageVolInfo info
;
3248 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3250 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3252 LIBVIRT_BEGIN_ALLOW_THREADS
;
3253 c_retval
= virStorageVolGetInfo(pool
, &info
);
3254 LIBVIRT_END_ALLOW_THREADS
;
3258 if ((py_retval
= PyList_New(3)) == NULL
)
3260 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
3261 PyList_SetItem(py_retval
, 1,
3262 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3263 PyList_SetItem(py_retval
, 2,
3264 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3269 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3270 PyObject
*py_retval
;
3271 unsigned char uuid
[VIR_UUID_BUFLEN
];
3272 virStoragePoolPtr pool
;
3273 PyObject
*pyobj_pool
;
3276 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3278 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3282 LIBVIRT_BEGIN_ALLOW_THREADS
;
3283 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3284 LIBVIRT_END_ALLOW_THREADS
;
3289 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3295 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3297 PyObject
*py_retval
;
3298 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3299 virStoragePoolPtr pool
;
3300 PyObject
*pyobj_pool
;
3303 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool
))
3305 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3309 LIBVIRT_BEGIN_ALLOW_THREADS
;
3310 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3311 LIBVIRT_END_ALLOW_THREADS
;
3316 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3321 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3322 PyObject
*py_retval
;
3323 virStoragePoolPtr c_retval
;
3325 PyObject
*pyobj_conn
;
3326 unsigned char * uuid
;
3329 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3331 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3333 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3336 LIBVIRT_BEGIN_ALLOW_THREADS
;
3337 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
3338 LIBVIRT_END_ALLOW_THREADS
;
3339 py_retval
= libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
3344 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3346 PyObject
*py_retval
;
3347 char **names
= NULL
;
3350 PyObject
*pyobj_conn
;
3354 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virNodeListDevices",
3355 &pyobj_conn
, &cap
, &flags
))
3357 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3359 LIBVIRT_BEGIN_ALLOW_THREADS
;
3360 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
3361 LIBVIRT_END_ALLOW_THREADS
;
3366 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3368 LIBVIRT_BEGIN_ALLOW_THREADS
;
3369 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
3370 LIBVIRT_END_ALLOW_THREADS
;
3376 py_retval
= PyList_New(c_retval
);
3379 for (i
= 0;i
< c_retval
;i
++) {
3380 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3390 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3393 PyObject
*pyobj_conn
;
3394 PyObject
*py_retval
= NULL
;
3395 PyObject
*tmp
= NULL
;
3397 virNodeDevicePtr
*devices
= NULL
;
3402 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNodeDevices",
3403 &pyobj_conn
, &flags
))
3405 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3407 LIBVIRT_BEGIN_ALLOW_THREADS
;
3408 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
3409 LIBVIRT_END_ALLOW_THREADS
;
3413 if (!(py_retval
= PyList_New(c_retval
)))
3416 for (i
= 0; i
< c_retval
; i
++) {
3417 if (!(tmp
= libvirt_virNodeDevicePtrWrap(devices
[i
])) ||
3418 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3420 Py_DECREF(py_retval
);
3424 /* python steals the pointer */
3429 for (i
= 0; i
< c_retval
; i
++)
3431 virNodeDeviceFree(devices
[i
]);
3437 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
3439 PyObject
*py_retval
;
3440 char **names
= NULL
;
3442 virNodeDevicePtr dev
;
3443 PyObject
*pyobj_dev
;
3445 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
3447 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
3449 LIBVIRT_BEGIN_ALLOW_THREADS
;
3450 c_retval
= virNodeDeviceNumOfCaps(dev
);
3451 LIBVIRT_END_ALLOW_THREADS
;
3456 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3458 LIBVIRT_BEGIN_ALLOW_THREADS
;
3459 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
3460 LIBVIRT_END_ALLOW_THREADS
;
3466 py_retval
= PyList_New(c_retval
);
3469 for (i
= 0;i
< c_retval
;i
++) {
3470 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3480 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3481 PyObject
*py_retval
;
3482 unsigned char uuid
[VIR_UUID_BUFLEN
];
3483 virSecretPtr secret
;
3484 PyObject
*pyobj_secret
;
3487 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
3489 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
3493 LIBVIRT_BEGIN_ALLOW_THREADS
;
3494 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
3495 LIBVIRT_END_ALLOW_THREADS
;
3499 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3505 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3507 PyObject
*py_retval
;
3508 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3510 PyObject
*pyobj_dom
;
3513 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
3516 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
3520 LIBVIRT_BEGIN_ALLOW_THREADS
;
3521 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
3522 LIBVIRT_END_ALLOW_THREADS
;
3527 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3532 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3533 PyObject
*py_retval
;
3534 virSecretPtr c_retval
;
3536 PyObject
*pyobj_conn
;
3537 unsigned char * uuid
;
3540 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3542 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3544 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3547 LIBVIRT_BEGIN_ALLOW_THREADS
;
3548 c_retval
= virSecretLookupByUUID(conn
, uuid
);
3549 LIBVIRT_END_ALLOW_THREADS
;
3550 py_retval
= libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
3556 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
3558 PyObject
*py_retval
;
3559 char **uuids
= NULL
;
3562 PyObject
*pyobj_conn
;
3564 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
3566 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3568 LIBVIRT_BEGIN_ALLOW_THREADS
;
3569 c_retval
= virConnectNumOfSecrets(conn
);
3570 LIBVIRT_END_ALLOW_THREADS
;
3575 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
3577 LIBVIRT_BEGIN_ALLOW_THREADS
;
3578 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
3579 LIBVIRT_END_ALLOW_THREADS
;
3585 py_retval
= PyList_New(c_retval
);
3588 for (i
= 0;i
< c_retval
;i
++) {
3589 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
3599 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
3602 PyObject
*pyobj_conn
;
3603 PyObject
*py_retval
= NULL
;
3604 PyObject
*tmp
= NULL
;
3606 virSecretPtr
*secrets
= NULL
;
3611 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllSecrets",
3612 &pyobj_conn
, &flags
))
3614 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3616 LIBVIRT_BEGIN_ALLOW_THREADS
;
3617 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
3618 LIBVIRT_END_ALLOW_THREADS
;
3622 if (!(py_retval
= PyList_New(c_retval
)))
3625 for (i
= 0; i
< c_retval
; i
++) {
3626 if (!(tmp
= libvirt_virSecretPtrWrap(secrets
[i
])) ||
3627 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3629 Py_DECREF(py_retval
);
3633 /* python steals the pointer */
3638 for (i
= 0; i
< c_retval
; i
++)
3640 virSecretFree(secrets
[i
]);
3646 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
3648 PyObject
*py_retval
;
3649 unsigned char *c_retval
;
3651 virSecretPtr secret
;
3652 PyObject
*pyobj_secret
;
3655 if (!PyArg_ParseTuple(args
, (char *)"Oi:virSecretGetValue", &pyobj_secret
,
3658 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
3660 LIBVIRT_BEGIN_ALLOW_THREADS
;
3661 c_retval
= virSecretGetValue(secret
, &size
, flags
);
3662 LIBVIRT_END_ALLOW_THREADS
;
3664 if (c_retval
== NULL
)
3667 py_retval
= PyString_FromStringAndSize((const char *)c_retval
, size
);
3674 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
3676 PyObject
*py_retval
;
3678 virSecretPtr secret
;
3679 PyObject
*pyobj_secret
;
3684 if (!PyArg_ParseTuple(args
, (char *)"Oz#i:virSecretSetValue", &pyobj_secret
,
3685 &value
, &size
, &flags
))
3687 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
3689 LIBVIRT_BEGIN_ALLOW_THREADS
;
3690 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
3692 LIBVIRT_END_ALLOW_THREADS
;
3694 py_retval
= libvirt_intWrap(c_retval
);
3699 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3700 PyObject
*py_retval
;
3701 unsigned char uuid
[VIR_UUID_BUFLEN
];
3702 virNWFilterPtr nwfilter
;
3703 PyObject
*pyobj_nwfilter
;
3706 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID", &pyobj_nwfilter
))
3708 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
3710 if (nwfilter
== NULL
)
3712 LIBVIRT_BEGIN_ALLOW_THREADS
;
3713 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
3714 LIBVIRT_END_ALLOW_THREADS
;
3718 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3724 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3726 PyObject
*py_retval
;
3727 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3728 virNWFilterPtr nwfilter
;
3729 PyObject
*pyobj_nwfilter
;
3732 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
3735 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
3737 if (nwfilter
== NULL
)
3739 LIBVIRT_BEGIN_ALLOW_THREADS
;
3740 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
3741 LIBVIRT_END_ALLOW_THREADS
;
3746 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3751 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3752 PyObject
*py_retval
;
3753 virNWFilterPtr c_retval
;
3755 PyObject
*pyobj_conn
;
3756 unsigned char * uuid
;
3759 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3761 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3763 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3766 LIBVIRT_BEGIN_ALLOW_THREADS
;
3767 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
3768 LIBVIRT_END_ALLOW_THREADS
;
3769 py_retval
= libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
3775 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
3777 PyObject
*py_retval
;
3778 char **uuids
= NULL
;
3781 PyObject
*pyobj_conn
;
3783 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters", &pyobj_conn
))
3785 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3787 LIBVIRT_BEGIN_ALLOW_THREADS
;
3788 c_retval
= virConnectNumOfNWFilters(conn
);
3789 LIBVIRT_END_ALLOW_THREADS
;
3794 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
3796 LIBVIRT_BEGIN_ALLOW_THREADS
;
3797 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
3798 LIBVIRT_END_ALLOW_THREADS
;
3804 py_retval
= PyList_New(c_retval
);
3807 for (i
= 0;i
< c_retval
;i
++) {
3808 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
3818 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
3821 PyObject
*pyobj_conn
;
3822 PyObject
*py_retval
= NULL
;
3823 PyObject
*tmp
= NULL
;
3825 virNWFilterPtr
*filters
= NULL
;
3830 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNWFilters",
3831 &pyobj_conn
, &flags
))
3833 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3835 LIBVIRT_BEGIN_ALLOW_THREADS
;
3836 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
3837 LIBVIRT_END_ALLOW_THREADS
;
3841 if (!(py_retval
= PyList_New(c_retval
)))
3844 for (i
= 0; i
< c_retval
; i
++) {
3845 if (!(tmp
= libvirt_virNWFilterPtrWrap(filters
[i
])) ||
3846 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3848 Py_DECREF(py_retval
);
3852 /* python steals the pointer */
3857 for (i
= 0; i
< c_retval
; i
++)
3859 virNWFilterFree(filters
[i
]);
3865 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
3867 PyObject
*py_retval
;
3868 char **names
= NULL
;
3871 PyObject
*pyobj_conn
;
3874 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces", &pyobj_conn
))
3876 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3878 LIBVIRT_BEGIN_ALLOW_THREADS
;
3879 c_retval
= virConnectNumOfInterfaces(conn
);
3880 LIBVIRT_END_ALLOW_THREADS
;
3885 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3887 LIBVIRT_BEGIN_ALLOW_THREADS
;
3888 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
3889 LIBVIRT_END_ALLOW_THREADS
;
3895 py_retval
= PyList_New(c_retval
);
3896 if (py_retval
== NULL
) {
3898 for (i
= 0;i
< c_retval
;i
++)
3906 for (i
= 0;i
< c_retval
;i
++) {
3907 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3918 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
3920 PyObject
*py_retval
;
3921 char **names
= NULL
;
3924 PyObject
*pyobj_conn
;
3927 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
3930 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3932 LIBVIRT_BEGIN_ALLOW_THREADS
;
3933 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
3934 LIBVIRT_END_ALLOW_THREADS
;
3939 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3941 LIBVIRT_BEGIN_ALLOW_THREADS
;
3942 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
3943 LIBVIRT_END_ALLOW_THREADS
;
3949 py_retval
= PyList_New(c_retval
);
3950 if (py_retval
== NULL
) {
3952 for (i
= 0;i
< c_retval
;i
++)
3960 for (i
= 0;i
< c_retval
;i
++) {
3961 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3972 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
3975 PyObject
*pyobj_conn
;
3976 PyObject
*py_retval
= NULL
;
3977 PyObject
*tmp
= NULL
;
3979 virInterfacePtr
*ifaces
= NULL
;
3984 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllInterfaces",
3985 &pyobj_conn
, &flags
))
3987 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3989 LIBVIRT_BEGIN_ALLOW_THREADS
;
3990 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
3991 LIBVIRT_END_ALLOW_THREADS
;
3995 if (!(py_retval
= PyList_New(c_retval
)))
3998 for (i
= 0; i
< c_retval
; i
++) {
3999 if (!(tmp
= libvirt_virInterfacePtrWrap(ifaces
[i
])) ||
4000 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4002 Py_DECREF(py_retval
);
4006 /* python steals the pointer */
4011 for (i
= 0; i
< c_retval
; i
++)
4013 virInterfaceFree(ifaces
[i
]);
4019 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4021 PyObject
*pyobj_conn
;
4025 const char **xmlcpus
= NULL
;
4028 PyObject
*pybase_cpu
;
4030 if (!PyArg_ParseTuple(args
, (char *)"OOi:virConnectBaselineCPU",
4031 &pyobj_conn
, &list
, &flags
))
4033 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4035 if (PyList_Check(list
)) {
4038 ncpus
= PyList_Size(list
);
4039 if (VIR_ALLOC_N(xmlcpus
, ncpus
) < 0)
4040 return VIR_PY_INT_FAIL
;
4042 for (i
= 0; i
< ncpus
; i
++) {
4043 xmlcpus
[i
] = PyString_AsString(PyList_GetItem(list
, i
));
4044 if (xmlcpus
[i
] == NULL
) {
4046 return VIR_PY_INT_FAIL
;
4051 LIBVIRT_BEGIN_ALLOW_THREADS
;
4052 base_cpu
= virConnectBaselineCPU(conn
, xmlcpus
, ncpus
, flags
);
4053 LIBVIRT_END_ALLOW_THREADS
;
4057 if (base_cpu
== NULL
)
4058 return VIR_PY_INT_FAIL
;
4060 pybase_cpu
= PyString_FromString(base_cpu
);
4063 if (pybase_cpu
== NULL
)
4064 return VIR_PY_INT_FAIL
;
4071 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4072 PyObject
*py_retval
;
4074 virDomainPtr domain
;
4075 PyObject
*pyobj_domain
;
4076 virDomainJobInfo info
;
4078 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4080 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4082 LIBVIRT_BEGIN_ALLOW_THREADS
;
4083 c_retval
= virDomainGetJobInfo(domain
, &info
);
4084 LIBVIRT_END_ALLOW_THREADS
;
4087 py_retval
= PyList_New(12);
4088 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
4089 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.timeElapsed
));
4090 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.timeRemaining
));
4091 PyList_SetItem(py_retval
, 3, libvirt_ulonglongWrap(info
.dataTotal
));
4092 PyList_SetItem(py_retval
, 4, libvirt_ulonglongWrap(info
.dataProcessed
));
4093 PyList_SetItem(py_retval
, 5, libvirt_ulonglongWrap(info
.dataRemaining
));
4094 PyList_SetItem(py_retval
, 6, libvirt_ulonglongWrap(info
.memTotal
));
4095 PyList_SetItem(py_retval
, 7, libvirt_ulonglongWrap(info
.memProcessed
));
4096 PyList_SetItem(py_retval
, 8, libvirt_ulonglongWrap(info
.memRemaining
));
4097 PyList_SetItem(py_retval
, 9, libvirt_ulonglongWrap(info
.fileTotal
));
4098 PyList_SetItem(py_retval
, 10, libvirt_ulonglongWrap(info
.fileProcessed
));
4099 PyList_SetItem(py_retval
, 11, libvirt_ulonglongWrap(info
.fileRemaining
));
4105 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4108 virDomainPtr domain
;
4109 PyObject
*pyobj_domain
;
4112 virDomainBlockJobInfo info
;
4116 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockJobInfo",
4117 &pyobj_domain
, &path
, &flags
))
4119 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4121 LIBVIRT_BEGIN_ALLOW_THREADS
;
4122 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4123 LIBVIRT_END_ALLOW_THREADS
;
4128 if ((ret
= PyDict_New()) == NULL
)
4131 PyDict_SetItem(ret
, libvirt_constcharPtrWrap("type"),
4132 libvirt_intWrap(info
.type
));
4133 PyDict_SetItem(ret
, libvirt_constcharPtrWrap("bandwidth"),
4134 libvirt_ulongWrap(info
.bandwidth
));
4135 PyDict_SetItem(ret
, libvirt_constcharPtrWrap("cur"),
4136 libvirt_ulonglongWrap(info
.cur
));
4137 PyDict_SetItem(ret
, libvirt_constcharPtrWrap("end"),
4138 libvirt_ulonglongWrap(info
.end
));
4144 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4147 virDomainPtr domain
;
4148 PyObject
*pyobj_domain
, *info
;
4149 PyObject
*ret
= NULL
;
4152 Py_ssize_t size
= 0;
4155 virTypedParameterPtr params
, new_params
;
4157 if (!PyArg_ParseTuple(args
, (char *)"OzOi:virDomainSetBlockIoTune",
4158 &pyobj_domain
, &disk
, &info
, &flags
))
4160 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4162 if ((size
= PyDict_Size(info
)) < 0)
4166 PyErr_Format(PyExc_LookupError
,
4167 "Need non-empty dictionary to set attributes");
4171 LIBVIRT_BEGIN_ALLOW_THREADS
;
4172 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4173 LIBVIRT_END_ALLOW_THREADS
;
4176 return VIR_PY_INT_FAIL
;
4179 PyErr_Format(PyExc_LookupError
,
4180 "Domain has no settable attributes");
4184 if (VIR_ALLOC_N(params
, nparams
) < 0)
4185 return PyErr_NoMemory();
4187 LIBVIRT_BEGIN_ALLOW_THREADS
;
4188 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4189 LIBVIRT_END_ALLOW_THREADS
;
4192 ret
= VIR_PY_INT_FAIL
;
4196 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
4200 LIBVIRT_BEGIN_ALLOW_THREADS
;
4201 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
4202 LIBVIRT_END_ALLOW_THREADS
;
4205 ret
= VIR_PY_INT_FAIL
;
4209 ret
= VIR_PY_INT_SUCCESS
;
4212 virTypedParameterArrayClear(params
, nparams
);
4214 VIR_FREE(new_params
);
4219 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4222 virDomainPtr domain
;
4223 PyObject
*pyobj_domain
;
4224 PyObject
*ret
= NULL
;
4229 virTypedParameterPtr params
;
4231 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockIoTune",
4232 &pyobj_domain
, &disk
, &flags
))
4234 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4236 LIBVIRT_BEGIN_ALLOW_THREADS
;
4237 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4238 LIBVIRT_END_ALLOW_THREADS
;
4244 return PyDict_New();
4246 if (VIR_ALLOC_N(params
, nparams
) < 0)
4247 return PyErr_NoMemory();
4249 LIBVIRT_BEGIN_ALLOW_THREADS
;
4250 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4251 LIBVIRT_END_ALLOW_THREADS
;
4258 ret
= getPyVirTypedParameter(params
, nparams
);
4261 virTypedParameterArrayClear(params
, nparams
);
4267 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
4270 PyObject
*py_retval
= VIR_PY_NONE
;
4271 virDomainPtr domain
;
4272 PyObject
*pyobj_domain
;
4274 virDomainDiskErrorPtr disks
= NULL
;
4275 unsigned int ndisks
;
4279 if (!PyArg_ParseTuple(args
, (char *) "Oi:virDomainGetDiskErrors",
4280 &pyobj_domain
, &flags
))
4283 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4285 if ((count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0)) < 0)
4290 if (VIR_ALLOC_N(disks
, ndisks
) < 0)
4293 LIBVIRT_BEGIN_ALLOW_THREADS
;
4294 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
4295 LIBVIRT_END_ALLOW_THREADS
;
4301 if (!(py_retval
= PyDict_New()))
4304 for (i
= 0; i
< count
; i
++) {
4305 PyDict_SetItem(py_retval
,
4306 libvirt_constcharPtrWrap(disks
[i
].disk
),
4307 libvirt_intWrap(disks
[i
].error
));
4312 for (i
= 0; i
< count
; i
++)
4313 VIR_FREE(disks
[i
].disk
);
4319 /*******************************************
4320 * Helper functions to avoid importing modules
4321 * for every callback
4322 *******************************************/
4323 static PyObject
*libvirt_module
= NULL
;
4324 static PyObject
*libvirt_dict
= NULL
;
4325 static PyObject
*libvirt_dom_class
= NULL
;
4328 getLibvirtModuleObject (void) {
4330 return libvirt_module
;
4332 // PyImport_ImportModule returns a new reference
4333 /* Bogus (char *) cast for RHEL-5 python API brokenness */
4334 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
4335 if(!libvirt_module
) {
4336 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
4341 return libvirt_module
;
4345 getLibvirtDictObject (void) {
4347 return libvirt_dict
;
4349 // PyModule_GetDict returns a borrowed reference
4350 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
4352 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
4357 Py_INCREF(libvirt_dict
);
4358 return libvirt_dict
;
4362 getLibvirtDomainClassObject (void) {
4363 if(libvirt_dom_class
)
4364 return libvirt_dom_class
;
4366 // PyDict_GetItemString returns a borrowed reference
4367 libvirt_dom_class
= PyDict_GetItemString(getLibvirtDictObject(),
4369 if(!libvirt_dom_class
) {
4370 DEBUG("%s Error importing virDomain class\n", __FUNCTION__
);
4375 Py_INCREF(libvirt_dom_class
);
4376 return libvirt_dom_class
;
4380 libvirt_lookupPythonFunc(const char *funcname
)
4382 PyObject
*python_cb
;
4384 /* Lookup the python callback */
4385 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
4388 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
4394 if (!PyCallable_Check(python_cb
)) {
4395 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
4402 /*******************************************
4404 *******************************************/
4407 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
4413 PyObject
*pyobj_ret
;
4415 PyObject
*pyobj_conn_inst
= (PyObject
*)opaque
;
4416 PyObject
*pyobj_dom
;
4418 PyObject
*pyobj_dom_args
;
4419 PyObject
*pyobj_dom_inst
;
4421 PyObject
*dom_class
;
4424 LIBVIRT_ENSURE_THREAD_STATE
;
4426 /* Create a python instance of this virDomainPtr */
4428 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
4429 pyobj_dom_args
= PyTuple_New(2);
4430 if(PyTuple_SetItem(pyobj_dom_args
, 0, pyobj_conn_inst
)!=0) {
4431 DEBUG("%s error creating tuple",__FUNCTION__
);
4434 if(PyTuple_SetItem(pyobj_dom_args
, 1, pyobj_dom
)!=0) {
4435 DEBUG("%s error creating tuple",__FUNCTION__
);
4438 Py_INCREF(pyobj_conn_inst
);
4440 dom_class
= getLibvirtDomainClassObject();
4441 if(!PyClass_Check(dom_class
)) {
4442 DEBUG("%s dom_class is not a class!\n", __FUNCTION__
);
4446 pyobj_dom_inst
= PyInstance_New(dom_class
,
4450 Py_DECREF(pyobj_dom_args
);
4452 if(!pyobj_dom_inst
) {
4453 DEBUG("%s Error creating a python instance of virDomain\n",
4459 /* Call the Callback Dispatcher */
4460 pyobj_ret
= PyObject_CallMethod(pyobj_conn_inst
,
4461 (char*)"_dispatchDomainEventCallbacks",
4467 Py_DECREF(pyobj_dom_inst
);
4470 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
4473 Py_DECREF(pyobj_ret
);
4479 LIBVIRT_RELEASE_THREAD_STATE
;
4484 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
* self
,
4487 PyObject
*py_retval
; /* return value */
4488 PyObject
*pyobj_conn
; /* virConnectPtr */
4489 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
4494 if (!PyArg_ParseTuple
4495 (args
, (char *) "OO:virConnectDomainEventRegister",
4496 &pyobj_conn
, &pyobj_conn_inst
)) {
4497 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
4498 return VIR_PY_INT_FAIL
;
4501 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
4502 pyobj_conn
, pyobj_conn_inst
);
4503 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4505 Py_INCREF(pyobj_conn_inst
);
4507 LIBVIRT_BEGIN_ALLOW_THREADS
;
4509 ret
= virConnectDomainEventRegister(conn
,
4510 libvirt_virConnectDomainEventCallback
,
4511 (void *)pyobj_conn_inst
, NULL
);
4513 LIBVIRT_END_ALLOW_THREADS
;
4515 py_retval
= libvirt_intWrap(ret
);
4520 libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject
* self
,
4523 PyObject
*py_retval
;
4524 PyObject
*pyobj_conn
;
4525 PyObject
*pyobj_conn_inst
;
4530 if (!PyArg_ParseTuple
4531 (args
, (char *) "OO:virConnectDomainEventDeregister",
4532 &pyobj_conn
, &pyobj_conn_inst
))
4535 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
4537 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4539 LIBVIRT_BEGIN_ALLOW_THREADS
;
4541 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
4543 LIBVIRT_END_ALLOW_THREADS
;
4545 Py_DECREF(pyobj_conn_inst
);
4546 py_retval
= libvirt_intWrap(ret
);
4550 /*******************************************
4552 *******************************************/
4553 static PyObject
*addHandleObj
= NULL
;
4554 static char *addHandleName
= NULL
;
4555 static PyObject
*updateHandleObj
= NULL
;
4556 static char *updateHandleName
= NULL
;
4557 static PyObject
*removeHandleObj
= NULL
;
4558 static char *removeHandleName
= NULL
;
4559 static PyObject
*addTimeoutObj
= NULL
;
4560 static char *addTimeoutName
= NULL
;
4561 static PyObject
*updateTimeoutObj
= NULL
;
4562 static char *updateTimeoutName
= NULL
;
4563 static PyObject
*removeTimeoutObj
= NULL
;
4564 static char *removeTimeoutName
= NULL
;
4566 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
4569 libvirt_virEventAddHandleFunc (int fd
,
4571 virEventHandleCallback cb
,
4576 PyObject
*python_cb
;
4579 PyObject
*opaque_obj
;
4581 PyObject
*pyobj_args
;
4584 LIBVIRT_ENSURE_THREAD_STATE
;
4586 /* Lookup the python callback */
4587 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
4591 Py_INCREF(python_cb
);
4593 /* create tuple for cb */
4594 cb_obj
= libvirt_virEventHandleCallbackWrap(cb
);
4595 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
4596 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
4598 cb_args
= PyTuple_New(3);
4599 PyTuple_SetItem(cb_args
, 0, cb_obj
);
4600 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
4601 PyTuple_SetItem(cb_args
, 2, ff_obj
);
4603 pyobj_args
= PyTuple_New(4);
4604 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(fd
));
4605 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
4606 PyTuple_SetItem(pyobj_args
, 2, python_cb
);
4607 PyTuple_SetItem(pyobj_args
, 3, cb_args
);
4609 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
4613 } else if (!PyInt_Check(result
)) {
4614 DEBUG("%s: %s should return an int\n", __FUNCTION__
, NAME(addHandle
));
4616 retval
= (int)PyInt_AsLong(result
);
4620 Py_DECREF(pyobj_args
);
4623 LIBVIRT_RELEASE_THREAD_STATE
;
4629 libvirt_virEventUpdateHandleFunc(int watch
, int event
)
4632 PyObject
*pyobj_args
;
4634 LIBVIRT_ENSURE_THREAD_STATE
;
4636 pyobj_args
= PyTuple_New(2);
4637 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
4638 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
4640 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
4647 Py_DECREF(pyobj_args
);
4649 LIBVIRT_RELEASE_THREAD_STATE
;
4654 libvirt_virEventRemoveHandleFunc(int watch
)
4657 PyObject
*pyobj_args
;
4661 virFreeCallback cff
;
4663 LIBVIRT_ENSURE_THREAD_STATE
;
4665 pyobj_args
= PyTuple_New(1);
4666 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
4668 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
4672 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
4673 DEBUG("%s: %s must return opaque obj registered with %s"
4674 "to avoid leaking libvirt memory\n",
4675 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
4677 opaque
= PyTuple_GetItem(result
, 1);
4678 ff
= PyTuple_GetItem(result
, 2);
4679 cff
= PyvirFreeCallback_Get(ff
);
4681 (*cff
)(PyvirVoidPtr_Get(opaque
));
4686 Py_DECREF(pyobj_args
);
4688 LIBVIRT_RELEASE_THREAD_STATE
;
4695 libvirt_virEventAddTimeoutFunc(int timeout
,
4696 virEventTimeoutCallback cb
,
4702 PyObject
*python_cb
;
4706 PyObject
*opaque_obj
;
4708 PyObject
*pyobj_args
;
4711 LIBVIRT_ENSURE_THREAD_STATE
;
4713 /* Lookup the python callback */
4714 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
4718 Py_INCREF(python_cb
);
4720 /* create tuple for cb */
4721 cb_obj
= libvirt_virEventTimeoutCallbackWrap(cb
);
4722 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
4723 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
4725 cb_args
= PyTuple_New(3);
4726 PyTuple_SetItem(cb_args
, 0, cb_obj
);
4727 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
4728 PyTuple_SetItem(cb_args
, 2, ff_obj
);
4730 pyobj_args
= PyTuple_New(3);
4732 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timeout
));
4733 PyTuple_SetItem(pyobj_args
, 1, python_cb
);
4734 PyTuple_SetItem(pyobj_args
, 2, cb_args
);
4736 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
4740 } else if (!PyInt_Check(result
)) {
4741 DEBUG("%s: %s should return an int\n", __FUNCTION__
, NAME(addTimeout
));
4743 retval
= (int)PyInt_AsLong(result
);
4747 Py_DECREF(pyobj_args
);
4750 LIBVIRT_RELEASE_THREAD_STATE
;
4755 libvirt_virEventUpdateTimeoutFunc(int timer
, int timeout
)
4757 PyObject
*result
= NULL
;
4758 PyObject
*pyobj_args
;
4760 LIBVIRT_ENSURE_THREAD_STATE
;
4762 pyobj_args
= PyTuple_New(2);
4763 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
4764 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(timeout
));
4766 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
4773 Py_DECREF(pyobj_args
);
4775 LIBVIRT_RELEASE_THREAD_STATE
;
4779 libvirt_virEventRemoveTimeoutFunc(int timer
)
4781 PyObject
*result
= NULL
;
4782 PyObject
*pyobj_args
;
4786 virFreeCallback cff
;
4788 LIBVIRT_ENSURE_THREAD_STATE
;
4790 pyobj_args
= PyTuple_New(1);
4791 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
4793 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
4797 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
4798 DEBUG("%s: %s must return opaque obj registered with %s"
4799 "to avoid leaking libvirt memory\n",
4800 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
4802 opaque
= PyTuple_GetItem(result
, 1);
4803 ff
= PyTuple_GetItem(result
, 2);
4804 cff
= PyvirFreeCallback_Get(ff
);
4806 (*cff
)(PyvirVoidPtr_Get(opaque
));
4811 Py_DECREF(pyobj_args
);
4813 LIBVIRT_RELEASE_THREAD_STATE
;
4819 libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject
* self
,
4822 /* Unref the previously-registered impl (if any) */
4823 Py_XDECREF(addHandleObj
);
4824 Py_XDECREF(updateHandleObj
);
4825 Py_XDECREF(removeHandleObj
);
4826 Py_XDECREF(addTimeoutObj
);
4827 Py_XDECREF(updateTimeoutObj
);
4828 Py_XDECREF(removeTimeoutObj
);
4830 /* Parse and check arguments */
4831 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
4832 &addHandleObj
, &updateHandleObj
,
4833 &removeHandleObj
, &addTimeoutObj
,
4834 &updateTimeoutObj
, &removeTimeoutObj
) ||
4835 !PyCallable_Check(addHandleObj
) ||
4836 !PyCallable_Check(updateHandleObj
) ||
4837 !PyCallable_Check(removeHandleObj
) ||
4838 !PyCallable_Check(addTimeoutObj
) ||
4839 !PyCallable_Check(updateTimeoutObj
) ||
4840 !PyCallable_Check(removeTimeoutObj
))
4841 return VIR_PY_INT_FAIL
;
4843 /* Get argument string representations (for error reporting) */
4844 addHandleName
= py_str(addHandleObj
);
4845 updateHandleName
= py_str(updateHandleObj
);
4846 removeHandleName
= py_str(removeHandleObj
);
4847 addTimeoutName
= py_str(addTimeoutObj
);
4848 updateTimeoutName
= py_str(updateTimeoutObj
);
4849 removeTimeoutName
= py_str(removeTimeoutObj
);
4851 /* Inc refs since we're holding onto these objects until
4852 * the next call (if any) to this function.
4854 Py_INCREF(addHandleObj
);
4855 Py_INCREF(updateHandleObj
);
4856 Py_INCREF(removeHandleObj
);
4857 Py_INCREF(addTimeoutObj
);
4858 Py_INCREF(updateTimeoutObj
);
4859 Py_INCREF(removeTimeoutObj
);
4861 LIBVIRT_BEGIN_ALLOW_THREADS
;
4863 /* Now register our C EventImpl, which will dispatch
4864 * to the Python callbacks passed in as args.
4866 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
4867 libvirt_virEventUpdateHandleFunc
,
4868 libvirt_virEventRemoveHandleFunc
,
4869 libvirt_virEventAddTimeoutFunc
,
4870 libvirt_virEventUpdateTimeoutFunc
,
4871 libvirt_virEventRemoveTimeoutFunc
);
4873 LIBVIRT_END_ALLOW_THREADS
;
4875 return VIR_PY_INT_SUCCESS
;
4879 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
4882 int watch
, fd
, event
;
4884 PyObject
*py_opaque
;
4885 virEventHandleCallback cb
;
4888 if (!PyArg_ParseTuple
4889 (args
, (char *) "iiiOO:virEventInvokeHandleCallback",
4890 &watch
, &fd
, &event
, &py_f
, &py_opaque
4892 return VIR_PY_INT_FAIL
;
4894 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
4895 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
4898 LIBVIRT_BEGIN_ALLOW_THREADS
;
4899 cb (watch
, fd
, event
, opaque
);
4900 LIBVIRT_END_ALLOW_THREADS
;
4903 return VIR_PY_INT_SUCCESS
;
4907 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
4912 PyObject
*py_opaque
;
4913 virEventTimeoutCallback cb
;
4916 if (!PyArg_ParseTuple
4917 (args
, (char *) "iOO:virEventInvokeTimeoutCallback",
4918 &timer
, &py_f
, &py_opaque
4920 return VIR_PY_INT_FAIL
;
4922 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
4923 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
4925 LIBVIRT_BEGIN_ALLOW_THREADS
;
4927 LIBVIRT_END_ALLOW_THREADS
;
4930 return VIR_PY_INT_SUCCESS
;
4934 libvirt_virEventHandleCallback(int watch
,
4939 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
4940 PyObject
*pyobj_ret
;
4941 PyObject
*python_cb
;
4943 LIBVIRT_ENSURE_THREAD_STATE
;
4945 /* Lookup the python callback */
4946 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
4951 Py_INCREF(pyobj_cbData
);
4953 /* Call the pure python dispatcher */
4954 pyobj_ret
= PyObject_CallFunction(python_cb
,
4956 watch
, fd
, events
, pyobj_cbData
);
4958 Py_DECREF(pyobj_cbData
);
4961 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
4964 Py_DECREF(pyobj_ret
);
4968 LIBVIRT_RELEASE_THREAD_STATE
;
4972 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
4975 PyObject
*py_retval
;
4976 PyObject
*pyobj_cbData
;
4977 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
4982 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
4983 &fd
, &events
, &pyobj_cbData
)) {
4984 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
4985 return VIR_PY_INT_FAIL
;
4988 Py_INCREF(pyobj_cbData
);
4990 LIBVIRT_BEGIN_ALLOW_THREADS
;
4991 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
4992 LIBVIRT_END_ALLOW_THREADS
;
4995 Py_DECREF(pyobj_cbData
);
4998 py_retval
= libvirt_intWrap(ret
);
5003 libvirt_virEventTimeoutCallback(int timer
,
5006 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5007 PyObject
*pyobj_ret
;
5008 PyObject
*python_cb
;
5010 LIBVIRT_ENSURE_THREAD_STATE
;
5012 /* Lookup the python callback */
5013 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5018 Py_INCREF(pyobj_cbData
);
5020 /* Call the pure python dispatcher */
5021 pyobj_ret
= PyObject_CallFunction(python_cb
,
5023 timer
, pyobj_cbData
);
5025 Py_DECREF(pyobj_cbData
);
5028 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5031 Py_DECREF(pyobj_ret
);
5035 LIBVIRT_RELEASE_THREAD_STATE
;
5039 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5042 PyObject
*py_retval
;
5043 PyObject
*pyobj_cbData
;
5044 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5048 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5049 &timeout
, &pyobj_cbData
)) {
5050 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5051 return VIR_PY_INT_FAIL
;
5054 Py_INCREF(pyobj_cbData
);
5056 LIBVIRT_BEGIN_ALLOW_THREADS
;
5057 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5058 LIBVIRT_END_ALLOW_THREADS
;
5061 Py_DECREF(pyobj_cbData
);
5064 py_retval
= libvirt_intWrap(ret
);
5069 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5071 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5072 LIBVIRT_ENSURE_THREAD_STATE
;
5073 Py_DECREF(pyobj_conn
);
5074 LIBVIRT_RELEASE_THREAD_STATE
;
5078 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5084 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5085 PyObject
*pyobj_dom
;
5086 PyObject
*pyobj_ret
;
5087 PyObject
*pyobj_conn
;
5091 LIBVIRT_ENSURE_THREAD_STATE
;
5093 /* Create a python instance of this virDomainPtr */
5095 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5096 Py_INCREF(pyobj_cbData
);
5098 dictKey
= libvirt_constcharPtrWrap("conn");
5099 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5102 /* Call the Callback Dispatcher */
5103 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5104 (char*)"_dispatchDomainEventLifecycleCallback",
5110 Py_DECREF(pyobj_cbData
);
5111 Py_DECREF(pyobj_dom
);
5114 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5117 Py_DECREF(pyobj_ret
);
5121 LIBVIRT_RELEASE_THREAD_STATE
;
5126 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5130 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5131 PyObject
*pyobj_dom
;
5132 PyObject
*pyobj_ret
;
5133 PyObject
*pyobj_conn
;
5137 LIBVIRT_ENSURE_THREAD_STATE
;
5139 /* Create a python instance of this virDomainPtr */
5141 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5142 Py_INCREF(pyobj_cbData
);
5144 dictKey
= libvirt_constcharPtrWrap("conn");
5145 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5148 /* Call the Callback Dispatcher */
5149 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5150 (char*)"_dispatchDomainEventGenericCallback",
5152 pyobj_dom
, pyobj_cbData
);
5154 Py_DECREF(pyobj_cbData
);
5155 Py_DECREF(pyobj_dom
);
5158 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5161 Py_DECREF(pyobj_ret
);
5165 LIBVIRT_RELEASE_THREAD_STATE
;
5170 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5172 long long utcoffset
,
5175 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5176 PyObject
*pyobj_dom
;
5177 PyObject
*pyobj_ret
;
5178 PyObject
*pyobj_conn
;
5182 LIBVIRT_ENSURE_THREAD_STATE
;
5184 /* Create a python instance of this virDomainPtr */
5186 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5187 Py_INCREF(pyobj_cbData
);
5189 dictKey
= libvirt_constcharPtrWrap("conn");
5190 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5193 /* Call the Callback Dispatcher */
5194 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5195 (char*)"_dispatchDomainEventRTCChangeCallback",
5198 (PY_LONG_LONG
)utcoffset
,
5201 Py_DECREF(pyobj_cbData
);
5202 Py_DECREF(pyobj_dom
);
5205 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5208 Py_DECREF(pyobj_ret
);
5212 LIBVIRT_RELEASE_THREAD_STATE
;
5217 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5222 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5223 PyObject
*pyobj_dom
;
5224 PyObject
*pyobj_ret
;
5225 PyObject
*pyobj_conn
;
5229 LIBVIRT_ENSURE_THREAD_STATE
;
5231 /* Create a python instance of this virDomainPtr */
5233 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5234 Py_INCREF(pyobj_cbData
);
5236 dictKey
= libvirt_constcharPtrWrap("conn");
5237 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5240 /* Call the Callback Dispatcher */
5241 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5242 (char*)"_dispatchDomainEventWatchdogCallback",
5248 Py_DECREF(pyobj_cbData
);
5249 Py_DECREF(pyobj_dom
);
5252 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5255 Py_DECREF(pyobj_ret
);
5259 LIBVIRT_RELEASE_THREAD_STATE
;
5264 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5266 const char *srcPath
,
5267 const char *devAlias
,
5271 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5272 PyObject
*pyobj_dom
;
5273 PyObject
*pyobj_ret
;
5274 PyObject
*pyobj_conn
;
5278 LIBVIRT_ENSURE_THREAD_STATE
;
5280 /* Create a python instance of this virDomainPtr */
5282 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5283 Py_INCREF(pyobj_cbData
);
5285 dictKey
= libvirt_constcharPtrWrap("conn");
5286 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5289 /* Call the Callback Dispatcher */
5290 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5291 (char*)"_dispatchDomainEventIOErrorCallback",
5294 srcPath
, devAlias
, action
,
5297 Py_DECREF(pyobj_cbData
);
5298 Py_DECREF(pyobj_dom
);
5301 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5304 Py_DECREF(pyobj_ret
);
5308 LIBVIRT_RELEASE_THREAD_STATE
;
5313 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5315 const char *srcPath
,
5316 const char *devAlias
,
5321 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5322 PyObject
*pyobj_dom
;
5323 PyObject
*pyobj_ret
;
5324 PyObject
*pyobj_conn
;
5328 LIBVIRT_ENSURE_THREAD_STATE
;
5330 /* Create a python instance of this virDomainPtr */
5332 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5333 Py_INCREF(pyobj_cbData
);
5335 dictKey
= libvirt_constcharPtrWrap("conn");
5336 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5339 /* Call the Callback Dispatcher */
5340 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5341 (char*)"_dispatchDomainEventIOErrorReasonCallback",
5344 srcPath
, devAlias
, action
, reason
,
5347 Py_DECREF(pyobj_cbData
);
5348 Py_DECREF(pyobj_dom
);
5351 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5354 Py_DECREF(pyobj_ret
);
5358 LIBVIRT_RELEASE_THREAD_STATE
;
5363 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5366 virDomainEventGraphicsAddressPtr local
,
5367 virDomainEventGraphicsAddressPtr remote
,
5368 const char *authScheme
,
5369 virDomainEventGraphicsSubjectPtr subject
,
5372 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5373 PyObject
*pyobj_dom
;
5374 PyObject
*pyobj_ret
;
5375 PyObject
*pyobj_conn
;
5377 PyObject
*pyobj_local
;
5378 PyObject
*pyobj_remote
;
5379 PyObject
*pyobj_subject
;
5383 LIBVIRT_ENSURE_THREAD_STATE
;
5385 /* Create a python instance of this virDomainPtr */
5387 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5388 Py_INCREF(pyobj_cbData
);
5390 dictKey
= libvirt_constcharPtrWrap("conn");
5391 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5394 pyobj_local
= PyDict_New();
5395 PyDict_SetItem(pyobj_local
,
5396 libvirt_constcharPtrWrap("family"),
5397 libvirt_intWrap(local
->family
));
5398 PyDict_SetItem(pyobj_local
,
5399 libvirt_constcharPtrWrap("node"),
5400 libvirt_constcharPtrWrap(local
->node
));
5401 PyDict_SetItem(pyobj_local
,
5402 libvirt_constcharPtrWrap("service"),
5403 libvirt_constcharPtrWrap(local
->service
));
5405 pyobj_remote
= PyDict_New();
5406 PyDict_SetItem(pyobj_remote
,
5407 libvirt_constcharPtrWrap("family"),
5408 libvirt_intWrap(remote
->family
));
5409 PyDict_SetItem(pyobj_remote
,
5410 libvirt_constcharPtrWrap("node"),
5411 libvirt_constcharPtrWrap(remote
->node
));
5412 PyDict_SetItem(pyobj_remote
,
5413 libvirt_constcharPtrWrap("service"),
5414 libvirt_constcharPtrWrap(remote
->service
));
5416 pyobj_subject
= PyList_New(subject
->nidentity
);
5417 for (i
= 0 ; i
< subject
->nidentity
; i
++) {
5418 PyObject
*pair
= PyTuple_New(2);
5419 PyTuple_SetItem(pair
, 0, libvirt_constcharPtrWrap(subject
->identities
[i
].type
));
5420 PyTuple_SetItem(pair
, 1, libvirt_constcharPtrWrap(subject
->identities
[i
].name
));
5422 PyList_SetItem(pyobj_subject
, i
, pair
);
5425 /* Call the Callback Dispatcher */
5426 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5427 (char*)"_dispatchDomainEventGraphicsCallback",
5430 phase
, pyobj_local
, pyobj_remote
,
5431 authScheme
, pyobj_subject
,
5434 Py_DECREF(pyobj_cbData
);
5435 Py_DECREF(pyobj_dom
);
5438 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5441 Py_DECREF(pyobj_ret
);
5445 LIBVIRT_RELEASE_THREAD_STATE
;
5450 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5457 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5458 PyObject
*pyobj_dom
;
5459 PyObject
*pyobj_ret
;
5460 PyObject
*pyobj_conn
;
5464 LIBVIRT_ENSURE_THREAD_STATE
;
5466 /* Create a python instance of this virDomainPtr */
5468 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5469 Py_INCREF(pyobj_cbData
);
5471 dictKey
= libvirt_constcharPtrWrap("conn");
5472 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5475 /* Call the Callback Dispatcher */
5476 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5477 (char*)"dispatchDomainEventBlockPullCallback",
5479 pyobj_dom
, path
, type
, status
, pyobj_cbData
);
5481 Py_DECREF(pyobj_cbData
);
5482 Py_DECREF(pyobj_dom
);
5486 printf("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5490 Py_DECREF(pyobj_ret
);
5494 LIBVIRT_RELEASE_THREAD_STATE
;
5499 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5501 const char *oldSrcPath
,
5502 const char *newSrcPath
,
5503 const char *devAlias
,
5507 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5508 PyObject
*pyobj_dom
;
5509 PyObject
*pyobj_ret
;
5510 PyObject
*pyobj_conn
;
5514 LIBVIRT_ENSURE_THREAD_STATE
;
5515 /* Create a python instance of this virDomainPtr */
5518 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5519 Py_INCREF(pyobj_cbData
);
5521 dictKey
= libvirt_constcharPtrWrap("conn");
5522 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5525 /* Call the Callback Dispatcher */
5526 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5527 (char*)"_dispatchDomainEventDiskChangeCallback",
5530 oldSrcPath
, newSrcPath
,
5531 devAlias
, reason
, pyobj_cbData
);
5533 Py_DECREF(pyobj_cbData
);
5534 Py_DECREF(pyobj_dom
);
5537 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5540 Py_DECREF(pyobj_ret
);
5544 LIBVIRT_RELEASE_THREAD_STATE
;
5549 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5551 const char *devAlias
,
5555 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5556 PyObject
*pyobj_dom
;
5557 PyObject
*pyobj_ret
;
5558 PyObject
*pyobj_conn
;
5562 LIBVIRT_ENSURE_THREAD_STATE
;
5563 /* Create a python instance of this virDomainPtr */
5566 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5567 Py_INCREF(pyobj_cbData
);
5569 dictKey
= libvirt_constcharPtrWrap("conn");
5570 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5573 /* Call the Callback Dispatcher */
5574 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5575 (char*)"_dispatchDomainEventTrayChangeCallback",
5578 devAlias
, reason
, pyobj_cbData
);
5580 Py_DECREF(pyobj_cbData
);
5581 Py_DECREF(pyobj_dom
);
5584 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5587 Py_DECREF(pyobj_ret
);
5591 LIBVIRT_RELEASE_THREAD_STATE
;
5596 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5601 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5602 PyObject
*pyobj_dom
;
5603 PyObject
*pyobj_ret
;
5604 PyObject
*pyobj_conn
;
5608 LIBVIRT_ENSURE_THREAD_STATE
;
5609 /* Create a python instance of this virDomainPtr */
5612 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5613 Py_INCREF(pyobj_cbData
);
5615 dictKey
= libvirt_constcharPtrWrap("conn");
5616 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5619 /* Call the Callback Dispatcher */
5620 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5621 (char*)"_dispatchDomainEventPMWakeupCallback",
5627 Py_DECREF(pyobj_cbData
);
5628 Py_DECREF(pyobj_dom
);
5631 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5634 Py_DECREF(pyobj_ret
);
5638 LIBVIRT_RELEASE_THREAD_STATE
;
5643 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5648 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5649 PyObject
*pyobj_dom
;
5650 PyObject
*pyobj_ret
;
5651 PyObject
*pyobj_conn
;
5655 LIBVIRT_ENSURE_THREAD_STATE
;
5656 /* Create a python instance of this virDomainPtr */
5659 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5660 Py_INCREF(pyobj_cbData
);
5662 dictKey
= libvirt_constcharPtrWrap("conn");
5663 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5666 /* Call the Callback Dispatcher */
5667 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5668 (char*)"_dispatchDomainEventPMSuspendCallback",
5674 Py_DECREF(pyobj_cbData
);
5675 Py_DECREF(pyobj_dom
);
5678 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5681 Py_DECREF(pyobj_ret
);
5685 LIBVIRT_RELEASE_THREAD_STATE
;
5690 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5692 unsigned long long actual
,
5695 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5696 PyObject
*pyobj_dom
;
5697 PyObject
*pyobj_ret
;
5698 PyObject
*pyobj_conn
;
5702 LIBVIRT_ENSURE_THREAD_STATE
;
5704 /* Create a python instance of this virDomainPtr */
5706 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5707 Py_INCREF(pyobj_cbData
);
5709 dictKey
= libvirt_constcharPtrWrap("conn");
5710 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5713 /* Call the Callback Dispatcher */
5714 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5715 (char*)"_dispatchDomainEventBalloonChangeCallback",
5718 (PY_LONG_LONG
)actual
,
5721 Py_DECREF(pyobj_cbData
);
5722 Py_DECREF(pyobj_dom
);
5725 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5728 Py_DECREF(pyobj_ret
);
5732 LIBVIRT_RELEASE_THREAD_STATE
;
5737 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5742 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5743 PyObject
*pyobj_dom
;
5744 PyObject
*pyobj_ret
;
5745 PyObject
*pyobj_conn
;
5749 LIBVIRT_ENSURE_THREAD_STATE
;
5750 /* Create a python instance of this virDomainPtr */
5753 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5754 Py_INCREF(pyobj_cbData
);
5756 dictKey
= libvirt_constcharPtrWrap("conn");
5757 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5760 /* Call the Callback Dispatcher */
5761 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5762 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
5768 Py_DECREF(pyobj_cbData
);
5769 Py_DECREF(pyobj_dom
);
5772 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5775 Py_DECREF(pyobj_ret
);
5779 LIBVIRT_RELEASE_THREAD_STATE
;
5784 libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject
* self
,
5787 PyObject
*py_retval
; /* return value */
5788 PyObject
*pyobj_conn
; /* virConnectPtr */
5789 PyObject
*pyobj_dom
;
5790 PyObject
*pyobj_cbData
; /* hash of callback data */
5794 virConnectDomainEventGenericCallback cb
= NULL
;
5797 if (!PyArg_ParseTuple
5798 (args
, (char *) "OOiO:virConnectDomainEventRegisterAny",
5799 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
)) {
5800 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
5801 return VIR_PY_INT_FAIL
;
5804 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
5805 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
5806 conn
= PyvirConnect_Get(pyobj_conn
);
5807 if (pyobj_dom
== Py_None
)
5810 dom
= PyvirDomain_Get(pyobj_dom
);
5813 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
5814 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
5816 case VIR_DOMAIN_EVENT_ID_REBOOT
:
5817 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
5819 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
5820 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
5822 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
5823 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
5825 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
5826 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
5828 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
5829 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
5831 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
5832 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
5834 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
5835 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
5837 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
5838 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
5840 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
5841 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
5843 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
5844 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
5846 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
5847 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
5849 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
5850 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
5852 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
5853 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
5855 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
5856 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
5861 return VIR_PY_INT_FAIL
;
5864 Py_INCREF(pyobj_cbData
);
5866 LIBVIRT_BEGIN_ALLOW_THREADS
;
5867 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
5869 libvirt_virConnectDomainEventFreeFunc
);
5870 LIBVIRT_END_ALLOW_THREADS
;
5873 Py_DECREF(pyobj_cbData
);
5876 py_retval
= libvirt_intWrap(ret
);
5881 libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED PyObject
* self
,
5884 PyObject
*py_retval
;
5885 PyObject
*pyobj_conn
;
5890 if (!PyArg_ParseTuple
5891 (args
, (char *) "Oi:virConnectDomainEventDeregister",
5892 &pyobj_conn
, &callbackID
))
5895 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
5897 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5899 LIBVIRT_BEGIN_ALLOW_THREADS
;
5901 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
5903 LIBVIRT_END_ALLOW_THREADS
;
5904 py_retval
= libvirt_intWrap(ret
);
5909 libvirt_virStreamEventFreeFunc(void *opaque
)
5911 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
5912 LIBVIRT_ENSURE_THREAD_STATE
;
5913 Py_DECREF(pyobj_stream
);
5914 LIBVIRT_RELEASE_THREAD_STATE
;
5918 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
5922 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5923 PyObject
*pyobj_stream
;
5924 PyObject
*pyobj_ret
;
5927 LIBVIRT_ENSURE_THREAD_STATE
;
5929 Py_INCREF(pyobj_cbData
);
5930 dictKey
= libvirt_constcharPtrWrap("stream");
5931 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5934 /* Call the pure python dispatcher */
5935 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
5936 (char *)"_dispatchStreamEventCallback",
5938 events
, pyobj_cbData
);
5940 Py_DECREF(pyobj_cbData
);
5943 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5946 Py_DECREF(pyobj_ret
);
5949 LIBVIRT_RELEASE_THREAD_STATE
;
5953 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5956 PyObject
*py_retval
;
5957 PyObject
*pyobj_stream
;
5958 PyObject
*pyobj_cbData
;
5959 virStreamPtr stream
;
5960 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
5964 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
5965 &pyobj_stream
, &events
, &pyobj_cbData
)) {
5966 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5967 return VIR_PY_INT_FAIL
;
5970 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
5971 pyobj_stream
, events
, pyobj_cbData
);
5972 stream
= PyvirStream_Get(pyobj_stream
);
5974 Py_INCREF(pyobj_cbData
);
5976 LIBVIRT_BEGIN_ALLOW_THREADS
;
5977 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
5978 libvirt_virStreamEventFreeFunc
);
5979 LIBVIRT_END_ALLOW_THREADS
;
5982 Py_DECREF(pyobj_cbData
);
5985 py_retval
= libvirt_intWrap(ret
);
5990 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
5993 PyObject
*pyobj_stream
;
5994 virStreamPtr stream
;
5999 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
6000 &pyobj_stream
, &nbytes
)) {
6001 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6004 stream
= PyvirStream_Get(pyobj_stream
);
6006 if (VIR_ALLOC_N(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
6009 LIBVIRT_BEGIN_ALLOW_THREADS
;
6010 ret
= virStreamRecv(stream
, buf
, nbytes
);
6011 LIBVIRT_END_ALLOW_THREADS
;
6013 buf
[ret
> -1 ? ret
: 0] = '\0';
6014 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
6017 return libvirt_intWrap(ret
);
6020 return libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
6024 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
6027 PyObject
*py_retval
;
6028 PyObject
*pyobj_stream
;
6029 virStreamPtr stream
;
6035 if (!PyArg_ParseTuple(args
, (char *) "Oz#i:virStreamRecv",
6036 &pyobj_stream
, &data
, &datalen
, &nbytes
)) {
6037 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6038 return VIR_PY_INT_FAIL
;
6040 stream
= PyvirStream_Get(pyobj_stream
);
6042 LIBVIRT_BEGIN_ALLOW_THREADS
;
6043 ret
= virStreamSend(stream
, data
, nbytes
);
6044 LIBVIRT_END_ALLOW_THREADS
;
6046 DEBUG("StreamSend ret=%d\n", ret
);
6048 py_retval
= libvirt_intWrap(ret
);
6053 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
6056 PyObject
*py_retval
;
6057 virDomainPtr domain
;
6058 PyObject
*pyobj_domain
;
6059 PyObject
*pyobj_list
;
6065 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
6066 unsigned int nkeycodes
;
6068 if (!PyArg_ParseTuple(args
, (char *)"OiiOii:virDomainSendKey",
6069 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
6070 &nkeycodes
, &flags
)) {
6071 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6072 return VIR_PY_INT_FAIL
;
6074 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6076 if (!PyList_Check(pyobj_list
)) {
6077 return VIR_PY_INT_FAIL
;
6080 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
6081 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
6082 return VIR_PY_INT_FAIL
;
6085 for (i
= 0; i
< nkeycodes
; i
++) {
6086 keycodes
[i
] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list
, i
));
6089 LIBVIRT_BEGIN_ALLOW_THREADS
;
6090 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
6091 LIBVIRT_END_ALLOW_THREADS
;
6093 DEBUG("virDomainSendKey ret=%d\n", ret
);
6095 py_retval
= libvirt_intWrap(ret
);
6100 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
6101 PyObject
*py_retval
;
6103 unsigned long bandwidth
;
6104 virDomainPtr domain
;
6105 PyObject
*pyobj_domain
;
6106 unsigned int flags
= 0;
6108 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainMigrateGetMaxSpeed",
6109 &pyobj_domain
, &flags
))
6112 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6114 LIBVIRT_BEGIN_ALLOW_THREADS
;
6115 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
6116 LIBVIRT_END_ALLOW_THREADS
;
6119 return VIR_PY_INT_FAIL
;
6120 py_retval
= libvirt_ulongWrap(bandwidth
);
6125 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
6127 PyObject
*py_retval
= NULL
;
6129 virDomainPtr domain
;
6130 PyObject
*pyobj_domain
;
6132 unsigned long long offset
;
6137 if (!PyArg_ParseTuple(args
, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain
,
6138 &disk
, &offset
, &size
, &flags
))
6141 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6143 if (VIR_ALLOC_N(buf
, size
) < 0)
6146 LIBVIRT_BEGIN_ALLOW_THREADS
;
6147 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
6148 LIBVIRT_END_ALLOW_THREADS
;
6151 py_retval
= VIR_PY_NONE
;
6155 py_retval
= PyString_FromStringAndSize(buf
, size
);
6163 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
6165 PyObject
*py_retval
= NULL
;
6167 virDomainPtr domain
;
6168 PyObject
*pyobj_domain
;
6169 unsigned long long start
;
6174 if (!PyArg_ParseTuple(args
, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain
,
6175 &start
, &size
, &flags
))
6178 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6180 if (VIR_ALLOC_N(buf
, size
) < 0)
6183 LIBVIRT_BEGIN_ALLOW_THREADS
;
6184 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
6185 LIBVIRT_END_ALLOW_THREADS
;
6188 py_retval
= VIR_PY_NONE
;
6192 py_retval
= PyString_FromStringAndSize(buf
, size
);
6200 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
6204 PyObject
*pyobj_conn
, *info
;
6205 PyObject
*ret
= NULL
;
6208 Py_ssize_t size
= 0;
6210 virTypedParameterPtr params
, new_params
;
6212 if (!PyArg_ParseTuple(args
,
6213 (char *)"OOi:virNodeSetMemoryParameters",
6214 &pyobj_conn
, &info
, &flags
))
6216 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6218 if ((size
= PyDict_Size(info
)) < 0)
6222 PyErr_Format(PyExc_LookupError
,
6223 "Need non-empty dictionary to set attributes");
6227 LIBVIRT_BEGIN_ALLOW_THREADS
;
6228 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
6229 LIBVIRT_END_ALLOW_THREADS
;
6232 return VIR_PY_INT_FAIL
;
6235 PyErr_Format(PyExc_LookupError
,
6236 "no settable attributes");
6240 if (VIR_ALLOC_N(params
, nparams
) < 0)
6241 return PyErr_NoMemory();
6243 LIBVIRT_BEGIN_ALLOW_THREADS
;
6244 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
6245 LIBVIRT_END_ALLOW_THREADS
;
6248 ret
= VIR_PY_INT_FAIL
;
6252 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
6256 LIBVIRT_BEGIN_ALLOW_THREADS
;
6257 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
6258 LIBVIRT_END_ALLOW_THREADS
;
6261 ret
= VIR_PY_INT_FAIL
;
6265 ret
= VIR_PY_INT_SUCCESS
;
6268 virTypedParameterArrayClear(params
, nparams
);
6270 VIR_FREE(new_params
);
6275 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
6279 PyObject
*pyobj_conn
;
6280 PyObject
*ret
= NULL
;
6284 virTypedParameterPtr params
;
6286 if (!PyArg_ParseTuple(args
, (char *)"Oi:virNodeGetMemoryParameters",
6287 &pyobj_conn
, &flags
))
6289 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6291 LIBVIRT_BEGIN_ALLOW_THREADS
;
6292 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
6293 LIBVIRT_END_ALLOW_THREADS
;
6299 return PyDict_New();
6301 if (VIR_ALLOC_N(params
, nparams
) < 0)
6302 return PyErr_NoMemory();
6304 LIBVIRT_BEGIN_ALLOW_THREADS
;
6305 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
6306 LIBVIRT_END_ALLOW_THREADS
;
6313 ret
= getPyVirTypedParameter(params
, nparams
);
6316 virTypedParameterArrayClear(params
, nparams
);
6322 /************************************************************************
6324 * The registration stuff *
6326 ************************************************************************/
6327 static PyMethodDef libvirtMethods
[] = {
6328 #include "libvirt-export.c"
6329 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
6330 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
6331 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
6332 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
6333 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
6334 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
6335 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
6336 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
6337 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
6338 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
6339 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
6340 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
6341 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
6342 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
6343 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
6344 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
6345 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
6346 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
6347 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
6348 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
6349 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
6350 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
6351 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
6352 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
6353 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
6354 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
6355 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
6356 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
6357 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
6358 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
6359 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
6360 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
6361 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
6362 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
6363 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
6364 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
6365 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
6366 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
6367 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
6368 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
6369 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
6370 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
6371 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
6372 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
6373 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
6374 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
6375 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
6376 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
6377 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
6378 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
6379 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
6380 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
6381 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
6382 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
6383 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
6384 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
6385 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
6386 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
6387 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
6388 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
6389 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
6390 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
6391 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
6392 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
6393 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
6394 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
6395 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
6396 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
6397 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
6398 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
6399 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
6400 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
6401 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
6402 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
6403 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
6404 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
6405 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
6406 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
6407 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
6408 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
6409 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
6410 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
6411 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
6412 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
6413 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
6414 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
6415 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
6416 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
6417 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
6418 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
6419 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
6420 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
6421 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
6422 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
6423 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
6424 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
6425 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
6426 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
6427 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
6428 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
6429 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
6430 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
6431 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
6432 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
6433 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
6434 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
6435 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
6436 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
6437 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
6438 {NULL
, NULL
, 0, NULL
}
6449 static int initialized
= 0;
6451 if (initialized
!= 0)
6454 if (virInitialize() < 0)
6457 /* initialize the python extension module */
6458 Py_InitModule((char *)