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-2013 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"
31 #include "virstring.h"
34 extern void initlibvirtmod(void);
36 extern void initcygvirtmod(void);
40 # define DEBUG_ERROR 1
44 # define DEBUG(fmt, ...) \
45 printf(fmt, __VA_ARGS__)
47 # define DEBUG(fmt, ...) \
51 /* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
52 is so common that we encapsulate it here. Now, each use is simply
53 return VIR_PY_NONE; */
54 #define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
55 #define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
56 #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
58 /* We don't want to free() returned value. As written in doc:
59 * PyString_AsString returns pointer to 'internal buffer of string,
60 * not a copy' and 'It must not be deallocated'. */
61 static char *py_str(PyObject
*obj
)
63 PyObject
*str
= PyObject_Str(obj
);
69 return PyString_AsString(str
);
72 /* Helper function to convert a virTypedParameter output array into a
73 * Python dictionary for return to the user. Return NULL on failure,
74 * after raising a python exception. */
76 getPyVirTypedParameter(const virTypedParameterPtr params
, int nparams
)
78 PyObject
*key
, *val
, *info
;
81 if ((info
= PyDict_New()) == NULL
)
84 for (i
= 0; i
< nparams
; i
++) {
85 switch (params
[i
].type
) {
86 case VIR_TYPED_PARAM_INT
:
87 val
= PyInt_FromLong(params
[i
].value
.i
);
90 case VIR_TYPED_PARAM_UINT
:
91 val
= PyInt_FromLong(params
[i
].value
.ui
);
94 case VIR_TYPED_PARAM_LLONG
:
95 val
= PyLong_FromLongLong(params
[i
].value
.l
);
98 case VIR_TYPED_PARAM_ULLONG
:
99 val
= PyLong_FromUnsignedLongLong(params
[i
].value
.ul
);
102 case VIR_TYPED_PARAM_DOUBLE
:
103 val
= PyFloat_FromDouble(params
[i
].value
.d
);
106 case VIR_TYPED_PARAM_BOOLEAN
:
107 val
= PyBool_FromLong(params
[i
].value
.b
);
110 case VIR_TYPED_PARAM_STRING
:
111 val
= libvirt_constcharPtrWrap(params
[i
].value
.s
);
115 /* Possible if a newer server has a bug and sent stuff we
116 * don't recognize. */
117 PyErr_Format(PyExc_LookupError
,
118 "Type value \"%d\" not recognized",
124 key
= libvirt_constcharPtrWrap(params
[i
].field
);
128 if (PyDict_SetItem(info
, key
, val
) < 0) {
144 /* Allocate a new typed parameter array with the same contents and
145 * length as info, and using the array params of length nparams as
146 * hints on what types to use when creating the new array. The caller
147 * must NOT clear the array before freeing it, as it points into info
148 * rather than allocated strings. Return NULL on failure, after
149 * raising a python exception. */
150 static virTypedParameterPtr
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
151 setPyVirTypedParameter(PyObject
*info
,
152 const virTypedParameterPtr params
, int nparams
)
154 PyObject
*key
, *value
;
155 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
160 virTypedParameterPtr temp
= NULL
, ret
= NULL
;
164 if ((size
= PyDict_Size(info
)) < 0)
167 /* Libvirt APIs use NULL array and 0 size as a special case;
168 * setting should have at least one parameter. */
170 PyErr_Format(PyExc_LookupError
, "Dictionary must not be empty");
174 if (VIR_ALLOC_N_QUIET(ret
, size
) < 0) {
180 while (PyDict_Next(info
, &pos
, &key
, &value
)) {
183 if ((keystr
= PyString_AsString(key
)) == NULL
)
186 for (i
= 0; i
< nparams
; i
++) {
187 if (STREQ(params
[i
].field
, keystr
))
191 PyErr_Format(PyExc_LookupError
,
192 "Attribute name \"%s\" could not be recognized",
197 ignore_value(virStrcpyStatic(temp
->field
, keystr
));
198 temp
->type
= params
[i
].type
;
200 switch (params
[i
].type
) {
201 case VIR_TYPED_PARAM_INT
:
202 if (libvirt_intUnwrap(value
, &temp
->value
.i
) < 0)
206 case VIR_TYPED_PARAM_UINT
:
207 if (libvirt_uintUnwrap(value
, &temp
->value
.ui
) < 0)
211 case VIR_TYPED_PARAM_LLONG
:
212 if (libvirt_longlongUnwrap(value
, &temp
->value
.l
) < 0)
216 case VIR_TYPED_PARAM_ULLONG
:
217 if (libvirt_ulonglongUnwrap(value
, &temp
->value
.ul
) < 0)
221 case VIR_TYPED_PARAM_DOUBLE
:
222 if (libvirt_doubleUnwrap(value
, &temp
->value
.d
) < 0)
226 case VIR_TYPED_PARAM_BOOLEAN
:
229 if (libvirt_boolUnwrap(value
, &b
) < 0)
234 case VIR_TYPED_PARAM_STRING
:
236 char *string_val
= PyString_AsString(value
);
239 temp
->value
.s
= string_val
;
244 /* Possible if a newer server has a bug and sent stuff we
245 * don't recognize. */
246 PyErr_Format(PyExc_LookupError
,
247 "Type value \"%d\" not recognized",
265 } virPyTypedParamsHint
;
266 typedef virPyTypedParamsHint
*virPyTypedParamsHintPtr
;
268 /* Automatically convert dict into type parameters based on types reported
269 * by python. All integer types are converted into LLONG (in case of a negative
270 * value) or ULLONG (in case of a positive value). If you need different
271 * handling, use @hints to explicitly specify what types should be used for
272 * specific parameters.
275 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
276 virPyDictToTypedParams(PyObject
*dict
,
277 virTypedParameterPtr
*ret_params
,
279 virPyTypedParamsHintPtr hints
,
284 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
289 virTypedParameterPtr params
= NULL
;
298 if (PyDict_Size(dict
) < 0)
301 while (PyDict_Next(dict
, &pos
, &key
, &value
)) {
305 if (!(keystr
= PyString_AsString(key
)))
308 for (i
= 0; i
< nhints
; i
++) {
309 if (STREQ(hints
[i
].name
, keystr
)) {
310 type
= hints
[i
].type
;
316 if (PyString_Check(value
)) {
317 type
= VIR_TYPED_PARAM_STRING
;
318 } else if (PyBool_Check(value
)) {
319 type
= VIR_TYPED_PARAM_BOOLEAN
;
320 } else if (PyLong_Check(value
)) {
321 unsigned long long ull
= PyLong_AsUnsignedLongLong(value
);
322 if (ull
== (unsigned long long) -1 && PyErr_Occurred())
323 type
= VIR_TYPED_PARAM_LLONG
;
325 type
= VIR_TYPED_PARAM_ULLONG
;
326 } else if (PyInt_Check(value
)) {
327 if (PyInt_AS_LONG(value
) < 0)
328 type
= VIR_TYPED_PARAM_LLONG
;
330 type
= VIR_TYPED_PARAM_ULLONG
;
331 } else if (PyFloat_Check(value
)) {
332 type
= VIR_TYPED_PARAM_DOUBLE
;
337 PyErr_Format(PyExc_TypeError
,
338 "Unknown type of \"%s\" field", keystr
);
342 switch ((virTypedParameterType
) type
) {
343 case VIR_TYPED_PARAM_INT
:
346 if (libvirt_intUnwrap(value
, &val
) < 0 ||
347 virTypedParamsAddInt(¶ms
, &n
, &max
, keystr
, val
) < 0)
351 case VIR_TYPED_PARAM_UINT
:
354 if (libvirt_uintUnwrap(value
, &val
) < 0 ||
355 virTypedParamsAddUInt(¶ms
, &n
, &max
, keystr
, val
) < 0)
359 case VIR_TYPED_PARAM_LLONG
:
362 if (libvirt_longlongUnwrap(value
, &val
) < 0 ||
363 virTypedParamsAddLLong(¶ms
, &n
, &max
, keystr
, val
) < 0)
367 case VIR_TYPED_PARAM_ULLONG
:
369 unsigned long long val
;
370 if (libvirt_ulonglongUnwrap(value
, &val
) < 0 ||
371 virTypedParamsAddULLong(¶ms
, &n
, &max
, keystr
, val
) < 0)
375 case VIR_TYPED_PARAM_DOUBLE
:
378 if (libvirt_doubleUnwrap(value
, &val
) < 0 ||
379 virTypedParamsAddDouble(¶ms
, &n
, &max
, keystr
, val
) < 0)
383 case VIR_TYPED_PARAM_BOOLEAN
:
386 if (libvirt_boolUnwrap(value
, &val
) < 0 ||
387 virTypedParamsAddBoolean(¶ms
, &n
, &max
, keystr
, val
) < 0)
391 case VIR_TYPED_PARAM_STRING
:
393 char *val
= PyString_AsString(value
);
395 virTypedParamsAddString(¶ms
, &n
, &max
, keystr
, val
) < 0)
399 case VIR_TYPED_PARAM_LAST
:
400 break; /* unreachable */
404 *ret_params
= params
;
410 virTypedParamsFree(params
, n
);
416 * Utility function to retrieve the number of node CPUs present.
417 * It first tries virGetNodeCPUMap, which will return the
418 * number reliably, if available.
419 * As a fallback and for compatibility with backlevel libvirt
420 * versions virGetNodeInfo will be called to calculate the
421 * CPU number, which has the potential to return a too small
422 * number if some host CPUs are offline.
425 getPyNodeCPUCount(virConnectPtr conn
) {
427 virNodeInfo nodeinfo
;
429 LIBVIRT_BEGIN_ALLOW_THREADS
;
430 i_retval
= virNodeGetCPUMap(conn
, NULL
, NULL
, 0);
431 LIBVIRT_END_ALLOW_THREADS
;
434 /* fallback: use nodeinfo */
435 LIBVIRT_BEGIN_ALLOW_THREADS
;
436 i_retval
= virNodeGetInfo(conn
, &nodeinfo
);
437 LIBVIRT_END_ALLOW_THREADS
;
441 i_retval
= VIR_NODEINFO_MAXCPUS(nodeinfo
);
448 /************************************************************************
452 ************************************************************************/
455 libvirt_virDomainBlockStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
457 PyObject
*pyobj_domain
;
460 virDomainBlockStatsStruct stats
;
463 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainBlockStats",
464 &pyobj_domain
,&path
))
466 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
468 LIBVIRT_BEGIN_ALLOW_THREADS
;
469 c_retval
= virDomainBlockStats(domain
, path
, &stats
, sizeof(stats
));
470 LIBVIRT_END_ALLOW_THREADS
;
475 /* convert to a Python tuple of long objects */
476 if ((info
= PyTuple_New(5)) == NULL
)
478 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rd_req
));
479 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rd_bytes
));
480 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.wr_req
));
481 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.wr_bytes
));
482 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.errs
));
487 libvirt_virDomainBlockStatsFlags(PyObject
*self ATTRIBUTE_UNUSED
,
491 PyObject
*pyobj_domain
;
492 PyObject
*ret
= NULL
;
496 virTypedParameterPtr params
;
499 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainBlockStatsFlags",
500 &pyobj_domain
, &path
, &flags
))
502 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
504 LIBVIRT_BEGIN_ALLOW_THREADS
;
505 i_retval
= virDomainBlockStatsFlags(domain
, path
, NULL
, &nparams
, flags
);
506 LIBVIRT_END_ALLOW_THREADS
;
514 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
515 return PyErr_NoMemory();
517 LIBVIRT_BEGIN_ALLOW_THREADS
;
518 i_retval
= virDomainBlockStatsFlags(domain
, path
, params
, &nparams
, flags
);
519 LIBVIRT_END_ALLOW_THREADS
;
526 ret
= getPyVirTypedParameter(params
, nparams
);
529 virTypedParamsFree(params
, nparams
);
534 libvirt_virDomainGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
537 PyObject
*pyobj_domain
, *totalbool
;
538 PyObject
*cpu
, *total
;
539 PyObject
*ret
= NULL
;
540 PyObject
*error
= NULL
;
541 int ncpus
= -1, start_cpu
= 0;
542 int sumparams
= 0, nparams
= -1;
547 virTypedParameterPtr params
= NULL
, cpuparams
;
549 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainGetCPUStats",
550 &pyobj_domain
, &totalbool
, &flags
))
552 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
554 if (libvirt_boolUnwrap(totalbool
, &totalflag
) < 0)
557 if ((ret
= PyList_New(0)) == NULL
)
561 LIBVIRT_BEGIN_ALLOW_THREADS
;
562 ncpus
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 0, flags
);
563 LIBVIRT_END_ALLOW_THREADS
;
570 LIBVIRT_BEGIN_ALLOW_THREADS
;
571 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 1, flags
);
572 LIBVIRT_END_ALLOW_THREADS
;
579 sumparams
= nparams
* MIN(ncpus
, 128);
581 if (VIR_ALLOC_N_QUIET(params
, sumparams
) < 0) {
582 error
= PyErr_NoMemory();
587 int queried_ncpus
= MIN(ncpus
, 128);
590 LIBVIRT_BEGIN_ALLOW_THREADS
;
591 i_retval
= virDomainGetCPUStats(domain
, params
,
592 nparams
, start_cpu
, queried_ncpus
, flags
);
593 LIBVIRT_END_ALLOW_THREADS
;
603 for (i
= 0; i
< queried_ncpus
; i
++) {
604 cpuparams
= ¶ms
[i
* nparams
];
605 if ((cpu
= getPyVirTypedParameter(cpuparams
, i_retval
)) == NULL
) {
609 if (PyList_Append(ret
, cpu
) < 0) {
616 start_cpu
+= queried_ncpus
;
617 ncpus
-= queried_ncpus
;
618 virTypedParamsClear(params
, sumparams
);
621 LIBVIRT_BEGIN_ALLOW_THREADS
;
622 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, -1, 1, flags
);
623 LIBVIRT_END_ALLOW_THREADS
;
633 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0) {
634 error
= PyErr_NoMemory();
638 LIBVIRT_BEGIN_ALLOW_THREADS
;
639 i_retval
= virDomainGetCPUStats(domain
, params
, nparams
, -1, 1, flags
);
640 LIBVIRT_END_ALLOW_THREADS
;
650 if ((total
= getPyVirTypedParameter(params
, i_retval
)) == NULL
) {
653 if (PyList_Append(ret
, total
) < 0) {
660 virTypedParamsFree(params
, sumparams
);
664 virTypedParamsFree(params
, sumparams
);
670 libvirt_virDomainInterfaceStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
672 PyObject
*pyobj_domain
;
675 virDomainInterfaceStatsStruct stats
;
678 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainInterfaceStats",
679 &pyobj_domain
,&path
))
681 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
683 LIBVIRT_BEGIN_ALLOW_THREADS
;
684 c_retval
= virDomainInterfaceStats(domain
, path
, &stats
, sizeof(stats
));
685 LIBVIRT_END_ALLOW_THREADS
;
690 /* convert to a Python tuple of long objects */
691 if ((info
= PyTuple_New(8)) == NULL
)
693 PyTuple_SetItem(info
, 0, PyLong_FromLongLong(stats
.rx_bytes
));
694 PyTuple_SetItem(info
, 1, PyLong_FromLongLong(stats
.rx_packets
));
695 PyTuple_SetItem(info
, 2, PyLong_FromLongLong(stats
.rx_errs
));
696 PyTuple_SetItem(info
, 3, PyLong_FromLongLong(stats
.rx_drop
));
697 PyTuple_SetItem(info
, 4, PyLong_FromLongLong(stats
.tx_bytes
));
698 PyTuple_SetItem(info
, 5, PyLong_FromLongLong(stats
.tx_packets
));
699 PyTuple_SetItem(info
, 6, PyLong_FromLongLong(stats
.tx_errs
));
700 PyTuple_SetItem(info
, 7, PyLong_FromLongLong(stats
.tx_drop
));
705 libvirt_virDomainMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
707 PyObject
*pyobj_domain
;
708 unsigned int nr_stats
;
710 virDomainMemoryStatStruct stats
[VIR_DOMAIN_MEMORY_STAT_NR
];
713 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainMemoryStats", &pyobj_domain
))
715 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
717 nr_stats
= virDomainMemoryStats(domain
, stats
,
718 VIR_DOMAIN_MEMORY_STAT_NR
, 0);
722 /* convert to a Python dictionary */
723 if ((info
= PyDict_New()) == NULL
)
726 for (i
= 0; i
< nr_stats
; i
++) {
727 if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_SWAP_IN
)
728 PyDict_SetItem(info
, libvirt_constcharPtrWrap("swap_in"),
729 PyLong_FromUnsignedLongLong(stats
[i
].val
));
730 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
)
731 PyDict_SetItem(info
, libvirt_constcharPtrWrap("swap_out"),
732 PyLong_FromUnsignedLongLong(stats
[i
].val
));
733 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
)
734 PyDict_SetItem(info
, libvirt_constcharPtrWrap("major_fault"),
735 PyLong_FromUnsignedLongLong(stats
[i
].val
));
736 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
)
737 PyDict_SetItem(info
, libvirt_constcharPtrWrap("minor_fault"),
738 PyLong_FromUnsignedLongLong(stats
[i
].val
));
739 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_UNUSED
)
740 PyDict_SetItem(info
, libvirt_constcharPtrWrap("unused"),
741 PyLong_FromUnsignedLongLong(stats
[i
].val
));
742 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_AVAILABLE
)
743 PyDict_SetItem(info
, libvirt_constcharPtrWrap("available"),
744 PyLong_FromUnsignedLongLong(stats
[i
].val
));
745 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
)
746 PyDict_SetItem(info
, libvirt_constcharPtrWrap("actual"),
747 PyLong_FromUnsignedLongLong(stats
[i
].val
));
748 else if (stats
[i
].tag
== VIR_DOMAIN_MEMORY_STAT_RSS
)
749 PyDict_SetItem(info
, libvirt_constcharPtrWrap("rss"),
750 PyLong_FromUnsignedLongLong(stats
[i
].val
));
756 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
759 PyObject
*pyobj_domain
, *info
;
763 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
766 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
768 LIBVIRT_BEGIN_ALLOW_THREADS
;
769 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
770 LIBVIRT_END_ALLOW_THREADS
;
771 if (c_retval
== NULL
)
774 /* convert to a Python tuple of long objects */
775 if ((info
= PyTuple_New(2)) == NULL
) {
780 PyTuple_SetItem(info
, 0, libvirt_constcharPtrWrap(c_retval
));
781 PyTuple_SetItem(info
, 1, PyInt_FromLong((long)nparams
));
787 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
791 PyObject
*pyobj_domain
;
792 PyObject
*ret
= NULL
;
796 virTypedParameterPtr params
;
798 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
801 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
803 LIBVIRT_BEGIN_ALLOW_THREADS
;
804 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
805 LIBVIRT_END_ALLOW_THREADS
;
807 if (c_retval
== NULL
)
814 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
815 return PyErr_NoMemory();
817 LIBVIRT_BEGIN_ALLOW_THREADS
;
818 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
819 LIBVIRT_END_ALLOW_THREADS
;
826 ret
= getPyVirTypedParameter(params
, nparams
);
829 virTypedParamsFree(params
, nparams
);
834 libvirt_virDomainGetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
838 PyObject
*pyobj_domain
;
839 PyObject
*ret
= NULL
;
844 virTypedParameterPtr params
;
846 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetScedulerParametersFlags",
847 &pyobj_domain
, &flags
))
849 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
851 LIBVIRT_BEGIN_ALLOW_THREADS
;
852 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
853 LIBVIRT_END_ALLOW_THREADS
;
855 if (c_retval
== NULL
)
862 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
863 return PyErr_NoMemory();
865 LIBVIRT_BEGIN_ALLOW_THREADS
;
866 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
867 LIBVIRT_END_ALLOW_THREADS
;
874 ret
= getPyVirTypedParameter(params
, nparams
);
877 virTypedParamsFree(params
, nparams
);
882 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
886 PyObject
*pyobj_domain
, *info
;
887 PyObject
*ret
= NULL
;
892 virTypedParameterPtr params
, new_params
= NULL
;
894 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetScedulerParameters",
895 &pyobj_domain
, &info
))
897 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
899 if ((size
= PyDict_Size(info
)) < 0)
903 PyErr_Format(PyExc_LookupError
,
904 "Need non-empty dictionary to set attributes");
908 LIBVIRT_BEGIN_ALLOW_THREADS
;
909 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
910 LIBVIRT_END_ALLOW_THREADS
;
912 if (c_retval
== NULL
)
913 return VIR_PY_INT_FAIL
;
917 PyErr_Format(PyExc_LookupError
,
918 "Domain has no settable attributes");
922 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
923 return PyErr_NoMemory();
925 LIBVIRT_BEGIN_ALLOW_THREADS
;
926 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
927 LIBVIRT_END_ALLOW_THREADS
;
930 ret
= VIR_PY_INT_FAIL
;
934 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
938 LIBVIRT_BEGIN_ALLOW_THREADS
;
939 i_retval
= virDomainSetSchedulerParameters(domain
, new_params
, size
);
940 LIBVIRT_END_ALLOW_THREADS
;
943 ret
= VIR_PY_INT_FAIL
;
947 ret
= VIR_PY_INT_SUCCESS
;
950 virTypedParamsFree(params
, nparams
);
951 VIR_FREE(new_params
);
956 libvirt_virDomainSetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
960 PyObject
*pyobj_domain
, *info
;
961 PyObject
*ret
= NULL
;
967 virTypedParameterPtr params
, new_params
= NULL
;
969 if (!PyArg_ParseTuple(args
,
970 (char *)"OOi:virDomainSetScedulerParametersFlags",
971 &pyobj_domain
, &info
, &flags
))
973 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
975 if ((size
= PyDict_Size(info
)) < 0)
979 PyErr_Format(PyExc_LookupError
,
980 "Need non-empty dictionary to set attributes");
984 LIBVIRT_BEGIN_ALLOW_THREADS
;
985 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
986 LIBVIRT_END_ALLOW_THREADS
;
988 if (c_retval
== NULL
)
989 return VIR_PY_INT_FAIL
;
993 PyErr_Format(PyExc_LookupError
,
994 "Domain has no settable attributes");
998 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
999 return PyErr_NoMemory();
1001 LIBVIRT_BEGIN_ALLOW_THREADS
;
1002 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
1003 LIBVIRT_END_ALLOW_THREADS
;
1006 ret
= VIR_PY_INT_FAIL
;
1010 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1014 LIBVIRT_BEGIN_ALLOW_THREADS
;
1015 i_retval
= virDomainSetSchedulerParametersFlags(domain
, new_params
, size
, flags
);
1016 LIBVIRT_END_ALLOW_THREADS
;
1019 ret
= VIR_PY_INT_FAIL
;
1023 ret
= VIR_PY_INT_SUCCESS
;
1026 virTypedParamsFree(params
, nparams
);
1027 VIR_FREE(new_params
);
1032 libvirt_virDomainSetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1035 virDomainPtr domain
;
1036 PyObject
*pyobj_domain
, *info
;
1037 PyObject
*ret
= NULL
;
1040 Py_ssize_t size
= 0;
1042 virTypedParameterPtr params
, new_params
= NULL
;
1044 if (!PyArg_ParseTuple(args
,
1045 (char *)"OOi:virDomainSetBlkioParameters",
1046 &pyobj_domain
, &info
, &flags
))
1048 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1050 if ((size
= PyDict_Size(info
)) < 0)
1054 PyErr_Format(PyExc_LookupError
,
1055 "Need non-empty dictionary to set attributes");
1059 LIBVIRT_BEGIN_ALLOW_THREADS
;
1060 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
1061 LIBVIRT_END_ALLOW_THREADS
;
1064 return VIR_PY_INT_FAIL
;
1067 PyErr_Format(PyExc_LookupError
,
1068 "Domain has no settable attributes");
1072 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1073 return PyErr_NoMemory();
1075 LIBVIRT_BEGIN_ALLOW_THREADS
;
1076 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
1077 LIBVIRT_END_ALLOW_THREADS
;
1080 ret
= VIR_PY_INT_FAIL
;
1084 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1088 LIBVIRT_BEGIN_ALLOW_THREADS
;
1089 i_retval
= virDomainSetBlkioParameters(domain
, new_params
, size
, flags
);
1090 LIBVIRT_END_ALLOW_THREADS
;
1093 ret
= VIR_PY_INT_FAIL
;
1097 ret
= VIR_PY_INT_SUCCESS
;
1100 virTypedParamsFree(params
, nparams
);
1101 VIR_FREE(new_params
);
1106 libvirt_virDomainGetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1109 virDomainPtr domain
;
1110 PyObject
*pyobj_domain
;
1111 PyObject
*ret
= NULL
;
1115 virTypedParameterPtr params
;
1117 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetBlkioParameters",
1118 &pyobj_domain
, &flags
))
1120 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1122 LIBVIRT_BEGIN_ALLOW_THREADS
;
1123 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
1124 LIBVIRT_END_ALLOW_THREADS
;
1130 return PyDict_New();
1132 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1133 return PyErr_NoMemory();
1135 LIBVIRT_BEGIN_ALLOW_THREADS
;
1136 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
1137 LIBVIRT_END_ALLOW_THREADS
;
1144 ret
= getPyVirTypedParameter(params
, nparams
);
1147 virTypedParamsFree(params
, nparams
);
1152 libvirt_virDomainSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1155 virDomainPtr domain
;
1156 PyObject
*pyobj_domain
, *info
;
1157 PyObject
*ret
= NULL
;
1160 Py_ssize_t size
= 0;
1162 virTypedParameterPtr params
, new_params
= NULL
;
1164 if (!PyArg_ParseTuple(args
,
1165 (char *)"OOi:virDomainSetMemoryParameters",
1166 &pyobj_domain
, &info
, &flags
))
1168 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1170 if ((size
= PyDict_Size(info
)) < 0)
1174 PyErr_Format(PyExc_LookupError
,
1175 "Need non-empty dictionary to set attributes");
1179 LIBVIRT_BEGIN_ALLOW_THREADS
;
1180 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
1181 LIBVIRT_END_ALLOW_THREADS
;
1184 return VIR_PY_INT_FAIL
;
1187 PyErr_Format(PyExc_LookupError
,
1188 "Domain has no settable attributes");
1192 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1193 return PyErr_NoMemory();
1195 LIBVIRT_BEGIN_ALLOW_THREADS
;
1196 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1197 LIBVIRT_END_ALLOW_THREADS
;
1200 ret
= VIR_PY_INT_FAIL
;
1204 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1208 LIBVIRT_BEGIN_ALLOW_THREADS
;
1209 i_retval
= virDomainSetMemoryParameters(domain
, new_params
, size
, flags
);
1210 LIBVIRT_END_ALLOW_THREADS
;
1213 ret
= VIR_PY_INT_FAIL
;
1217 ret
= VIR_PY_INT_SUCCESS
;
1220 virTypedParamsFree(params
, nparams
);
1221 VIR_FREE(new_params
);
1226 libvirt_virDomainGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1229 virDomainPtr domain
;
1230 PyObject
*pyobj_domain
;
1231 PyObject
*ret
= NULL
;
1235 virTypedParameterPtr params
;
1237 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetMemoryParameters",
1238 &pyobj_domain
, &flags
))
1240 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1242 LIBVIRT_BEGIN_ALLOW_THREADS
;
1243 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
1244 LIBVIRT_END_ALLOW_THREADS
;
1250 return PyDict_New();
1252 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1253 return PyErr_NoMemory();
1255 LIBVIRT_BEGIN_ALLOW_THREADS
;
1256 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1257 LIBVIRT_END_ALLOW_THREADS
;
1264 ret
= getPyVirTypedParameter(params
, nparams
);
1267 virTypedParamsFree(params
, nparams
);
1272 libvirt_virDomainSetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1275 virDomainPtr domain
;
1276 PyObject
*pyobj_domain
, *info
;
1277 PyObject
*ret
= NULL
;
1280 Py_ssize_t size
= 0;
1282 virTypedParameterPtr params
, new_params
= NULL
;
1284 if (!PyArg_ParseTuple(args
,
1285 (char *)"OOi:virDomainSetNumaParameters",
1286 &pyobj_domain
, &info
, &flags
))
1288 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1290 if ((size
= PyDict_Size(info
)) < 0)
1294 PyErr_Format(PyExc_LookupError
,
1295 "Need non-empty dictionary to set attributes");
1299 LIBVIRT_BEGIN_ALLOW_THREADS
;
1300 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1301 LIBVIRT_END_ALLOW_THREADS
;
1304 return VIR_PY_INT_FAIL
;
1307 PyErr_Format(PyExc_LookupError
,
1308 "Domain has no settable attributes");
1312 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1313 return PyErr_NoMemory();
1315 LIBVIRT_BEGIN_ALLOW_THREADS
;
1316 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1317 LIBVIRT_END_ALLOW_THREADS
;
1320 ret
= VIR_PY_INT_FAIL
;
1324 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1328 LIBVIRT_BEGIN_ALLOW_THREADS
;
1329 i_retval
= virDomainSetNumaParameters(domain
, new_params
, size
, flags
);
1330 LIBVIRT_END_ALLOW_THREADS
;
1333 ret
= VIR_PY_INT_FAIL
;
1337 ret
= VIR_PY_INT_SUCCESS
;
1340 virTypedParamsFree(params
, nparams
);
1341 VIR_FREE(new_params
);
1346 libvirt_virDomainGetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1349 virDomainPtr domain
;
1350 PyObject
*pyobj_domain
;
1351 PyObject
*ret
= NULL
;
1355 virTypedParameterPtr params
;
1357 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetNumaParameters",
1358 &pyobj_domain
, &flags
))
1360 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1362 LIBVIRT_BEGIN_ALLOW_THREADS
;
1363 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1364 LIBVIRT_END_ALLOW_THREADS
;
1370 return PyDict_New();
1372 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1373 return PyErr_NoMemory();
1375 LIBVIRT_BEGIN_ALLOW_THREADS
;
1376 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1377 LIBVIRT_END_ALLOW_THREADS
;
1384 ret
= getPyVirTypedParameter(params
, nparams
);
1387 virTypedParamsFree(params
, nparams
);
1392 libvirt_virDomainSetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1395 virDomainPtr domain
;
1396 PyObject
*pyobj_domain
, *info
;
1397 PyObject
*ret
= NULL
;
1400 Py_ssize_t size
= 0;
1402 const char *device
= NULL
;
1403 virTypedParameterPtr params
, new_params
= NULL
;
1405 if (!PyArg_ParseTuple(args
,
1406 (char *)"OzOi:virDomainSetInterfaceParameters",
1407 &pyobj_domain
, &device
, &info
, &flags
))
1409 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1411 if ((size
= PyDict_Size(info
)) < 0)
1415 PyErr_Format(PyExc_LookupError
,
1416 "Need non-empty dictionary to set attributes");
1420 LIBVIRT_BEGIN_ALLOW_THREADS
;
1421 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1422 LIBVIRT_END_ALLOW_THREADS
;
1425 return VIR_PY_INT_FAIL
;
1428 PyErr_Format(PyExc_LookupError
,
1429 "Domain has no settable attributes");
1433 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1434 return PyErr_NoMemory();
1436 LIBVIRT_BEGIN_ALLOW_THREADS
;
1437 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1438 LIBVIRT_END_ALLOW_THREADS
;
1441 ret
= VIR_PY_INT_FAIL
;
1445 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1449 LIBVIRT_BEGIN_ALLOW_THREADS
;
1450 i_retval
= virDomainSetInterfaceParameters(domain
, device
, new_params
, size
, flags
);
1451 LIBVIRT_END_ALLOW_THREADS
;
1454 ret
= VIR_PY_INT_FAIL
;
1458 ret
= VIR_PY_INT_SUCCESS
;
1461 virTypedParamsFree(params
, nparams
);
1462 VIR_FREE(new_params
);
1467 libvirt_virDomainGetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1470 virDomainPtr domain
;
1471 PyObject
*pyobj_domain
;
1472 PyObject
*ret
= NULL
;
1476 const char *device
= NULL
;
1477 virTypedParameterPtr params
;
1479 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInterfaceParameters",
1480 &pyobj_domain
, &device
, &flags
))
1482 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1484 LIBVIRT_BEGIN_ALLOW_THREADS
;
1485 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1486 LIBVIRT_END_ALLOW_THREADS
;
1492 return PyDict_New();
1494 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
1495 return PyErr_NoMemory();
1497 LIBVIRT_BEGIN_ALLOW_THREADS
;
1498 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1499 LIBVIRT_END_ALLOW_THREADS
;
1506 ret
= getPyVirTypedParameter(params
, nparams
);
1509 virTypedParamsFree(params
, nparams
);
1514 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
1517 virDomainPtr domain
;
1518 PyObject
*pyobj_domain
, *pyretval
= NULL
, *pycpuinfo
= NULL
, *pycpumap
= NULL
;
1519 PyObject
*error
= NULL
;
1520 virDomainInfo dominfo
;
1521 virVcpuInfoPtr cpuinfo
= NULL
;
1522 unsigned char *cpumap
= NULL
;
1523 size_t cpumaplen
, i
;
1524 int i_retval
, cpunum
;
1526 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
1529 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1531 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1532 return VIR_PY_INT_FAIL
;
1534 LIBVIRT_BEGIN_ALLOW_THREADS
;
1535 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1536 LIBVIRT_END_ALLOW_THREADS
;
1538 return VIR_PY_INT_FAIL
;
1540 if (VIR_ALLOC_N_QUIET(cpuinfo
, dominfo
.nrVirtCpu
) < 0)
1541 return PyErr_NoMemory();
1543 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1544 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1545 VIR_ALLOC_N_QUIET(cpumap
, dominfo
.nrVirtCpu
* cpumaplen
) < 0) {
1546 error
= PyErr_NoMemory();
1550 LIBVIRT_BEGIN_ALLOW_THREADS
;
1551 i_retval
= virDomainGetVcpus(domain
,
1552 cpuinfo
, dominfo
.nrVirtCpu
,
1554 LIBVIRT_END_ALLOW_THREADS
;
1556 error
= VIR_PY_INT_FAIL
;
1560 /* convert to a Python tuple of long objects */
1561 if ((pyretval
= PyTuple_New(2)) == NULL
)
1563 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1565 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1568 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1569 PyObject
*info
= PyTuple_New(4);
1570 PyObject
*item
= NULL
;
1575 if ((item
= PyInt_FromLong((long)cpuinfo
[i
].number
)) == NULL
||
1576 PyTuple_SetItem(info
, 0, item
) < 0)
1579 if ((item
= PyInt_FromLong((long)cpuinfo
[i
].state
)) == NULL
||
1580 PyTuple_SetItem(info
, 1, item
) < 0)
1583 if ((item
= PyLong_FromLongLong((long long)cpuinfo
[i
].cpuTime
)) == NULL
||
1584 PyTuple_SetItem(info
, 2, item
) < 0)
1587 if ((item
= PyInt_FromLong((long)cpuinfo
[i
].cpu
)) == NULL
||
1588 PyTuple_SetItem(info
, 3, item
) < 0)
1591 if (PyList_SetItem(pycpuinfo
, i
, info
) < 0)
1600 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1601 PyObject
*info
= PyTuple_New(cpunum
);
1605 for (j
= 0; j
< cpunum
; j
++) {
1606 PyObject
*item
= NULL
;
1607 if ((item
= PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
, i
, j
))) == NULL
||
1608 PyTuple_SetItem(info
, j
, item
) < 0) {
1614 if (PyList_SetItem(pycpumap
, i
, info
) < 0) {
1619 if (PyTuple_SetItem(pyretval
, 0, pycpuinfo
) < 0 ||
1620 PyTuple_SetItem(pyretval
, 1, pycpumap
) < 0)
1631 Py_XDECREF(pyretval
);
1632 Py_XDECREF(pycpuinfo
);
1633 Py_XDECREF(pycpumap
);
1639 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
1642 virDomainPtr domain
;
1643 PyObject
*pyobj_domain
, *pycpumap
;
1644 PyObject
*ret
= NULL
;
1645 unsigned char *cpumap
;
1646 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1650 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
1651 &pyobj_domain
, &vcpu
, &pycpumap
))
1653 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1655 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1656 return VIR_PY_INT_FAIL
;
1658 if (PyTuple_Check(pycpumap
)) {
1659 tuple_size
= PyTuple_Size(pycpumap
);
1660 if (tuple_size
== -1)
1663 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1667 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1668 if (VIR_ALLOC_N_QUIET(cpumap
, cpumaplen
) < 0)
1669 return PyErr_NoMemory();
1671 for (i
= 0; i
< tuple_size
; i
++) {
1672 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1675 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1679 VIR_USE_CPU(cpumap
, i
);
1681 VIR_UNUSE_CPU(cpumap
, i
);
1684 for (; i
< cpunum
; i
++)
1685 VIR_UNUSE_CPU(cpumap
, i
);
1687 LIBVIRT_BEGIN_ALLOW_THREADS
;
1688 i_retval
= virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
1689 LIBVIRT_END_ALLOW_THREADS
;
1692 ret
= VIR_PY_INT_FAIL
;
1695 ret
= VIR_PY_INT_SUCCESS
;
1703 libvirt_virDomainPinVcpuFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1706 virDomainPtr domain
;
1707 PyObject
*pyobj_domain
, *pycpumap
;
1708 PyObject
*ret
= NULL
;
1709 unsigned char *cpumap
;
1710 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1715 if (!PyArg_ParseTuple(args
, (char *)"OiOi:virDomainPinVcpuFlags",
1716 &pyobj_domain
, &vcpu
, &pycpumap
, &flags
))
1718 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1720 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1721 return VIR_PY_INT_FAIL
;
1723 if (PyTuple_Check(pycpumap
)) {
1724 tuple_size
= PyTuple_Size(pycpumap
);
1725 if (tuple_size
== -1)
1728 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1732 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1733 if (VIR_ALLOC_N_QUIET(cpumap
, cpumaplen
) < 0)
1734 return PyErr_NoMemory();
1736 for (i
= 0; i
< tuple_size
; i
++) {
1737 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1740 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1744 VIR_USE_CPU(cpumap
, i
);
1746 VIR_UNUSE_CPU(cpumap
, i
);
1749 for (; i
< cpunum
; i
++)
1750 VIR_UNUSE_CPU(cpumap
, i
);
1752 LIBVIRT_BEGIN_ALLOW_THREADS
;
1753 i_retval
= virDomainPinVcpuFlags(domain
, vcpu
, cpumap
, cpumaplen
, flags
);
1754 LIBVIRT_END_ALLOW_THREADS
;
1756 ret
= VIR_PY_INT_FAIL
;
1759 ret
= VIR_PY_INT_SUCCESS
;
1767 libvirt_virDomainGetVcpuPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1769 virDomainPtr domain
;
1770 PyObject
*pyobj_domain
, *pycpumaps
= NULL
;
1771 virDomainInfo dominfo
;
1772 unsigned char *cpumaps
;
1773 size_t cpumaplen
, vcpu
, pcpu
;
1775 int i_retval
, cpunum
;
1777 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetVcpuPinInfo",
1778 &pyobj_domain
, &flags
))
1780 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1782 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1783 return VIR_PY_INT_FAIL
;
1785 LIBVIRT_BEGIN_ALLOW_THREADS
;
1786 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1787 LIBVIRT_END_ALLOW_THREADS
;
1791 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1792 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1793 VIR_ALLOC_N_QUIET(cpumaps
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1796 LIBVIRT_BEGIN_ALLOW_THREADS
;
1797 i_retval
= virDomainGetVcpuPinInfo(domain
, dominfo
.nrVirtCpu
,
1798 cpumaps
, cpumaplen
, flags
);
1799 LIBVIRT_END_ALLOW_THREADS
;
1803 if ((pycpumaps
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1806 for (vcpu
= 0; vcpu
< dominfo
.nrVirtCpu
; vcpu
++) {
1807 PyObject
*mapinfo
= PyTuple_New(cpunum
);
1808 if (mapinfo
== NULL
)
1811 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1812 PyTuple_SetItem(mapinfo
, pcpu
,
1813 PyBool_FromLong(VIR_CPU_USABLE(cpumaps
, cpumaplen
, vcpu
, pcpu
)));
1815 PyList_SetItem(pycpumaps
, vcpu
, mapinfo
);
1825 Py_XDECREF(pycpumaps
);
1832 libvirt_virDomainPinEmulator(PyObject
*self ATTRIBUTE_UNUSED
,
1835 virDomainPtr domain
;
1836 PyObject
*pyobj_domain
, *pycpumap
;
1837 unsigned char *cpumap
= NULL
;
1838 int cpumaplen
, tuple_size
, cpunum
;
1843 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainPinVcpu",
1844 &pyobj_domain
, &pycpumap
, &flags
))
1847 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1849 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1850 return VIR_PY_INT_FAIL
;
1852 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1854 if (!PyTuple_Check(pycpumap
)) {
1855 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1859 if ((tuple_size
= PyTuple_Size(pycpumap
)) == -1)
1862 if (VIR_ALLOC_N_QUIET(cpumap
, cpumaplen
) < 0)
1863 return PyErr_NoMemory();
1865 for (i
= 0; i
< tuple_size
; i
++) {
1866 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1869 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0) {
1871 return VIR_PY_INT_FAIL
;
1875 VIR_USE_CPU(cpumap
, i
);
1877 VIR_UNUSE_CPU(cpumap
, i
);
1880 for (; i
< cpunum
; i
++)
1881 VIR_UNUSE_CPU(cpumap
, i
);
1883 LIBVIRT_BEGIN_ALLOW_THREADS
;
1884 i_retval
= virDomainPinEmulator(domain
, cpumap
, cpumaplen
, flags
);
1885 LIBVIRT_END_ALLOW_THREADS
;
1890 return VIR_PY_INT_FAIL
;
1892 return VIR_PY_INT_SUCCESS
;
1897 libvirt_virDomainGetEmulatorPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1900 virDomainPtr domain
;
1901 PyObject
*pyobj_domain
;
1903 unsigned char *cpumap
;
1910 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainEmulatorPinInfo",
1911 &pyobj_domain
, &flags
))
1914 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1916 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1919 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1921 if (VIR_ALLOC_N_QUIET(cpumap
, cpumaplen
) < 0)
1922 return PyErr_NoMemory();
1924 LIBVIRT_BEGIN_ALLOW_THREADS
;
1925 ret
= virDomainGetEmulatorPinInfo(domain
, cpumap
, cpumaplen
, flags
);
1926 LIBVIRT_END_ALLOW_THREADS
;
1932 if (!(pycpumap
= PyTuple_New(cpunum
))) {
1937 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++)
1938 PyTuple_SET_ITEM(pycpumap
, pcpu
,
1939 PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
,
1947 /************************************************************************
1949 * Global error handler at the Python level *
1951 ************************************************************************/
1953 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
1954 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
1957 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args ATTRIBUTE_UNUSED
)
1962 if ((err
= virGetLastError()) == NULL
)
1965 if ((info
= PyTuple_New(9)) == NULL
)
1967 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
1968 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
1969 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
1970 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
1971 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
1972 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
1973 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
1974 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
1975 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
1981 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
1986 PyObject
*pyobj_conn
;
1988 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
1990 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1992 LIBVIRT_BEGIN_ALLOW_THREADS
;
1993 err
= virConnGetLastError(conn
);
1994 LIBVIRT_END_ALLOW_THREADS
;
1998 if ((info
= PyTuple_New(9)) == NULL
)
2000 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
2001 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
2002 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
2003 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
2004 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
2005 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
2006 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
2007 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
2008 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
2014 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
, virErrorPtr err
)
2016 PyObject
*list
, *info
;
2019 DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
2022 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
2025 LIBVIRT_ENSURE_THREAD_STATE
;
2027 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
2028 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
2029 virDefaultErrorFunc(err
);
2031 list
= PyTuple_New(2);
2032 info
= PyTuple_New(9);
2033 PyTuple_SetItem(list
, 0, libvirt_virPythonErrorFuncCtxt
);
2034 PyTuple_SetItem(list
, 1, info
);
2035 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
2036 PyTuple_SetItem(info
, 0, PyInt_FromLong((long) err
->code
));
2037 PyTuple_SetItem(info
, 1, PyInt_FromLong((long) err
->domain
));
2038 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
2039 PyTuple_SetItem(info
, 3, PyInt_FromLong((long) err
->level
));
2040 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
2041 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
2042 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
2043 PyTuple_SetItem(info
, 7, PyInt_FromLong((long) err
->int1
));
2044 PyTuple_SetItem(info
, 8, PyInt_FromLong((long) err
->int2
));
2045 /* TODO pass conn and dom if available */
2046 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
2051 LIBVIRT_RELEASE_THREAD_STATE
;
2055 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
* self
,
2058 PyObject
*py_retval
;
2060 PyObject
*pyobj_ctx
;
2062 if (!PyArg_ParseTuple
2063 (args
, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f
,
2067 DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
2070 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
2071 if (libvirt_virPythonErrorFuncHandler
!= NULL
) {
2072 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
2074 if (libvirt_virPythonErrorFuncCtxt
!= NULL
) {
2075 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
2078 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
2079 libvirt_virPythonErrorFuncHandler
= NULL
;
2080 libvirt_virPythonErrorFuncCtxt
= NULL
;
2082 Py_XINCREF(pyobj_ctx
);
2083 Py_XINCREF(pyobj_f
);
2085 /* TODO: check f is a function ! */
2086 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
2087 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
2090 py_retval
= libvirt_intWrap(1);
2094 static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
2099 PyObject
*pyauth
= (PyObject
*)cbdata
;
2106 LIBVIRT_ENSURE_THREAD_STATE
;
2108 pycb
= PyList_GetItem(pyauth
, 1);
2109 pycbdata
= PyList_GetItem(pyauth
, 2);
2111 list
= PyTuple_New(2);
2112 pycred
= PyTuple_New(ncred
);
2113 for (i
= 0; i
< ncred
; i
++) {
2114 PyObject
*pycreditem
;
2115 pycreditem
= PyList_New(5);
2117 PyTuple_SetItem(pycred
, i
, pycreditem
);
2118 PyList_SetItem(pycreditem
, 0, PyInt_FromLong((long) cred
[i
].type
));
2119 PyList_SetItem(pycreditem
, 1, PyString_FromString(cred
[i
].prompt
));
2120 if (cred
[i
].challenge
) {
2121 PyList_SetItem(pycreditem
, 2, PyString_FromString(cred
[i
].challenge
));
2124 PyList_SetItem(pycreditem
, 2, Py_None
);
2126 if (cred
[i
].defresult
) {
2127 PyList_SetItem(pycreditem
, 3, PyString_FromString(cred
[i
].defresult
));
2130 PyList_SetItem(pycreditem
, 3, Py_None
);
2132 PyList_SetItem(pycreditem
, 4, Py_None
);
2135 PyTuple_SetItem(list
, 0, pycred
);
2136 Py_XINCREF(pycbdata
);
2137 PyTuple_SetItem(list
, 1, pycbdata
);
2140 pyret
= PyEval_CallObject(pycb
, list
);
2141 if (PyErr_Occurred()) {
2146 ret
= PyLong_AsLong(pyret
);
2148 for (i
= 0; i
< ncred
; i
++) {
2149 PyObject
*pycreditem
;
2151 char *result
= NULL
;
2152 pycreditem
= PyTuple_GetItem(pycred
, i
);
2153 pyresult
= PyList_GetItem(pycreditem
, 4);
2154 if (pyresult
!= Py_None
)
2155 result
= PyString_AsString(pyresult
);
2156 if (result
!= NULL
) {
2157 cred
[i
].result
= strdup(result
);
2158 cred
[i
].resultlen
= strlen(result
);
2160 cred
[i
].result
= NULL
;
2161 cred
[i
].resultlen
= 0;
2170 LIBVIRT_RELEASE_THREAD_STATE
;
2177 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2178 PyObject
*py_retval
;
2179 virConnectPtr c_retval
;
2184 PyObject
*pycredtype
;
2185 virConnectAuth auth
;
2187 memset(&auth
, 0, sizeof(auth
));
2188 if (!PyArg_ParseTuple(args
, (char *)"zOi:virConnectOpenAuth", &name
, &pyauth
, &flags
))
2191 pycredtype
= PyList_GetItem(pyauth
, 0);
2192 pycredcb
= PyList_GetItem(pyauth
, 1);
2194 auth
.ncredtype
= PyList_Size(pycredtype
);
2195 if (auth
.ncredtype
) {
2197 if (VIR_ALLOC_N_QUIET(auth
.credtype
, auth
.ncredtype
) < 0)
2199 for (i
= 0; i
< auth
.ncredtype
; i
++) {
2201 val
= PyList_GetItem(pycredtype
, i
);
2202 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
2205 if (pycredcb
&& pycredcb
!= Py_None
)
2206 auth
.cb
= virConnectCredCallbackWrapper
;
2207 auth
.cbdata
= pyauth
;
2209 LIBVIRT_BEGIN_ALLOW_THREADS
;
2211 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
2212 LIBVIRT_END_ALLOW_THREADS
;
2213 VIR_FREE(auth
.credtype
);
2214 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
2219 /************************************************************************
2221 * Wrappers for functions where generator fails *
2223 ************************************************************************/
2226 libvirt_virGetVersion(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2229 unsigned long libVer
, typeVer
= 0;
2232 if (!PyArg_ParseTuple(args
, (char *) "|s", &type
))
2235 LIBVIRT_BEGIN_ALLOW_THREADS
;
2238 c_retval
= virGetVersion(&libVer
, NULL
, NULL
);
2240 c_retval
= virGetVersion(&libVer
, type
, &typeVer
);
2242 LIBVIRT_END_ALLOW_THREADS
;
2248 return PyInt_FromLong(libVer
);
2250 return Py_BuildValue((char *) "kk", libVer
, typeVer
);
2254 libvirt_virConnectGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2257 unsigned long hvVersion
;
2260 PyObject
*pyobj_conn
;
2262 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetVersion",
2265 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2267 LIBVIRT_BEGIN_ALLOW_THREADS
;
2269 c_retval
= virConnectGetVersion(conn
, &hvVersion
);
2271 LIBVIRT_END_ALLOW_THREADS
;
2274 return VIR_PY_INT_FAIL
;
2276 return PyInt_FromLong(hvVersion
);
2280 libvirt_virConnectGetLibVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2283 unsigned long libVer
;
2286 PyObject
*pyobj_conn
;
2288 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetLibVersion",
2291 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2293 LIBVIRT_BEGIN_ALLOW_THREADS
;
2295 c_retval
= virConnectGetLibVersion(conn
, &libVer
);
2297 LIBVIRT_END_ALLOW_THREADS
;
2300 return VIR_PY_INT_FAIL
;
2302 return PyInt_FromLong(libVer
);
2306 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
2308 PyObject
*py_retval
;
2309 int *ids
= NULL
, c_retval
;
2312 PyObject
*pyobj_conn
;
2315 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
2317 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2319 LIBVIRT_BEGIN_ALLOW_THREADS
;
2320 c_retval
= virConnectNumOfDomains(conn
);
2321 LIBVIRT_END_ALLOW_THREADS
;
2326 if (VIR_ALLOC_N_QUIET(ids
, c_retval
) < 0)
2329 LIBVIRT_BEGIN_ALLOW_THREADS
;
2330 c_retval
= virConnectListDomains(conn
, ids
, c_retval
);
2331 LIBVIRT_END_ALLOW_THREADS
;
2337 py_retval
= PyList_New(c_retval
);
2340 for (i
= 0; i
< c_retval
; i
++) {
2341 PyList_SetItem(py_retval
, i
, libvirt_intWrap(ids
[i
]));
2350 libvirt_virConnectListAllDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2353 PyObject
*pyobj_conn
;
2354 PyObject
*py_retval
= NULL
;
2355 PyObject
*tmp
= NULL
;
2357 virDomainPtr
*doms
= NULL
;
2362 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllDomains",
2363 &pyobj_conn
, &flags
))
2365 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2367 LIBVIRT_BEGIN_ALLOW_THREADS
;
2368 c_retval
= virConnectListAllDomains(conn
, &doms
, flags
);
2369 LIBVIRT_END_ALLOW_THREADS
;
2373 if (!(py_retval
= PyList_New(c_retval
)))
2376 for (i
= 0; i
< c_retval
; i
++) {
2377 if (!(tmp
= libvirt_virDomainPtrWrap(doms
[i
])) ||
2378 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
2380 Py_DECREF(py_retval
);
2384 /* python steals the pointer */
2389 for (i
= 0; i
< c_retval
; i
++)
2391 virDomainFree(doms
[i
]);
2397 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2399 PyObject
*py_retval
;
2400 char **names
= NULL
;
2404 PyObject
*pyobj_conn
;
2407 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains", &pyobj_conn
))
2409 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2411 LIBVIRT_BEGIN_ALLOW_THREADS
;
2412 c_retval
= virConnectNumOfDefinedDomains(conn
);
2413 LIBVIRT_END_ALLOW_THREADS
;
2418 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
2420 LIBVIRT_BEGIN_ALLOW_THREADS
;
2421 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
2422 LIBVIRT_END_ALLOW_THREADS
;
2428 py_retval
= PyList_New(c_retval
);
2431 for (i
= 0; i
< c_retval
; i
++) {
2432 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2442 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2445 PyObject
*py_retval
;
2446 char **names
= NULL
;
2450 PyObject
*pyobj_dom
;
2451 PyObject
*pyobj_snap
;
2454 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListNames",
2455 &pyobj_dom
, &flags
))
2457 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2459 LIBVIRT_BEGIN_ALLOW_THREADS
;
2460 c_retval
= virDomainSnapshotNum(dom
, flags
);
2461 LIBVIRT_END_ALLOW_THREADS
;
2466 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
2467 return PyErr_NoMemory();
2468 LIBVIRT_BEGIN_ALLOW_THREADS
;
2469 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2470 LIBVIRT_END_ALLOW_THREADS
;
2476 py_retval
= PyList_New(c_retval
);
2480 for (i
= 0; i
< c_retval
; i
++) {
2481 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2482 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2483 Py_XDECREF(pyobj_snap
);
2484 Py_DECREF(py_retval
);
2492 for (i
= 0; i
< c_retval
; i
++)
2499 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2502 PyObject
*py_retval
= NULL
;
2503 virDomainSnapshotPtr
*snaps
= NULL
;
2507 PyObject
*pyobj_dom
;
2509 PyObject
*pyobj_snap
;
2511 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainListAllSnapshots",
2512 &pyobj_dom
, &flags
))
2514 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2516 LIBVIRT_BEGIN_ALLOW_THREADS
;
2517 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2518 LIBVIRT_END_ALLOW_THREADS
;
2522 if (!(py_retval
= PyList_New(c_retval
)))
2525 for (i
= 0; i
< c_retval
; i
++) {
2526 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2527 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2528 Py_XDECREF(pyobj_snap
);
2529 Py_DECREF(py_retval
);
2537 for (i
= 0; i
< c_retval
; i
++)
2539 virDomainSnapshotFree(snaps
[i
]);
2545 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2548 PyObject
*py_retval
;
2549 char **names
= NULL
;
2552 virDomainSnapshotPtr snap
;
2553 PyObject
*pyobj_snap
;
2556 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListChildrenNames",
2557 &pyobj_snap
, &flags
))
2559 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2561 LIBVIRT_BEGIN_ALLOW_THREADS
;
2562 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2563 LIBVIRT_END_ALLOW_THREADS
;
2568 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
2569 return PyErr_NoMemory();
2570 LIBVIRT_BEGIN_ALLOW_THREADS
;
2571 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2573 LIBVIRT_END_ALLOW_THREADS
;
2579 py_retval
= PyList_New(c_retval
);
2581 for (i
= 0; i
< c_retval
; i
++) {
2582 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2583 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2584 Py_XDECREF(pyobj_snap
);
2585 Py_DECREF(py_retval
);
2593 for (i
= 0; i
< c_retval
; i
++)
2600 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2603 PyObject
*py_retval
= NULL
;
2604 virDomainSnapshotPtr
*snaps
= NULL
;
2607 virDomainSnapshotPtr parent
;
2608 PyObject
*pyobj_parent
;
2610 PyObject
*pyobj_snap
;
2612 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListAllChildren",
2613 &pyobj_parent
, &flags
))
2615 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2617 LIBVIRT_BEGIN_ALLOW_THREADS
;
2618 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2619 LIBVIRT_END_ALLOW_THREADS
;
2623 if (!(py_retval
= PyList_New(c_retval
)))
2626 for (i
= 0; i
< c_retval
; i
++) {
2627 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2628 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2629 Py_XDECREF(pyobj_snap
);
2630 Py_DECREF(py_retval
);
2638 for (i
= 0; i
< c_retval
; i
++)
2640 virDomainSnapshotFree(snaps
[i
]);
2646 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2649 virDomainSnapshotPtr snap
;
2650 PyObject
*pyobj_snap
;
2651 PyObject
*pyobj_dom
;
2654 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainRevertToSnapshot", &pyobj_dom
, &pyobj_snap
, &flags
))
2656 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2658 LIBVIRT_BEGIN_ALLOW_THREADS
;
2659 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2660 LIBVIRT_END_ALLOW_THREADS
;
2662 return VIR_PY_INT_FAIL
;
2664 return PyInt_FromLong(c_retval
);
2668 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2669 PyObject
*py_retval
;
2671 virDomainPtr domain
;
2672 PyObject
*pyobj_domain
;
2675 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2677 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2679 LIBVIRT_BEGIN_ALLOW_THREADS
;
2680 c_retval
= virDomainGetInfo(domain
, &info
);
2681 LIBVIRT_END_ALLOW_THREADS
;
2684 py_retval
= PyList_New(5);
2685 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
2686 PyList_SetItem(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
));
2687 PyList_SetItem(py_retval
, 2, libvirt_ulongWrap(info
.memory
));
2688 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.nrVirtCpu
));
2689 PyList_SetItem(py_retval
, 4,
2690 libvirt_longlongWrap((unsigned long long) info
.cpuTime
));
2695 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2697 PyObject
*py_retval
;
2699 virDomainPtr domain
;
2700 PyObject
*pyobj_domain
;
2705 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetState",
2706 &pyobj_domain
, &flags
))
2709 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2711 LIBVIRT_BEGIN_ALLOW_THREADS
;
2712 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2713 LIBVIRT_END_ALLOW_THREADS
;
2717 py_retval
= PyList_New(2);
2718 PyList_SetItem(py_retval
, 0, libvirt_intWrap(state
));
2719 PyList_SetItem(py_retval
, 1, libvirt_intWrap(reason
));
2724 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2725 PyObject
*py_retval
;
2727 virDomainPtr domain
;
2728 PyObject
*pyobj_domain
;
2729 virDomainControlInfo info
;
2732 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetControlInfo",
2733 &pyobj_domain
, &flags
))
2735 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2737 LIBVIRT_BEGIN_ALLOW_THREADS
;
2738 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2739 LIBVIRT_END_ALLOW_THREADS
;
2742 py_retval
= PyList_New(3);
2743 PyList_SetItem(py_retval
, 0, libvirt_intWrap(info
.state
));
2744 PyList_SetItem(py_retval
, 1, libvirt_intWrap(info
.details
));
2745 PyList_SetItem(py_retval
, 2, libvirt_longlongWrap(info
.stateTime
));
2750 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2751 PyObject
*py_retval
;
2753 virDomainPtr domain
;
2754 PyObject
*pyobj_domain
;
2755 virDomainBlockInfo info
;
2759 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInfo", &pyobj_domain
, &path
, &flags
))
2761 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2763 LIBVIRT_BEGIN_ALLOW_THREADS
;
2764 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2765 LIBVIRT_END_ALLOW_THREADS
;
2768 py_retval
= PyList_New(3);
2769 PyList_SetItem(py_retval
, 0, libvirt_ulonglongWrap(info
.capacity
));
2770 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.allocation
));
2771 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.physical
));
2776 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2777 PyObject
*py_retval
;
2780 PyObject
*pyobj_conn
;
2783 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_conn
))
2785 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2787 LIBVIRT_BEGIN_ALLOW_THREADS
;
2788 c_retval
= virNodeGetInfo(conn
, &info
);
2789 LIBVIRT_END_ALLOW_THREADS
;
2792 py_retval
= PyList_New(8);
2793 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&info
.model
[0]));
2794 PyList_SetItem(py_retval
, 1, libvirt_longWrap((long) info
.memory
>> 10));
2795 PyList_SetItem(py_retval
, 2, libvirt_intWrap((int) info
.cpus
));
2796 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.mhz
));
2797 PyList_SetItem(py_retval
, 4, libvirt_intWrap((int) info
.nodes
));
2798 PyList_SetItem(py_retval
, 5, libvirt_intWrap((int) info
.sockets
));
2799 PyList_SetItem(py_retval
, 6, libvirt_intWrap((int) info
.cores
));
2800 PyList_SetItem(py_retval
, 7, libvirt_intWrap((int) info
.threads
));
2805 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2806 PyObject
*py_retval
;
2807 unsigned char uuid
[VIR_UUID_BUFLEN
];
2808 virDomainPtr domain
;
2809 PyObject
*pyobj_domain
;
2812 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2814 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2818 LIBVIRT_BEGIN_ALLOW_THREADS
;
2819 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
2820 LIBVIRT_END_ALLOW_THREADS
;
2824 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
2830 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
2832 PyObject
*py_retval
;
2833 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
2835 PyObject
*pyobj_dom
;
2838 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
2841 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2845 LIBVIRT_BEGIN_ALLOW_THREADS
;
2846 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
2847 LIBVIRT_END_ALLOW_THREADS
;
2852 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
2857 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2858 PyObject
*py_retval
;
2859 virDomainPtr c_retval
;
2861 PyObject
*pyobj_conn
;
2862 unsigned char * uuid
;
2865 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn
, &uuid
, &len
))
2867 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2869 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
2872 LIBVIRT_BEGIN_ALLOW_THREADS
;
2873 c_retval
= virDomainLookupByUUID(conn
, uuid
);
2874 LIBVIRT_END_ALLOW_THREADS
;
2875 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
2881 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2883 PyObject
*py_retval
;
2884 char **names
= NULL
;
2888 PyObject
*pyobj_conn
;
2891 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks", &pyobj_conn
))
2893 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2895 LIBVIRT_BEGIN_ALLOW_THREADS
;
2896 c_retval
= virConnectNumOfNetworks(conn
);
2897 LIBVIRT_END_ALLOW_THREADS
;
2902 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
2904 LIBVIRT_BEGIN_ALLOW_THREADS
;
2905 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
2906 LIBVIRT_END_ALLOW_THREADS
;
2912 py_retval
= PyList_New(c_retval
);
2915 for (i
= 0; i
< c_retval
; i
++) {
2916 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2927 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2929 PyObject
*py_retval
;
2930 char **names
= NULL
;
2934 PyObject
*pyobj_conn
;
2937 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn
))
2939 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2941 LIBVIRT_BEGIN_ALLOW_THREADS
;
2942 c_retval
= virConnectNumOfDefinedNetworks(conn
);
2943 LIBVIRT_END_ALLOW_THREADS
;
2948 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
2950 LIBVIRT_BEGIN_ALLOW_THREADS
;
2951 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
2952 LIBVIRT_END_ALLOW_THREADS
;
2958 py_retval
= PyList_New(c_retval
);
2961 for (i
= 0; i
< c_retval
; i
++) {
2962 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2972 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2975 PyObject
*pyobj_conn
;
2976 PyObject
*py_retval
= NULL
;
2977 PyObject
*tmp
= NULL
;
2979 virNetworkPtr
*nets
= NULL
;
2984 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNetworks",
2985 &pyobj_conn
, &flags
))
2987 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2989 LIBVIRT_BEGIN_ALLOW_THREADS
;
2990 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
2991 LIBVIRT_END_ALLOW_THREADS
;
2995 if (!(py_retval
= PyList_New(c_retval
)))
2998 for (i
= 0; i
< c_retval
; i
++) {
2999 if (!(tmp
= libvirt_virNetworkPtrWrap(nets
[i
])) ||
3000 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3002 Py_DECREF(py_retval
);
3006 /* python steals the pointer */
3011 for (i
= 0; i
< c_retval
; i
++)
3013 virNetworkFree(nets
[i
]);
3020 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3021 PyObject
*py_retval
;
3022 unsigned char uuid
[VIR_UUID_BUFLEN
];
3023 virNetworkPtr domain
;
3024 PyObject
*pyobj_domain
;
3027 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
3029 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
3033 LIBVIRT_BEGIN_ALLOW_THREADS
;
3034 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
3035 LIBVIRT_END_ALLOW_THREADS
;
3039 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3045 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3047 PyObject
*py_retval
;
3048 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3050 PyObject
*pyobj_net
;
3053 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
3056 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
3060 LIBVIRT_BEGIN_ALLOW_THREADS
;
3061 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
3062 LIBVIRT_END_ALLOW_THREADS
;
3067 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3072 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3073 PyObject
*py_retval
;
3074 virNetworkPtr c_retval
;
3076 PyObject
*pyobj_conn
;
3077 unsigned char * uuid
;
3080 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3082 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3084 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3087 LIBVIRT_BEGIN_ALLOW_THREADS
;
3088 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
3089 LIBVIRT_END_ALLOW_THREADS
;
3090 py_retval
= libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
3096 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3097 PyObject
*py_retval
;
3098 int c_retval
, autostart
;
3099 virDomainPtr domain
;
3100 PyObject
*pyobj_domain
;
3102 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart", &pyobj_domain
))
3105 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3107 LIBVIRT_BEGIN_ALLOW_THREADS
;
3108 c_retval
= virDomainGetAutostart(domain
, &autostart
);
3109 LIBVIRT_END_ALLOW_THREADS
;
3112 return VIR_PY_INT_FAIL
;
3113 py_retval
= libvirt_intWrap(autostart
);
3119 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3120 PyObject
*py_retval
;
3121 int c_retval
, autostart
;
3122 virNetworkPtr network
;
3123 PyObject
*pyobj_network
;
3125 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart", &pyobj_network
))
3128 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
3130 LIBVIRT_BEGIN_ALLOW_THREADS
;
3131 c_retval
= virNetworkGetAutostart(network
, &autostart
);
3132 LIBVIRT_END_ALLOW_THREADS
;
3135 return VIR_PY_INT_FAIL
;
3136 py_retval
= libvirt_intWrap(autostart
);
3141 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3143 PyObject
*py_retval
;
3144 PyObject
*pyobj_conn
;
3145 int startCell
, maxCells
, c_retval
;
3148 unsigned long long *freeMems
;
3150 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn
, &startCell
, &maxCells
))
3153 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
3156 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3157 if (VIR_ALLOC_N_QUIET(freeMems
, maxCells
) < 0)
3160 LIBVIRT_BEGIN_ALLOW_THREADS
;
3161 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
3162 LIBVIRT_END_ALLOW_THREADS
;
3168 py_retval
= PyList_New(c_retval
);
3169 for (i
= 0; i
< c_retval
; i
++) {
3170 PyList_SetItem(py_retval
, i
,
3171 libvirt_longlongWrap((long long) freeMems
[i
]));
3178 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3180 PyObject
*ret
= NULL
;
3181 PyObject
*key
= NULL
;
3182 PyObject
*val
= NULL
;
3183 PyObject
*pyobj_conn
;
3186 int cpuNum
, c_retval
;
3189 virNodeCPUStatsPtr stats
= NULL
;
3191 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCPUStats", &pyobj_conn
, &cpuNum
, &flags
))
3193 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3195 LIBVIRT_BEGIN_ALLOW_THREADS
;
3196 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
3197 LIBVIRT_END_ALLOW_THREADS
;
3202 if (VIR_ALLOC_N_QUIET(stats
, nparams
) < 0)
3203 return PyErr_NoMemory();
3205 LIBVIRT_BEGIN_ALLOW_THREADS
;
3206 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
3207 LIBVIRT_END_ALLOW_THREADS
;
3214 if (!(ret
= PyDict_New()))
3217 for (i
= 0; i
< nparams
; i
++) {
3218 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3219 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3221 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
3242 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3244 PyObject
*ret
= NULL
;
3245 PyObject
*key
= NULL
;
3246 PyObject
*val
= NULL
;
3247 PyObject
*pyobj_conn
;
3250 int cellNum
, c_retval
;
3253 virNodeMemoryStatsPtr stats
= NULL
;
3255 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetMemoryStats", &pyobj_conn
, &cellNum
, &flags
))
3257 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3259 LIBVIRT_BEGIN_ALLOW_THREADS
;
3260 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
3261 LIBVIRT_END_ALLOW_THREADS
;
3266 if (VIR_ALLOC_N_QUIET(stats
, nparams
) < 0)
3267 return PyErr_NoMemory();
3269 LIBVIRT_BEGIN_ALLOW_THREADS
;
3270 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
3271 LIBVIRT_END_ALLOW_THREADS
;
3278 if (!(ret
= PyDict_New()))
3281 for (i
= 0; i
< nparams
; i
++) {
3282 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3283 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3285 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
3306 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3308 PyObject
*py_retval
;
3309 char **names
= NULL
;
3313 PyObject
*pyobj_conn
;
3316 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools", &pyobj_conn
))
3318 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3320 LIBVIRT_BEGIN_ALLOW_THREADS
;
3321 c_retval
= virConnectNumOfStoragePools(conn
);
3322 LIBVIRT_END_ALLOW_THREADS
;
3327 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
3329 LIBVIRT_BEGIN_ALLOW_THREADS
;
3330 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
3331 LIBVIRT_END_ALLOW_THREADS
;
3337 py_retval
= PyList_New(c_retval
);
3338 if (py_retval
== NULL
) {
3340 for (i
= 0; i
< c_retval
; i
++)
3348 for (i
= 0; i
< c_retval
; i
++) {
3349 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3360 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3362 PyObject
*py_retval
;
3363 char **names
= NULL
;
3367 PyObject
*pyobj_conn
;
3370 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn
))
3372 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3374 LIBVIRT_BEGIN_ALLOW_THREADS
;
3375 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3376 LIBVIRT_END_ALLOW_THREADS
;
3381 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
3383 LIBVIRT_BEGIN_ALLOW_THREADS
;
3384 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3385 LIBVIRT_END_ALLOW_THREADS
;
3391 py_retval
= PyList_New(c_retval
);
3392 if (py_retval
== NULL
) {
3394 for (i
= 0; i
< c_retval
; i
++)
3402 for (i
= 0; i
< c_retval
; i
++) {
3403 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3413 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3416 PyObject
*pyobj_conn
;
3417 PyObject
*py_retval
= NULL
;
3418 PyObject
*tmp
= NULL
;
3420 virStoragePoolPtr
*pools
= NULL
;
3425 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllStoragePools",
3426 &pyobj_conn
, &flags
))
3428 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3430 LIBVIRT_BEGIN_ALLOW_THREADS
;
3431 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3432 LIBVIRT_END_ALLOW_THREADS
;
3436 if (!(py_retval
= PyList_New(c_retval
)))
3439 for (i
= 0; i
< c_retval
; i
++) {
3440 if (!(tmp
= libvirt_virStoragePoolPtrWrap(pools
[i
])) ||
3441 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3443 Py_DECREF(py_retval
);
3447 /* python steals the pointer */
3452 for (i
= 0; i
< c_retval
; i
++)
3454 virStoragePoolFree(pools
[i
]);
3460 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3462 PyObject
*py_retval
;
3463 char **names
= NULL
;
3466 virStoragePoolPtr pool
;
3467 PyObject
*pyobj_pool
;
3470 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes", &pyobj_pool
))
3472 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3474 LIBVIRT_BEGIN_ALLOW_THREADS
;
3475 c_retval
= virStoragePoolNumOfVolumes(pool
);
3476 LIBVIRT_END_ALLOW_THREADS
;
3481 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
3483 LIBVIRT_BEGIN_ALLOW_THREADS
;
3484 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3485 LIBVIRT_END_ALLOW_THREADS
;
3491 py_retval
= PyList_New(c_retval
);
3492 if (py_retval
== NULL
) {
3494 for (i
= 0; i
< c_retval
; i
++)
3502 for (i
= 0; i
< c_retval
; i
++) {
3503 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3513 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3516 PyObject
*py_retval
= NULL
;
3517 PyObject
*tmp
= NULL
;
3518 virStoragePoolPtr pool
;
3519 virStorageVolPtr
*vols
= NULL
;
3523 PyObject
*pyobj_pool
;
3525 if (!PyArg_ParseTuple(args
, (char *)"Oi:virStoragePoolListAllVolumes",
3526 &pyobj_pool
, &flags
))
3529 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3531 LIBVIRT_BEGIN_ALLOW_THREADS
;
3532 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3533 LIBVIRT_END_ALLOW_THREADS
;
3537 if (!(py_retval
= PyList_New(c_retval
)))
3540 for (i
= 0; i
< c_retval
; i
++) {
3541 if (!(tmp
= libvirt_virStorageVolPtrWrap(vols
[i
])) ||
3542 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3544 Py_DECREF(py_retval
);
3548 /* python steals the pointer */
3553 for (i
= 0; i
< c_retval
; i
++)
3555 virStorageVolFree(vols
[i
]);
3562 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3563 PyObject
*py_retval
;
3564 int c_retval
, autostart
;
3565 virStoragePoolPtr pool
;
3566 PyObject
*pyobj_pool
;
3568 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool
))
3571 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3573 LIBVIRT_BEGIN_ALLOW_THREADS
;
3574 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3575 LIBVIRT_END_ALLOW_THREADS
;
3580 py_retval
= libvirt_intWrap(autostart
);
3585 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3586 PyObject
*py_retval
;
3588 virStoragePoolPtr pool
;
3589 PyObject
*pyobj_pool
;
3590 virStoragePoolInfo info
;
3592 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3594 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3596 LIBVIRT_BEGIN_ALLOW_THREADS
;
3597 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3598 LIBVIRT_END_ALLOW_THREADS
;
3602 if ((py_retval
= PyList_New(4)) == NULL
)
3605 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
3606 PyList_SetItem(py_retval
, 1,
3607 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3608 PyList_SetItem(py_retval
, 2,
3609 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3610 PyList_SetItem(py_retval
, 3,
3611 libvirt_longlongWrap((unsigned long long) info
.available
));
3617 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3618 PyObject
*py_retval
;
3620 virStorageVolPtr pool
;
3621 PyObject
*pyobj_pool
;
3622 virStorageVolInfo info
;
3624 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3626 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3628 LIBVIRT_BEGIN_ALLOW_THREADS
;
3629 c_retval
= virStorageVolGetInfo(pool
, &info
);
3630 LIBVIRT_END_ALLOW_THREADS
;
3634 if ((py_retval
= PyList_New(3)) == NULL
)
3636 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
3637 PyList_SetItem(py_retval
, 1,
3638 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3639 PyList_SetItem(py_retval
, 2,
3640 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3645 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3646 PyObject
*py_retval
;
3647 unsigned char uuid
[VIR_UUID_BUFLEN
];
3648 virStoragePoolPtr pool
;
3649 PyObject
*pyobj_pool
;
3652 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3654 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3658 LIBVIRT_BEGIN_ALLOW_THREADS
;
3659 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3660 LIBVIRT_END_ALLOW_THREADS
;
3665 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3671 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3673 PyObject
*py_retval
;
3674 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3675 virStoragePoolPtr pool
;
3676 PyObject
*pyobj_pool
;
3679 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool
))
3681 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3685 LIBVIRT_BEGIN_ALLOW_THREADS
;
3686 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3687 LIBVIRT_END_ALLOW_THREADS
;
3692 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3697 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3698 PyObject
*py_retval
;
3699 virStoragePoolPtr c_retval
;
3701 PyObject
*pyobj_conn
;
3702 unsigned char * uuid
;
3705 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3707 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3709 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3712 LIBVIRT_BEGIN_ALLOW_THREADS
;
3713 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
3714 LIBVIRT_END_ALLOW_THREADS
;
3715 py_retval
= libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
3720 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3722 PyObject
*py_retval
;
3723 char **names
= NULL
;
3727 PyObject
*pyobj_conn
;
3731 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virNodeListDevices",
3732 &pyobj_conn
, &cap
, &flags
))
3734 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3736 LIBVIRT_BEGIN_ALLOW_THREADS
;
3737 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
3738 LIBVIRT_END_ALLOW_THREADS
;
3743 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
3745 LIBVIRT_BEGIN_ALLOW_THREADS
;
3746 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
3747 LIBVIRT_END_ALLOW_THREADS
;
3753 py_retval
= PyList_New(c_retval
);
3756 for (i
= 0; i
< c_retval
; i
++) {
3757 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3767 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3770 PyObject
*pyobj_conn
;
3771 PyObject
*py_retval
= NULL
;
3772 PyObject
*tmp
= NULL
;
3774 virNodeDevicePtr
*devices
= NULL
;
3779 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNodeDevices",
3780 &pyobj_conn
, &flags
))
3782 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3784 LIBVIRT_BEGIN_ALLOW_THREADS
;
3785 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
3786 LIBVIRT_END_ALLOW_THREADS
;
3790 if (!(py_retval
= PyList_New(c_retval
)))
3793 for (i
= 0; i
< c_retval
; i
++) {
3794 if (!(tmp
= libvirt_virNodeDevicePtrWrap(devices
[i
])) ||
3795 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3797 Py_DECREF(py_retval
);
3801 /* python steals the pointer */
3806 for (i
= 0; i
< c_retval
; i
++)
3808 virNodeDeviceFree(devices
[i
]);
3814 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
3816 PyObject
*py_retval
;
3817 char **names
= NULL
;
3820 virNodeDevicePtr dev
;
3821 PyObject
*pyobj_dev
;
3823 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
3825 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
3827 LIBVIRT_BEGIN_ALLOW_THREADS
;
3828 c_retval
= virNodeDeviceNumOfCaps(dev
);
3829 LIBVIRT_END_ALLOW_THREADS
;
3834 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
3836 LIBVIRT_BEGIN_ALLOW_THREADS
;
3837 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
3838 LIBVIRT_END_ALLOW_THREADS
;
3844 py_retval
= PyList_New(c_retval
);
3847 for (i
= 0; i
< c_retval
; i
++) {
3848 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3858 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3859 PyObject
*py_retval
;
3860 unsigned char uuid
[VIR_UUID_BUFLEN
];
3861 virSecretPtr secret
;
3862 PyObject
*pyobj_secret
;
3865 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
3867 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
3871 LIBVIRT_BEGIN_ALLOW_THREADS
;
3872 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
3873 LIBVIRT_END_ALLOW_THREADS
;
3877 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3883 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3885 PyObject
*py_retval
;
3886 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3888 PyObject
*pyobj_dom
;
3891 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
3894 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
3898 LIBVIRT_BEGIN_ALLOW_THREADS
;
3899 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
3900 LIBVIRT_END_ALLOW_THREADS
;
3905 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
3910 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3911 PyObject
*py_retval
;
3912 virSecretPtr c_retval
;
3914 PyObject
*pyobj_conn
;
3915 unsigned char * uuid
;
3918 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3920 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3922 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3925 LIBVIRT_BEGIN_ALLOW_THREADS
;
3926 c_retval
= virSecretLookupByUUID(conn
, uuid
);
3927 LIBVIRT_END_ALLOW_THREADS
;
3928 py_retval
= libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
3934 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
3936 PyObject
*py_retval
;
3937 char **uuids
= NULL
;
3941 PyObject
*pyobj_conn
;
3943 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
3945 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3947 LIBVIRT_BEGIN_ALLOW_THREADS
;
3948 c_retval
= virConnectNumOfSecrets(conn
);
3949 LIBVIRT_END_ALLOW_THREADS
;
3954 if (VIR_ALLOC_N_QUIET(uuids
, c_retval
) < 0)
3956 LIBVIRT_BEGIN_ALLOW_THREADS
;
3957 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
3958 LIBVIRT_END_ALLOW_THREADS
;
3964 py_retval
= PyList_New(c_retval
);
3967 for (i
= 0; i
< c_retval
; i
++) {
3968 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
3978 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
3981 PyObject
*pyobj_conn
;
3982 PyObject
*py_retval
= NULL
;
3983 PyObject
*tmp
= NULL
;
3985 virSecretPtr
*secrets
= NULL
;
3990 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllSecrets",
3991 &pyobj_conn
, &flags
))
3993 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3995 LIBVIRT_BEGIN_ALLOW_THREADS
;
3996 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
3997 LIBVIRT_END_ALLOW_THREADS
;
4001 if (!(py_retval
= PyList_New(c_retval
)))
4004 for (i
= 0; i
< c_retval
; i
++) {
4005 if (!(tmp
= libvirt_virSecretPtrWrap(secrets
[i
])) ||
4006 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4008 Py_DECREF(py_retval
);
4012 /* python steals the pointer */
4017 for (i
= 0; i
< c_retval
; i
++)
4019 virSecretFree(secrets
[i
]);
4025 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4027 PyObject
*py_retval
;
4028 unsigned char *c_retval
;
4030 virSecretPtr secret
;
4031 PyObject
*pyobj_secret
;
4034 if (!PyArg_ParseTuple(args
, (char *)"Oi:virSecretGetValue", &pyobj_secret
,
4037 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4039 LIBVIRT_BEGIN_ALLOW_THREADS
;
4040 c_retval
= virSecretGetValue(secret
, &size
, flags
);
4041 LIBVIRT_END_ALLOW_THREADS
;
4043 if (c_retval
== NULL
)
4046 py_retval
= PyString_FromStringAndSize((const char *)c_retval
, size
);
4053 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4055 PyObject
*py_retval
;
4057 virSecretPtr secret
;
4058 PyObject
*pyobj_secret
;
4063 if (!PyArg_ParseTuple(args
, (char *)"Oz#i:virSecretSetValue", &pyobj_secret
,
4064 &value
, &size
, &flags
))
4066 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4068 LIBVIRT_BEGIN_ALLOW_THREADS
;
4069 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
4071 LIBVIRT_END_ALLOW_THREADS
;
4073 py_retval
= libvirt_intWrap(c_retval
);
4078 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4079 PyObject
*py_retval
;
4080 unsigned char uuid
[VIR_UUID_BUFLEN
];
4081 virNWFilterPtr nwfilter
;
4082 PyObject
*pyobj_nwfilter
;
4085 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID", &pyobj_nwfilter
))
4087 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4089 if (nwfilter
== NULL
)
4091 LIBVIRT_BEGIN_ALLOW_THREADS
;
4092 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
4093 LIBVIRT_END_ALLOW_THREADS
;
4097 py_retval
= PyString_FromStringAndSize((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4103 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4105 PyObject
*py_retval
;
4106 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4107 virNWFilterPtr nwfilter
;
4108 PyObject
*pyobj_nwfilter
;
4111 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
4114 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4116 if (nwfilter
== NULL
)
4118 LIBVIRT_BEGIN_ALLOW_THREADS
;
4119 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
4120 LIBVIRT_END_ALLOW_THREADS
;
4125 py_retval
= PyString_FromString((char *) &uuidstr
[0]);
4130 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4131 PyObject
*py_retval
;
4132 virNWFilterPtr c_retval
;
4134 PyObject
*pyobj_conn
;
4135 unsigned char * uuid
;
4138 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID", &pyobj_conn
, &uuid
, &len
))
4140 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4142 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4145 LIBVIRT_BEGIN_ALLOW_THREADS
;
4146 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
4147 LIBVIRT_END_ALLOW_THREADS
;
4148 py_retval
= libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
4154 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4156 PyObject
*py_retval
;
4157 char **uuids
= NULL
;
4161 PyObject
*pyobj_conn
;
4163 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters", &pyobj_conn
))
4165 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4167 LIBVIRT_BEGIN_ALLOW_THREADS
;
4168 c_retval
= virConnectNumOfNWFilters(conn
);
4169 LIBVIRT_END_ALLOW_THREADS
;
4174 if (VIR_ALLOC_N_QUIET(uuids
, c_retval
) < 0)
4176 LIBVIRT_BEGIN_ALLOW_THREADS
;
4177 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
4178 LIBVIRT_END_ALLOW_THREADS
;
4184 py_retval
= PyList_New(c_retval
);
4187 for (i
= 0; i
< c_retval
; i
++) {
4188 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
4198 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4201 PyObject
*pyobj_conn
;
4202 PyObject
*py_retval
= NULL
;
4203 PyObject
*tmp
= NULL
;
4205 virNWFilterPtr
*filters
= NULL
;
4210 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNWFilters",
4211 &pyobj_conn
, &flags
))
4213 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4215 LIBVIRT_BEGIN_ALLOW_THREADS
;
4216 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
4217 LIBVIRT_END_ALLOW_THREADS
;
4221 if (!(py_retval
= PyList_New(c_retval
)))
4224 for (i
= 0; i
< c_retval
; i
++) {
4225 if (!(tmp
= libvirt_virNWFilterPtrWrap(filters
[i
])) ||
4226 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4228 Py_DECREF(py_retval
);
4232 /* python steals the pointer */
4237 for (i
= 0; i
< c_retval
; i
++)
4239 virNWFilterFree(filters
[i
]);
4245 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4247 PyObject
*py_retval
;
4248 char **names
= NULL
;
4252 PyObject
*pyobj_conn
;
4255 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces", &pyobj_conn
))
4257 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4259 LIBVIRT_BEGIN_ALLOW_THREADS
;
4260 c_retval
= virConnectNumOfInterfaces(conn
);
4261 LIBVIRT_END_ALLOW_THREADS
;
4266 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
4268 LIBVIRT_BEGIN_ALLOW_THREADS
;
4269 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
4270 LIBVIRT_END_ALLOW_THREADS
;
4276 py_retval
= PyList_New(c_retval
);
4277 if (py_retval
== NULL
) {
4279 for (i
= 0; i
< c_retval
; i
++)
4287 for (i
= 0; i
< c_retval
; i
++) {
4288 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
4299 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4301 PyObject
*py_retval
;
4302 char **names
= NULL
;
4306 PyObject
*pyobj_conn
;
4309 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
4312 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4314 LIBVIRT_BEGIN_ALLOW_THREADS
;
4315 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
4316 LIBVIRT_END_ALLOW_THREADS
;
4321 if (VIR_ALLOC_N_QUIET(names
, c_retval
) < 0)
4323 LIBVIRT_BEGIN_ALLOW_THREADS
;
4324 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
4325 LIBVIRT_END_ALLOW_THREADS
;
4331 py_retval
= PyList_New(c_retval
);
4332 if (py_retval
== NULL
) {
4334 for (i
= 0; i
< c_retval
; i
++)
4342 for (i
= 0; i
< c_retval
; i
++) {
4343 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
4354 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4357 PyObject
*pyobj_conn
;
4358 PyObject
*py_retval
= NULL
;
4359 PyObject
*tmp
= NULL
;
4361 virInterfacePtr
*ifaces
= NULL
;
4366 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllInterfaces",
4367 &pyobj_conn
, &flags
))
4369 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4371 LIBVIRT_BEGIN_ALLOW_THREADS
;
4372 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
4373 LIBVIRT_END_ALLOW_THREADS
;
4377 if (!(py_retval
= PyList_New(c_retval
)))
4380 for (i
= 0; i
< c_retval
; i
++) {
4381 if (!(tmp
= libvirt_virInterfacePtrWrap(ifaces
[i
])) ||
4382 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4384 Py_DECREF(py_retval
);
4388 /* python steals the pointer */
4393 for (i
= 0; i
< c_retval
; i
++)
4395 virInterfaceFree(ifaces
[i
]);
4401 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4403 PyObject
*pyobj_conn
;
4407 const char **xmlcpus
= NULL
;
4410 PyObject
*pybase_cpu
;
4412 if (!PyArg_ParseTuple(args
, (char *)"OOi:virConnectBaselineCPU",
4413 &pyobj_conn
, &list
, &flags
))
4415 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4417 if (PyList_Check(list
)) {
4420 ncpus
= PyList_Size(list
);
4421 if (VIR_ALLOC_N_QUIET(xmlcpus
, ncpus
) < 0)
4422 return VIR_PY_INT_FAIL
;
4424 for (i
= 0; i
< ncpus
; i
++) {
4425 xmlcpus
[i
] = PyString_AsString(PyList_GetItem(list
, i
));
4426 if (xmlcpus
[i
] == NULL
) {
4428 return VIR_PY_INT_FAIL
;
4433 LIBVIRT_BEGIN_ALLOW_THREADS
;
4434 base_cpu
= virConnectBaselineCPU(conn
, xmlcpus
, ncpus
, flags
);
4435 LIBVIRT_END_ALLOW_THREADS
;
4439 if (base_cpu
== NULL
)
4440 return VIR_PY_INT_FAIL
;
4442 pybase_cpu
= PyString_FromString(base_cpu
);
4445 if (pybase_cpu
== NULL
)
4446 return VIR_PY_INT_FAIL
;
4453 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4454 PyObject
*py_retval
;
4456 virDomainPtr domain
;
4457 PyObject
*pyobj_domain
;
4458 virDomainJobInfo info
;
4460 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4462 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4464 LIBVIRT_BEGIN_ALLOW_THREADS
;
4465 c_retval
= virDomainGetJobInfo(domain
, &info
);
4466 LIBVIRT_END_ALLOW_THREADS
;
4469 py_retval
= PyList_New(12);
4470 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
4471 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.timeElapsed
));
4472 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.timeRemaining
));
4473 PyList_SetItem(py_retval
, 3, libvirt_ulonglongWrap(info
.dataTotal
));
4474 PyList_SetItem(py_retval
, 4, libvirt_ulonglongWrap(info
.dataProcessed
));
4475 PyList_SetItem(py_retval
, 5, libvirt_ulonglongWrap(info
.dataRemaining
));
4476 PyList_SetItem(py_retval
, 6, libvirt_ulonglongWrap(info
.memTotal
));
4477 PyList_SetItem(py_retval
, 7, libvirt_ulonglongWrap(info
.memProcessed
));
4478 PyList_SetItem(py_retval
, 8, libvirt_ulonglongWrap(info
.memRemaining
));
4479 PyList_SetItem(py_retval
, 9, libvirt_ulonglongWrap(info
.fileTotal
));
4480 PyList_SetItem(py_retval
, 10, libvirt_ulonglongWrap(info
.fileProcessed
));
4481 PyList_SetItem(py_retval
, 11, libvirt_ulonglongWrap(info
.fileRemaining
));
4487 libvirt_virDomainGetJobStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
4489 PyObject
*pyobj_domain
;
4490 virDomainPtr domain
;
4492 virTypedParameterPtr params
= NULL
;
4495 PyObject
*dict
= NULL
;
4498 if (!PyArg_ParseTuple(args
, (char *) "Oi:virDomainGetJobStats",
4499 &pyobj_domain
, &flags
))
4501 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4503 LIBVIRT_BEGIN_ALLOW_THREADS
;
4504 rc
= virDomainGetJobStats(domain
, &type
, ¶ms
, &nparams
, flags
);
4505 LIBVIRT_END_ALLOW_THREADS
;
4509 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
4512 if (PyDict_SetItem(dict
, libvirt_constcharPtrWrap("type"),
4513 libvirt_intWrap(type
)) < 0) {
4520 virTypedParamsFree(params
, nparams
);
4528 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4531 virDomainPtr domain
;
4532 PyObject
*pyobj_domain
;
4535 virDomainBlockJobInfo info
;
4537 PyObject
*type
= NULL
, *bandwidth
= NULL
, *cur
= NULL
, *end
= NULL
;
4540 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockJobInfo",
4541 &pyobj_domain
, &path
, &flags
))
4543 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4545 if ((dict
= PyDict_New()) == NULL
)
4548 LIBVIRT_BEGIN_ALLOW_THREADS
;
4549 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4550 LIBVIRT_END_ALLOW_THREADS
;
4554 } else if (c_ret
< 0) {
4559 if ((type
= libvirt_intWrap(info
.type
)) == NULL
||
4560 PyDict_SetItemString(dict
, "type", type
) < 0)
4564 if ((bandwidth
= libvirt_ulongWrap(info
.bandwidth
)) == NULL
||
4565 PyDict_SetItemString(dict
, "bandwidth", bandwidth
) < 0)
4567 Py_DECREF(bandwidth
);
4569 if ((cur
= libvirt_ulonglongWrap(info
.cur
)) == NULL
||
4570 PyDict_SetItemString(dict
, "cur", cur
) < 0)
4574 if ((end
= libvirt_ulonglongWrap(info
.end
)) == NULL
||
4575 PyDict_SetItemString(dict
, "end", end
) < 0)
4584 Py_XDECREF(bandwidth
);
4591 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4594 virDomainPtr domain
;
4595 PyObject
*pyobj_domain
, *info
;
4596 PyObject
*ret
= NULL
;
4599 Py_ssize_t size
= 0;
4602 virTypedParameterPtr params
, new_params
= NULL
;
4604 if (!PyArg_ParseTuple(args
, (char *)"OzOi:virDomainSetBlockIoTune",
4605 &pyobj_domain
, &disk
, &info
, &flags
))
4607 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4609 if ((size
= PyDict_Size(info
)) < 0)
4613 PyErr_Format(PyExc_LookupError
,
4614 "Need non-empty dictionary to set attributes");
4618 LIBVIRT_BEGIN_ALLOW_THREADS
;
4619 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4620 LIBVIRT_END_ALLOW_THREADS
;
4623 return VIR_PY_INT_FAIL
;
4626 PyErr_Format(PyExc_LookupError
,
4627 "Domain has no settable attributes");
4631 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
4632 return PyErr_NoMemory();
4634 LIBVIRT_BEGIN_ALLOW_THREADS
;
4635 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4636 LIBVIRT_END_ALLOW_THREADS
;
4639 ret
= VIR_PY_INT_FAIL
;
4643 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
4647 LIBVIRT_BEGIN_ALLOW_THREADS
;
4648 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
4649 LIBVIRT_END_ALLOW_THREADS
;
4652 ret
= VIR_PY_INT_FAIL
;
4656 ret
= VIR_PY_INT_SUCCESS
;
4659 virTypedParamsFree(params
, nparams
);
4660 VIR_FREE(new_params
);
4665 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4668 virDomainPtr domain
;
4669 PyObject
*pyobj_domain
;
4670 PyObject
*ret
= NULL
;
4675 virTypedParameterPtr params
;
4677 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockIoTune",
4678 &pyobj_domain
, &disk
, &flags
))
4680 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4682 LIBVIRT_BEGIN_ALLOW_THREADS
;
4683 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4684 LIBVIRT_END_ALLOW_THREADS
;
4690 return PyDict_New();
4692 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
4693 return PyErr_NoMemory();
4695 LIBVIRT_BEGIN_ALLOW_THREADS
;
4696 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4697 LIBVIRT_END_ALLOW_THREADS
;
4704 ret
= getPyVirTypedParameter(params
, nparams
);
4707 virTypedParamsFree(params
, nparams
);
4712 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
4715 PyObject
*py_retval
= VIR_PY_NONE
;
4716 virDomainPtr domain
;
4717 PyObject
*pyobj_domain
;
4719 virDomainDiskErrorPtr disks
= NULL
;
4720 unsigned int ndisks
;
4724 if (!PyArg_ParseTuple(args
, (char *) "Oi:virDomainGetDiskErrors",
4725 &pyobj_domain
, &flags
))
4728 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4730 if ((count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0)) < 0)
4735 if (VIR_ALLOC_N_QUIET(disks
, ndisks
) < 0)
4738 LIBVIRT_BEGIN_ALLOW_THREADS
;
4739 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
4740 LIBVIRT_END_ALLOW_THREADS
;
4746 if (!(py_retval
= PyDict_New()))
4749 for (i
= 0; i
< count
; i
++) {
4750 PyDict_SetItem(py_retval
,
4751 libvirt_constcharPtrWrap(disks
[i
].disk
),
4752 libvirt_intWrap(disks
[i
].error
));
4757 for (i
= 0; i
< count
; i
++)
4758 VIR_FREE(disks
[i
].disk
);
4764 /*******************************************
4765 * Helper functions to avoid importing modules
4766 * for every callback
4767 *******************************************/
4768 static PyObject
*libvirt_module
= NULL
;
4769 static PyObject
*libvirt_dict
= NULL
;
4770 static PyObject
*libvirt_dom_class
= NULL
;
4773 getLibvirtModuleObject(void) {
4775 return libvirt_module
;
4777 // PyImport_ImportModule returns a new reference
4778 /* Bogus (char *) cast for RHEL-5 python API brokenness */
4779 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
4780 if (!libvirt_module
) {
4781 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
4786 return libvirt_module
;
4790 getLibvirtDictObject(void) {
4792 return libvirt_dict
;
4794 // PyModule_GetDict returns a borrowed reference
4795 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
4796 if (!libvirt_dict
) {
4797 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
4802 Py_INCREF(libvirt_dict
);
4803 return libvirt_dict
;
4807 getLibvirtDomainClassObject(void) {
4808 if (libvirt_dom_class
)
4809 return libvirt_dom_class
;
4811 // PyDict_GetItemString returns a borrowed reference
4812 libvirt_dom_class
= PyDict_GetItemString(getLibvirtDictObject(),
4814 if (!libvirt_dom_class
) {
4815 DEBUG("%s Error importing virDomain class\n", __FUNCTION__
);
4820 Py_INCREF(libvirt_dom_class
);
4821 return libvirt_dom_class
;
4825 libvirt_lookupPythonFunc(const char *funcname
)
4827 PyObject
*python_cb
;
4829 /* Lookup the python callback */
4830 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
4833 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
4839 if (!PyCallable_Check(python_cb
)) {
4840 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
4847 /*******************************************
4849 *******************************************/
4852 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
4858 PyObject
*pyobj_ret
;
4860 PyObject
*pyobj_conn_inst
= (PyObject
*)opaque
;
4861 PyObject
*pyobj_dom
;
4863 PyObject
*pyobj_dom_args
;
4864 PyObject
*pyobj_dom_inst
;
4866 PyObject
*dom_class
;
4869 LIBVIRT_ENSURE_THREAD_STATE
;
4871 /* Create a python instance of this virDomainPtr */
4873 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
4874 pyobj_dom_args
= PyTuple_New(2);
4875 if (PyTuple_SetItem(pyobj_dom_args
, 0, pyobj_conn_inst
)!=0) {
4876 DEBUG("%s error creating tuple",__FUNCTION__
);
4879 if (PyTuple_SetItem(pyobj_dom_args
, 1, pyobj_dom
)!=0) {
4880 DEBUG("%s error creating tuple",__FUNCTION__
);
4883 Py_INCREF(pyobj_conn_inst
);
4885 dom_class
= getLibvirtDomainClassObject();
4886 if (!PyClass_Check(dom_class
)) {
4887 DEBUG("%s dom_class is not a class!\n", __FUNCTION__
);
4891 pyobj_dom_inst
= PyInstance_New(dom_class
,
4895 Py_DECREF(pyobj_dom_args
);
4897 if (!pyobj_dom_inst
) {
4898 DEBUG("%s Error creating a python instance of virDomain\n",
4904 /* Call the Callback Dispatcher */
4905 pyobj_ret
= PyObject_CallMethod(pyobj_conn_inst
,
4906 (char*)"_dispatchDomainEventCallbacks",
4912 Py_DECREF(pyobj_dom_inst
);
4915 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
4918 Py_DECREF(pyobj_ret
);
4924 LIBVIRT_RELEASE_THREAD_STATE
;
4929 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
* self
,
4932 PyObject
*py_retval
; /* return value */
4933 PyObject
*pyobj_conn
; /* virConnectPtr */
4934 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
4939 if (!PyArg_ParseTuple
4940 (args
, (char *) "OO:virConnectDomainEventRegister",
4941 &pyobj_conn
, &pyobj_conn_inst
)) {
4942 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
4943 return VIR_PY_INT_FAIL
;
4946 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
4947 pyobj_conn
, pyobj_conn_inst
);
4948 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4950 Py_INCREF(pyobj_conn_inst
);
4952 LIBVIRT_BEGIN_ALLOW_THREADS
;
4954 ret
= virConnectDomainEventRegister(conn
,
4955 libvirt_virConnectDomainEventCallback
,
4956 (void *)pyobj_conn_inst
, NULL
);
4958 LIBVIRT_END_ALLOW_THREADS
;
4960 py_retval
= libvirt_intWrap(ret
);
4965 libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject
* self
,
4968 PyObject
*py_retval
;
4969 PyObject
*pyobj_conn
;
4970 PyObject
*pyobj_conn_inst
;
4975 if (!PyArg_ParseTuple
4976 (args
, (char *) "OO:virConnectDomainEventDeregister",
4977 &pyobj_conn
, &pyobj_conn_inst
))
4980 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
4982 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4984 LIBVIRT_BEGIN_ALLOW_THREADS
;
4986 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
4988 LIBVIRT_END_ALLOW_THREADS
;
4990 Py_DECREF(pyobj_conn_inst
);
4991 py_retval
= libvirt_intWrap(ret
);
4995 /*******************************************
4997 *******************************************/
4998 static PyObject
*addHandleObj
= NULL
;
4999 static char *addHandleName
= NULL
;
5000 static PyObject
*updateHandleObj
= NULL
;
5001 static char *updateHandleName
= NULL
;
5002 static PyObject
*removeHandleObj
= NULL
;
5003 static char *removeHandleName
= NULL
;
5004 static PyObject
*addTimeoutObj
= NULL
;
5005 static char *addTimeoutName
= NULL
;
5006 static PyObject
*updateTimeoutObj
= NULL
;
5007 static char *updateTimeoutName
= NULL
;
5008 static PyObject
*removeTimeoutObj
= NULL
;
5009 static char *removeTimeoutName
= NULL
;
5011 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
5014 libvirt_virEventAddHandleFunc (int fd
,
5016 virEventHandleCallback cb
,
5021 PyObject
*python_cb
;
5024 PyObject
*opaque_obj
;
5026 PyObject
*pyobj_args
;
5029 LIBVIRT_ENSURE_THREAD_STATE
;
5031 /* Lookup the python callback */
5032 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
5036 Py_INCREF(python_cb
);
5038 /* create tuple for cb */
5039 cb_obj
= libvirt_virEventHandleCallbackWrap(cb
);
5040 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
5041 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
5043 cb_args
= PyTuple_New(3);
5044 PyTuple_SetItem(cb_args
, 0, cb_obj
);
5045 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
5046 PyTuple_SetItem(cb_args
, 2, ff_obj
);
5048 pyobj_args
= PyTuple_New(4);
5049 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(fd
));
5050 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
5051 PyTuple_SetItem(pyobj_args
, 2, python_cb
);
5052 PyTuple_SetItem(pyobj_args
, 3, cb_args
);
5054 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
5058 } else if (!PyInt_Check(result
)) {
5059 DEBUG("%s: %s should return an int\n", __FUNCTION__
, NAME(addHandle
));
5061 retval
= (int)PyInt_AsLong(result
);
5065 Py_DECREF(pyobj_args
);
5068 LIBVIRT_RELEASE_THREAD_STATE
;
5074 libvirt_virEventUpdateHandleFunc(int watch
, int event
)
5077 PyObject
*pyobj_args
;
5079 LIBVIRT_ENSURE_THREAD_STATE
;
5081 pyobj_args
= PyTuple_New(2);
5082 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
5083 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
5085 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
5092 Py_DECREF(pyobj_args
);
5094 LIBVIRT_RELEASE_THREAD_STATE
;
5099 libvirt_virEventRemoveHandleFunc(int watch
)
5102 PyObject
*pyobj_args
;
5106 virFreeCallback cff
;
5108 LIBVIRT_ENSURE_THREAD_STATE
;
5110 pyobj_args
= PyTuple_New(1);
5111 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
5113 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
5117 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5118 DEBUG("%s: %s must return opaque obj registered with %s"
5119 "to avoid leaking libvirt memory\n",
5120 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
5122 opaque
= PyTuple_GetItem(result
, 1);
5123 ff
= PyTuple_GetItem(result
, 2);
5124 cff
= PyvirFreeCallback_Get(ff
);
5126 (*cff
)(PyvirVoidPtr_Get(opaque
));
5131 Py_DECREF(pyobj_args
);
5133 LIBVIRT_RELEASE_THREAD_STATE
;
5140 libvirt_virEventAddTimeoutFunc(int timeout
,
5141 virEventTimeoutCallback cb
,
5147 PyObject
*python_cb
;
5151 PyObject
*opaque_obj
;
5153 PyObject
*pyobj_args
;
5156 LIBVIRT_ENSURE_THREAD_STATE
;
5158 /* Lookup the python callback */
5159 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
5163 Py_INCREF(python_cb
);
5165 /* create tuple for cb */
5166 cb_obj
= libvirt_virEventTimeoutCallbackWrap(cb
);
5167 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
5168 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
5170 cb_args
= PyTuple_New(3);
5171 PyTuple_SetItem(cb_args
, 0, cb_obj
);
5172 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
5173 PyTuple_SetItem(cb_args
, 2, ff_obj
);
5175 pyobj_args
= PyTuple_New(3);
5177 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timeout
));
5178 PyTuple_SetItem(pyobj_args
, 1, python_cb
);
5179 PyTuple_SetItem(pyobj_args
, 2, cb_args
);
5181 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
5185 } else if (!PyInt_Check(result
)) {
5186 DEBUG("%s: %s should return an int\n", __FUNCTION__
, NAME(addTimeout
));
5188 retval
= (int)PyInt_AsLong(result
);
5192 Py_DECREF(pyobj_args
);
5195 LIBVIRT_RELEASE_THREAD_STATE
;
5200 libvirt_virEventUpdateTimeoutFunc(int timer
, int timeout
)
5202 PyObject
*result
= NULL
;
5203 PyObject
*pyobj_args
;
5205 LIBVIRT_ENSURE_THREAD_STATE
;
5207 pyobj_args
= PyTuple_New(2);
5208 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
5209 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(timeout
));
5211 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
5218 Py_DECREF(pyobj_args
);
5220 LIBVIRT_RELEASE_THREAD_STATE
;
5224 libvirt_virEventRemoveTimeoutFunc(int timer
)
5226 PyObject
*result
= NULL
;
5227 PyObject
*pyobj_args
;
5231 virFreeCallback cff
;
5233 LIBVIRT_ENSURE_THREAD_STATE
;
5235 pyobj_args
= PyTuple_New(1);
5236 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
5238 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
5242 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5243 DEBUG("%s: %s must return opaque obj registered with %s"
5244 "to avoid leaking libvirt memory\n",
5245 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
5247 opaque
= PyTuple_GetItem(result
, 1);
5248 ff
= PyTuple_GetItem(result
, 2);
5249 cff
= PyvirFreeCallback_Get(ff
);
5251 (*cff
)(PyvirVoidPtr_Get(opaque
));
5256 Py_DECREF(pyobj_args
);
5258 LIBVIRT_RELEASE_THREAD_STATE
;
5264 libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject
* self
,
5267 /* Unref the previously-registered impl (if any) */
5268 Py_XDECREF(addHandleObj
);
5269 Py_XDECREF(updateHandleObj
);
5270 Py_XDECREF(removeHandleObj
);
5271 Py_XDECREF(addTimeoutObj
);
5272 Py_XDECREF(updateTimeoutObj
);
5273 Py_XDECREF(removeTimeoutObj
);
5275 /* Parse and check arguments */
5276 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
5277 &addHandleObj
, &updateHandleObj
,
5278 &removeHandleObj
, &addTimeoutObj
,
5279 &updateTimeoutObj
, &removeTimeoutObj
) ||
5280 !PyCallable_Check(addHandleObj
) ||
5281 !PyCallable_Check(updateHandleObj
) ||
5282 !PyCallable_Check(removeHandleObj
) ||
5283 !PyCallable_Check(addTimeoutObj
) ||
5284 !PyCallable_Check(updateTimeoutObj
) ||
5285 !PyCallable_Check(removeTimeoutObj
))
5286 return VIR_PY_INT_FAIL
;
5288 /* Get argument string representations (for error reporting) */
5289 addHandleName
= py_str(addHandleObj
);
5290 updateHandleName
= py_str(updateHandleObj
);
5291 removeHandleName
= py_str(removeHandleObj
);
5292 addTimeoutName
= py_str(addTimeoutObj
);
5293 updateTimeoutName
= py_str(updateTimeoutObj
);
5294 removeTimeoutName
= py_str(removeTimeoutObj
);
5296 /* Inc refs since we're holding on to these objects until
5297 * the next call (if any) to this function.
5299 Py_INCREF(addHandleObj
);
5300 Py_INCREF(updateHandleObj
);
5301 Py_INCREF(removeHandleObj
);
5302 Py_INCREF(addTimeoutObj
);
5303 Py_INCREF(updateTimeoutObj
);
5304 Py_INCREF(removeTimeoutObj
);
5306 LIBVIRT_BEGIN_ALLOW_THREADS
;
5308 /* Now register our C EventImpl, which will dispatch
5309 * to the Python callbacks passed in as args.
5311 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
5312 libvirt_virEventUpdateHandleFunc
,
5313 libvirt_virEventRemoveHandleFunc
,
5314 libvirt_virEventAddTimeoutFunc
,
5315 libvirt_virEventUpdateTimeoutFunc
,
5316 libvirt_virEventRemoveTimeoutFunc
);
5318 LIBVIRT_END_ALLOW_THREADS
;
5320 return VIR_PY_INT_SUCCESS
;
5324 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5327 int watch
, fd
, event
;
5329 PyObject
*py_opaque
;
5330 virEventHandleCallback cb
;
5333 if (!PyArg_ParseTuple
5334 (args
, (char *) "iiiOO:virEventInvokeHandleCallback",
5335 &watch
, &fd
, &event
, &py_f
, &py_opaque
5337 return VIR_PY_INT_FAIL
;
5339 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
5340 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5343 LIBVIRT_BEGIN_ALLOW_THREADS
;
5344 cb(watch
, fd
, event
, opaque
);
5345 LIBVIRT_END_ALLOW_THREADS
;
5348 return VIR_PY_INT_SUCCESS
;
5352 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5357 PyObject
*py_opaque
;
5358 virEventTimeoutCallback cb
;
5361 if (!PyArg_ParseTuple
5362 (args
, (char *) "iOO:virEventInvokeTimeoutCallback",
5363 &timer
, &py_f
, &py_opaque
5365 return VIR_PY_INT_FAIL
;
5367 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
5368 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5370 LIBVIRT_BEGIN_ALLOW_THREADS
;
5372 LIBVIRT_END_ALLOW_THREADS
;
5375 return VIR_PY_INT_SUCCESS
;
5379 libvirt_virEventHandleCallback(int watch
,
5384 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5385 PyObject
*pyobj_ret
;
5386 PyObject
*python_cb
;
5388 LIBVIRT_ENSURE_THREAD_STATE
;
5390 /* Lookup the python callback */
5391 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
5396 Py_INCREF(pyobj_cbData
);
5398 /* Call the pure python dispatcher */
5399 pyobj_ret
= PyObject_CallFunction(python_cb
,
5401 watch
, fd
, events
, pyobj_cbData
);
5403 Py_DECREF(pyobj_cbData
);
5406 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5409 Py_DECREF(pyobj_ret
);
5413 LIBVIRT_RELEASE_THREAD_STATE
;
5417 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
5420 PyObject
*py_retval
;
5421 PyObject
*pyobj_cbData
;
5422 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
5427 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
5428 &fd
, &events
, &pyobj_cbData
)) {
5429 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5430 return VIR_PY_INT_FAIL
;
5433 Py_INCREF(pyobj_cbData
);
5435 LIBVIRT_BEGIN_ALLOW_THREADS
;
5436 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
5437 LIBVIRT_END_ALLOW_THREADS
;
5440 Py_DECREF(pyobj_cbData
);
5443 py_retval
= libvirt_intWrap(ret
);
5448 libvirt_virEventTimeoutCallback(int timer
,
5451 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5452 PyObject
*pyobj_ret
;
5453 PyObject
*python_cb
;
5455 LIBVIRT_ENSURE_THREAD_STATE
;
5457 /* Lookup the python callback */
5458 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5463 Py_INCREF(pyobj_cbData
);
5465 /* Call the pure python dispatcher */
5466 pyobj_ret
= PyObject_CallFunction(python_cb
,
5468 timer
, pyobj_cbData
);
5470 Py_DECREF(pyobj_cbData
);
5473 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5476 Py_DECREF(pyobj_ret
);
5480 LIBVIRT_RELEASE_THREAD_STATE
;
5484 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5487 PyObject
*py_retval
;
5488 PyObject
*pyobj_cbData
;
5489 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5493 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5494 &timeout
, &pyobj_cbData
)) {
5495 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5496 return VIR_PY_INT_FAIL
;
5499 Py_INCREF(pyobj_cbData
);
5501 LIBVIRT_BEGIN_ALLOW_THREADS
;
5502 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5503 LIBVIRT_END_ALLOW_THREADS
;
5506 Py_DECREF(pyobj_cbData
);
5509 py_retval
= libvirt_intWrap(ret
);
5514 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5516 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5517 LIBVIRT_ENSURE_THREAD_STATE
;
5518 Py_DECREF(pyobj_conn
);
5519 LIBVIRT_RELEASE_THREAD_STATE
;
5523 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5529 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5530 PyObject
*pyobj_dom
;
5531 PyObject
*pyobj_ret
;
5532 PyObject
*pyobj_conn
;
5536 LIBVIRT_ENSURE_THREAD_STATE
;
5538 /* Create a python instance of this virDomainPtr */
5540 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5541 Py_INCREF(pyobj_cbData
);
5543 dictKey
= libvirt_constcharPtrWrap("conn");
5544 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5547 /* Call the Callback Dispatcher */
5548 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5549 (char*)"_dispatchDomainEventLifecycleCallback",
5555 Py_DECREF(pyobj_cbData
);
5556 Py_DECREF(pyobj_dom
);
5559 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5562 Py_DECREF(pyobj_ret
);
5566 LIBVIRT_RELEASE_THREAD_STATE
;
5571 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5575 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5576 PyObject
*pyobj_dom
;
5577 PyObject
*pyobj_ret
;
5578 PyObject
*pyobj_conn
;
5582 LIBVIRT_ENSURE_THREAD_STATE
;
5584 /* Create a python instance of this virDomainPtr */
5586 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5587 Py_INCREF(pyobj_cbData
);
5589 dictKey
= libvirt_constcharPtrWrap("conn");
5590 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5593 /* Call the Callback Dispatcher */
5594 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5595 (char*)"_dispatchDomainEventGenericCallback",
5597 pyobj_dom
, pyobj_cbData
);
5599 Py_DECREF(pyobj_cbData
);
5600 Py_DECREF(pyobj_dom
);
5603 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5606 Py_DECREF(pyobj_ret
);
5610 LIBVIRT_RELEASE_THREAD_STATE
;
5615 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5617 long long utcoffset
,
5620 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5621 PyObject
*pyobj_dom
;
5622 PyObject
*pyobj_ret
;
5623 PyObject
*pyobj_conn
;
5627 LIBVIRT_ENSURE_THREAD_STATE
;
5629 /* Create a python instance of this virDomainPtr */
5631 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5632 Py_INCREF(pyobj_cbData
);
5634 dictKey
= libvirt_constcharPtrWrap("conn");
5635 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5638 /* Call the Callback Dispatcher */
5639 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5640 (char*)"_dispatchDomainEventRTCChangeCallback",
5643 (PY_LONG_LONG
)utcoffset
,
5646 Py_DECREF(pyobj_cbData
);
5647 Py_DECREF(pyobj_dom
);
5650 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5653 Py_DECREF(pyobj_ret
);
5657 LIBVIRT_RELEASE_THREAD_STATE
;
5662 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5667 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5668 PyObject
*pyobj_dom
;
5669 PyObject
*pyobj_ret
;
5670 PyObject
*pyobj_conn
;
5674 LIBVIRT_ENSURE_THREAD_STATE
;
5676 /* Create a python instance of this virDomainPtr */
5678 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5679 Py_INCREF(pyobj_cbData
);
5681 dictKey
= libvirt_constcharPtrWrap("conn");
5682 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5685 /* Call the Callback Dispatcher */
5686 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5687 (char*)"_dispatchDomainEventWatchdogCallback",
5693 Py_DECREF(pyobj_cbData
);
5694 Py_DECREF(pyobj_dom
);
5697 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5700 Py_DECREF(pyobj_ret
);
5704 LIBVIRT_RELEASE_THREAD_STATE
;
5709 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5711 const char *srcPath
,
5712 const char *devAlias
,
5716 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5717 PyObject
*pyobj_dom
;
5718 PyObject
*pyobj_ret
;
5719 PyObject
*pyobj_conn
;
5723 LIBVIRT_ENSURE_THREAD_STATE
;
5725 /* Create a python instance of this virDomainPtr */
5727 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5728 Py_INCREF(pyobj_cbData
);
5730 dictKey
= libvirt_constcharPtrWrap("conn");
5731 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5734 /* Call the Callback Dispatcher */
5735 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5736 (char*)"_dispatchDomainEventIOErrorCallback",
5739 srcPath
, devAlias
, action
,
5742 Py_DECREF(pyobj_cbData
);
5743 Py_DECREF(pyobj_dom
);
5746 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5749 Py_DECREF(pyobj_ret
);
5753 LIBVIRT_RELEASE_THREAD_STATE
;
5758 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5760 const char *srcPath
,
5761 const char *devAlias
,
5766 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5767 PyObject
*pyobj_dom
;
5768 PyObject
*pyobj_ret
;
5769 PyObject
*pyobj_conn
;
5773 LIBVIRT_ENSURE_THREAD_STATE
;
5775 /* Create a python instance of this virDomainPtr */
5777 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5778 Py_INCREF(pyobj_cbData
);
5780 dictKey
= libvirt_constcharPtrWrap("conn");
5781 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5784 /* Call the Callback Dispatcher */
5785 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5786 (char*)"_dispatchDomainEventIOErrorReasonCallback",
5789 srcPath
, devAlias
, action
, reason
,
5792 Py_DECREF(pyobj_cbData
);
5793 Py_DECREF(pyobj_dom
);
5796 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5799 Py_DECREF(pyobj_ret
);
5803 LIBVIRT_RELEASE_THREAD_STATE
;
5808 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5811 virDomainEventGraphicsAddressPtr local
,
5812 virDomainEventGraphicsAddressPtr remote
,
5813 const char *authScheme
,
5814 virDomainEventGraphicsSubjectPtr subject
,
5817 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5818 PyObject
*pyobj_dom
;
5819 PyObject
*pyobj_ret
;
5820 PyObject
*pyobj_conn
;
5822 PyObject
*pyobj_local
;
5823 PyObject
*pyobj_remote
;
5824 PyObject
*pyobj_subject
;
5828 LIBVIRT_ENSURE_THREAD_STATE
;
5830 /* Create a python instance of this virDomainPtr */
5832 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5833 Py_INCREF(pyobj_cbData
);
5835 dictKey
= libvirt_constcharPtrWrap("conn");
5836 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5839 pyobj_local
= PyDict_New();
5840 PyDict_SetItem(pyobj_local
,
5841 libvirt_constcharPtrWrap("family"),
5842 libvirt_intWrap(local
->family
));
5843 PyDict_SetItem(pyobj_local
,
5844 libvirt_constcharPtrWrap("node"),
5845 libvirt_constcharPtrWrap(local
->node
));
5846 PyDict_SetItem(pyobj_local
,
5847 libvirt_constcharPtrWrap("service"),
5848 libvirt_constcharPtrWrap(local
->service
));
5850 pyobj_remote
= PyDict_New();
5851 PyDict_SetItem(pyobj_remote
,
5852 libvirt_constcharPtrWrap("family"),
5853 libvirt_intWrap(remote
->family
));
5854 PyDict_SetItem(pyobj_remote
,
5855 libvirt_constcharPtrWrap("node"),
5856 libvirt_constcharPtrWrap(remote
->node
));
5857 PyDict_SetItem(pyobj_remote
,
5858 libvirt_constcharPtrWrap("service"),
5859 libvirt_constcharPtrWrap(remote
->service
));
5861 pyobj_subject
= PyList_New(subject
->nidentity
);
5862 for (i
= 0; i
< subject
->nidentity
; i
++) {
5863 PyObject
*pair
= PyTuple_New(2);
5864 PyTuple_SetItem(pair
, 0, libvirt_constcharPtrWrap(subject
->identities
[i
].type
));
5865 PyTuple_SetItem(pair
, 1, libvirt_constcharPtrWrap(subject
->identities
[i
].name
));
5867 PyList_SetItem(pyobj_subject
, i
, pair
);
5870 /* Call the Callback Dispatcher */
5871 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5872 (char*)"_dispatchDomainEventGraphicsCallback",
5875 phase
, pyobj_local
, pyobj_remote
,
5876 authScheme
, pyobj_subject
,
5879 Py_DECREF(pyobj_cbData
);
5880 Py_DECREF(pyobj_dom
);
5883 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5886 Py_DECREF(pyobj_ret
);
5890 LIBVIRT_RELEASE_THREAD_STATE
;
5895 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5902 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5903 PyObject
*pyobj_dom
;
5904 PyObject
*pyobj_ret
;
5905 PyObject
*pyobj_conn
;
5909 LIBVIRT_ENSURE_THREAD_STATE
;
5911 /* Create a python instance of this virDomainPtr */
5913 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5914 Py_INCREF(pyobj_cbData
);
5916 dictKey
= libvirt_constcharPtrWrap("conn");
5917 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5920 /* Call the Callback Dispatcher */
5921 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5922 (char*)"dispatchDomainEventBlockPullCallback",
5924 pyobj_dom
, path
, type
, status
, pyobj_cbData
);
5926 Py_DECREF(pyobj_cbData
);
5927 Py_DECREF(pyobj_dom
);
5931 printf("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5935 Py_DECREF(pyobj_ret
);
5939 LIBVIRT_RELEASE_THREAD_STATE
;
5944 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5946 const char *oldSrcPath
,
5947 const char *newSrcPath
,
5948 const char *devAlias
,
5952 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5953 PyObject
*pyobj_dom
;
5954 PyObject
*pyobj_ret
;
5955 PyObject
*pyobj_conn
;
5959 LIBVIRT_ENSURE_THREAD_STATE
;
5960 /* Create a python instance of this virDomainPtr */
5963 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
5964 Py_INCREF(pyobj_cbData
);
5966 dictKey
= libvirt_constcharPtrWrap("conn");
5967 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5970 /* Call the Callback Dispatcher */
5971 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5972 (char*)"_dispatchDomainEventDiskChangeCallback",
5975 oldSrcPath
, newSrcPath
,
5976 devAlias
, reason
, pyobj_cbData
);
5978 Py_DECREF(pyobj_cbData
);
5979 Py_DECREF(pyobj_dom
);
5982 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5985 Py_DECREF(pyobj_ret
);
5989 LIBVIRT_RELEASE_THREAD_STATE
;
5994 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5996 const char *devAlias
,
6000 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6001 PyObject
*pyobj_dom
;
6002 PyObject
*pyobj_ret
;
6003 PyObject
*pyobj_conn
;
6007 LIBVIRT_ENSURE_THREAD_STATE
;
6008 /* Create a python instance of this virDomainPtr */
6011 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
6012 Py_INCREF(pyobj_cbData
);
6014 dictKey
= libvirt_constcharPtrWrap("conn");
6015 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6018 /* Call the Callback Dispatcher */
6019 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6020 (char*)"_dispatchDomainEventTrayChangeCallback",
6023 devAlias
, reason
, pyobj_cbData
);
6025 Py_DECREF(pyobj_cbData
);
6026 Py_DECREF(pyobj_dom
);
6029 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6032 Py_DECREF(pyobj_ret
);
6036 LIBVIRT_RELEASE_THREAD_STATE
;
6041 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6046 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6047 PyObject
*pyobj_dom
;
6048 PyObject
*pyobj_ret
;
6049 PyObject
*pyobj_conn
;
6053 LIBVIRT_ENSURE_THREAD_STATE
;
6054 /* Create a python instance of this virDomainPtr */
6057 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
6058 Py_INCREF(pyobj_cbData
);
6060 dictKey
= libvirt_constcharPtrWrap("conn");
6061 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6064 /* Call the Callback Dispatcher */
6065 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6066 (char*)"_dispatchDomainEventPMWakeupCallback",
6072 Py_DECREF(pyobj_cbData
);
6073 Py_DECREF(pyobj_dom
);
6076 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6079 Py_DECREF(pyobj_ret
);
6083 LIBVIRT_RELEASE_THREAD_STATE
;
6088 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6093 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6094 PyObject
*pyobj_dom
;
6095 PyObject
*pyobj_ret
;
6096 PyObject
*pyobj_conn
;
6100 LIBVIRT_ENSURE_THREAD_STATE
;
6101 /* Create a python instance of this virDomainPtr */
6104 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
6105 Py_INCREF(pyobj_cbData
);
6107 dictKey
= libvirt_constcharPtrWrap("conn");
6108 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6111 /* Call the Callback Dispatcher */
6112 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6113 (char*)"_dispatchDomainEventPMSuspendCallback",
6119 Py_DECREF(pyobj_cbData
);
6120 Py_DECREF(pyobj_dom
);
6123 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6126 Py_DECREF(pyobj_ret
);
6130 LIBVIRT_RELEASE_THREAD_STATE
;
6135 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6137 unsigned long long actual
,
6140 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6141 PyObject
*pyobj_dom
;
6142 PyObject
*pyobj_ret
;
6143 PyObject
*pyobj_conn
;
6147 LIBVIRT_ENSURE_THREAD_STATE
;
6149 /* Create a python instance of this virDomainPtr */
6151 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
6152 Py_INCREF(pyobj_cbData
);
6154 dictKey
= libvirt_constcharPtrWrap("conn");
6155 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6158 /* Call the Callback Dispatcher */
6159 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6160 (char*)"_dispatchDomainEventBalloonChangeCallback",
6163 (PY_LONG_LONG
)actual
,
6166 Py_DECREF(pyobj_cbData
);
6167 Py_DECREF(pyobj_dom
);
6170 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6173 Py_DECREF(pyobj_ret
);
6177 LIBVIRT_RELEASE_THREAD_STATE
;
6182 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6187 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6188 PyObject
*pyobj_dom
;
6189 PyObject
*pyobj_ret
;
6190 PyObject
*pyobj_conn
;
6194 LIBVIRT_ENSURE_THREAD_STATE
;
6195 /* Create a python instance of this virDomainPtr */
6198 pyobj_dom
= libvirt_virDomainPtrWrap(dom
);
6199 Py_INCREF(pyobj_cbData
);
6201 dictKey
= libvirt_constcharPtrWrap("conn");
6202 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6205 /* Call the Callback Dispatcher */
6206 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6207 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
6213 Py_DECREF(pyobj_cbData
);
6214 Py_DECREF(pyobj_dom
);
6217 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6220 Py_DECREF(pyobj_ret
);
6224 LIBVIRT_RELEASE_THREAD_STATE
;
6229 libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject
* self
,
6232 PyObject
*py_retval
; /* return value */
6233 PyObject
*pyobj_conn
; /* virConnectPtr */
6234 PyObject
*pyobj_dom
;
6235 PyObject
*pyobj_cbData
; /* hash of callback data */
6239 virConnectDomainEventGenericCallback cb
= NULL
;
6242 if (!PyArg_ParseTuple
6243 (args
, (char *) "OOiO:virConnectDomainEventRegisterAny",
6244 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
)) {
6245 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
6246 return VIR_PY_INT_FAIL
;
6249 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
6250 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
6251 conn
= PyvirConnect_Get(pyobj_conn
);
6252 if (pyobj_dom
== Py_None
)
6255 dom
= PyvirDomain_Get(pyobj_dom
);
6258 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
6259 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
6261 case VIR_DOMAIN_EVENT_ID_REBOOT
:
6262 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
6264 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
6265 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
6267 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
6268 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
6270 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
6271 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
6273 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
6274 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
6276 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
6277 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
6279 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
6280 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
6282 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
6283 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
6285 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
6286 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
6288 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
6289 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
6291 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
6292 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
6294 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
6295 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
6297 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
6298 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
6300 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
6301 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
6306 return VIR_PY_INT_FAIL
;
6309 Py_INCREF(pyobj_cbData
);
6311 LIBVIRT_BEGIN_ALLOW_THREADS
;
6312 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
6314 libvirt_virConnectDomainEventFreeFunc
);
6315 LIBVIRT_END_ALLOW_THREADS
;
6318 Py_DECREF(pyobj_cbData
);
6321 py_retval
= libvirt_intWrap(ret
);
6326 libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED PyObject
* self
,
6329 PyObject
*py_retval
;
6330 PyObject
*pyobj_conn
;
6335 if (!PyArg_ParseTuple
6336 (args
, (char *) "Oi:virConnectDomainEventDeregister",
6337 &pyobj_conn
, &callbackID
))
6340 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
6342 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6344 LIBVIRT_BEGIN_ALLOW_THREADS
;
6346 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
6348 LIBVIRT_END_ALLOW_THREADS
;
6349 py_retval
= libvirt_intWrap(ret
);
6355 libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED
,
6359 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6360 PyObject
*pyobj_ret
;
6361 PyObject
*pyobj_conn
;
6364 LIBVIRT_ENSURE_THREAD_STATE
;
6366 Py_INCREF(pyobj_cbData
);
6368 dictKey
= libvirt_constcharPtrWrap("conn");
6369 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6372 /* Call the Callback Dispatcher */
6373 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6374 (char*)"_dispatchCloseCallback",
6379 Py_DECREF(pyobj_cbData
);
6382 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6385 Py_DECREF(pyobj_ret
);
6388 LIBVIRT_RELEASE_THREAD_STATE
;
6392 libvirt_virConnectRegisterCloseCallback(ATTRIBUTE_UNUSED PyObject
* self
,
6395 PyObject
*py_retval
; /* return value */
6396 PyObject
*pyobj_conn
; /* virConnectPtr */
6397 PyObject
*pyobj_cbData
; /* hash of callback data */
6401 if (!PyArg_ParseTuple
6402 (args
, (char *) "OO:virConnectRegisterCloseCallback",
6403 &pyobj_conn
, &pyobj_cbData
)) {
6404 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
6405 return VIR_PY_INT_FAIL
;
6408 DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
6409 pyobj_conn
, pyobj_cbData
);
6410 conn
= PyvirConnect_Get(pyobj_conn
);
6412 Py_INCREF(pyobj_cbData
);
6414 LIBVIRT_BEGIN_ALLOW_THREADS
;
6415 ret
= virConnectRegisterCloseCallback(conn
,
6416 libvirt_virConnectCloseCallbackDispatch
,
6418 libvirt_virConnectDomainEventFreeFunc
);
6419 LIBVIRT_END_ALLOW_THREADS
;
6422 Py_DECREF(pyobj_cbData
);
6425 py_retval
= libvirt_intWrap(ret
);
6430 libvirt_virConnectUnregisterCloseCallback(ATTRIBUTE_UNUSED PyObject
* self
,
6433 PyObject
*py_retval
;
6434 PyObject
*pyobj_conn
;
6438 if (!PyArg_ParseTuple
6439 (args
, (char *) "O:virConnectDomainEventUnregister",
6443 DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
6446 conn
= PyvirConnect_Get(pyobj_conn
);
6448 LIBVIRT_BEGIN_ALLOW_THREADS
;
6450 ret
= virConnectUnregisterCloseCallback(conn
,
6451 libvirt_virConnectCloseCallbackDispatch
);
6453 LIBVIRT_END_ALLOW_THREADS
;
6454 py_retval
= libvirt_intWrap(ret
);
6459 libvirt_virStreamEventFreeFunc(void *opaque
)
6461 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
6462 LIBVIRT_ENSURE_THREAD_STATE
;
6463 Py_DECREF(pyobj_stream
);
6464 LIBVIRT_RELEASE_THREAD_STATE
;
6468 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
6472 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6473 PyObject
*pyobj_stream
;
6474 PyObject
*pyobj_ret
;
6477 LIBVIRT_ENSURE_THREAD_STATE
;
6479 Py_INCREF(pyobj_cbData
);
6480 dictKey
= libvirt_constcharPtrWrap("stream");
6481 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6484 /* Call the pure python dispatcher */
6485 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
6486 (char *)"_dispatchStreamEventCallback",
6488 events
, pyobj_cbData
);
6490 Py_DECREF(pyobj_cbData
);
6493 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6496 Py_DECREF(pyobj_ret
);
6499 LIBVIRT_RELEASE_THREAD_STATE
;
6503 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
6506 PyObject
*py_retval
;
6507 PyObject
*pyobj_stream
;
6508 PyObject
*pyobj_cbData
;
6509 virStreamPtr stream
;
6510 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
6514 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
6515 &pyobj_stream
, &events
, &pyobj_cbData
)) {
6516 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6517 return VIR_PY_INT_FAIL
;
6520 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
6521 pyobj_stream
, events
, pyobj_cbData
);
6522 stream
= PyvirStream_Get(pyobj_stream
);
6524 Py_INCREF(pyobj_cbData
);
6526 LIBVIRT_BEGIN_ALLOW_THREADS
;
6527 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
6528 libvirt_virStreamEventFreeFunc
);
6529 LIBVIRT_END_ALLOW_THREADS
;
6532 Py_DECREF(pyobj_cbData
);
6535 py_retval
= libvirt_intWrap(ret
);
6540 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
6543 PyObject
*pyobj_stream
;
6544 virStreamPtr stream
;
6549 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
6550 &pyobj_stream
, &nbytes
)) {
6551 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6554 stream
= PyvirStream_Get(pyobj_stream
);
6556 if (VIR_ALLOC_N_QUIET(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
6559 LIBVIRT_BEGIN_ALLOW_THREADS
;
6560 ret
= virStreamRecv(stream
, buf
, nbytes
);
6561 LIBVIRT_END_ALLOW_THREADS
;
6563 buf
[ret
> -1 ? ret
: 0] = '\0';
6564 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
6567 return libvirt_intWrap(ret
);
6570 return libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
6574 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
6577 PyObject
*py_retval
;
6578 PyObject
*pyobj_stream
;
6579 virStreamPtr stream
;
6585 if (!PyArg_ParseTuple(args
, (char *) "Oz#i:virStreamRecv",
6586 &pyobj_stream
, &data
, &datalen
, &nbytes
)) {
6587 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6588 return VIR_PY_INT_FAIL
;
6590 stream
= PyvirStream_Get(pyobj_stream
);
6592 LIBVIRT_BEGIN_ALLOW_THREADS
;
6593 ret
= virStreamSend(stream
, data
, nbytes
);
6594 LIBVIRT_END_ALLOW_THREADS
;
6596 DEBUG("StreamSend ret=%d\n", ret
);
6598 py_retval
= libvirt_intWrap(ret
);
6603 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
6606 PyObject
*py_retval
;
6607 virDomainPtr domain
;
6608 PyObject
*pyobj_domain
;
6609 PyObject
*pyobj_list
;
6615 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
6616 unsigned int nkeycodes
;
6618 if (!PyArg_ParseTuple(args
, (char *)"OiiOii:virDomainSendKey",
6619 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
6620 &nkeycodes
, &flags
)) {
6621 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6622 return VIR_PY_INT_FAIL
;
6624 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6626 if (!PyList_Check(pyobj_list
)) {
6627 return VIR_PY_INT_FAIL
;
6630 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
6631 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
6632 return VIR_PY_INT_FAIL
;
6635 for (i
= 0; i
< nkeycodes
; i
++) {
6636 keycodes
[i
] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list
, i
));
6639 LIBVIRT_BEGIN_ALLOW_THREADS
;
6640 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
6641 LIBVIRT_END_ALLOW_THREADS
;
6643 DEBUG("virDomainSendKey ret=%d\n", ret
);
6645 py_retval
= libvirt_intWrap(ret
);
6650 libvirt_virDomainMigrateGetCompressionCache(PyObject
*self ATTRIBUTE_UNUSED
,
6653 PyObject
*pyobj_domain
;
6654 virDomainPtr domain
;
6656 unsigned long long cacheSize
;
6659 if (!PyArg_ParseTuple(args
,
6660 (char *) "Oi:virDomainMigrateGetCompressionCache",
6661 &pyobj_domain
, &flags
))
6664 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6666 LIBVIRT_BEGIN_ALLOW_THREADS
;
6667 rc
= virDomainMigrateGetCompressionCache(domain
, &cacheSize
, flags
);
6668 LIBVIRT_END_ALLOW_THREADS
;
6673 return libvirt_ulonglongWrap(cacheSize
);
6677 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
6678 PyObject
*py_retval
;
6680 unsigned long bandwidth
;
6681 virDomainPtr domain
;
6682 PyObject
*pyobj_domain
;
6683 unsigned int flags
= 0;
6685 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainMigrateGetMaxSpeed",
6686 &pyobj_domain
, &flags
))
6689 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6691 LIBVIRT_BEGIN_ALLOW_THREADS
;
6692 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
6693 LIBVIRT_END_ALLOW_THREADS
;
6696 return VIR_PY_INT_FAIL
;
6697 py_retval
= libvirt_ulongWrap(bandwidth
);
6702 libvirt_virDomainMigrate3(PyObject
*self ATTRIBUTE_UNUSED
,
6705 PyObject
*pyobj_domain
;
6706 virDomainPtr domain
;
6707 PyObject
*pyobj_dconn
;
6708 virConnectPtr dconn
;
6711 virTypedParameterPtr params
;
6713 virDomainPtr ddom
= NULL
;
6715 if (!PyArg_ParseTuple(args
, (char *) "OOOi:virDomainMigrate3",
6716 &pyobj_domain
, &pyobj_dconn
, &dict
, &flags
))
6719 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6720 dconn
= (virConnectPtr
) PyvirConnect_Get(pyobj_dconn
);
6722 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
6725 LIBVIRT_BEGIN_ALLOW_THREADS
;
6726 ddom
= virDomainMigrate3(domain
, dconn
, params
, nparams
, flags
);
6727 LIBVIRT_END_ALLOW_THREADS
;
6729 virTypedParamsFree(params
, nparams
);
6730 return libvirt_virDomainPtrWrap(ddom
);
6734 libvirt_virDomainMigrateToURI3(PyObject
*self ATTRIBUTE_UNUSED
,
6737 PyObject
*pyobj_domain
;
6738 virDomainPtr domain
;
6742 virTypedParameterPtr params
;
6746 if (!PyArg_ParseTuple(args
, (char *) "OzOi:virDomainMigrate3",
6747 &pyobj_domain
, &dconnuri
, &dict
, &flags
))
6750 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6752 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
6755 LIBVIRT_BEGIN_ALLOW_THREADS
;
6756 ret
= virDomainMigrateToURI3(domain
, dconnuri
, params
, nparams
, flags
);
6757 LIBVIRT_END_ALLOW_THREADS
;
6759 virTypedParamsFree(params
, nparams
);
6760 return libvirt_intWrap(ret
);
6764 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
6766 PyObject
*py_retval
= NULL
;
6768 virDomainPtr domain
;
6769 PyObject
*pyobj_domain
;
6771 unsigned long long offset
;
6776 if (!PyArg_ParseTuple(args
, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain
,
6777 &disk
, &offset
, &size
, &flags
))
6780 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6782 if (VIR_ALLOC_N_QUIET(buf
, size
) < 0)
6785 LIBVIRT_BEGIN_ALLOW_THREADS
;
6786 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
6787 LIBVIRT_END_ALLOW_THREADS
;
6790 py_retval
= VIR_PY_NONE
;
6794 py_retval
= PyString_FromStringAndSize(buf
, size
);
6802 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
6804 PyObject
*py_retval
= NULL
;
6806 virDomainPtr domain
;
6807 PyObject
*pyobj_domain
;
6808 unsigned long long start
;
6813 if (!PyArg_ParseTuple(args
, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain
,
6814 &start
, &size
, &flags
))
6817 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
6819 if (VIR_ALLOC_N_QUIET(buf
, size
) < 0)
6822 LIBVIRT_BEGIN_ALLOW_THREADS
;
6823 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
6824 LIBVIRT_END_ALLOW_THREADS
;
6827 py_retval
= VIR_PY_NONE
;
6831 py_retval
= PyString_FromStringAndSize(buf
, size
);
6839 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
6843 PyObject
*pyobj_conn
, *info
;
6844 PyObject
*ret
= NULL
;
6847 Py_ssize_t size
= 0;
6849 virTypedParameterPtr params
, new_params
= NULL
;
6851 if (!PyArg_ParseTuple(args
,
6852 (char *)"OOi:virNodeSetMemoryParameters",
6853 &pyobj_conn
, &info
, &flags
))
6855 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6857 if ((size
= PyDict_Size(info
)) < 0)
6861 PyErr_Format(PyExc_LookupError
,
6862 "Need non-empty dictionary to set attributes");
6866 LIBVIRT_BEGIN_ALLOW_THREADS
;
6867 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
6868 LIBVIRT_END_ALLOW_THREADS
;
6871 return VIR_PY_INT_FAIL
;
6874 PyErr_Format(PyExc_LookupError
,
6875 "no settable attributes");
6879 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
6880 return PyErr_NoMemory();
6882 LIBVIRT_BEGIN_ALLOW_THREADS
;
6883 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
6884 LIBVIRT_END_ALLOW_THREADS
;
6887 ret
= VIR_PY_INT_FAIL
;
6891 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
6895 LIBVIRT_BEGIN_ALLOW_THREADS
;
6896 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
6897 LIBVIRT_END_ALLOW_THREADS
;
6900 ret
= VIR_PY_INT_FAIL
;
6904 ret
= VIR_PY_INT_SUCCESS
;
6907 virTypedParamsFree(params
, nparams
);
6908 VIR_FREE(new_params
);
6913 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
6917 PyObject
*pyobj_conn
;
6918 PyObject
*ret
= NULL
;
6922 virTypedParameterPtr params
;
6924 if (!PyArg_ParseTuple(args
, (char *)"Oi:virNodeGetMemoryParameters",
6925 &pyobj_conn
, &flags
))
6927 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6929 LIBVIRT_BEGIN_ALLOW_THREADS
;
6930 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
6931 LIBVIRT_END_ALLOW_THREADS
;
6937 return PyDict_New();
6939 if (VIR_ALLOC_N_QUIET(params
, nparams
) < 0)
6940 return PyErr_NoMemory();
6942 LIBVIRT_BEGIN_ALLOW_THREADS
;
6943 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
6944 LIBVIRT_END_ALLOW_THREADS
;
6951 ret
= getPyVirTypedParameter(params
, nparams
);
6954 virTypedParamsFree(params
, nparams
);
6959 libvirt_virNodeGetCPUMap(PyObject
*self ATTRIBUTE_UNUSED
,
6963 PyObject
*pyobj_conn
;
6964 PyObject
*ret
= NULL
;
6965 PyObject
*pycpumap
= NULL
;
6966 PyObject
*pyused
= NULL
;
6967 PyObject
*pycpunum
= NULL
;
6968 PyObject
*pyonline
= NULL
;
6970 unsigned char *cpumap
= NULL
;
6971 unsigned int online
= 0;
6975 if (!PyArg_ParseTuple(args
, (char *)"Oi:virNodeGetCPUMap",
6976 &pyobj_conn
, &flags
))
6978 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6980 LIBVIRT_BEGIN_ALLOW_THREADS
;
6981 i_retval
= virNodeGetCPUMap(conn
, &cpumap
, &online
, flags
);
6982 LIBVIRT_END_ALLOW_THREADS
;
6987 if ((ret
= PyTuple_New(3)) == NULL
)
6990 /* 0: number of CPUs */
6991 if ((pycpunum
= PyLong_FromLong(i_retval
)) == NULL
||
6992 PyTuple_SetItem(ret
, 0, pycpunum
) < 0)
6996 if ((pycpumap
= PyList_New(i_retval
)) == NULL
)
6999 for (i
= 0; i
< i_retval
; i
++) {
7000 if ((pyused
= PyBool_FromLong(VIR_CPU_USED(cpumap
, i
))) == NULL
)
7002 if (PyList_SetItem(pycpumap
, i
, pyused
) < 0)
7006 if (PyTuple_SetItem(ret
, 1, pycpumap
) < 0)
7009 /* 2: number of online CPUs */
7010 if ((pyonline
= PyLong_FromLong(online
)) == NULL
||
7011 PyTuple_SetItem(ret
, 2, pyonline
) < 0)
7019 Py_XDECREF(pycpumap
);
7021 Py_XDECREF(pycpunum
);
7022 Py_XDECREF(pyonline
);
7028 /************************************************************************
7030 * The registration stuff *
7032 ************************************************************************/
7033 static PyMethodDef libvirtMethods
[] = {
7034 #include "libvirt-export.c"
7035 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
7036 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
7037 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
7038 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
7039 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
7040 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
7041 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
7042 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
7043 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
7044 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
7045 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
7046 {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback
, METH_VARARGS
, NULL
},
7047 {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback
, METH_VARARGS
, NULL
},
7048 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
7049 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
7050 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
7051 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
7052 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
7053 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
7054 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
7055 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
7056 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
7057 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
7058 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
7059 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
7060 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
7061 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
7062 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
7063 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
7064 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
7065 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
7066 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
7067 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
7068 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
7069 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
7070 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
7071 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
7072 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
7073 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
7074 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
7075 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
7076 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
7077 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
7078 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
7079 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
7080 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
7081 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
7082 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
7083 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
7084 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
7085 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
7086 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
7087 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
7088 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
7089 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
7090 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
7091 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
7092 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
7093 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
7094 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
7095 {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo
, METH_VARARGS
, NULL
},
7096 {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator
, METH_VARARGS
, NULL
},
7097 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
7098 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
7099 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
7100 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
7101 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
7102 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
7103 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
7104 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
7105 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
7106 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
7107 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
7108 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
7109 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
7110 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
7111 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
7112 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
7113 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
7114 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
7115 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
7116 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
7117 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
7118 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
7119 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
7120 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
7121 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
7122 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
7123 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
7124 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
7125 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
7126 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
7127 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
7128 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
7129 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
7130 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
7131 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
7132 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
7133 {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats
, METH_VARARGS
, NULL
},
7134 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
7135 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
7136 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
7137 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
7138 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
7139 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
7140 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
7141 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
7142 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
7143 {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache
, METH_VARARGS
, NULL
},
7144 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
7145 {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3
, METH_VARARGS
, NULL
},
7146 {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3
, METH_VARARGS
, NULL
},
7147 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
7148 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
7149 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
7150 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
7151 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
7152 {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap
, METH_VARARGS
, NULL
},
7153 {NULL
, NULL
, 0, NULL
}
7164 static int initialized
= 0;
7166 if (initialized
!= 0)
7169 if (virInitialize() < 0)
7172 /* initialize the python extension module */
7173 Py_InitModule((char *)