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-2014 Red Hat, Inc.
9 * Daniel Veillard <veillard@redhat.com>
12 /* Horrible kludge to work around even more horrible name-space pollution
13 via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
14 which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
17 /* We want to see *_LAST enums. */
18 #define VIR_ENUM_SENTINELS
21 #include <libvirt/libvirt.h>
22 #include <libvirt/virterror.h>
24 #include "typewrappers.h"
25 #include "build/libvirt.h"
26 #include "libvirt-utils.h"
28 #if PY_MAJOR_VERSION > 2
30 extern PyObject
*PyInit_libvirtmod(void);
32 extern PyObject
*PyInit_cygvirtmod(void);
36 extern void initlibvirtmod(void);
38 extern void initcygvirtmod(void);
43 # define DEBUG_ERROR 1
47 # define DEBUG(fmt, ...) \
48 printf(fmt, __VA_ARGS__)
50 # define DEBUG(fmt, ...) \
54 /* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
55 is so common that we encapsulate it here. Now, each use is simply
56 return VIR_PY_NONE; */
57 #define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
58 #define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
59 #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
61 static char *py_str(PyObject
*obj
)
63 PyObject
*str
= PyObject_Str(obj
);
70 libvirt_charPtrUnwrap(str
, &ret
);
74 /* Helper function to convert a virTypedParameter output array into a
75 * Python dictionary for return to the user. Return NULL on failure,
76 * after raising a python exception. */
78 getPyVirTypedParameter(const virTypedParameter
*params
, int nparams
)
80 PyObject
*key
, *val
, *info
;
83 if ((info
= PyDict_New()) == NULL
)
86 for (i
= 0; i
< nparams
; i
++) {
87 switch (params
[i
].type
) {
88 case VIR_TYPED_PARAM_INT
:
89 val
= libvirt_intWrap(params
[i
].value
.i
);
92 case VIR_TYPED_PARAM_UINT
:
93 val
= libvirt_intWrap(params
[i
].value
.ui
);
96 case VIR_TYPED_PARAM_LLONG
:
97 val
= libvirt_longlongWrap(params
[i
].value
.l
);
100 case VIR_TYPED_PARAM_ULLONG
:
101 val
= libvirt_ulonglongWrap(params
[i
].value
.ul
);
104 case VIR_TYPED_PARAM_DOUBLE
:
105 val
= PyFloat_FromDouble(params
[i
].value
.d
);
108 case VIR_TYPED_PARAM_BOOLEAN
:
109 val
= PyBool_FromLong(params
[i
].value
.b
);
112 case VIR_TYPED_PARAM_STRING
:
113 val
= libvirt_constcharPtrWrap(params
[i
].value
.s
);
117 /* Possible if a newer server has a bug and sent stuff we
118 * don't recognize. */
119 PyErr_Format(PyExc_LookupError
,
120 "Type value \"%d\" not recognized",
126 key
= libvirt_constcharPtrWrap(params
[i
].field
);
130 if (PyDict_SetItem(info
, key
, val
) < 0) {
146 /* Allocate a new typed parameter array with the same contents and
147 * length as info, and using the array params of length nparams as
148 * hints on what types to use when creating the new array. The caller
149 * must clear the array before freeing it. Return NULL on failure,
150 * after raising a python exception. */
151 static virTypedParameterPtr
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
152 setPyVirTypedParameter(PyObject
*info
,
153 const virTypedParameter
*params
, int nparams
)
155 PyObject
*key
, *value
;
156 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
161 virTypedParameterPtr temp
= NULL
, ret
= NULL
;
165 if ((size
= PyDict_Size(info
)) < 0)
168 /* Libvirt APIs use NULL array and 0 size as a special case;
169 * setting should have at least one parameter. */
171 PyErr_Format(PyExc_LookupError
, "Dictionary must not be empty");
175 if (VIR_ALLOC_N(ret
, size
) < 0) {
181 while (PyDict_Next(info
, &pos
, &key
, &value
)) {
184 if (libvirt_charPtrUnwrap(key
, &keystr
) < 0 ||
188 for (i
= 0; i
< nparams
; i
++) {
189 if (STREQ(params
[i
].field
, keystr
))
193 PyErr_Format(PyExc_LookupError
,
194 "Attribute name \"%s\" could not be recognized",
200 strncpy(temp
->field
, keystr
, VIR_TYPED_PARAM_FIELD_LENGTH
- 1);
201 temp
->type
= params
[i
].type
;
204 switch (params
[i
].type
) {
205 case VIR_TYPED_PARAM_INT
:
206 if (libvirt_intUnwrap(value
, &temp
->value
.i
) < 0)
210 case VIR_TYPED_PARAM_UINT
:
211 if (libvirt_uintUnwrap(value
, &temp
->value
.ui
) < 0)
215 case VIR_TYPED_PARAM_LLONG
:
216 if (libvirt_longlongUnwrap(value
, &temp
->value
.l
) < 0)
220 case VIR_TYPED_PARAM_ULLONG
:
221 if (libvirt_ulonglongUnwrap(value
, &temp
->value
.ul
) < 0)
225 case VIR_TYPED_PARAM_DOUBLE
:
226 if (libvirt_doubleUnwrap(value
, &temp
->value
.d
) < 0)
230 case VIR_TYPED_PARAM_BOOLEAN
:
233 if (libvirt_boolUnwrap(value
, &b
) < 0)
238 case VIR_TYPED_PARAM_STRING
:
241 if (libvirt_charPtrUnwrap(value
, &string_val
) < 0 ||
244 temp
->value
.s
= string_val
;
249 /* Possible if a newer server has a bug and sent stuff we
250 * don't recognize. */
251 PyErr_Format(PyExc_LookupError
,
252 "Type value \"%d\" not recognized",
262 virTypedParamsFree(ret
, size
);
266 /* While these appeared in libvirt in 1.0.2, we only
267 * need them in the python from 1.1.0 onwards */
268 #if LIBVIR_CHECK_VERSION(1, 1, 0)
272 } virPyTypedParamsHint
;
273 typedef virPyTypedParamsHint
*virPyTypedParamsHintPtr
;
275 # if PY_MAJOR_VERSION > 2
276 # define libvirt_PyString_Check PyUnicode_Check
278 # define libvirt_PyString_Check PyString_Check
281 /* Automatically convert dict into type parameters based on types reported
282 * by python. All integer types are converted into LLONG (in case of a negative
283 * value) or ULLONG (in case of a positive value). If you need different
284 * handling, use @hints to explicitly specify what types should be used for
285 * specific parameters.
288 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
289 virPyDictToTypedParams(PyObject
*dict
,
290 virTypedParameterPtr
*ret_params
,
292 virPyTypedParamsHintPtr hints
,
297 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
302 virTypedParameterPtr params
= NULL
;
312 if (PyDict_Size(dict
) < 0)
315 while (PyDict_Next(dict
, &pos
, &key
, &value
)) {
318 if (libvirt_charPtrUnwrap(key
, &keystr
) < 0 ||
322 for (i
= 0; i
< nhints
; i
++) {
323 if (STREQ(hints
[i
].name
, keystr
)) {
324 type
= hints
[i
].type
;
330 if (libvirt_PyString_Check(value
)) {
331 type
= VIR_TYPED_PARAM_STRING
;
332 } else if (PyBool_Check(value
)) {
333 type
= VIR_TYPED_PARAM_BOOLEAN
;
334 } else if (PyLong_Check(value
)) {
335 unsigned long long ull
= PyLong_AsUnsignedLongLong(value
);
336 if (ull
== (unsigned long long) -1 && PyErr_Occurred())
337 type
= VIR_TYPED_PARAM_LLONG
;
339 type
= VIR_TYPED_PARAM_ULLONG
;
340 #if PY_MAJOR_VERSION < 3
341 } else if (PyInt_Check(value
)) {
342 if (PyInt_AS_LONG(value
) < 0)
343 type
= VIR_TYPED_PARAM_LLONG
;
345 type
= VIR_TYPED_PARAM_ULLONG
;
347 } else if (PyFloat_Check(value
)) {
348 type
= VIR_TYPED_PARAM_DOUBLE
;
353 PyErr_Format(PyExc_TypeError
,
354 "Unknown type of \"%s\" field", keystr
);
358 switch ((virTypedParameterType
) type
) {
359 case VIR_TYPED_PARAM_INT
:
362 if (libvirt_intUnwrap(value
, &val
) < 0 ||
363 virTypedParamsAddInt(¶ms
, &n
, &max
, keystr
, val
) < 0)
367 case VIR_TYPED_PARAM_UINT
:
370 if (libvirt_uintUnwrap(value
, &val
) < 0 ||
371 virTypedParamsAddUInt(¶ms
, &n
, &max
, keystr
, val
) < 0)
375 case VIR_TYPED_PARAM_LLONG
:
378 if (libvirt_longlongUnwrap(value
, &val
) < 0 ||
379 virTypedParamsAddLLong(¶ms
, &n
, &max
, keystr
, val
) < 0)
383 case VIR_TYPED_PARAM_ULLONG
:
385 unsigned long long val
;
386 if (libvirt_ulonglongUnwrap(value
, &val
) < 0 ||
387 virTypedParamsAddULLong(¶ms
, &n
, &max
, keystr
, val
) < 0)
391 case VIR_TYPED_PARAM_DOUBLE
:
394 if (libvirt_doubleUnwrap(value
, &val
) < 0 ||
395 virTypedParamsAddDouble(¶ms
, &n
, &max
, keystr
, val
) < 0)
399 case VIR_TYPED_PARAM_BOOLEAN
:
402 if (libvirt_boolUnwrap(value
, &val
) < 0 ||
403 virTypedParamsAddBoolean(¶ms
, &n
, &max
, keystr
, val
) < 0)
407 case VIR_TYPED_PARAM_STRING
:
410 if (libvirt_charPtrUnwrap(value
, &val
) < 0 ||
412 virTypedParamsAddString(¶ms
, &n
, &max
, keystr
, val
) < 0) {
419 case VIR_TYPED_PARAM_LAST
:
420 break; /* unreachable */
425 *ret_params
= params
;
432 virTypedParamsFree(params
, n
);
435 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
439 * Utility function to retrieve the number of node CPUs present.
440 * It first tries virGetNodeCPUMap, which will return the
441 * number reliably, if available.
442 * As a fallback and for compatibility with backlevel libvirt
443 * versions virGetNodeInfo will be called to calculate the
444 * CPU number, which has the potential to return a too small
445 * number if some host CPUs are offline.
448 getPyNodeCPUCount(virConnectPtr conn
) {
450 virNodeInfo nodeinfo
;
452 #if LIBVIR_CHECK_VERSION(1, 0, 0)
453 LIBVIRT_BEGIN_ALLOW_THREADS
;
454 i_retval
= virNodeGetCPUMap(conn
, NULL
, NULL
, 0);
455 LIBVIRT_END_ALLOW_THREADS
;
456 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
459 /* fallback: use nodeinfo */
460 LIBVIRT_BEGIN_ALLOW_THREADS
;
461 i_retval
= virNodeGetInfo(conn
, &nodeinfo
);
462 LIBVIRT_END_ALLOW_THREADS
;
466 i_retval
= VIR_NODEINFO_MAXCPUS(nodeinfo
);
473 /************************************************************************
477 ************************************************************************/
480 libvirt_virDomainBlockStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
482 PyObject
*pyobj_domain
;
485 virDomainBlockStatsStruct stats
;
488 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainBlockStats",
489 &pyobj_domain
, &path
))
491 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
493 LIBVIRT_BEGIN_ALLOW_THREADS
;
494 c_retval
= virDomainBlockStats(domain
, path
, &stats
, sizeof(stats
));
495 LIBVIRT_END_ALLOW_THREADS
;
500 /* convert to a Python tuple of long objects */
501 if ((info
= PyTuple_New(5)) == NULL
)
503 PyTuple_SetItem(info
, 0, libvirt_longlongWrap(stats
.rd_req
));
504 PyTuple_SetItem(info
, 1, libvirt_longlongWrap(stats
.rd_bytes
));
505 PyTuple_SetItem(info
, 2, libvirt_longlongWrap(stats
.wr_req
));
506 PyTuple_SetItem(info
, 3, libvirt_longlongWrap(stats
.wr_bytes
));
507 PyTuple_SetItem(info
, 4, libvirt_longlongWrap(stats
.errs
));
512 libvirt_virDomainBlockStatsFlags(PyObject
*self ATTRIBUTE_UNUSED
,
516 PyObject
*pyobj_domain
;
517 PyObject
*ret
= NULL
;
521 virTypedParameterPtr params
;
524 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainBlockStatsFlags",
525 &pyobj_domain
, &path
, &flags
))
527 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
529 LIBVIRT_BEGIN_ALLOW_THREADS
;
530 i_retval
= virDomainBlockStatsFlags(domain
, path
, NULL
, &nparams
, flags
);
531 LIBVIRT_END_ALLOW_THREADS
;
539 if (VIR_ALLOC_N(params
, nparams
) < 0)
540 return PyErr_NoMemory();
542 LIBVIRT_BEGIN_ALLOW_THREADS
;
543 i_retval
= virDomainBlockStatsFlags(domain
, path
, params
, &nparams
, flags
);
544 LIBVIRT_END_ALLOW_THREADS
;
551 ret
= getPyVirTypedParameter(params
, nparams
);
554 virTypedParamsFree(params
, nparams
);
559 libvirt_virDomainGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
562 PyObject
*pyobj_domain
, *totalbool
;
563 PyObject
*cpu
, *total
;
564 PyObject
*ret
= NULL
;
565 PyObject
*error
= NULL
;
566 int ncpus
= -1, start_cpu
= 0;
567 int sumparams
= 0, nparams
= -1;
572 virTypedParameterPtr params
= NULL
, cpuparams
;
574 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainGetCPUStats",
575 &pyobj_domain
, &totalbool
, &flags
))
577 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
579 if (libvirt_boolUnwrap(totalbool
, &totalflag
) < 0)
582 if ((ret
= PyList_New(0)) == NULL
)
586 LIBVIRT_BEGIN_ALLOW_THREADS
;
587 ncpus
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 0, flags
);
588 LIBVIRT_END_ALLOW_THREADS
;
595 LIBVIRT_BEGIN_ALLOW_THREADS
;
596 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 1, flags
);
597 LIBVIRT_END_ALLOW_THREADS
;
604 sumparams
= nparams
* MIN(ncpus
, 128);
606 if (VIR_ALLOC_N(params
, sumparams
) < 0) {
607 error
= PyErr_NoMemory();
612 int queried_ncpus
= MIN(ncpus
, 128);
615 LIBVIRT_BEGIN_ALLOW_THREADS
;
616 i_retval
= virDomainGetCPUStats(domain
, params
,
617 nparams
, start_cpu
, queried_ncpus
, flags
);
618 LIBVIRT_END_ALLOW_THREADS
;
628 for (i
= 0; i
< queried_ncpus
; i
++) {
629 cpuparams
= ¶ms
[i
* nparams
];
630 if ((cpu
= getPyVirTypedParameter(cpuparams
, i_retval
)) == NULL
) {
634 if (PyList_Append(ret
, cpu
) < 0) {
641 start_cpu
+= queried_ncpus
;
642 ncpus
-= queried_ncpus
;
643 virTypedParamsClear(params
, sumparams
);
646 LIBVIRT_BEGIN_ALLOW_THREADS
;
647 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, -1, 1, flags
);
648 LIBVIRT_END_ALLOW_THREADS
;
658 if (VIR_ALLOC_N(params
, nparams
) < 0) {
659 error
= PyErr_NoMemory();
663 LIBVIRT_BEGIN_ALLOW_THREADS
;
664 i_retval
= virDomainGetCPUStats(domain
, params
, nparams
, -1, 1, flags
);
665 LIBVIRT_END_ALLOW_THREADS
;
675 if ((total
= getPyVirTypedParameter(params
, i_retval
)) == NULL
) {
678 if (PyList_Append(ret
, total
) < 0) {
685 virTypedParamsFree(params
, sumparams
);
689 virTypedParamsFree(params
, sumparams
);
695 libvirt_virDomainInterfaceStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
697 PyObject
*pyobj_domain
;
700 virDomainInterfaceStatsStruct stats
;
703 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainInterfaceStats",
704 &pyobj_domain
, &path
))
706 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
708 LIBVIRT_BEGIN_ALLOW_THREADS
;
709 c_retval
= virDomainInterfaceStats(domain
, path
, &stats
, sizeof(stats
));
710 LIBVIRT_END_ALLOW_THREADS
;
715 /* convert to a Python tuple of long objects */
716 if ((info
= PyTuple_New(8)) == NULL
)
718 PyTuple_SetItem(info
, 0, libvirt_longlongWrap(stats
.rx_bytes
));
719 PyTuple_SetItem(info
, 1, libvirt_longlongWrap(stats
.rx_packets
));
720 PyTuple_SetItem(info
, 2, libvirt_longlongWrap(stats
.rx_errs
));
721 PyTuple_SetItem(info
, 3, libvirt_longlongWrap(stats
.rx_drop
));
722 PyTuple_SetItem(info
, 4, libvirt_longlongWrap(stats
.tx_bytes
));
723 PyTuple_SetItem(info
, 5, libvirt_longlongWrap(stats
.tx_packets
));
724 PyTuple_SetItem(info
, 6, libvirt_longlongWrap(stats
.tx_errs
));
725 PyTuple_SetItem(info
, 7, libvirt_longlongWrap(stats
.tx_drop
));
730 libvirt_virDomainMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
732 PyObject
*pyobj_domain
;
733 unsigned int nr_stats
;
735 virDomainMemoryStatStruct stats
[VIR_DOMAIN_MEMORY_STAT_NR
];
737 PyObject
*key
= NULL
, *val
= NULL
;
739 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainMemoryStats", &pyobj_domain
))
741 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
743 nr_stats
= virDomainMemoryStats(domain
, stats
,
744 VIR_DOMAIN_MEMORY_STAT_NR
, 0);
748 /* convert to a Python dictionary */
749 if ((info
= PyDict_New()) == NULL
)
752 for (i
= 0; i
< nr_stats
; i
++) {
753 switch (stats
[i
].tag
) {
754 case VIR_DOMAIN_MEMORY_STAT_SWAP_IN
:
755 key
= libvirt_constcharPtrWrap("swap_in");
757 case VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
:
758 key
= libvirt_constcharPtrWrap("swap_out");
760 case VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
:
761 key
= libvirt_constcharPtrWrap("major_fault");
763 case VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
:
764 key
= libvirt_constcharPtrWrap("minor_fault");
766 case VIR_DOMAIN_MEMORY_STAT_UNUSED
:
767 key
= libvirt_constcharPtrWrap("unused");
769 case VIR_DOMAIN_MEMORY_STAT_AVAILABLE
:
770 key
= libvirt_constcharPtrWrap("available");
772 case VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
:
773 key
= libvirt_constcharPtrWrap("actual");
775 case VIR_DOMAIN_MEMORY_STAT_RSS
:
776 key
= libvirt_constcharPtrWrap("rss");
781 val
= libvirt_ulonglongWrap(stats
[i
].val
);
783 if (!key
|| !val
|| PyDict_SetItem(info
, key
, val
) < 0) {
801 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
804 PyObject
*pyobj_domain
, *info
;
808 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
811 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
813 LIBVIRT_BEGIN_ALLOW_THREADS
;
814 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
815 LIBVIRT_END_ALLOW_THREADS
;
816 if (c_retval
== NULL
)
819 /* convert to a Python tuple of long objects */
820 if ((info
= PyTuple_New(2)) == NULL
) {
825 PyTuple_SetItem(info
, 0, libvirt_constcharPtrWrap(c_retval
));
826 PyTuple_SetItem(info
, 1, libvirt_intWrap((long)nparams
));
832 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
836 PyObject
*pyobj_domain
;
837 PyObject
*ret
= NULL
;
841 virTypedParameterPtr params
;
843 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
846 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
848 LIBVIRT_BEGIN_ALLOW_THREADS
;
849 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
850 LIBVIRT_END_ALLOW_THREADS
;
852 if (c_retval
== NULL
)
859 if (VIR_ALLOC_N(params
, nparams
) < 0)
860 return PyErr_NoMemory();
862 LIBVIRT_BEGIN_ALLOW_THREADS
;
863 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
864 LIBVIRT_END_ALLOW_THREADS
;
871 ret
= getPyVirTypedParameter(params
, nparams
);
874 virTypedParamsFree(params
, nparams
);
879 libvirt_virDomainGetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
883 PyObject
*pyobj_domain
;
884 PyObject
*ret
= NULL
;
889 virTypedParameterPtr params
;
891 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetScedulerParametersFlags",
892 &pyobj_domain
, &flags
))
894 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
896 LIBVIRT_BEGIN_ALLOW_THREADS
;
897 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
898 LIBVIRT_END_ALLOW_THREADS
;
900 if (c_retval
== NULL
)
907 if (VIR_ALLOC_N(params
, nparams
) < 0)
908 return PyErr_NoMemory();
910 LIBVIRT_BEGIN_ALLOW_THREADS
;
911 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
912 LIBVIRT_END_ALLOW_THREADS
;
919 ret
= getPyVirTypedParameter(params
, nparams
);
922 virTypedParamsFree(params
, nparams
);
927 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
931 PyObject
*pyobj_domain
, *info
;
932 PyObject
*ret
= NULL
;
937 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
939 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetScedulerParameters",
940 &pyobj_domain
, &info
))
942 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
944 if ((size
= PyDict_Size(info
)) < 0)
948 PyErr_Format(PyExc_LookupError
,
949 "Need non-empty dictionary to set attributes");
953 LIBVIRT_BEGIN_ALLOW_THREADS
;
954 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
955 LIBVIRT_END_ALLOW_THREADS
;
957 if (c_retval
== NULL
)
958 return VIR_PY_INT_FAIL
;
962 PyErr_Format(PyExc_LookupError
,
963 "Domain has no settable attributes");
967 if (VIR_ALLOC_N(params
, nparams
) < 0)
968 return PyErr_NoMemory();
970 LIBVIRT_BEGIN_ALLOW_THREADS
;
971 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
972 LIBVIRT_END_ALLOW_THREADS
;
975 ret
= VIR_PY_INT_FAIL
;
979 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
983 LIBVIRT_BEGIN_ALLOW_THREADS
;
984 i_retval
= virDomainSetSchedulerParameters(domain
, new_params
, size
);
985 LIBVIRT_END_ALLOW_THREADS
;
988 ret
= VIR_PY_INT_FAIL
;
992 ret
= VIR_PY_INT_SUCCESS
;
995 virTypedParamsFree(params
, nparams
);
996 virTypedParamsFree(new_params
, size
);
1001 libvirt_virDomainSetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1004 virDomainPtr domain
;
1005 PyObject
*pyobj_domain
, *info
;
1006 PyObject
*ret
= NULL
;
1010 Py_ssize_t size
= 0;
1012 virTypedParameterPtr params
, new_params
= NULL
;
1014 if (!PyArg_ParseTuple(args
,
1015 (char *)"OOi:virDomainSetScedulerParametersFlags",
1016 &pyobj_domain
, &info
, &flags
))
1018 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1020 if ((size
= PyDict_Size(info
)) < 0)
1024 PyErr_Format(PyExc_LookupError
,
1025 "Need non-empty dictionary to set attributes");
1029 LIBVIRT_BEGIN_ALLOW_THREADS
;
1030 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
1031 LIBVIRT_END_ALLOW_THREADS
;
1033 if (c_retval
== NULL
)
1034 return VIR_PY_INT_FAIL
;
1038 PyErr_Format(PyExc_LookupError
,
1039 "Domain has no settable attributes");
1043 if (VIR_ALLOC_N(params
, nparams
) < 0)
1044 return PyErr_NoMemory();
1046 LIBVIRT_BEGIN_ALLOW_THREADS
;
1047 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
, flags
);
1048 LIBVIRT_END_ALLOW_THREADS
;
1051 ret
= VIR_PY_INT_FAIL
;
1055 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1059 LIBVIRT_BEGIN_ALLOW_THREADS
;
1060 i_retval
= virDomainSetSchedulerParametersFlags(domain
, new_params
, size
, flags
);
1061 LIBVIRT_END_ALLOW_THREADS
;
1064 ret
= VIR_PY_INT_FAIL
;
1068 ret
= VIR_PY_INT_SUCCESS
;
1071 virTypedParamsFree(params
, nparams
);
1072 virTypedParamsFree(new_params
, nparams
);
1077 libvirt_virDomainSetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1080 virDomainPtr domain
;
1081 PyObject
*pyobj_domain
, *info
;
1082 PyObject
*ret
= NULL
;
1085 Py_ssize_t size
= 0;
1087 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1089 if (!PyArg_ParseTuple(args
,
1090 (char *)"OOi:virDomainSetBlkioParameters",
1091 &pyobj_domain
, &info
, &flags
))
1093 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1095 if ((size
= PyDict_Size(info
)) < 0)
1099 PyErr_Format(PyExc_LookupError
,
1100 "Need non-empty dictionary to set attributes");
1104 LIBVIRT_BEGIN_ALLOW_THREADS
;
1105 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
1106 LIBVIRT_END_ALLOW_THREADS
;
1109 return VIR_PY_INT_FAIL
;
1112 PyErr_Format(PyExc_LookupError
,
1113 "Domain has no settable attributes");
1117 if (VIR_ALLOC_N(params
, nparams
) < 0)
1118 return PyErr_NoMemory();
1120 LIBVIRT_BEGIN_ALLOW_THREADS
;
1121 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
1122 LIBVIRT_END_ALLOW_THREADS
;
1125 ret
= VIR_PY_INT_FAIL
;
1129 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1133 LIBVIRT_BEGIN_ALLOW_THREADS
;
1134 i_retval
= virDomainSetBlkioParameters(domain
, new_params
, size
, flags
);
1135 LIBVIRT_END_ALLOW_THREADS
;
1138 ret
= VIR_PY_INT_FAIL
;
1142 ret
= VIR_PY_INT_SUCCESS
;
1145 virTypedParamsFree(params
, nparams
);
1146 virTypedParamsFree(new_params
, size
);
1151 libvirt_virDomainGetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1154 virDomainPtr domain
;
1155 PyObject
*pyobj_domain
;
1156 PyObject
*ret
= NULL
;
1160 virTypedParameterPtr params
;
1162 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetBlkioParameters",
1163 &pyobj_domain
, &flags
))
1165 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1167 LIBVIRT_BEGIN_ALLOW_THREADS
;
1168 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
1169 LIBVIRT_END_ALLOW_THREADS
;
1175 return PyDict_New();
1177 if (VIR_ALLOC_N(params
, nparams
) < 0)
1178 return PyErr_NoMemory();
1180 LIBVIRT_BEGIN_ALLOW_THREADS
;
1181 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
1182 LIBVIRT_END_ALLOW_THREADS
;
1189 ret
= getPyVirTypedParameter(params
, nparams
);
1192 virTypedParamsFree(params
, nparams
);
1197 libvirt_virDomainSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1200 virDomainPtr domain
;
1201 PyObject
*pyobj_domain
, *info
;
1202 PyObject
*ret
= NULL
;
1205 Py_ssize_t size
= 0;
1207 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1209 if (!PyArg_ParseTuple(args
,
1210 (char *)"OOi:virDomainSetMemoryParameters",
1211 &pyobj_domain
, &info
, &flags
))
1213 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1215 if ((size
= PyDict_Size(info
)) < 0)
1219 PyErr_Format(PyExc_LookupError
,
1220 "Need non-empty dictionary to set attributes");
1224 LIBVIRT_BEGIN_ALLOW_THREADS
;
1225 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
1226 LIBVIRT_END_ALLOW_THREADS
;
1229 return VIR_PY_INT_FAIL
;
1232 PyErr_Format(PyExc_LookupError
,
1233 "Domain has no settable attributes");
1237 if (VIR_ALLOC_N(params
, nparams
) < 0)
1238 return PyErr_NoMemory();
1240 LIBVIRT_BEGIN_ALLOW_THREADS
;
1241 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1242 LIBVIRT_END_ALLOW_THREADS
;
1245 ret
= VIR_PY_INT_FAIL
;
1249 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1253 LIBVIRT_BEGIN_ALLOW_THREADS
;
1254 i_retval
= virDomainSetMemoryParameters(domain
, new_params
, size
, flags
);
1255 LIBVIRT_END_ALLOW_THREADS
;
1258 ret
= VIR_PY_INT_FAIL
;
1262 ret
= VIR_PY_INT_SUCCESS
;
1265 virTypedParamsFree(params
, nparams
);
1266 virTypedParamsFree(new_params
, size
);
1271 libvirt_virDomainGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1274 virDomainPtr domain
;
1275 PyObject
*pyobj_domain
;
1276 PyObject
*ret
= NULL
;
1280 virTypedParameterPtr params
;
1282 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetMemoryParameters",
1283 &pyobj_domain
, &flags
))
1285 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1287 LIBVIRT_BEGIN_ALLOW_THREADS
;
1288 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
1289 LIBVIRT_END_ALLOW_THREADS
;
1295 return PyDict_New();
1297 if (VIR_ALLOC_N(params
, nparams
) < 0)
1298 return PyErr_NoMemory();
1300 LIBVIRT_BEGIN_ALLOW_THREADS
;
1301 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
1302 LIBVIRT_END_ALLOW_THREADS
;
1309 ret
= getPyVirTypedParameter(params
, nparams
);
1312 virTypedParamsFree(params
, nparams
);
1317 libvirt_virDomainSetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1320 virDomainPtr domain
;
1321 PyObject
*pyobj_domain
, *info
;
1322 PyObject
*ret
= NULL
;
1325 Py_ssize_t size
= 0;
1327 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1329 if (!PyArg_ParseTuple(args
,
1330 (char *)"OOi:virDomainSetNumaParameters",
1331 &pyobj_domain
, &info
, &flags
))
1333 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1335 if ((size
= PyDict_Size(info
)) < 0)
1339 PyErr_Format(PyExc_LookupError
,
1340 "Need non-empty dictionary to set attributes");
1344 LIBVIRT_BEGIN_ALLOW_THREADS
;
1345 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1346 LIBVIRT_END_ALLOW_THREADS
;
1349 return VIR_PY_INT_FAIL
;
1352 PyErr_Format(PyExc_LookupError
,
1353 "Domain has no settable attributes");
1357 if (VIR_ALLOC_N(params
, nparams
) < 0)
1358 return PyErr_NoMemory();
1360 LIBVIRT_BEGIN_ALLOW_THREADS
;
1361 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1362 LIBVIRT_END_ALLOW_THREADS
;
1365 ret
= VIR_PY_INT_FAIL
;
1369 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1373 LIBVIRT_BEGIN_ALLOW_THREADS
;
1374 i_retval
= virDomainSetNumaParameters(domain
, new_params
, size
, flags
);
1375 LIBVIRT_END_ALLOW_THREADS
;
1378 ret
= VIR_PY_INT_FAIL
;
1382 ret
= VIR_PY_INT_SUCCESS
;
1385 virTypedParamsFree(params
, nparams
);
1386 virTypedParamsFree(new_params
, size
);
1391 libvirt_virDomainGetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1394 virDomainPtr domain
;
1395 PyObject
*pyobj_domain
;
1396 PyObject
*ret
= NULL
;
1400 virTypedParameterPtr params
;
1402 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetNumaParameters",
1403 &pyobj_domain
, &flags
))
1405 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1407 LIBVIRT_BEGIN_ALLOW_THREADS
;
1408 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1409 LIBVIRT_END_ALLOW_THREADS
;
1415 return PyDict_New();
1417 if (VIR_ALLOC_N(params
, nparams
) < 0)
1418 return PyErr_NoMemory();
1420 LIBVIRT_BEGIN_ALLOW_THREADS
;
1421 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1422 LIBVIRT_END_ALLOW_THREADS
;
1429 ret
= getPyVirTypedParameter(params
, nparams
);
1432 virTypedParamsFree(params
, nparams
);
1437 libvirt_virDomainSetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1440 virDomainPtr domain
;
1441 PyObject
*pyobj_domain
, *info
;
1442 PyObject
*ret
= NULL
;
1445 Py_ssize_t size
= 0;
1447 const char *device
= NULL
;
1448 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1450 if (!PyArg_ParseTuple(args
,
1451 (char *)"OzOi:virDomainSetInterfaceParameters",
1452 &pyobj_domain
, &device
, &info
, &flags
))
1454 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1456 if ((size
= PyDict_Size(info
)) < 0)
1460 PyErr_Format(PyExc_LookupError
,
1461 "Need non-empty dictionary to set attributes");
1465 LIBVIRT_BEGIN_ALLOW_THREADS
;
1466 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1467 LIBVIRT_END_ALLOW_THREADS
;
1470 return VIR_PY_INT_FAIL
;
1473 PyErr_Format(PyExc_LookupError
,
1474 "Domain has no settable attributes");
1478 if (VIR_ALLOC_N(params
, nparams
) < 0)
1479 return PyErr_NoMemory();
1481 LIBVIRT_BEGIN_ALLOW_THREADS
;
1482 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1483 LIBVIRT_END_ALLOW_THREADS
;
1486 ret
= VIR_PY_INT_FAIL
;
1490 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1494 LIBVIRT_BEGIN_ALLOW_THREADS
;
1495 i_retval
= virDomainSetInterfaceParameters(domain
, device
, new_params
, size
, flags
);
1496 LIBVIRT_END_ALLOW_THREADS
;
1499 ret
= VIR_PY_INT_FAIL
;
1503 ret
= VIR_PY_INT_SUCCESS
;
1506 virTypedParamsFree(params
, nparams
);
1507 virTypedParamsFree(new_params
, size
);
1512 libvirt_virDomainGetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1515 virDomainPtr domain
;
1516 PyObject
*pyobj_domain
;
1517 PyObject
*ret
= NULL
;
1521 const char *device
= NULL
;
1522 virTypedParameterPtr params
;
1524 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInterfaceParameters",
1525 &pyobj_domain
, &device
, &flags
))
1527 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1529 LIBVIRT_BEGIN_ALLOW_THREADS
;
1530 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
, flags
);
1531 LIBVIRT_END_ALLOW_THREADS
;
1537 return PyDict_New();
1539 if (VIR_ALLOC_N(params
, nparams
) < 0)
1540 return PyErr_NoMemory();
1542 LIBVIRT_BEGIN_ALLOW_THREADS
;
1543 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
, flags
);
1544 LIBVIRT_END_ALLOW_THREADS
;
1551 ret
= getPyVirTypedParameter(params
, nparams
);
1554 virTypedParamsFree(params
, nparams
);
1559 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
1562 virDomainPtr domain
;
1563 PyObject
*pyobj_domain
, *pyretval
= NULL
, *pycpuinfo
= NULL
, *pycpumap
= NULL
;
1564 PyObject
*error
= NULL
;
1565 virDomainInfo dominfo
;
1566 virVcpuInfoPtr cpuinfo
= NULL
;
1567 unsigned char *cpumap
= NULL
;
1568 size_t cpumaplen
, i
;
1569 int i_retval
, cpunum
;
1571 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
1574 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1576 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1577 return VIR_PY_INT_FAIL
;
1579 LIBVIRT_BEGIN_ALLOW_THREADS
;
1580 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1581 LIBVIRT_END_ALLOW_THREADS
;
1583 return VIR_PY_INT_FAIL
;
1585 if (VIR_ALLOC_N(cpuinfo
, dominfo
.nrVirtCpu
) < 0)
1586 return PyErr_NoMemory();
1588 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1589 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1590 VIR_ALLOC_N(cpumap
, dominfo
.nrVirtCpu
* cpumaplen
) < 0) {
1591 error
= PyErr_NoMemory();
1595 LIBVIRT_BEGIN_ALLOW_THREADS
;
1596 i_retval
= virDomainGetVcpus(domain
,
1597 cpuinfo
, dominfo
.nrVirtCpu
,
1599 LIBVIRT_END_ALLOW_THREADS
;
1601 error
= VIR_PY_INT_FAIL
;
1605 /* convert to a Python tuple of long objects */
1606 if ((pyretval
= PyTuple_New(2)) == NULL
)
1608 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1610 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1613 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1614 PyObject
*info
= PyTuple_New(4);
1615 PyObject
*item
= NULL
;
1620 if ((item
= libvirt_intWrap((long)cpuinfo
[i
].number
)) == NULL
||
1621 PyTuple_SetItem(info
, 0, item
) < 0)
1624 if ((item
= libvirt_intWrap((long)cpuinfo
[i
].state
)) == NULL
||
1625 PyTuple_SetItem(info
, 1, item
) < 0)
1628 if ((item
= libvirt_longlongWrap((long long)cpuinfo
[i
].cpuTime
)) == NULL
||
1629 PyTuple_SetItem(info
, 2, item
) < 0)
1632 if ((item
= libvirt_intWrap((long)cpuinfo
[i
].cpu
)) == NULL
||
1633 PyTuple_SetItem(info
, 3, item
) < 0)
1636 if (PyList_SetItem(pycpuinfo
, i
, info
) < 0)
1645 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1646 PyObject
*info
= PyTuple_New(cpunum
);
1650 for (j
= 0; j
< cpunum
; j
++) {
1651 PyObject
*item
= NULL
;
1652 if ((item
= PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
, i
, j
))) == NULL
||
1653 PyTuple_SetItem(info
, j
, item
) < 0) {
1659 if (PyList_SetItem(pycpumap
, i
, info
) < 0) {
1664 if (PyTuple_SetItem(pyretval
, 0, pycpuinfo
) < 0 ||
1665 PyTuple_SetItem(pyretval
, 1, pycpumap
) < 0)
1676 Py_XDECREF(pyretval
);
1677 Py_XDECREF(pycpuinfo
);
1678 Py_XDECREF(pycpumap
);
1684 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
1687 virDomainPtr domain
;
1688 PyObject
*pyobj_domain
, *pycpumap
;
1689 PyObject
*ret
= NULL
;
1690 unsigned char *cpumap
;
1691 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1695 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
1696 &pyobj_domain
, &vcpu
, &pycpumap
))
1698 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1700 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1701 return VIR_PY_INT_FAIL
;
1703 if (PyTuple_Check(pycpumap
)) {
1704 tuple_size
= PyTuple_Size(pycpumap
);
1705 if (tuple_size
== -1)
1708 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1712 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1713 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1714 return PyErr_NoMemory();
1716 for (i
= 0; i
< tuple_size
; i
++) {
1717 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1720 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1724 VIR_USE_CPU(cpumap
, i
);
1726 VIR_UNUSE_CPU(cpumap
, i
);
1729 for (; i
< cpunum
; i
++)
1730 VIR_UNUSE_CPU(cpumap
, i
);
1732 LIBVIRT_BEGIN_ALLOW_THREADS
;
1733 i_retval
= virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
1734 LIBVIRT_END_ALLOW_THREADS
;
1737 ret
= VIR_PY_INT_FAIL
;
1740 ret
= VIR_PY_INT_SUCCESS
;
1748 libvirt_virDomainPinVcpuFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1751 virDomainPtr domain
;
1752 PyObject
*pyobj_domain
, *pycpumap
;
1753 PyObject
*ret
= NULL
;
1754 unsigned char *cpumap
;
1755 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1760 if (!PyArg_ParseTuple(args
, (char *)"OiOi:virDomainPinVcpuFlags",
1761 &pyobj_domain
, &vcpu
, &pycpumap
, &flags
))
1763 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1765 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1766 return VIR_PY_INT_FAIL
;
1768 if (PyTuple_Check(pycpumap
)) {
1769 tuple_size
= PyTuple_Size(pycpumap
);
1770 if (tuple_size
== -1)
1773 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1777 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1778 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1779 return PyErr_NoMemory();
1781 for (i
= 0; i
< tuple_size
; i
++) {
1782 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1785 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1789 VIR_USE_CPU(cpumap
, i
);
1791 VIR_UNUSE_CPU(cpumap
, i
);
1794 for (; i
< cpunum
; i
++)
1795 VIR_UNUSE_CPU(cpumap
, i
);
1797 LIBVIRT_BEGIN_ALLOW_THREADS
;
1798 i_retval
= virDomainPinVcpuFlags(domain
, vcpu
, cpumap
, cpumaplen
, flags
);
1799 LIBVIRT_END_ALLOW_THREADS
;
1801 ret
= VIR_PY_INT_FAIL
;
1804 ret
= VIR_PY_INT_SUCCESS
;
1812 libvirt_virDomainGetVcpuPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1814 virDomainPtr domain
;
1815 PyObject
*pyobj_domain
, *pycpumaps
= NULL
;
1816 virDomainInfo dominfo
;
1817 unsigned char *cpumaps
= NULL
;
1818 size_t cpumaplen
, vcpu
, pcpu
;
1820 int i_retval
, cpunum
;
1822 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetVcpuPinInfo",
1823 &pyobj_domain
, &flags
))
1825 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1827 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1828 return VIR_PY_INT_FAIL
;
1830 LIBVIRT_BEGIN_ALLOW_THREADS
;
1831 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1832 LIBVIRT_END_ALLOW_THREADS
;
1836 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1837 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1838 VIR_ALLOC_N(cpumaps
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1841 LIBVIRT_BEGIN_ALLOW_THREADS
;
1842 i_retval
= virDomainGetVcpuPinInfo(domain
, dominfo
.nrVirtCpu
,
1843 cpumaps
, cpumaplen
, flags
);
1844 LIBVIRT_END_ALLOW_THREADS
;
1848 if ((pycpumaps
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1851 for (vcpu
= 0; vcpu
< dominfo
.nrVirtCpu
; vcpu
++) {
1852 PyObject
*mapinfo
= PyTuple_New(cpunum
);
1853 if (mapinfo
== NULL
)
1856 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1857 PyTuple_SetItem(mapinfo
, pcpu
,
1858 PyBool_FromLong(VIR_CPU_USABLE(cpumaps
, cpumaplen
, vcpu
, pcpu
)));
1860 PyList_SetItem(pycpumaps
, vcpu
, mapinfo
);
1870 Py_XDECREF(pycpumaps
);
1876 #if LIBVIR_CHECK_VERSION(0, 10, 0)
1878 libvirt_virDomainPinEmulator(PyObject
*self ATTRIBUTE_UNUSED
,
1881 virDomainPtr domain
;
1882 PyObject
*pyobj_domain
, *pycpumap
;
1883 unsigned char *cpumap
= NULL
;
1884 int cpumaplen
, tuple_size
, cpunum
;
1889 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainPinVcpu",
1890 &pyobj_domain
, &pycpumap
, &flags
))
1893 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1895 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1896 return VIR_PY_INT_FAIL
;
1898 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1900 if (!PyTuple_Check(pycpumap
)) {
1901 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1905 if ((tuple_size
= PyTuple_Size(pycpumap
)) == -1)
1908 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1909 return PyErr_NoMemory();
1911 for (i
= 0; i
< tuple_size
; i
++) {
1912 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1915 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0) {
1917 return VIR_PY_INT_FAIL
;
1921 VIR_USE_CPU(cpumap
, i
);
1923 VIR_UNUSE_CPU(cpumap
, i
);
1926 for (; i
< cpunum
; i
++)
1927 VIR_UNUSE_CPU(cpumap
, i
);
1929 LIBVIRT_BEGIN_ALLOW_THREADS
;
1930 i_retval
= virDomainPinEmulator(domain
, cpumap
, cpumaplen
, flags
);
1931 LIBVIRT_END_ALLOW_THREADS
;
1936 return VIR_PY_INT_FAIL
;
1938 return VIR_PY_INT_SUCCESS
;
1943 libvirt_virDomainGetEmulatorPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1946 virDomainPtr domain
;
1947 PyObject
*pyobj_domain
;
1949 unsigned char *cpumap
;
1956 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainEmulatorPinInfo",
1957 &pyobj_domain
, &flags
))
1960 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1962 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1965 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1967 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1968 return PyErr_NoMemory();
1970 LIBVIRT_BEGIN_ALLOW_THREADS
;
1971 ret
= virDomainGetEmulatorPinInfo(domain
, cpumap
, cpumaplen
, flags
);
1972 LIBVIRT_END_ALLOW_THREADS
;
1978 if (!(pycpumap
= PyTuple_New(cpunum
))) {
1983 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++)
1984 PyTuple_SET_ITEM(pycpumap
, pcpu
,
1985 PyBool_FromLong(VIR_CPU_USABLE(cpumap
, cpumaplen
,
1991 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
1994 /************************************************************************
1996 * Global error handler at the Python level *
1998 ************************************************************************/
2000 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
2001 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
2004 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args ATTRIBUTE_UNUSED
)
2009 if ((err
= virGetLastError()) == NULL
)
2012 if ((info
= PyTuple_New(9)) == NULL
)
2014 PyTuple_SetItem(info
, 0, libvirt_intWrap((long) err
->code
));
2015 PyTuple_SetItem(info
, 1, libvirt_intWrap((long) err
->domain
));
2016 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
2017 PyTuple_SetItem(info
, 3, libvirt_intWrap((long) err
->level
));
2018 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
2019 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
2020 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
2021 PyTuple_SetItem(info
, 7, libvirt_intWrap((long) err
->int1
));
2022 PyTuple_SetItem(info
, 8, libvirt_intWrap((long) err
->int2
));
2028 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2033 PyObject
*pyobj_conn
;
2035 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
2037 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2039 LIBVIRT_BEGIN_ALLOW_THREADS
;
2040 err
= virConnGetLastError(conn
);
2041 LIBVIRT_END_ALLOW_THREADS
;
2045 if ((info
= PyTuple_New(9)) == NULL
)
2047 PyTuple_SetItem(info
, 0, libvirt_intWrap((long) err
->code
));
2048 PyTuple_SetItem(info
, 1, libvirt_intWrap((long) err
->domain
));
2049 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
2050 PyTuple_SetItem(info
, 3, libvirt_intWrap((long) err
->level
));
2051 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
2052 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
2053 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
2054 PyTuple_SetItem(info
, 7, libvirt_intWrap((long) err
->int1
));
2055 PyTuple_SetItem(info
, 8, libvirt_intWrap((long) err
->int2
));
2061 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
, virErrorPtr err
)
2063 PyObject
*list
, *info
;
2066 DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
2069 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
2072 LIBVIRT_ENSURE_THREAD_STATE
;
2074 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
2075 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
2076 virDefaultErrorFunc(err
);
2078 list
= PyTuple_New(2);
2079 info
= PyTuple_New(9);
2080 PyTuple_SetItem(list
, 0, libvirt_virPythonErrorFuncCtxt
);
2081 PyTuple_SetItem(list
, 1, info
);
2082 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
2083 PyTuple_SetItem(info
, 0, libvirt_intWrap((long) err
->code
));
2084 PyTuple_SetItem(info
, 1, libvirt_intWrap((long) err
->domain
));
2085 PyTuple_SetItem(info
, 2, libvirt_constcharPtrWrap(err
->message
));
2086 PyTuple_SetItem(info
, 3, libvirt_intWrap((long) err
->level
));
2087 PyTuple_SetItem(info
, 4, libvirt_constcharPtrWrap(err
->str1
));
2088 PyTuple_SetItem(info
, 5, libvirt_constcharPtrWrap(err
->str2
));
2089 PyTuple_SetItem(info
, 6, libvirt_constcharPtrWrap(err
->str3
));
2090 PyTuple_SetItem(info
, 7, libvirt_intWrap((long) err
->int1
));
2091 PyTuple_SetItem(info
, 8, libvirt_intWrap((long) err
->int2
));
2092 /* TODO pass conn and dom if available */
2093 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
2098 LIBVIRT_RELEASE_THREAD_STATE
;
2102 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
* self
,
2105 PyObject
*py_retval
;
2107 PyObject
*pyobj_ctx
;
2109 if (!PyArg_ParseTuple
2110 (args
, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f
,
2114 DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
2117 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
2118 if (libvirt_virPythonErrorFuncHandler
!= NULL
) {
2119 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
2121 if (libvirt_virPythonErrorFuncCtxt
!= NULL
) {
2122 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
2125 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
2126 libvirt_virPythonErrorFuncHandler
= NULL
;
2127 libvirt_virPythonErrorFuncCtxt
= NULL
;
2129 Py_XINCREF(pyobj_ctx
);
2130 Py_XINCREF(pyobj_f
);
2132 /* TODO: check f is a function ! */
2133 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
2134 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
2137 py_retval
= libvirt_intWrap(1);
2141 static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
2146 PyObject
*pyauth
= (PyObject
*)cbdata
;
2153 LIBVIRT_ENSURE_THREAD_STATE
;
2155 pycb
= PyList_GetItem(pyauth
, 1);
2156 pycbdata
= PyList_GetItem(pyauth
, 2);
2158 list
= PyTuple_New(2);
2159 pycred
= PyTuple_New(ncred
);
2160 for (i
= 0; i
< ncred
; i
++) {
2161 PyObject
*pycreditem
;
2162 pycreditem
= PyList_New(5);
2164 PyTuple_SetItem(pycred
, i
, pycreditem
);
2165 PyList_SetItem(pycreditem
, 0, libvirt_intWrap((long) cred
[i
].type
));
2166 PyList_SetItem(pycreditem
, 1, libvirt_constcharPtrWrap(cred
[i
].prompt
));
2167 if (cred
[i
].challenge
) {
2168 PyList_SetItem(pycreditem
, 2, libvirt_constcharPtrWrap(cred
[i
].challenge
));
2171 PyList_SetItem(pycreditem
, 2, Py_None
);
2173 if (cred
[i
].defresult
) {
2174 PyList_SetItem(pycreditem
, 3, libvirt_constcharPtrWrap(cred
[i
].defresult
));
2177 PyList_SetItem(pycreditem
, 3, Py_None
);
2179 PyList_SetItem(pycreditem
, 4, Py_None
);
2182 PyTuple_SetItem(list
, 0, pycred
);
2183 Py_XINCREF(pycbdata
);
2184 PyTuple_SetItem(list
, 1, pycbdata
);
2187 pyret
= PyEval_CallObject(pycb
, list
);
2188 if (PyErr_Occurred()) {
2193 ret
= PyLong_AsLong(pyret
);
2195 for (i
= 0; i
< ncred
; i
++) {
2196 PyObject
*pycreditem
;
2198 char *result
= NULL
;
2199 pycreditem
= PyTuple_GetItem(pycred
, i
);
2200 pyresult
= PyList_GetItem(pycreditem
, 4);
2201 if (pyresult
!= Py_None
)
2202 libvirt_charPtrUnwrap(pyresult
, &result
);
2203 if (result
!= NULL
) {
2204 cred
[i
].result
= result
;
2205 cred
[i
].resultlen
= strlen(result
);
2207 cred
[i
].result
= NULL
;
2208 cred
[i
].resultlen
= 0;
2217 LIBVIRT_RELEASE_THREAD_STATE
;
2224 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2225 PyObject
*py_retval
;
2226 virConnectPtr c_retval
;
2231 PyObject
*pycredtype
;
2232 virConnectAuth auth
;
2234 memset(&auth
, 0, sizeof(auth
));
2235 if (!PyArg_ParseTuple(args
, (char *)"zOi:virConnectOpenAuth", &name
, &pyauth
, &flags
))
2238 pycredtype
= PyList_GetItem(pyauth
, 0);
2239 pycredcb
= PyList_GetItem(pyauth
, 1);
2241 auth
.ncredtype
= PyList_Size(pycredtype
);
2242 if (auth
.ncredtype
) {
2244 if (VIR_ALLOC_N(auth
.credtype
, auth
.ncredtype
) < 0)
2246 for (i
= 0; i
< auth
.ncredtype
; i
++) {
2248 val
= PyList_GetItem(pycredtype
, i
);
2249 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
2252 if (pycredcb
&& pycredcb
!= Py_None
)
2253 auth
.cb
= virConnectCredCallbackWrapper
;
2254 auth
.cbdata
= pyauth
;
2256 LIBVIRT_BEGIN_ALLOW_THREADS
;
2258 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
2259 LIBVIRT_END_ALLOW_THREADS
;
2260 VIR_FREE(auth
.credtype
);
2261 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
2266 /************************************************************************
2268 * Wrappers for functions where generator fails *
2270 ************************************************************************/
2273 libvirt_virGetVersion(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2276 unsigned long libVer
, typeVer
= 0;
2279 if (!PyArg_ParseTuple(args
, (char *) "|s", &type
))
2282 LIBVIRT_BEGIN_ALLOW_THREADS
;
2285 c_retval
= virGetVersion(&libVer
, NULL
, NULL
);
2287 c_retval
= virGetVersion(&libVer
, type
, &typeVer
);
2289 LIBVIRT_END_ALLOW_THREADS
;
2295 return libvirt_intWrap(libVer
);
2297 return Py_BuildValue((char *) "kk", libVer
, typeVer
);
2301 libvirt_virConnectGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2304 unsigned long hvVersion
;
2307 PyObject
*pyobj_conn
;
2309 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetVersion",
2312 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2314 LIBVIRT_BEGIN_ALLOW_THREADS
;
2316 c_retval
= virConnectGetVersion(conn
, &hvVersion
);
2318 LIBVIRT_END_ALLOW_THREADS
;
2321 return VIR_PY_INT_FAIL
;
2323 return libvirt_intWrap(hvVersion
);
2326 #if LIBVIR_CHECK_VERSION(1, 1, 3)
2328 libvirt_virConnectGetCPUModelNames(PyObject
*self ATTRIBUTE_UNUSED
,
2333 PyObject
*rv
= NULL
, *pyobj_conn
;
2334 char **models
= NULL
;
2337 const char *arch
= NULL
;
2339 if (!PyArg_ParseTuple(args
, (char *)"Osi:virConnectGetCPUModelNames",
2340 &pyobj_conn
, &arch
, &flags
))
2342 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2344 LIBVIRT_BEGIN_ALLOW_THREADS
;
2346 c_retval
= virConnectGetCPUModelNames(conn
, arch
, &models
, flags
);
2348 LIBVIRT_END_ALLOW_THREADS
;
2353 if ((rv
= PyList_New(c_retval
)) == NULL
)
2356 for (i
= 0; i
< c_retval
; i
++) {
2358 if ((str
= libvirt_constcharPtrWrap(models
[i
])) == NULL
)
2361 PyList_SET_ITEM(rv
, i
, str
);
2366 for (i
= 0; i
< c_retval
; i
++)
2367 VIR_FREE(models
[i
]);
2378 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
2381 libvirt_virConnectGetLibVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2384 unsigned long libVer
;
2387 PyObject
*pyobj_conn
;
2389 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetLibVersion",
2392 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2394 LIBVIRT_BEGIN_ALLOW_THREADS
;
2396 c_retval
= virConnectGetLibVersion(conn
, &libVer
);
2398 LIBVIRT_END_ALLOW_THREADS
;
2401 return VIR_PY_INT_FAIL
;
2403 return libvirt_intWrap(libVer
);
2407 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
2409 PyObject
*py_retval
;
2410 int *ids
= NULL
, c_retval
;
2413 PyObject
*pyobj_conn
;
2416 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
2418 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2420 LIBVIRT_BEGIN_ALLOW_THREADS
;
2421 c_retval
= virConnectNumOfDomains(conn
);
2422 LIBVIRT_END_ALLOW_THREADS
;
2427 if (VIR_ALLOC_N(ids
, c_retval
) < 0)
2430 LIBVIRT_BEGIN_ALLOW_THREADS
;
2431 c_retval
= virConnectListDomains(conn
, ids
, c_retval
);
2432 LIBVIRT_END_ALLOW_THREADS
;
2438 py_retval
= PyList_New(c_retval
);
2441 for (i
= 0; i
< c_retval
; i
++) {
2442 PyList_SetItem(py_retval
, i
, libvirt_intWrap(ids
[i
]));
2450 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2452 libvirt_virConnectListAllDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2455 PyObject
*pyobj_conn
;
2456 PyObject
*py_retval
= NULL
;
2457 PyObject
*tmp
= NULL
;
2459 virDomainPtr
*doms
= NULL
;
2464 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllDomains",
2465 &pyobj_conn
, &flags
))
2467 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2469 LIBVIRT_BEGIN_ALLOW_THREADS
;
2470 c_retval
= virConnectListAllDomains(conn
, &doms
, flags
);
2471 LIBVIRT_END_ALLOW_THREADS
;
2475 if (!(py_retval
= PyList_New(c_retval
)))
2478 for (i
= 0; i
< c_retval
; i
++) {
2479 if (!(tmp
= libvirt_virDomainPtrWrap(doms
[i
])) ||
2480 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
2482 Py_DECREF(py_retval
);
2486 /* python steals the pointer */
2491 for (i
= 0; i
< c_retval
; i
++)
2493 virDomainFree(doms
[i
]);
2497 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2500 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2502 PyObject
*py_retval
;
2503 char **names
= NULL
;
2507 PyObject
*pyobj_conn
;
2510 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains", &pyobj_conn
))
2512 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2514 LIBVIRT_BEGIN_ALLOW_THREADS
;
2515 c_retval
= virConnectNumOfDefinedDomains(conn
);
2516 LIBVIRT_END_ALLOW_THREADS
;
2521 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2523 LIBVIRT_BEGIN_ALLOW_THREADS
;
2524 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
2525 LIBVIRT_END_ALLOW_THREADS
;
2531 py_retval
= PyList_New(c_retval
);
2534 for (i
= 0; i
< c_retval
; i
++) {
2535 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
2545 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2548 PyObject
*py_retval
;
2549 char **names
= NULL
;
2553 PyObject
*pyobj_dom
;
2554 PyObject
*pyobj_snap
;
2557 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListNames",
2558 &pyobj_dom
, &flags
))
2560 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2562 LIBVIRT_BEGIN_ALLOW_THREADS
;
2563 c_retval
= virDomainSnapshotNum(dom
, flags
);
2564 LIBVIRT_END_ALLOW_THREADS
;
2569 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2570 return PyErr_NoMemory();
2571 LIBVIRT_BEGIN_ALLOW_THREADS
;
2572 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2573 LIBVIRT_END_ALLOW_THREADS
;
2579 py_retval
= PyList_New(c_retval
);
2583 for (i
= 0; i
< c_retval
; i
++) {
2584 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2585 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2586 Py_XDECREF(pyobj_snap
);
2587 Py_DECREF(py_retval
);
2595 for (i
= 0; i
< c_retval
; i
++)
2601 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2603 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2606 PyObject
*py_retval
= NULL
;
2607 virDomainSnapshotPtr
*snaps
= NULL
;
2611 PyObject
*pyobj_dom
;
2613 PyObject
*pyobj_snap
;
2615 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainListAllSnapshots",
2616 &pyobj_dom
, &flags
))
2618 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2620 LIBVIRT_BEGIN_ALLOW_THREADS
;
2621 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2622 LIBVIRT_END_ALLOW_THREADS
;
2626 if (!(py_retval
= PyList_New(c_retval
)))
2629 for (i
= 0; i
< c_retval
; i
++) {
2630 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2631 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2632 Py_XDECREF(pyobj_snap
);
2633 Py_DECREF(py_retval
);
2641 for (i
= 0; i
< c_retval
; i
++)
2643 virDomainSnapshotFree(snaps
[i
]);
2647 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2650 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2653 PyObject
*py_retval
;
2654 char **names
= NULL
;
2657 virDomainSnapshotPtr snap
;
2658 PyObject
*pyobj_snap
;
2661 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListChildrenNames",
2662 &pyobj_snap
, &flags
))
2664 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2666 LIBVIRT_BEGIN_ALLOW_THREADS
;
2667 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2668 LIBVIRT_END_ALLOW_THREADS
;
2673 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2674 return PyErr_NoMemory();
2675 LIBVIRT_BEGIN_ALLOW_THREADS
;
2676 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2678 LIBVIRT_END_ALLOW_THREADS
;
2684 py_retval
= PyList_New(c_retval
);
2686 for (i
= 0; i
< c_retval
; i
++) {
2687 if ((pyobj_snap
= libvirt_constcharPtrWrap(names
[i
])) == NULL
||
2688 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2689 Py_XDECREF(pyobj_snap
);
2690 Py_DECREF(py_retval
);
2698 for (i
= 0; i
< c_retval
; i
++)
2704 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2706 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2709 PyObject
*py_retval
= NULL
;
2710 virDomainSnapshotPtr
*snaps
= NULL
;
2713 virDomainSnapshotPtr parent
;
2714 PyObject
*pyobj_parent
;
2716 PyObject
*pyobj_snap
;
2718 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainSnapshotListAllChildren",
2719 &pyobj_parent
, &flags
))
2721 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2723 LIBVIRT_BEGIN_ALLOW_THREADS
;
2724 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2725 LIBVIRT_END_ALLOW_THREADS
;
2729 if (!(py_retval
= PyList_New(c_retval
)))
2732 for (i
= 0; i
< c_retval
; i
++) {
2733 if ((pyobj_snap
= libvirt_virDomainSnapshotPtrWrap(snaps
[i
])) == NULL
||
2734 PyList_SetItem(py_retval
, i
, pyobj_snap
) < 0) {
2735 Py_XDECREF(pyobj_snap
);
2736 Py_DECREF(py_retval
);
2744 for (i
= 0; i
< c_retval
; i
++)
2746 virDomainSnapshotFree(snaps
[i
]);
2750 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2753 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2756 virDomainSnapshotPtr snap
;
2757 PyObject
*pyobj_snap
;
2758 PyObject
*pyobj_dom
;
2761 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainRevertToSnapshot", &pyobj_dom
, &pyobj_snap
, &flags
))
2763 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2765 LIBVIRT_BEGIN_ALLOW_THREADS
;
2766 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2767 LIBVIRT_END_ALLOW_THREADS
;
2769 return VIR_PY_INT_FAIL
;
2771 return libvirt_intWrap(c_retval
);
2775 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2776 PyObject
*py_retval
;
2778 virDomainPtr domain
;
2779 PyObject
*pyobj_domain
;
2782 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2784 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2786 LIBVIRT_BEGIN_ALLOW_THREADS
;
2787 c_retval
= virDomainGetInfo(domain
, &info
);
2788 LIBVIRT_END_ALLOW_THREADS
;
2791 py_retval
= PyList_New(5);
2792 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
2793 PyList_SetItem(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
));
2794 PyList_SetItem(py_retval
, 2, libvirt_ulongWrap(info
.memory
));
2795 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.nrVirtCpu
));
2796 PyList_SetItem(py_retval
, 4,
2797 libvirt_longlongWrap((unsigned long long) info
.cpuTime
));
2802 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
2804 PyObject
*py_retval
;
2806 virDomainPtr domain
;
2807 PyObject
*pyobj_domain
;
2812 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetState",
2813 &pyobj_domain
, &flags
))
2816 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2818 LIBVIRT_BEGIN_ALLOW_THREADS
;
2819 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2820 LIBVIRT_END_ALLOW_THREADS
;
2824 py_retval
= PyList_New(2);
2825 PyList_SetItem(py_retval
, 0, libvirt_intWrap(state
));
2826 PyList_SetItem(py_retval
, 1, libvirt_intWrap(reason
));
2831 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2832 PyObject
*py_retval
;
2834 virDomainPtr domain
;
2835 PyObject
*pyobj_domain
;
2836 virDomainControlInfo info
;
2839 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainGetControlInfo",
2840 &pyobj_domain
, &flags
))
2842 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2844 LIBVIRT_BEGIN_ALLOW_THREADS
;
2845 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2846 LIBVIRT_END_ALLOW_THREADS
;
2849 py_retval
= PyList_New(3);
2850 PyList_SetItem(py_retval
, 0, libvirt_intWrap(info
.state
));
2851 PyList_SetItem(py_retval
, 1, libvirt_intWrap(info
.details
));
2852 PyList_SetItem(py_retval
, 2, libvirt_longlongWrap(info
.stateTime
));
2857 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2858 PyObject
*py_retval
;
2860 virDomainPtr domain
;
2861 PyObject
*pyobj_domain
;
2862 virDomainBlockInfo info
;
2866 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetInfo", &pyobj_domain
, &path
, &flags
))
2868 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2870 LIBVIRT_BEGIN_ALLOW_THREADS
;
2871 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2872 LIBVIRT_END_ALLOW_THREADS
;
2875 py_retval
= PyList_New(3);
2876 PyList_SetItem(py_retval
, 0, libvirt_ulonglongWrap(info
.capacity
));
2877 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.allocation
));
2878 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.physical
));
2883 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2884 PyObject
*py_retval
;
2887 PyObject
*pyobj_conn
;
2890 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_conn
))
2892 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2894 LIBVIRT_BEGIN_ALLOW_THREADS
;
2895 c_retval
= virNodeGetInfo(conn
, &info
);
2896 LIBVIRT_END_ALLOW_THREADS
;
2899 py_retval
= PyList_New(8);
2900 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&info
.model
[0]));
2901 PyList_SetItem(py_retval
, 1, libvirt_longWrap((long) info
.memory
>> 10));
2902 PyList_SetItem(py_retval
, 2, libvirt_intWrap((int) info
.cpus
));
2903 PyList_SetItem(py_retval
, 3, libvirt_intWrap((int) info
.mhz
));
2904 PyList_SetItem(py_retval
, 4, libvirt_intWrap((int) info
.nodes
));
2905 PyList_SetItem(py_retval
, 5, libvirt_intWrap((int) info
.sockets
));
2906 PyList_SetItem(py_retval
, 6, libvirt_intWrap((int) info
.cores
));
2907 PyList_SetItem(py_retval
, 7, libvirt_intWrap((int) info
.threads
));
2912 libvirt_virNodeGetSecurityModel(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2913 PyObject
*py_retval
;
2916 PyObject
*pyobj_conn
;
2917 virSecurityModel model
;
2919 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityModel", &pyobj_conn
))
2921 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2923 LIBVIRT_BEGIN_ALLOW_THREADS
;
2924 c_retval
= virNodeGetSecurityModel(conn
, &model
);
2925 LIBVIRT_END_ALLOW_THREADS
;
2928 py_retval
= PyList_New(2);
2929 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&model
.model
[0]));
2930 PyList_SetItem(py_retval
, 1, libvirt_constcharPtrWrap(&model
.doi
[0]));
2935 libvirt_virDomainGetSecurityLabel(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2936 PyObject
*py_retval
;
2939 PyObject
*pyobj_dom
;
2940 virSecurityLabel label
;
2942 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom
))
2944 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2946 LIBVIRT_BEGIN_ALLOW_THREADS
;
2947 c_retval
= virDomainGetSecurityLabel(dom
, &label
);
2948 LIBVIRT_END_ALLOW_THREADS
;
2951 py_retval
= PyList_New(2);
2952 PyList_SetItem(py_retval
, 0, libvirt_constcharPtrWrap(&label
.label
[0]));
2953 PyList_SetItem(py_retval
, 1, libvirt_boolWrap(label
.enforcing
));
2957 #if LIBVIR_CHECK_VERSION(0, 10, 0)
2959 libvirt_virDomainGetSecurityLabelList(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2960 PyObject
*py_retval
;
2963 PyObject
*pyobj_dom
;
2964 virSecurityLabel
*labels
;
2967 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom
))
2969 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2971 LIBVIRT_BEGIN_ALLOW_THREADS
;
2972 c_retval
= virDomainGetSecurityLabelList(dom
, &labels
);
2973 LIBVIRT_END_ALLOW_THREADS
;
2976 py_retval
= PyList_New(0);
2977 for (i
= 0 ; i
< c_retval
; i
++) {
2978 PyObject
*entry
= PyList_New(2);
2979 PyList_SetItem(entry
, 0, libvirt_constcharPtrWrap(&labels
[i
].label
[0]));
2980 PyList_SetItem(entry
, 1, libvirt_boolWrap(labels
[i
].enforcing
));
2981 PyList_Append(py_retval
, entry
);
2986 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
2989 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
2990 PyObject
*py_retval
;
2991 unsigned char uuid
[VIR_UUID_BUFLEN
];
2992 virDomainPtr domain
;
2993 PyObject
*pyobj_domain
;
2996 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2998 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3002 LIBVIRT_BEGIN_ALLOW_THREADS
;
3003 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
3004 LIBVIRT_END_ALLOW_THREADS
;
3008 py_retval
= libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3014 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3016 PyObject
*py_retval
;
3017 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3019 PyObject
*pyobj_dom
;
3022 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
3025 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
3029 LIBVIRT_BEGIN_ALLOW_THREADS
;
3030 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
3031 LIBVIRT_END_ALLOW_THREADS
;
3036 py_retval
= libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3041 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3042 PyObject
*py_retval
;
3043 virDomainPtr c_retval
;
3045 PyObject
*pyobj_conn
;
3046 unsigned char * uuid
;
3049 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3051 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3053 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3056 LIBVIRT_BEGIN_ALLOW_THREADS
;
3057 c_retval
= virDomainLookupByUUID(conn
, uuid
);
3058 LIBVIRT_END_ALLOW_THREADS
;
3059 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
3065 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3067 PyObject
*py_retval
;
3068 char **names
= NULL
;
3072 PyObject
*pyobj_conn
;
3075 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks", &pyobj_conn
))
3077 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3079 LIBVIRT_BEGIN_ALLOW_THREADS
;
3080 c_retval
= virConnectNumOfNetworks(conn
);
3081 LIBVIRT_END_ALLOW_THREADS
;
3086 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3088 LIBVIRT_BEGIN_ALLOW_THREADS
;
3089 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
3090 LIBVIRT_END_ALLOW_THREADS
;
3096 py_retval
= PyList_New(c_retval
);
3099 for (i
= 0; i
< c_retval
; i
++) {
3100 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3111 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3113 PyObject
*py_retval
;
3114 char **names
= NULL
;
3118 PyObject
*pyobj_conn
;
3121 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn
))
3123 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3125 LIBVIRT_BEGIN_ALLOW_THREADS
;
3126 c_retval
= virConnectNumOfDefinedNetworks(conn
);
3127 LIBVIRT_END_ALLOW_THREADS
;
3132 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3134 LIBVIRT_BEGIN_ALLOW_THREADS
;
3135 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
3136 LIBVIRT_END_ALLOW_THREADS
;
3142 py_retval
= PyList_New(c_retval
);
3145 for (i
= 0; i
< c_retval
; i
++) {
3146 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3155 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3157 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3160 PyObject
*pyobj_conn
;
3161 PyObject
*py_retval
= NULL
;
3162 PyObject
*tmp
= NULL
;
3164 virNetworkPtr
*nets
= NULL
;
3169 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNetworks",
3170 &pyobj_conn
, &flags
))
3172 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3174 LIBVIRT_BEGIN_ALLOW_THREADS
;
3175 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
3176 LIBVIRT_END_ALLOW_THREADS
;
3180 if (!(py_retval
= PyList_New(c_retval
)))
3183 for (i
= 0; i
< c_retval
; i
++) {
3184 if (!(tmp
= libvirt_virNetworkPtrWrap(nets
[i
])) ||
3185 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3187 Py_DECREF(py_retval
);
3191 /* python steals the pointer */
3196 for (i
= 0; i
< c_retval
; i
++)
3198 virNetworkFree(nets
[i
]);
3202 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3206 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3207 PyObject
*py_retval
;
3208 unsigned char uuid
[VIR_UUID_BUFLEN
];
3209 virNetworkPtr domain
;
3210 PyObject
*pyobj_domain
;
3213 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
3215 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
3219 LIBVIRT_BEGIN_ALLOW_THREADS
;
3220 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
3221 LIBVIRT_END_ALLOW_THREADS
;
3225 py_retval
= libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3231 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3233 PyObject
*py_retval
;
3234 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3236 PyObject
*pyobj_net
;
3239 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
3242 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
3246 LIBVIRT_BEGIN_ALLOW_THREADS
;
3247 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
3248 LIBVIRT_END_ALLOW_THREADS
;
3253 py_retval
= libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3258 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3259 PyObject
*py_retval
;
3260 virNetworkPtr c_retval
;
3262 PyObject
*pyobj_conn
;
3263 unsigned char * uuid
;
3266 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3268 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3270 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3273 LIBVIRT_BEGIN_ALLOW_THREADS
;
3274 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
3275 LIBVIRT_END_ALLOW_THREADS
;
3276 py_retval
= libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
3282 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3283 PyObject
*py_retval
;
3284 int c_retval
, autostart
;
3285 virDomainPtr domain
;
3286 PyObject
*pyobj_domain
;
3288 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart", &pyobj_domain
))
3291 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3293 LIBVIRT_BEGIN_ALLOW_THREADS
;
3294 c_retval
= virDomainGetAutostart(domain
, &autostart
);
3295 LIBVIRT_END_ALLOW_THREADS
;
3298 return VIR_PY_INT_FAIL
;
3299 py_retval
= libvirt_intWrap(autostart
);
3305 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3306 PyObject
*py_retval
;
3307 int c_retval
, autostart
;
3308 virNetworkPtr network
;
3309 PyObject
*pyobj_network
;
3311 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart", &pyobj_network
))
3314 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
3316 LIBVIRT_BEGIN_ALLOW_THREADS
;
3317 c_retval
= virNetworkGetAutostart(network
, &autostart
);
3318 LIBVIRT_END_ALLOW_THREADS
;
3321 return VIR_PY_INT_FAIL
;
3322 py_retval
= libvirt_intWrap(autostart
);
3327 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3329 PyObject
*py_retval
;
3330 PyObject
*pyobj_conn
;
3331 int startCell
, maxCells
, c_retval
;
3334 unsigned long long *freeMems
;
3336 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn
, &startCell
, &maxCells
))
3339 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
3342 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3343 if (VIR_ALLOC_N(freeMems
, maxCells
) < 0)
3346 LIBVIRT_BEGIN_ALLOW_THREADS
;
3347 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
3348 LIBVIRT_END_ALLOW_THREADS
;
3354 py_retval
= PyList_New(c_retval
);
3355 for (i
= 0; i
< c_retval
; i
++) {
3356 PyList_SetItem(py_retval
, i
,
3357 libvirt_longlongWrap((long long) freeMems
[i
]));
3364 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3366 PyObject
*ret
= NULL
;
3367 PyObject
*key
= NULL
;
3368 PyObject
*val
= NULL
;
3369 PyObject
*pyobj_conn
;
3372 int cpuNum
, c_retval
;
3375 virNodeCPUStatsPtr stats
= NULL
;
3377 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCPUStats", &pyobj_conn
, &cpuNum
, &flags
))
3379 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3381 LIBVIRT_BEGIN_ALLOW_THREADS
;
3382 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
3383 LIBVIRT_END_ALLOW_THREADS
;
3388 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3389 return PyErr_NoMemory();
3391 LIBVIRT_BEGIN_ALLOW_THREADS
;
3392 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
3393 LIBVIRT_END_ALLOW_THREADS
;
3400 if (!(ret
= PyDict_New()))
3403 for (i
= 0; i
< nparams
; i
++) {
3404 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3405 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3407 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
3428 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
3430 PyObject
*ret
= NULL
;
3431 PyObject
*key
= NULL
;
3432 PyObject
*val
= NULL
;
3433 PyObject
*pyobj_conn
;
3436 int cellNum
, c_retval
;
3439 virNodeMemoryStatsPtr stats
= NULL
;
3441 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetMemoryStats", &pyobj_conn
, &cellNum
, &flags
))
3443 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3445 LIBVIRT_BEGIN_ALLOW_THREADS
;
3446 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
3447 LIBVIRT_END_ALLOW_THREADS
;
3452 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3453 return PyErr_NoMemory();
3455 LIBVIRT_BEGIN_ALLOW_THREADS
;
3456 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
3457 LIBVIRT_END_ALLOW_THREADS
;
3464 if (!(ret
= PyDict_New()))
3467 for (i
= 0; i
< nparams
; i
++) {
3468 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3469 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3471 if (!key
|| !val
|| PyDict_SetItem(ret
, key
, val
) < 0) {
3492 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3494 PyObject
*py_retval
;
3495 char **names
= NULL
;
3499 PyObject
*pyobj_conn
;
3502 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools", &pyobj_conn
))
3504 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3506 LIBVIRT_BEGIN_ALLOW_THREADS
;
3507 c_retval
= virConnectNumOfStoragePools(conn
);
3508 LIBVIRT_END_ALLOW_THREADS
;
3513 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3515 LIBVIRT_BEGIN_ALLOW_THREADS
;
3516 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
3517 LIBVIRT_END_ALLOW_THREADS
;
3523 py_retval
= PyList_New(c_retval
);
3524 if (py_retval
== NULL
) {
3526 for (i
= 0; i
< c_retval
; i
++)
3534 for (i
= 0; i
< c_retval
; i
++) {
3535 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3546 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3548 PyObject
*py_retval
;
3549 char **names
= NULL
;
3553 PyObject
*pyobj_conn
;
3556 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn
))
3558 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3560 LIBVIRT_BEGIN_ALLOW_THREADS
;
3561 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3562 LIBVIRT_END_ALLOW_THREADS
;
3567 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3569 LIBVIRT_BEGIN_ALLOW_THREADS
;
3570 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3571 LIBVIRT_END_ALLOW_THREADS
;
3577 py_retval
= PyList_New(c_retval
);
3578 if (py_retval
== NULL
) {
3580 for (i
= 0; i
< c_retval
; i
++)
3588 for (i
= 0; i
< c_retval
; i
++) {
3589 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3598 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3600 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3603 PyObject
*pyobj_conn
;
3604 PyObject
*py_retval
= NULL
;
3605 PyObject
*tmp
= NULL
;
3607 virStoragePoolPtr
*pools
= NULL
;
3612 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllStoragePools",
3613 &pyobj_conn
, &flags
))
3615 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3617 LIBVIRT_BEGIN_ALLOW_THREADS
;
3618 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3619 LIBVIRT_END_ALLOW_THREADS
;
3623 if (!(py_retval
= PyList_New(c_retval
)))
3626 for (i
= 0; i
< c_retval
; i
++) {
3627 if (!(tmp
= libvirt_virStoragePoolPtrWrap(pools
[i
])) ||
3628 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3630 Py_DECREF(py_retval
);
3634 /* python steals the pointer */
3639 for (i
= 0; i
< c_retval
; i
++)
3641 virStoragePoolFree(pools
[i
]);
3645 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3648 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3650 PyObject
*py_retval
;
3651 char **names
= NULL
;
3654 virStoragePoolPtr pool
;
3655 PyObject
*pyobj_pool
;
3658 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes", &pyobj_pool
))
3660 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3662 LIBVIRT_BEGIN_ALLOW_THREADS
;
3663 c_retval
= virStoragePoolNumOfVolumes(pool
);
3664 LIBVIRT_END_ALLOW_THREADS
;
3669 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3671 LIBVIRT_BEGIN_ALLOW_THREADS
;
3672 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3673 LIBVIRT_END_ALLOW_THREADS
;
3679 py_retval
= PyList_New(c_retval
);
3680 if (py_retval
== NULL
) {
3682 for (i
= 0; i
< c_retval
; i
++)
3690 for (i
= 0; i
< c_retval
; i
++) {
3691 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3700 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3702 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3705 PyObject
*py_retval
= NULL
;
3706 PyObject
*tmp
= NULL
;
3707 virStoragePoolPtr pool
;
3708 virStorageVolPtr
*vols
= NULL
;
3712 PyObject
*pyobj_pool
;
3714 if (!PyArg_ParseTuple(args
, (char *)"Oi:virStoragePoolListAllVolumes",
3715 &pyobj_pool
, &flags
))
3718 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3720 LIBVIRT_BEGIN_ALLOW_THREADS
;
3721 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3722 LIBVIRT_END_ALLOW_THREADS
;
3726 if (!(py_retval
= PyList_New(c_retval
)))
3729 for (i
= 0; i
< c_retval
; i
++) {
3730 if (!(tmp
= libvirt_virStorageVolPtrWrap(vols
[i
])) ||
3731 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3733 Py_DECREF(py_retval
);
3737 /* python steals the pointer */
3742 for (i
= 0; i
< c_retval
; i
++)
3744 virStorageVolFree(vols
[i
]);
3748 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3752 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3753 PyObject
*py_retval
;
3754 int c_retval
, autostart
;
3755 virStoragePoolPtr pool
;
3756 PyObject
*pyobj_pool
;
3758 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool
))
3761 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3763 LIBVIRT_BEGIN_ALLOW_THREADS
;
3764 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3765 LIBVIRT_END_ALLOW_THREADS
;
3770 py_retval
= libvirt_intWrap(autostart
);
3775 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3776 PyObject
*py_retval
;
3778 virStoragePoolPtr pool
;
3779 PyObject
*pyobj_pool
;
3780 virStoragePoolInfo info
;
3782 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3784 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3786 LIBVIRT_BEGIN_ALLOW_THREADS
;
3787 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3788 LIBVIRT_END_ALLOW_THREADS
;
3792 if ((py_retval
= PyList_New(4)) == NULL
)
3795 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.state
));
3796 PyList_SetItem(py_retval
, 1,
3797 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3798 PyList_SetItem(py_retval
, 2,
3799 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3800 PyList_SetItem(py_retval
, 3,
3801 libvirt_longlongWrap((unsigned long long) info
.available
));
3807 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3808 PyObject
*py_retval
;
3810 virStorageVolPtr pool
;
3811 PyObject
*pyobj_pool
;
3812 virStorageVolInfo info
;
3814 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3816 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3818 LIBVIRT_BEGIN_ALLOW_THREADS
;
3819 c_retval
= virStorageVolGetInfo(pool
, &info
);
3820 LIBVIRT_END_ALLOW_THREADS
;
3824 if ((py_retval
= PyList_New(3)) == NULL
)
3826 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
3827 PyList_SetItem(py_retval
, 1,
3828 libvirt_longlongWrap((unsigned long long) info
.capacity
));
3829 PyList_SetItem(py_retval
, 2,
3830 libvirt_longlongWrap((unsigned long long) info
.allocation
));
3835 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3836 PyObject
*py_retval
;
3837 unsigned char uuid
[VIR_UUID_BUFLEN
];
3838 virStoragePoolPtr pool
;
3839 PyObject
*pyobj_pool
;
3842 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3844 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3848 LIBVIRT_BEGIN_ALLOW_THREADS
;
3849 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3850 LIBVIRT_END_ALLOW_THREADS
;
3855 py_retval
= libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3861 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3863 PyObject
*py_retval
;
3864 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3865 virStoragePoolPtr pool
;
3866 PyObject
*pyobj_pool
;
3869 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool
))
3871 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3875 LIBVIRT_BEGIN_ALLOW_THREADS
;
3876 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3877 LIBVIRT_END_ALLOW_THREADS
;
3882 py_retval
= libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3887 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
3888 PyObject
*py_retval
;
3889 virStoragePoolPtr c_retval
;
3891 PyObject
*pyobj_conn
;
3892 unsigned char * uuid
;
3895 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn
, &uuid
, &len
))
3897 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3899 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3902 LIBVIRT_BEGIN_ALLOW_THREADS
;
3903 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
3904 LIBVIRT_END_ALLOW_THREADS
;
3905 py_retval
= libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
3910 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3912 PyObject
*py_retval
;
3913 char **names
= NULL
;
3917 PyObject
*pyobj_conn
;
3921 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virNodeListDevices",
3922 &pyobj_conn
, &cap
, &flags
))
3924 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3926 LIBVIRT_BEGIN_ALLOW_THREADS
;
3927 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
3928 LIBVIRT_END_ALLOW_THREADS
;
3933 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3935 LIBVIRT_BEGIN_ALLOW_THREADS
;
3936 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
3937 LIBVIRT_END_ALLOW_THREADS
;
3943 py_retval
= PyList_New(c_retval
);
3946 for (i
= 0; i
< c_retval
; i
++) {
3947 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
3956 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3958 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3961 PyObject
*pyobj_conn
;
3962 PyObject
*py_retval
= NULL
;
3963 PyObject
*tmp
= NULL
;
3965 virNodeDevicePtr
*devices
= NULL
;
3970 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNodeDevices",
3971 &pyobj_conn
, &flags
))
3973 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3975 LIBVIRT_BEGIN_ALLOW_THREADS
;
3976 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
3977 LIBVIRT_END_ALLOW_THREADS
;
3981 if (!(py_retval
= PyList_New(c_retval
)))
3984 for (i
= 0; i
< c_retval
; i
++) {
3985 if (!(tmp
= libvirt_virNodeDevicePtrWrap(devices
[i
])) ||
3986 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
3988 Py_DECREF(py_retval
);
3992 /* python steals the pointer */
3997 for (i
= 0; i
< c_retval
; i
++)
3999 virNodeDeviceFree(devices
[i
]);
4003 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4006 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
4008 PyObject
*py_retval
;
4009 char **names
= NULL
;
4012 virNodeDevicePtr dev
;
4013 PyObject
*pyobj_dev
;
4015 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
4017 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
4019 LIBVIRT_BEGIN_ALLOW_THREADS
;
4020 c_retval
= virNodeDeviceNumOfCaps(dev
);
4021 LIBVIRT_END_ALLOW_THREADS
;
4026 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4028 LIBVIRT_BEGIN_ALLOW_THREADS
;
4029 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
4030 LIBVIRT_END_ALLOW_THREADS
;
4036 py_retval
= PyList_New(c_retval
);
4039 for (i
= 0; i
< c_retval
; i
++) {
4040 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
4050 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4051 PyObject
*py_retval
;
4052 unsigned char uuid
[VIR_UUID_BUFLEN
];
4053 virSecretPtr secret
;
4054 PyObject
*pyobj_secret
;
4057 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
4059 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4063 LIBVIRT_BEGIN_ALLOW_THREADS
;
4064 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
4065 LIBVIRT_END_ALLOW_THREADS
;
4069 py_retval
= libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4075 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4077 PyObject
*py_retval
;
4078 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4080 PyObject
*pyobj_dom
;
4083 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
4086 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
4090 LIBVIRT_BEGIN_ALLOW_THREADS
;
4091 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
4092 LIBVIRT_END_ALLOW_THREADS
;
4097 py_retval
= libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4102 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4103 PyObject
*py_retval
;
4104 virSecretPtr c_retval
;
4106 PyObject
*pyobj_conn
;
4107 unsigned char * uuid
;
4110 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn
, &uuid
, &len
))
4112 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4114 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4117 LIBVIRT_BEGIN_ALLOW_THREADS
;
4118 c_retval
= virSecretLookupByUUID(conn
, uuid
);
4119 LIBVIRT_END_ALLOW_THREADS
;
4120 py_retval
= libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
4126 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4128 PyObject
*py_retval
;
4129 char **uuids
= NULL
;
4133 PyObject
*pyobj_conn
;
4135 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
4137 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4139 LIBVIRT_BEGIN_ALLOW_THREADS
;
4140 c_retval
= virConnectNumOfSecrets(conn
);
4141 LIBVIRT_END_ALLOW_THREADS
;
4146 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4148 LIBVIRT_BEGIN_ALLOW_THREADS
;
4149 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
4150 LIBVIRT_END_ALLOW_THREADS
;
4156 py_retval
= PyList_New(c_retval
);
4159 for (i
= 0; i
< c_retval
; i
++) {
4160 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
4169 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4171 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4174 PyObject
*pyobj_conn
;
4175 PyObject
*py_retval
= NULL
;
4176 PyObject
*tmp
= NULL
;
4178 virSecretPtr
*secrets
= NULL
;
4183 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllSecrets",
4184 &pyobj_conn
, &flags
))
4186 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4188 LIBVIRT_BEGIN_ALLOW_THREADS
;
4189 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
4190 LIBVIRT_END_ALLOW_THREADS
;
4194 if (!(py_retval
= PyList_New(c_retval
)))
4197 for (i
= 0; i
< c_retval
; i
++) {
4198 if (!(tmp
= libvirt_virSecretPtrWrap(secrets
[i
])) ||
4199 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4201 Py_DECREF(py_retval
);
4205 /* python steals the pointer */
4210 for (i
= 0; i
< c_retval
; i
++)
4212 virSecretFree(secrets
[i
]);
4216 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4219 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4221 PyObject
*py_retval
;
4222 unsigned char *c_retval
;
4224 virSecretPtr secret
;
4225 PyObject
*pyobj_secret
;
4228 if (!PyArg_ParseTuple(args
, (char *)"Oi:virSecretGetValue", &pyobj_secret
,
4231 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4233 LIBVIRT_BEGIN_ALLOW_THREADS
;
4234 c_retval
= virSecretGetValue(secret
, &size
, flags
);
4235 LIBVIRT_END_ALLOW_THREADS
;
4237 if (c_retval
== NULL
)
4240 py_retval
= libvirt_charPtrSizeWrap((char*)c_retval
, size
);
4247 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4249 PyObject
*py_retval
;
4251 virSecretPtr secret
;
4252 PyObject
*pyobj_secret
;
4257 if (!PyArg_ParseTuple(args
, (char *)"Oz#i:virSecretSetValue", &pyobj_secret
,
4258 &value
, &size
, &flags
))
4260 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4262 LIBVIRT_BEGIN_ALLOW_THREADS
;
4263 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
4265 LIBVIRT_END_ALLOW_THREADS
;
4267 py_retval
= libvirt_intWrap(c_retval
);
4272 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4273 PyObject
*py_retval
;
4274 unsigned char uuid
[VIR_UUID_BUFLEN
];
4275 virNWFilterPtr nwfilter
;
4276 PyObject
*pyobj_nwfilter
;
4279 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID", &pyobj_nwfilter
))
4281 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4283 if (nwfilter
== NULL
)
4285 LIBVIRT_BEGIN_ALLOW_THREADS
;
4286 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
4287 LIBVIRT_END_ALLOW_THREADS
;
4291 py_retval
= libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4297 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4299 PyObject
*py_retval
;
4300 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4301 virNWFilterPtr nwfilter
;
4302 PyObject
*pyobj_nwfilter
;
4305 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
4308 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4310 if (nwfilter
== NULL
)
4312 LIBVIRT_BEGIN_ALLOW_THREADS
;
4313 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
4314 LIBVIRT_END_ALLOW_THREADS
;
4319 py_retval
= libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4324 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4325 PyObject
*py_retval
;
4326 virNWFilterPtr c_retval
;
4328 PyObject
*pyobj_conn
;
4329 unsigned char * uuid
;
4332 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID", &pyobj_conn
, &uuid
, &len
))
4334 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4336 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4339 LIBVIRT_BEGIN_ALLOW_THREADS
;
4340 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
4341 LIBVIRT_END_ALLOW_THREADS
;
4342 py_retval
= libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
4348 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4350 PyObject
*py_retval
;
4351 char **uuids
= NULL
;
4355 PyObject
*pyobj_conn
;
4357 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters", &pyobj_conn
))
4359 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4361 LIBVIRT_BEGIN_ALLOW_THREADS
;
4362 c_retval
= virConnectNumOfNWFilters(conn
);
4363 LIBVIRT_END_ALLOW_THREADS
;
4368 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4370 LIBVIRT_BEGIN_ALLOW_THREADS
;
4371 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
4372 LIBVIRT_END_ALLOW_THREADS
;
4378 py_retval
= PyList_New(c_retval
);
4381 for (i
= 0; i
< c_retval
; i
++) {
4382 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(uuids
[i
]));
4391 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4393 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4396 PyObject
*pyobj_conn
;
4397 PyObject
*py_retval
= NULL
;
4398 PyObject
*tmp
= NULL
;
4400 virNWFilterPtr
*filters
= NULL
;
4405 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllNWFilters",
4406 &pyobj_conn
, &flags
))
4408 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4410 LIBVIRT_BEGIN_ALLOW_THREADS
;
4411 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
4412 LIBVIRT_END_ALLOW_THREADS
;
4416 if (!(py_retval
= PyList_New(c_retval
)))
4419 for (i
= 0; i
< c_retval
; i
++) {
4420 if (!(tmp
= libvirt_virNWFilterPtrWrap(filters
[i
])) ||
4421 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4423 Py_DECREF(py_retval
);
4427 /* python steals the pointer */
4432 for (i
= 0; i
< c_retval
; i
++)
4434 virNWFilterFree(filters
[i
]);
4438 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4441 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4443 PyObject
*py_retval
;
4444 char **names
= NULL
;
4448 PyObject
*pyobj_conn
;
4451 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces", &pyobj_conn
))
4453 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4455 LIBVIRT_BEGIN_ALLOW_THREADS
;
4456 c_retval
= virConnectNumOfInterfaces(conn
);
4457 LIBVIRT_END_ALLOW_THREADS
;
4462 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4464 LIBVIRT_BEGIN_ALLOW_THREADS
;
4465 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
4466 LIBVIRT_END_ALLOW_THREADS
;
4472 py_retval
= PyList_New(c_retval
);
4473 if (py_retval
== NULL
) {
4475 for (i
= 0; i
< c_retval
; i
++)
4483 for (i
= 0; i
< c_retval
; i
++) {
4484 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
4495 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4497 PyObject
*py_retval
;
4498 char **names
= NULL
;
4502 PyObject
*pyobj_conn
;
4505 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
4508 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4510 LIBVIRT_BEGIN_ALLOW_THREADS
;
4511 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
4512 LIBVIRT_END_ALLOW_THREADS
;
4517 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4519 LIBVIRT_BEGIN_ALLOW_THREADS
;
4520 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
4521 LIBVIRT_END_ALLOW_THREADS
;
4527 py_retval
= PyList_New(c_retval
);
4528 if (py_retval
== NULL
) {
4530 for (i
= 0; i
< c_retval
; i
++)
4538 for (i
= 0; i
< c_retval
; i
++) {
4539 PyList_SetItem(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]));
4549 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4551 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4554 PyObject
*pyobj_conn
;
4555 PyObject
*py_retval
= NULL
;
4556 PyObject
*tmp
= NULL
;
4558 virInterfacePtr
*ifaces
= NULL
;
4563 if (!PyArg_ParseTuple(args
, (char *)"Oi:virConnectListAllInterfaces",
4564 &pyobj_conn
, &flags
))
4566 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4568 LIBVIRT_BEGIN_ALLOW_THREADS
;
4569 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
4570 LIBVIRT_END_ALLOW_THREADS
;
4574 if (!(py_retval
= PyList_New(c_retval
)))
4577 for (i
= 0; i
< c_retval
; i
++) {
4578 if (!(tmp
= libvirt_virInterfacePtrWrap(ifaces
[i
])) ||
4579 PyList_SetItem(py_retval
, i
, tmp
) < 0) {
4581 Py_DECREF(py_retval
);
4585 /* python steals the pointer */
4590 for (i
= 0; i
< c_retval
; i
++)
4592 virInterfaceFree(ifaces
[i
]);
4596 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4599 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4601 PyObject
*pyobj_conn
;
4605 char **xmlcpus
= NULL
;
4608 PyObject
*pybase_cpu
;
4611 if (!PyArg_ParseTuple(args
, (char *)"OOi:virConnectBaselineCPU",
4612 &pyobj_conn
, &list
, &flags
))
4614 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4616 if (PyList_Check(list
)) {
4617 ncpus
= PyList_Size(list
);
4618 if (VIR_ALLOC_N(xmlcpus
, ncpus
) < 0)
4621 for (i
= 0; i
< ncpus
; i
++) {
4622 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
), &(xmlcpus
[i
])) < 0 ||
4623 xmlcpus
[i
] == NULL
) {
4624 for (j
= 0 ; j
< i
; j
++)
4625 VIR_FREE(xmlcpus
[j
]);
4632 LIBVIRT_BEGIN_ALLOW_THREADS
;
4633 base_cpu
= virConnectBaselineCPU(conn
, (const char **)xmlcpus
, ncpus
, flags
);
4634 LIBVIRT_END_ALLOW_THREADS
;
4636 for (i
= 0 ; i
< ncpus
; i
++)
4637 VIR_FREE(xmlcpus
[i
]);
4640 if (base_cpu
== NULL
)
4643 pybase_cpu
= libvirt_constcharPtrWrap(base_cpu
);
4646 if (pybase_cpu
== NULL
)
4654 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
4655 PyObject
*py_retval
;
4657 virDomainPtr domain
;
4658 PyObject
*pyobj_domain
;
4659 virDomainJobInfo info
;
4661 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4663 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4665 LIBVIRT_BEGIN_ALLOW_THREADS
;
4666 c_retval
= virDomainGetJobInfo(domain
, &info
);
4667 LIBVIRT_END_ALLOW_THREADS
;
4670 py_retval
= PyList_New(12);
4671 PyList_SetItem(py_retval
, 0, libvirt_intWrap((int) info
.type
));
4672 PyList_SetItem(py_retval
, 1, libvirt_ulonglongWrap(info
.timeElapsed
));
4673 PyList_SetItem(py_retval
, 2, libvirt_ulonglongWrap(info
.timeRemaining
));
4674 PyList_SetItem(py_retval
, 3, libvirt_ulonglongWrap(info
.dataTotal
));
4675 PyList_SetItem(py_retval
, 4, libvirt_ulonglongWrap(info
.dataProcessed
));
4676 PyList_SetItem(py_retval
, 5, libvirt_ulonglongWrap(info
.dataRemaining
));
4677 PyList_SetItem(py_retval
, 6, libvirt_ulonglongWrap(info
.memTotal
));
4678 PyList_SetItem(py_retval
, 7, libvirt_ulonglongWrap(info
.memProcessed
));
4679 PyList_SetItem(py_retval
, 8, libvirt_ulonglongWrap(info
.memRemaining
));
4680 PyList_SetItem(py_retval
, 9, libvirt_ulonglongWrap(info
.fileTotal
));
4681 PyList_SetItem(py_retval
, 10, libvirt_ulonglongWrap(info
.fileProcessed
));
4682 PyList_SetItem(py_retval
, 11, libvirt_ulonglongWrap(info
.fileRemaining
));
4687 #if LIBVIR_CHECK_VERSION(1, 0, 3)
4689 libvirt_virDomainGetJobStats(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
)
4691 PyObject
*pyobj_domain
;
4692 virDomainPtr domain
;
4694 virTypedParameterPtr params
= NULL
;
4697 PyObject
*dict
= NULL
;
4700 if (!PyArg_ParseTuple(args
, (char *) "Oi:virDomainGetJobStats",
4701 &pyobj_domain
, &flags
))
4703 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4705 LIBVIRT_BEGIN_ALLOW_THREADS
;
4706 rc
= virDomainGetJobStats(domain
, &type
, ¶ms
, &nparams
, flags
);
4707 LIBVIRT_END_ALLOW_THREADS
;
4711 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
4714 if (PyDict_SetItem(dict
, libvirt_constcharPtrWrap("type"),
4715 libvirt_intWrap(type
)) < 0) {
4722 virTypedParamsFree(params
, nparams
);
4728 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
4731 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4734 virDomainPtr domain
;
4735 PyObject
*pyobj_domain
;
4738 virDomainBlockJobInfo info
;
4740 PyObject
*type
= NULL
, *bandwidth
= NULL
, *cur
= NULL
, *end
= NULL
;
4743 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockJobInfo",
4744 &pyobj_domain
, &path
, &flags
))
4746 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4748 if ((dict
= PyDict_New()) == NULL
)
4751 LIBVIRT_BEGIN_ALLOW_THREADS
;
4752 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4753 LIBVIRT_END_ALLOW_THREADS
;
4757 } else if (c_ret
< 0) {
4762 if ((type
= libvirt_intWrap(info
.type
)) == NULL
||
4763 PyDict_SetItemString(dict
, "type", type
) < 0)
4767 if ((bandwidth
= libvirt_ulongWrap(info
.bandwidth
)) == NULL
||
4768 PyDict_SetItemString(dict
, "bandwidth", bandwidth
) < 0)
4770 Py_DECREF(bandwidth
);
4772 if ((cur
= libvirt_ulonglongWrap(info
.cur
)) == NULL
||
4773 PyDict_SetItemString(dict
, "cur", cur
) < 0)
4777 if ((end
= libvirt_ulonglongWrap(info
.end
)) == NULL
||
4778 PyDict_SetItemString(dict
, "end", end
) < 0)
4787 Py_XDECREF(bandwidth
);
4794 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4797 virDomainPtr domain
;
4798 PyObject
*pyobj_domain
, *info
;
4799 PyObject
*ret
= NULL
;
4802 Py_ssize_t size
= 0;
4805 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
4807 if (!PyArg_ParseTuple(args
, (char *)"OzOi:virDomainSetBlockIoTune",
4808 &pyobj_domain
, &disk
, &info
, &flags
))
4810 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4812 if ((size
= PyDict_Size(info
)) < 0)
4816 PyErr_Format(PyExc_LookupError
,
4817 "Need non-empty dictionary to set attributes");
4821 LIBVIRT_BEGIN_ALLOW_THREADS
;
4822 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4823 LIBVIRT_END_ALLOW_THREADS
;
4826 return VIR_PY_INT_FAIL
;
4829 PyErr_Format(PyExc_LookupError
,
4830 "Domain has no settable attributes");
4834 if (VIR_ALLOC_N(params
, nparams
) < 0)
4835 return PyErr_NoMemory();
4837 LIBVIRT_BEGIN_ALLOW_THREADS
;
4838 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4839 LIBVIRT_END_ALLOW_THREADS
;
4842 ret
= VIR_PY_INT_FAIL
;
4846 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
4850 LIBVIRT_BEGIN_ALLOW_THREADS
;
4851 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
4852 LIBVIRT_END_ALLOW_THREADS
;
4855 ret
= VIR_PY_INT_FAIL
;
4859 ret
= VIR_PY_INT_SUCCESS
;
4862 virTypedParamsFree(params
, nparams
);
4863 virTypedParamsFree(new_params
, size
);
4868 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4871 virDomainPtr domain
;
4872 PyObject
*pyobj_domain
;
4873 PyObject
*ret
= NULL
;
4878 virTypedParameterPtr params
;
4880 if (!PyArg_ParseTuple(args
, (char *)"Ozi:virDomainGetBlockIoTune",
4881 &pyobj_domain
, &disk
, &flags
))
4883 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4885 LIBVIRT_BEGIN_ALLOW_THREADS
;
4886 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4887 LIBVIRT_END_ALLOW_THREADS
;
4893 return PyDict_New();
4895 if (VIR_ALLOC_N(params
, nparams
) < 0)
4896 return PyErr_NoMemory();
4898 LIBVIRT_BEGIN_ALLOW_THREADS
;
4899 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4900 LIBVIRT_END_ALLOW_THREADS
;
4907 ret
= getPyVirTypedParameter(params
, nparams
);
4910 virTypedParamsFree(params
, nparams
);
4915 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
4918 PyObject
*py_retval
= VIR_PY_NONE
;
4919 virDomainPtr domain
;
4920 PyObject
*pyobj_domain
;
4922 virDomainDiskErrorPtr disks
= NULL
;
4923 unsigned int ndisks
;
4927 if (!PyArg_ParseTuple(args
, (char *) "Oi:virDomainGetDiskErrors",
4928 &pyobj_domain
, &flags
))
4931 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4933 if ((count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0)) < 0)
4938 if (VIR_ALLOC_N(disks
, ndisks
) < 0)
4941 LIBVIRT_BEGIN_ALLOW_THREADS
;
4942 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
4943 LIBVIRT_END_ALLOW_THREADS
;
4949 if (!(py_retval
= PyDict_New()))
4952 for (i
= 0; i
< count
; i
++) {
4953 PyDict_SetItem(py_retval
,
4954 libvirt_constcharPtrWrap(disks
[i
].disk
),
4955 libvirt_intWrap(disks
[i
].error
));
4960 for (i
= 0; i
< count
; i
++)
4961 VIR_FREE(disks
[i
].disk
);
4967 /*******************************************
4968 * Helper functions to avoid importing modules
4969 * for every callback
4970 *******************************************/
4971 static PyObject
*libvirt_module
= NULL
;
4972 static PyObject
*libvirt_dict
= NULL
;
4975 getLibvirtModuleObject(void) {
4977 return libvirt_module
;
4979 // PyImport_ImportModule returns a new reference
4980 /* Bogus (char *) cast for RHEL-5 python API brokenness */
4981 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
4982 if (!libvirt_module
) {
4983 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
4988 return libvirt_module
;
4992 getLibvirtDictObject(void) {
4994 return libvirt_dict
;
4996 // PyModule_GetDict returns a borrowed reference
4997 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
4998 if (!libvirt_dict
) {
4999 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
5004 Py_INCREF(libvirt_dict
);
5005 return libvirt_dict
;
5010 libvirt_lookupPythonFunc(const char *funcname
)
5012 PyObject
*python_cb
;
5014 /* Lookup the python callback */
5015 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
5018 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
5024 if (!PyCallable_Check(python_cb
)) {
5025 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
5032 /*******************************************
5034 *******************************************/
5037 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5043 PyObject
*pyobj_ret
= NULL
;
5045 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5046 PyObject
*pyobj_dom
;
5050 LIBVIRT_ENSURE_THREAD_STATE
;
5052 /* Create a python instance of this virDomainPtr */
5054 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5059 /* Call the Callback Dispatcher */
5060 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5061 (char*)"_dispatchDomainEventCallbacks",
5066 Py_DECREF(pyobj_dom
);
5070 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5073 Py_DECREF(pyobj_ret
);
5077 LIBVIRT_RELEASE_THREAD_STATE
;
5082 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
*self
,
5085 PyObject
*py_retval
; /* return value */
5086 PyObject
*pyobj_conn
; /* virConnectPtr */
5087 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
5092 if (!PyArg_ParseTuple
5093 (args
, (char *) "OO:virConnectDomainEventRegister",
5094 &pyobj_conn
, &pyobj_conn_inst
)) {
5095 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
5096 return VIR_PY_INT_FAIL
;
5099 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
5100 pyobj_conn
, pyobj_conn_inst
);
5101 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5103 Py_INCREF(pyobj_conn_inst
);
5105 LIBVIRT_BEGIN_ALLOW_THREADS
;
5107 ret
= virConnectDomainEventRegister(conn
,
5108 libvirt_virConnectDomainEventCallback
,
5109 pyobj_conn_inst
, NULL
);
5111 LIBVIRT_END_ALLOW_THREADS
;
5113 py_retval
= libvirt_intWrap(ret
);
5118 libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject
*self
,
5121 PyObject
*py_retval
;
5122 PyObject
*pyobj_conn
;
5123 PyObject
*pyobj_conn_inst
;
5128 if (!PyArg_ParseTuple
5129 (args
, (char *) "OO:virConnectDomainEventDeregister",
5130 &pyobj_conn
, &pyobj_conn_inst
))
5133 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
5135 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5137 LIBVIRT_BEGIN_ALLOW_THREADS
;
5139 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
5141 LIBVIRT_END_ALLOW_THREADS
;
5143 Py_DECREF(pyobj_conn_inst
);
5144 py_retval
= libvirt_intWrap(ret
);
5148 /*******************************************
5150 *******************************************/
5151 static PyObject
*addHandleObj
;
5152 static char *addHandleName
;
5153 static PyObject
*updateHandleObj
;
5154 static char *updateHandleName
;
5155 static PyObject
*removeHandleObj
;
5156 static char *removeHandleName
;
5157 static PyObject
*addTimeoutObj
;
5158 static char *addTimeoutName
;
5159 static PyObject
*updateTimeoutObj
;
5160 static char *updateTimeoutName
;
5161 static PyObject
*removeTimeoutObj
;
5162 static char *removeTimeoutName
;
5164 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
5167 libvirt_virEventAddHandleFunc (int fd
,
5169 virEventHandleCallback cb
,
5174 PyObject
*python_cb
;
5177 PyObject
*opaque_obj
;
5179 PyObject
*pyobj_args
;
5182 LIBVIRT_ENSURE_THREAD_STATE
;
5184 /* Lookup the python callback */
5185 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
5189 Py_INCREF(python_cb
);
5191 /* create tuple for cb */
5192 cb_obj
= libvirt_virEventHandleCallbackWrap(cb
);
5193 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
5194 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
5196 cb_args
= PyTuple_New(3);
5197 PyTuple_SetItem(cb_args
, 0, cb_obj
);
5198 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
5199 PyTuple_SetItem(cb_args
, 2, ff_obj
);
5201 pyobj_args
= PyTuple_New(4);
5202 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(fd
));
5203 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
5204 PyTuple_SetItem(pyobj_args
, 2, python_cb
);
5205 PyTuple_SetItem(pyobj_args
, 3, cb_args
);
5207 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
5212 libvirt_intUnwrap(result
, &retval
);
5216 Py_DECREF(pyobj_args
);
5219 LIBVIRT_RELEASE_THREAD_STATE
;
5225 libvirt_virEventUpdateHandleFunc(int watch
, int event
)
5228 PyObject
*pyobj_args
;
5230 LIBVIRT_ENSURE_THREAD_STATE
;
5232 pyobj_args
= PyTuple_New(2);
5233 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
5234 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(event
));
5236 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
5243 Py_DECREF(pyobj_args
);
5245 LIBVIRT_RELEASE_THREAD_STATE
;
5250 libvirt_virEventRemoveHandleFunc(int watch
)
5253 PyObject
*pyobj_args
;
5257 virFreeCallback cff
;
5259 LIBVIRT_ENSURE_THREAD_STATE
;
5261 pyobj_args
= PyTuple_New(1);
5262 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(watch
));
5264 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
5268 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5269 DEBUG("%s: %s must return opaque obj registered with %s"
5270 "to avoid leaking libvirt memory\n",
5271 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
5273 opaque
= PyTuple_GetItem(result
, 1);
5274 ff
= PyTuple_GetItem(result
, 2);
5275 cff
= PyvirFreeCallback_Get(ff
);
5277 (*cff
)(PyvirVoidPtr_Get(opaque
));
5282 Py_DECREF(pyobj_args
);
5284 LIBVIRT_RELEASE_THREAD_STATE
;
5291 libvirt_virEventAddTimeoutFunc(int timeout
,
5292 virEventTimeoutCallback cb
,
5298 PyObject
*python_cb
;
5302 PyObject
*opaque_obj
;
5304 PyObject
*pyobj_args
;
5307 LIBVIRT_ENSURE_THREAD_STATE
;
5309 /* Lookup the python callback */
5310 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
5314 Py_INCREF(python_cb
);
5316 /* create tuple for cb */
5317 cb_obj
= libvirt_virEventTimeoutCallbackWrap(cb
);
5318 ff_obj
= libvirt_virFreeCallbackWrap(ff
);
5319 opaque_obj
= libvirt_virVoidPtrWrap(opaque
);
5321 cb_args
= PyTuple_New(3);
5322 PyTuple_SetItem(cb_args
, 0, cb_obj
);
5323 PyTuple_SetItem(cb_args
, 1, opaque_obj
);
5324 PyTuple_SetItem(cb_args
, 2, ff_obj
);
5326 pyobj_args
= PyTuple_New(3);
5328 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timeout
));
5329 PyTuple_SetItem(pyobj_args
, 1, python_cb
);
5330 PyTuple_SetItem(pyobj_args
, 2, cb_args
);
5332 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
5337 libvirt_intUnwrap(result
, &retval
);
5341 Py_DECREF(pyobj_args
);
5344 LIBVIRT_RELEASE_THREAD_STATE
;
5349 libvirt_virEventUpdateTimeoutFunc(int timer
, int timeout
)
5351 PyObject
*result
= NULL
;
5352 PyObject
*pyobj_args
;
5354 LIBVIRT_ENSURE_THREAD_STATE
;
5356 pyobj_args
= PyTuple_New(2);
5357 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
5358 PyTuple_SetItem(pyobj_args
, 1, libvirt_intWrap(timeout
));
5360 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
5367 Py_DECREF(pyobj_args
);
5369 LIBVIRT_RELEASE_THREAD_STATE
;
5373 libvirt_virEventRemoveTimeoutFunc(int timer
)
5375 PyObject
*result
= NULL
;
5376 PyObject
*pyobj_args
;
5380 virFreeCallback cff
;
5382 LIBVIRT_ENSURE_THREAD_STATE
;
5384 pyobj_args
= PyTuple_New(1);
5385 PyTuple_SetItem(pyobj_args
, 0, libvirt_intWrap(timer
));
5387 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
5391 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5392 DEBUG("%s: %s must return opaque obj registered with %s"
5393 "to avoid leaking libvirt memory\n",
5394 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
5396 opaque
= PyTuple_GetItem(result
, 1);
5397 ff
= PyTuple_GetItem(result
, 2);
5398 cff
= PyvirFreeCallback_Get(ff
);
5400 (*cff
)(PyvirVoidPtr_Get(opaque
));
5405 Py_DECREF(pyobj_args
);
5407 LIBVIRT_RELEASE_THREAD_STATE
;
5413 libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject
* self
,
5416 /* Unref the previously-registered impl (if any) */
5417 Py_XDECREF(addHandleObj
);
5418 Py_XDECREF(updateHandleObj
);
5419 Py_XDECREF(removeHandleObj
);
5420 Py_XDECREF(addTimeoutObj
);
5421 Py_XDECREF(updateTimeoutObj
);
5422 Py_XDECREF(removeTimeoutObj
);
5423 VIR_FREE(addHandleName
);
5424 VIR_FREE(updateHandleName
);
5425 VIR_FREE(removeHandleName
);
5426 VIR_FREE(addTimeoutName
);
5427 VIR_FREE(updateTimeoutName
);
5428 VIR_FREE(removeTimeoutName
);
5430 /* Parse and check arguments */
5431 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
5432 &addHandleObj
, &updateHandleObj
,
5433 &removeHandleObj
, &addTimeoutObj
,
5434 &updateTimeoutObj
, &removeTimeoutObj
) ||
5435 !PyCallable_Check(addHandleObj
) ||
5436 !PyCallable_Check(updateHandleObj
) ||
5437 !PyCallable_Check(removeHandleObj
) ||
5438 !PyCallable_Check(addTimeoutObj
) ||
5439 !PyCallable_Check(updateTimeoutObj
) ||
5440 !PyCallable_Check(removeTimeoutObj
))
5441 return VIR_PY_INT_FAIL
;
5443 /* Get argument string representations (for error reporting) */
5444 addHandleName
= py_str(addHandleObj
);
5445 updateHandleName
= py_str(updateHandleObj
);
5446 removeHandleName
= py_str(removeHandleObj
);
5447 addTimeoutName
= py_str(addTimeoutObj
);
5448 updateTimeoutName
= py_str(updateTimeoutObj
);
5449 removeTimeoutName
= py_str(removeTimeoutObj
);
5451 /* Inc refs since we're holding on to these objects until
5452 * the next call (if any) to this function.
5454 Py_INCREF(addHandleObj
);
5455 Py_INCREF(updateHandleObj
);
5456 Py_INCREF(removeHandleObj
);
5457 Py_INCREF(addTimeoutObj
);
5458 Py_INCREF(updateTimeoutObj
);
5459 Py_INCREF(removeTimeoutObj
);
5461 LIBVIRT_BEGIN_ALLOW_THREADS
;
5463 /* Now register our C EventImpl, which will dispatch
5464 * to the Python callbacks passed in as args.
5466 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
5467 libvirt_virEventUpdateHandleFunc
,
5468 libvirt_virEventRemoveHandleFunc
,
5469 libvirt_virEventAddTimeoutFunc
,
5470 libvirt_virEventUpdateTimeoutFunc
,
5471 libvirt_virEventRemoveTimeoutFunc
);
5473 LIBVIRT_END_ALLOW_THREADS
;
5475 return VIR_PY_INT_SUCCESS
;
5479 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5482 int watch
, fd
, event
;
5484 PyObject
*py_opaque
;
5485 virEventHandleCallback cb
;
5488 if (!PyArg_ParseTuple
5489 (args
, (char *) "iiiOO:virEventInvokeHandleCallback",
5490 &watch
, &fd
, &event
, &py_f
, &py_opaque
5492 return VIR_PY_INT_FAIL
;
5494 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
5495 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5498 LIBVIRT_BEGIN_ALLOW_THREADS
;
5499 cb(watch
, fd
, event
, opaque
);
5500 LIBVIRT_END_ALLOW_THREADS
;
5503 return VIR_PY_INT_SUCCESS
;
5507 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5512 PyObject
*py_opaque
;
5513 virEventTimeoutCallback cb
;
5516 if (!PyArg_ParseTuple
5517 (args
, (char *) "iOO:virEventInvokeTimeoutCallback",
5518 &timer
, &py_f
, &py_opaque
5520 return VIR_PY_INT_FAIL
;
5522 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
5523 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5525 LIBVIRT_BEGIN_ALLOW_THREADS
;
5527 LIBVIRT_END_ALLOW_THREADS
;
5530 return VIR_PY_INT_SUCCESS
;
5534 libvirt_virEventHandleCallback(int watch
,
5539 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5540 PyObject
*pyobj_ret
;
5541 PyObject
*python_cb
;
5543 LIBVIRT_ENSURE_THREAD_STATE
;
5545 /* Lookup the python callback */
5546 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
5551 Py_INCREF(pyobj_cbData
);
5553 /* Call the pure python dispatcher */
5554 pyobj_ret
= PyObject_CallFunction(python_cb
,
5556 watch
, fd
, events
, pyobj_cbData
);
5558 Py_DECREF(pyobj_cbData
);
5561 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5564 Py_DECREF(pyobj_ret
);
5568 LIBVIRT_RELEASE_THREAD_STATE
;
5572 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
5575 PyObject
*py_retval
;
5576 PyObject
*pyobj_cbData
;
5577 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
5582 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
5583 &fd
, &events
, &pyobj_cbData
)) {
5584 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5585 return VIR_PY_INT_FAIL
;
5588 Py_INCREF(pyobj_cbData
);
5590 LIBVIRT_BEGIN_ALLOW_THREADS
;
5591 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
5592 LIBVIRT_END_ALLOW_THREADS
;
5595 Py_DECREF(pyobj_cbData
);
5598 py_retval
= libvirt_intWrap(ret
);
5603 libvirt_virEventTimeoutCallback(int timer
,
5606 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5607 PyObject
*pyobj_ret
;
5608 PyObject
*python_cb
;
5610 LIBVIRT_ENSURE_THREAD_STATE
;
5612 /* Lookup the python callback */
5613 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5618 Py_INCREF(pyobj_cbData
);
5620 /* Call the pure python dispatcher */
5621 pyobj_ret
= PyObject_CallFunction(python_cb
,
5623 timer
, pyobj_cbData
);
5625 Py_DECREF(pyobj_cbData
);
5628 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5631 Py_DECREF(pyobj_ret
);
5635 LIBVIRT_RELEASE_THREAD_STATE
;
5639 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5642 PyObject
*py_retval
;
5643 PyObject
*pyobj_cbData
;
5644 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5648 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5649 &timeout
, &pyobj_cbData
)) {
5650 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
5651 return VIR_PY_INT_FAIL
;
5654 Py_INCREF(pyobj_cbData
);
5656 LIBVIRT_BEGIN_ALLOW_THREADS
;
5657 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5658 LIBVIRT_END_ALLOW_THREADS
;
5661 Py_DECREF(pyobj_cbData
);
5664 py_retval
= libvirt_intWrap(ret
);
5669 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5671 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5672 LIBVIRT_ENSURE_THREAD_STATE
;
5673 Py_DECREF(pyobj_conn
);
5674 LIBVIRT_RELEASE_THREAD_STATE
;
5678 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5684 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5685 PyObject
*pyobj_dom
;
5686 PyObject
*pyobj_ret
= NULL
;
5687 PyObject
*pyobj_conn
;
5691 LIBVIRT_ENSURE_THREAD_STATE
;
5693 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5695 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5698 /* Create a python instance of this virDomainPtr */
5700 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5704 Py_INCREF(pyobj_cbData
);
5706 /* Call the Callback Dispatcher */
5707 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5708 (char*)"_dispatchDomainEventLifecycleCallback",
5714 Py_DECREF(pyobj_cbData
);
5715 Py_DECREF(pyobj_dom
);
5719 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5722 Py_DECREF(pyobj_ret
);
5726 LIBVIRT_RELEASE_THREAD_STATE
;
5731 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5735 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5736 PyObject
*pyobj_dom
;
5737 PyObject
*pyobj_ret
= NULL
;
5738 PyObject
*pyobj_conn
;
5742 LIBVIRT_ENSURE_THREAD_STATE
;
5744 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5746 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5749 /* Create a python instance of this virDomainPtr */
5751 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5755 Py_INCREF(pyobj_cbData
);
5757 /* Call the Callback Dispatcher */
5758 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5759 (char*)"_dispatchDomainEventGenericCallback",
5761 pyobj_dom
, pyobj_cbData
);
5763 Py_DECREF(pyobj_cbData
);
5764 Py_DECREF(pyobj_dom
);
5768 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5771 Py_DECREF(pyobj_ret
);
5775 LIBVIRT_RELEASE_THREAD_STATE
;
5780 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5782 long long utcoffset
,
5785 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5786 PyObject
*pyobj_dom
;
5787 PyObject
*pyobj_ret
= NULL
;
5788 PyObject
*pyobj_conn
;
5792 LIBVIRT_ENSURE_THREAD_STATE
;
5794 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5796 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5799 /* Create a python instance of this virDomainPtr */
5801 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5805 Py_INCREF(pyobj_cbData
);
5807 /* Call the Callback Dispatcher */
5808 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5809 (char*)"_dispatchDomainEventRTCChangeCallback",
5812 (PY_LONG_LONG
)utcoffset
,
5815 Py_DECREF(pyobj_cbData
);
5816 Py_DECREF(pyobj_dom
);
5820 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5823 Py_DECREF(pyobj_ret
);
5827 LIBVIRT_RELEASE_THREAD_STATE
;
5832 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5837 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5838 PyObject
*pyobj_dom
;
5839 PyObject
*pyobj_ret
= NULL
;
5840 PyObject
*pyobj_conn
;
5844 LIBVIRT_ENSURE_THREAD_STATE
;
5846 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5848 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5851 /* Create a python instance of this virDomainPtr */
5853 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5857 Py_INCREF(pyobj_cbData
);
5859 /* Call the Callback Dispatcher */
5860 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5861 (char*)"_dispatchDomainEventWatchdogCallback",
5867 Py_DECREF(pyobj_cbData
);
5868 Py_DECREF(pyobj_dom
);
5872 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5875 Py_DECREF(pyobj_ret
);
5879 LIBVIRT_RELEASE_THREAD_STATE
;
5884 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5886 const char *srcPath
,
5887 const char *devAlias
,
5891 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5892 PyObject
*pyobj_dom
;
5893 PyObject
*pyobj_ret
= NULL
;
5894 PyObject
*pyobj_conn
;
5898 LIBVIRT_ENSURE_THREAD_STATE
;
5900 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5902 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5905 /* Create a python instance of this virDomainPtr */
5907 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5911 Py_INCREF(pyobj_cbData
);
5913 /* Call the Callback Dispatcher */
5914 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5915 (char*)"_dispatchDomainEventIOErrorCallback",
5918 srcPath
, devAlias
, action
,
5921 Py_DECREF(pyobj_cbData
);
5922 Py_DECREF(pyobj_dom
);
5926 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5929 Py_DECREF(pyobj_ret
);
5933 LIBVIRT_RELEASE_THREAD_STATE
;
5938 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5940 const char *srcPath
,
5941 const char *devAlias
,
5946 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5947 PyObject
*pyobj_dom
;
5948 PyObject
*pyobj_ret
= NULL
;
5949 PyObject
*pyobj_conn
;
5953 LIBVIRT_ENSURE_THREAD_STATE
;
5955 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5957 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5960 /* Create a python instance of this virDomainPtr */
5962 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5966 Py_INCREF(pyobj_cbData
);
5968 /* Call the Callback Dispatcher */
5969 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5970 (char*)"_dispatchDomainEventIOErrorReasonCallback",
5973 srcPath
, devAlias
, action
, reason
,
5976 Py_DECREF(pyobj_cbData
);
5977 Py_DECREF(pyobj_dom
);
5981 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5984 Py_DECREF(pyobj_ret
);
5988 LIBVIRT_RELEASE_THREAD_STATE
;
5993 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5996 virDomainEventGraphicsAddressPtr local
,
5997 virDomainEventGraphicsAddressPtr remote
,
5998 const char *authScheme
,
5999 virDomainEventGraphicsSubjectPtr subject
,
6002 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6003 PyObject
*pyobj_dom
;
6004 PyObject
*pyobj_ret
= NULL
;
6005 PyObject
*pyobj_conn
;
6007 PyObject
*pyobj_local
;
6008 PyObject
*pyobj_remote
;
6009 PyObject
*pyobj_subject
;
6013 LIBVIRT_ENSURE_THREAD_STATE
;
6015 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6017 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6020 /* Create a python instance of this virDomainPtr */
6022 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6026 Py_INCREF(pyobj_cbData
);
6028 /* FIXME This code should check for errors... */
6029 pyobj_local
= PyDict_New();
6030 PyDict_SetItem(pyobj_local
,
6031 libvirt_constcharPtrWrap("family"),
6032 libvirt_intWrap(local
->family
));
6033 PyDict_SetItem(pyobj_local
,
6034 libvirt_constcharPtrWrap("node"),
6035 libvirt_constcharPtrWrap(local
->node
));
6036 PyDict_SetItem(pyobj_local
,
6037 libvirt_constcharPtrWrap("service"),
6038 libvirt_constcharPtrWrap(local
->service
));
6040 pyobj_remote
= PyDict_New();
6041 PyDict_SetItem(pyobj_remote
,
6042 libvirt_constcharPtrWrap("family"),
6043 libvirt_intWrap(remote
->family
));
6044 PyDict_SetItem(pyobj_remote
,
6045 libvirt_constcharPtrWrap("node"),
6046 libvirt_constcharPtrWrap(remote
->node
));
6047 PyDict_SetItem(pyobj_remote
,
6048 libvirt_constcharPtrWrap("service"),
6049 libvirt_constcharPtrWrap(remote
->service
));
6051 pyobj_subject
= PyList_New(subject
->nidentity
);
6052 for (i
= 0; i
< subject
->nidentity
; i
++) {
6053 PyObject
*pair
= PyTuple_New(2);
6054 PyTuple_SetItem(pair
, 0, libvirt_constcharPtrWrap(subject
->identities
[i
].type
));
6055 PyTuple_SetItem(pair
, 1, libvirt_constcharPtrWrap(subject
->identities
[i
].name
));
6057 PyList_SetItem(pyobj_subject
, i
, pair
);
6060 /* Call the Callback Dispatcher */
6061 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6062 (char*)"_dispatchDomainEventGraphicsCallback",
6065 phase
, pyobj_local
, pyobj_remote
,
6066 authScheme
, pyobj_subject
,
6069 Py_DECREF(pyobj_cbData
);
6070 Py_DECREF(pyobj_dom
);
6074 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6077 Py_DECREF(pyobj_ret
);
6081 LIBVIRT_RELEASE_THREAD_STATE
;
6086 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6093 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6094 PyObject
*pyobj_dom
;
6095 PyObject
*pyobj_ret
= NULL
;
6096 PyObject
*pyobj_conn
;
6100 LIBVIRT_ENSURE_THREAD_STATE
;
6102 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6104 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6107 /* Create a python instance of this virDomainPtr */
6109 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6113 Py_INCREF(pyobj_cbData
);
6115 /* Call the Callback Dispatcher */
6116 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6117 (char*)"_dispatchDomainEventBlockPullCallback",
6119 pyobj_dom
, path
, type
, status
, pyobj_cbData
);
6121 Py_DECREF(pyobj_cbData
);
6122 Py_DECREF(pyobj_dom
);
6126 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6129 Py_DECREF(pyobj_ret
);
6133 LIBVIRT_RELEASE_THREAD_STATE
;
6138 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6140 const char *oldSrcPath
,
6141 const char *newSrcPath
,
6142 const char *devAlias
,
6146 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6147 PyObject
*pyobj_dom
;
6148 PyObject
*pyobj_ret
= NULL
;
6149 PyObject
*pyobj_conn
;
6153 LIBVIRT_ENSURE_THREAD_STATE
;
6155 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6157 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6160 /* Create a python instance of this virDomainPtr */
6162 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6166 Py_INCREF(pyobj_cbData
);
6168 /* Call the Callback Dispatcher */
6169 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6170 (char*)"_dispatchDomainEventDiskChangeCallback",
6173 oldSrcPath
, newSrcPath
,
6174 devAlias
, reason
, pyobj_cbData
);
6176 Py_DECREF(pyobj_cbData
);
6177 Py_DECREF(pyobj_dom
);
6181 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6184 Py_DECREF(pyobj_ret
);
6188 LIBVIRT_RELEASE_THREAD_STATE
;
6193 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6195 const char *devAlias
,
6199 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6200 PyObject
*pyobj_dom
;
6201 PyObject
*pyobj_ret
= NULL
;
6202 PyObject
*pyobj_conn
;
6206 LIBVIRT_ENSURE_THREAD_STATE
;
6208 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6210 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6213 /* Create a python instance of this virDomainPtr */
6215 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6219 Py_INCREF(pyobj_cbData
);
6221 /* Call the Callback Dispatcher */
6222 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6223 (char*)"_dispatchDomainEventTrayChangeCallback",
6226 devAlias
, reason
, pyobj_cbData
);
6228 Py_DECREF(pyobj_cbData
);
6229 Py_DECREF(pyobj_dom
);
6233 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6236 Py_DECREF(pyobj_ret
);
6240 LIBVIRT_RELEASE_THREAD_STATE
;
6245 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6250 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6251 PyObject
*pyobj_dom
;
6252 PyObject
*pyobj_ret
= NULL
;
6253 PyObject
*pyobj_conn
;
6257 LIBVIRT_ENSURE_THREAD_STATE
;
6259 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6261 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6264 /* Create a python instance of this virDomainPtr */
6266 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6270 Py_INCREF(pyobj_cbData
);
6272 /* Call the Callback Dispatcher */
6273 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6274 (char*)"_dispatchDomainEventPMWakeupCallback",
6280 Py_DECREF(pyobj_cbData
);
6281 Py_DECREF(pyobj_dom
);
6285 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6288 Py_DECREF(pyobj_ret
);
6292 LIBVIRT_RELEASE_THREAD_STATE
;
6297 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6302 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6303 PyObject
*pyobj_dom
;
6304 PyObject
*pyobj_ret
= NULL
;
6305 PyObject
*pyobj_conn
;
6309 LIBVIRT_ENSURE_THREAD_STATE
;
6311 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6313 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6316 /* Create a python instance of this virDomainPtr */
6318 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6322 Py_INCREF(pyobj_cbData
);
6324 /* Call the Callback Dispatcher */
6325 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6326 (char*)"_dispatchDomainEventPMSuspendCallback",
6332 Py_DECREF(pyobj_cbData
);
6333 Py_DECREF(pyobj_dom
);
6337 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6340 Py_DECREF(pyobj_ret
);
6344 LIBVIRT_RELEASE_THREAD_STATE
;
6349 #if LIBVIR_CHECK_VERSION(0, 10, 0)
6351 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6353 unsigned long long actual
,
6356 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6357 PyObject
*pyobj_dom
;
6358 PyObject
*pyobj_ret
= NULL
;
6359 PyObject
*pyobj_conn
;
6363 LIBVIRT_ENSURE_THREAD_STATE
;
6365 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6367 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6370 /* Create a python instance of this virDomainPtr */
6372 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6376 Py_INCREF(pyobj_cbData
);
6378 /* Call the Callback Dispatcher */
6379 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6380 (char*)"_dispatchDomainEventBalloonChangeCallback",
6383 (PY_LONG_LONG
)actual
,
6386 Py_DECREF(pyobj_cbData
);
6387 Py_DECREF(pyobj_dom
);
6391 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6394 Py_DECREF(pyobj_ret
);
6398 LIBVIRT_RELEASE_THREAD_STATE
;
6401 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
6403 #if LIBVIR_CHECK_VERSION(1, 0, 0)
6405 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6410 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6411 PyObject
*pyobj_dom
;
6412 PyObject
*pyobj_ret
= NULL
;
6413 PyObject
*pyobj_conn
;
6417 LIBVIRT_ENSURE_THREAD_STATE
;
6419 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6421 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6424 /* Create a python instance of this virDomainPtr */
6426 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6430 Py_INCREF(pyobj_cbData
);
6432 /* Call the Callback Dispatcher */
6433 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6434 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
6440 Py_DECREF(pyobj_cbData
);
6441 Py_DECREF(pyobj_dom
);
6445 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6448 Py_DECREF(pyobj_ret
);
6452 LIBVIRT_RELEASE_THREAD_STATE
;
6455 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
6457 #if LIBVIR_CHECK_VERSION(1, 1, 1)
6459 libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6461 const char *devAlias
,
6464 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6465 PyObject
*pyobj_dom
;
6466 PyObject
*pyobj_ret
= NULL
;
6467 PyObject
*pyobj_conn
;
6471 LIBVIRT_ENSURE_THREAD_STATE
;
6473 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6475 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6478 /* Create a python instance of this virDomainPtr */
6480 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6484 Py_INCREF(pyobj_cbData
);
6486 /* Call the Callback Dispatcher */
6487 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6488 (char*)"_dispatchDomainEventDeviceRemovedCallback",
6490 pyobj_dom
, devAlias
, pyobj_cbData
);
6492 Py_DECREF(pyobj_cbData
);
6493 Py_DECREF(pyobj_dom
);
6497 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6500 Py_DECREF(pyobj_ret
);
6504 LIBVIRT_RELEASE_THREAD_STATE
;
6507 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
6510 libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject
*self
,
6513 PyObject
*py_retval
; /* return value */
6514 PyObject
*pyobj_conn
; /* virConnectPtr */
6515 PyObject
*pyobj_dom
;
6516 PyObject
*pyobj_cbData
; /* hash of callback data */
6520 virConnectDomainEventGenericCallback cb
= NULL
;
6523 if (!PyArg_ParseTuple
6524 (args
, (char *) "OOiO:virConnectDomainEventRegisterAny",
6525 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
)) {
6526 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
6527 return VIR_PY_INT_FAIL
;
6530 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
6531 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
6532 conn
= PyvirConnect_Get(pyobj_conn
);
6533 if (pyobj_dom
== Py_None
)
6536 dom
= PyvirDomain_Get(pyobj_dom
);
6538 switch ((virDomainEventID
) eventID
) {
6539 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
6540 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
6542 case VIR_DOMAIN_EVENT_ID_REBOOT
:
6543 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
6545 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
6546 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
6548 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
6549 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
6551 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
6552 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
6554 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
6555 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
6557 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
6558 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
6560 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
6561 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
6563 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
6564 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
6566 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
6567 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
6569 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
6570 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
6572 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
6573 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
6575 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
6576 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
6578 #if LIBVIR_CHECK_VERSION(0, 10, 0)
6579 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
6580 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
6582 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
6583 #if LIBVIR_CHECK_VERSION(1, 0, 0)
6584 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
6585 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
6587 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
6588 #if LIBVIR_CHECK_VERSION(1, 1, 1)
6589 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
:
6590 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback
);
6592 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
6593 case VIR_DOMAIN_EVENT_ID_LAST
:
6598 return VIR_PY_INT_FAIL
;
6601 Py_INCREF(pyobj_cbData
);
6603 LIBVIRT_BEGIN_ALLOW_THREADS
;
6604 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
6606 libvirt_virConnectDomainEventFreeFunc
);
6607 LIBVIRT_END_ALLOW_THREADS
;
6610 Py_DECREF(pyobj_cbData
);
6613 py_retval
= libvirt_intWrap(ret
);
6618 libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED PyObject
*self
,
6621 PyObject
*py_retval
;
6622 PyObject
*pyobj_conn
;
6627 if (!PyArg_ParseTuple
6628 (args
, (char *) "Oi:virConnectDomainEventDeregister",
6629 &pyobj_conn
, &callbackID
))
6632 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
6634 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6636 LIBVIRT_BEGIN_ALLOW_THREADS
;
6638 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
6640 LIBVIRT_END_ALLOW_THREADS
;
6641 py_retval
= libvirt_intWrap(ret
);
6645 #if LIBVIR_CHECK_VERSION(1, 2, 1)
6647 libvirt_virConnectNetworkEventFreeFunc(void *opaque
)
6649 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
6650 LIBVIRT_ENSURE_THREAD_STATE
;
6651 Py_DECREF(pyobj_conn
);
6652 LIBVIRT_RELEASE_THREAD_STATE
;
6656 libvirt_virConnectNetworkEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6662 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6663 PyObject
*pyobj_net
;
6664 PyObject
*pyobj_ret
= NULL
;
6665 PyObject
*pyobj_conn
;
6669 LIBVIRT_ENSURE_THREAD_STATE
;
6671 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6673 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6676 /* Create a python instance of this virNetworkPtr */
6678 if (!(pyobj_net
= libvirt_virNetworkPtrWrap(net
))) {
6679 virNetworkFree(net
);
6682 Py_INCREF(pyobj_cbData
);
6684 /* Call the Callback Dispatcher */
6685 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6686 (char*)"_dispatchNetworkEventLifecycleCallback",
6693 Py_DECREF(pyobj_cbData
);
6694 Py_DECREF(pyobj_net
);
6698 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6701 Py_DECREF(pyobj_ret
);
6705 LIBVIRT_RELEASE_THREAD_STATE
;
6710 libvirt_virConnectNetworkEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
6713 PyObject
*py_retval
; /* return value */
6714 PyObject
*pyobj_conn
; /* virConnectPtr */
6715 PyObject
*pyobj_net
;
6716 PyObject
*pyobj_cbData
; /* hash of callback data */
6720 virConnectNetworkEventGenericCallback cb
= NULL
;
6723 if (!PyArg_ParseTuple
6724 (args
, (char *) "OOiO:virConnectNetworkEventRegisterAny",
6725 &pyobj_conn
, &pyobj_net
, &eventID
, &pyobj_cbData
)) {
6726 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
6727 return VIR_PY_INT_FAIL
;
6730 DEBUG("libvirt_virConnectNetworkEventRegister(%p %p %d %p) called\n",
6731 pyobj_conn
, pyobj_net
, eventID
, pyobj_cbData
);
6732 conn
= PyvirConnect_Get(pyobj_conn
);
6733 if (pyobj_net
== Py_None
)
6736 net
= PyvirNetwork_Get(pyobj_net
);
6738 switch ((virNetworkEventID
) eventID
) {
6739 case VIR_NETWORK_EVENT_ID_LIFECYCLE
:
6740 cb
= VIR_NETWORK_EVENT_CALLBACK(libvirt_virConnectNetworkEventLifecycleCallback
);
6743 case VIR_NETWORK_EVENT_ID_LAST
:
6748 return VIR_PY_INT_FAIL
;
6751 Py_INCREF(pyobj_cbData
);
6753 LIBVIRT_BEGIN_ALLOW_THREADS
;
6754 ret
= virConnectNetworkEventRegisterAny(conn
, net
, eventID
,
6756 libvirt_virConnectNetworkEventFreeFunc
);
6757 LIBVIRT_END_ALLOW_THREADS
;
6760 Py_DECREF(pyobj_cbData
);
6763 py_retval
= libvirt_intWrap(ret
);
6768 *libvirt_virConnectNetworkEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
6771 PyObject
*py_retval
;
6772 PyObject
*pyobj_conn
;
6777 if (!PyArg_ParseTuple
6778 (args
, (char *) "Oi:virConnectNetworkEventDeregister",
6779 &pyobj_conn
, &callbackID
))
6782 DEBUG("libvirt_virConnectNetworkEventDeregister(%p) called\n", pyobj_conn
);
6784 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
6786 LIBVIRT_BEGIN_ALLOW_THREADS
;
6788 ret
= virConnectNetworkEventDeregisterAny(conn
, callbackID
);
6790 LIBVIRT_END_ALLOW_THREADS
;
6791 py_retval
= libvirt_intWrap(ret
);
6794 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1)*/
6796 #if LIBVIR_CHECK_VERSION(0, 10, 0)
6798 libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED
,
6802 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6803 PyObject
*pyobj_ret
;
6804 PyObject
*pyobj_conn
;
6807 LIBVIRT_ENSURE_THREAD_STATE
;
6809 Py_INCREF(pyobj_cbData
);
6811 dictKey
= libvirt_constcharPtrWrap("conn");
6812 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6815 /* Call the Callback Dispatcher */
6816 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6817 (char*)"_dispatchCloseCallback",
6822 Py_DECREF(pyobj_cbData
);
6825 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6828 Py_DECREF(pyobj_ret
);
6831 LIBVIRT_RELEASE_THREAD_STATE
;
6835 libvirt_virConnectRegisterCloseCallback(ATTRIBUTE_UNUSED PyObject
* self
,
6838 PyObject
*py_retval
; /* return value */
6839 PyObject
*pyobj_conn
; /* virConnectPtr */
6840 PyObject
*pyobj_cbData
; /* hash of callback data */
6844 if (!PyArg_ParseTuple
6845 (args
, (char *) "OO:virConnectRegisterCloseCallback",
6846 &pyobj_conn
, &pyobj_cbData
)) {
6847 DEBUG("%s failed parsing tuple\n", __FUNCTION__
);
6848 return VIR_PY_INT_FAIL
;
6851 DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
6852 pyobj_conn
, pyobj_cbData
);
6853 conn
= PyvirConnect_Get(pyobj_conn
);
6855 Py_INCREF(pyobj_cbData
);
6857 LIBVIRT_BEGIN_ALLOW_THREADS
;
6858 ret
= virConnectRegisterCloseCallback(conn
,
6859 libvirt_virConnectCloseCallbackDispatch
,
6861 libvirt_virConnectDomainEventFreeFunc
);
6862 LIBVIRT_END_ALLOW_THREADS
;
6865 Py_DECREF(pyobj_cbData
);
6868 py_retval
= libvirt_intWrap(ret
);
6873 libvirt_virConnectUnregisterCloseCallback(ATTRIBUTE_UNUSED PyObject
* self
,
6876 PyObject
*py_retval
;
6877 PyObject
*pyobj_conn
;
6881 if (!PyArg_ParseTuple
6882 (args
, (char *) "O:virConnectDomainEventUnregister",
6886 DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
6889 conn
= PyvirConnect_Get(pyobj_conn
);
6891 LIBVIRT_BEGIN_ALLOW_THREADS
;
6893 ret
= virConnectUnregisterCloseCallback(conn
,
6894 libvirt_virConnectCloseCallbackDispatch
);
6896 LIBVIRT_END_ALLOW_THREADS
;
6897 py_retval
= libvirt_intWrap(ret
);
6900 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
6903 libvirt_virStreamEventFreeFunc(void *opaque
)
6905 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
6906 LIBVIRT_ENSURE_THREAD_STATE
;
6907 Py_DECREF(pyobj_stream
);
6908 LIBVIRT_RELEASE_THREAD_STATE
;
6912 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
6916 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6917 PyObject
*pyobj_stream
;
6918 PyObject
*pyobj_ret
;
6921 LIBVIRT_ENSURE_THREAD_STATE
;
6923 Py_INCREF(pyobj_cbData
);
6924 dictKey
= libvirt_constcharPtrWrap("stream");
6925 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6928 /* Call the pure python dispatcher */
6929 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
6930 (char *)"_dispatchStreamEventCallback",
6932 events
, pyobj_cbData
);
6934 Py_DECREF(pyobj_cbData
);
6937 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6940 Py_DECREF(pyobj_ret
);
6943 LIBVIRT_RELEASE_THREAD_STATE
;
6947 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
6950 PyObject
*py_retval
;
6951 PyObject
*pyobj_stream
;
6952 PyObject
*pyobj_cbData
;
6953 virStreamPtr stream
;
6954 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
6958 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
6959 &pyobj_stream
, &events
, &pyobj_cbData
)) {
6960 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6961 return VIR_PY_INT_FAIL
;
6964 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
6965 pyobj_stream
, events
, pyobj_cbData
);
6966 stream
= PyvirStream_Get(pyobj_stream
);
6968 Py_INCREF(pyobj_cbData
);
6970 LIBVIRT_BEGIN_ALLOW_THREADS
;
6971 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
6972 libvirt_virStreamEventFreeFunc
);
6973 LIBVIRT_END_ALLOW_THREADS
;
6976 Py_DECREF(pyobj_cbData
);
6979 py_retval
= libvirt_intWrap(ret
);
6984 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
6987 PyObject
*pyobj_stream
;
6989 virStreamPtr stream
;
6994 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
6995 &pyobj_stream
, &nbytes
)) {
6996 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
6999 stream
= PyvirStream_Get(pyobj_stream
);
7001 if (VIR_ALLOC_N(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
7004 LIBVIRT_BEGIN_ALLOW_THREADS
;
7005 ret
= virStreamRecv(stream
, buf
, nbytes
);
7006 LIBVIRT_END_ALLOW_THREADS
;
7008 buf
[ret
> -1 ? ret
: 0] = '\0';
7009 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
7012 return libvirt_intWrap(ret
);
7015 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
7021 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
7024 PyObject
*py_retval
;
7025 PyObject
*pyobj_stream
;
7026 PyObject
*pyobj_data
;
7027 virStreamPtr stream
;
7032 if (!PyArg_ParseTuple(args
, (char *) "OO:virStreamRecv",
7033 &pyobj_stream
, &pyobj_data
)) {
7034 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
7035 return VIR_PY_INT_FAIL
;
7037 stream
= PyvirStream_Get(pyobj_stream
);
7038 libvirt_charPtrSizeUnwrap(pyobj_data
, &data
, &datalen
);
7040 LIBVIRT_BEGIN_ALLOW_THREADS
;
7041 ret
= virStreamSend(stream
, data
, datalen
);
7042 LIBVIRT_END_ALLOW_THREADS
;
7044 DEBUG("StreamSend ret=%d\n", ret
);
7046 py_retval
= libvirt_intWrap(ret
);
7051 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
7054 PyObject
*py_retval
;
7055 virDomainPtr domain
;
7056 PyObject
*pyobj_domain
;
7057 PyObject
*pyobj_list
;
7063 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
7064 unsigned int nkeycodes
;
7066 if (!PyArg_ParseTuple(args
, (char *)"OiiOii:virDomainSendKey",
7067 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
7068 &nkeycodes
, &flags
)) {
7069 DEBUG("%s failed to parse tuple\n", __FUNCTION__
);
7070 return VIR_PY_INT_FAIL
;
7072 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7074 if (!PyList_Check(pyobj_list
)) {
7075 return VIR_PY_INT_FAIL
;
7078 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
7079 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
7080 return VIR_PY_INT_FAIL
;
7083 for (i
= 0; i
< nkeycodes
; i
++) {
7084 libvirt_uintUnwrap(PyList_GetItem(pyobj_list
, i
), &(keycodes
[i
]));
7087 LIBVIRT_BEGIN_ALLOW_THREADS
;
7088 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
7089 LIBVIRT_END_ALLOW_THREADS
;
7091 DEBUG("virDomainSendKey ret=%d\n", ret
);
7093 py_retval
= libvirt_intWrap(ret
);
7097 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7099 libvirt_virDomainMigrateGetCompressionCache(PyObject
*self ATTRIBUTE_UNUSED
,
7102 PyObject
*pyobj_domain
;
7103 virDomainPtr domain
;
7105 unsigned long long cacheSize
;
7108 if (!PyArg_ParseTuple(args
,
7109 (char *) "Oi:virDomainMigrateGetCompressionCache",
7110 &pyobj_domain
, &flags
))
7113 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7115 LIBVIRT_BEGIN_ALLOW_THREADS
;
7116 rc
= virDomainMigrateGetCompressionCache(domain
, &cacheSize
, flags
);
7117 LIBVIRT_END_ALLOW_THREADS
;
7122 return libvirt_ulonglongWrap(cacheSize
);
7124 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7127 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7128 PyObject
*py_retval
;
7130 unsigned long bandwidth
;
7131 virDomainPtr domain
;
7132 PyObject
*pyobj_domain
;
7133 unsigned int flags
= 0;
7135 if (!PyArg_ParseTuple(args
, (char *)"Oi:virDomainMigrateGetMaxSpeed",
7136 &pyobj_domain
, &flags
))
7139 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7141 LIBVIRT_BEGIN_ALLOW_THREADS
;
7142 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
7143 LIBVIRT_END_ALLOW_THREADS
;
7146 return VIR_PY_INT_FAIL
;
7147 py_retval
= libvirt_ulongWrap(bandwidth
);
7151 #if LIBVIR_CHECK_VERSION(1, 1, 0)
7153 libvirt_virDomainMigrate3(PyObject
*self ATTRIBUTE_UNUSED
,
7156 PyObject
*pyobj_domain
;
7157 virDomainPtr domain
;
7158 PyObject
*pyobj_dconn
;
7159 virConnectPtr dconn
;
7162 virTypedParameterPtr params
;
7164 virDomainPtr ddom
= NULL
;
7166 if (!PyArg_ParseTuple(args
, (char *) "OOOi:virDomainMigrate3",
7167 &pyobj_domain
, &pyobj_dconn
, &dict
, &flags
))
7170 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7171 dconn
= (virConnectPtr
) PyvirConnect_Get(pyobj_dconn
);
7173 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
7176 LIBVIRT_BEGIN_ALLOW_THREADS
;
7177 ddom
= virDomainMigrate3(domain
, dconn
, params
, nparams
, flags
);
7178 LIBVIRT_END_ALLOW_THREADS
;
7180 virTypedParamsFree(params
, nparams
);
7181 return libvirt_virDomainPtrWrap(ddom
);
7185 libvirt_virDomainMigrateToURI3(PyObject
*self ATTRIBUTE_UNUSED
,
7188 PyObject
*pyobj_domain
;
7189 virDomainPtr domain
;
7193 virTypedParameterPtr params
;
7197 if (!PyArg_ParseTuple(args
, (char *) "OzOi:virDomainMigrate3",
7198 &pyobj_domain
, &dconnuri
, &dict
, &flags
))
7201 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7203 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
7206 LIBVIRT_BEGIN_ALLOW_THREADS
;
7207 ret
= virDomainMigrateToURI3(domain
, dconnuri
, params
, nparams
, flags
);
7208 LIBVIRT_END_ALLOW_THREADS
;
7210 virTypedParamsFree(params
, nparams
);
7211 return libvirt_intWrap(ret
);
7213 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
7216 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
7218 PyObject
*py_retval
= NULL
;
7220 virDomainPtr domain
;
7221 PyObject
*pyobj_domain
;
7223 unsigned long long offset
;
7228 if (!PyArg_ParseTuple(args
, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain
,
7229 &disk
, &offset
, &size
, &flags
))
7232 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7234 if (VIR_ALLOC_N(buf
, size
) < 0)
7237 LIBVIRT_BEGIN_ALLOW_THREADS
;
7238 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
7239 LIBVIRT_END_ALLOW_THREADS
;
7242 py_retval
= VIR_PY_NONE
;
7246 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
7254 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
7256 PyObject
*py_retval
= NULL
;
7258 virDomainPtr domain
;
7259 PyObject
*pyobj_domain
;
7260 unsigned long long start
;
7265 if (!PyArg_ParseTuple(args
, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain
,
7266 &start
, &size
, &flags
))
7269 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7271 if (VIR_ALLOC_N(buf
, size
) < 0)
7274 LIBVIRT_BEGIN_ALLOW_THREADS
;
7275 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
7276 LIBVIRT_END_ALLOW_THREADS
;
7279 py_retval
= VIR_PY_NONE
;
7283 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
7290 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7292 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
7296 PyObject
*pyobj_conn
, *info
;
7297 PyObject
*ret
= NULL
;
7300 Py_ssize_t size
= 0;
7302 virTypedParameterPtr params
, new_params
= NULL
;
7304 if (!PyArg_ParseTuple(args
,
7305 (char *)"OOi:virNodeSetMemoryParameters",
7306 &pyobj_conn
, &info
, &flags
))
7308 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7310 if ((size
= PyDict_Size(info
)) < 0)
7314 PyErr_Format(PyExc_LookupError
,
7315 "Need non-empty dictionary to set attributes");
7319 LIBVIRT_BEGIN_ALLOW_THREADS
;
7320 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
7321 LIBVIRT_END_ALLOW_THREADS
;
7324 return VIR_PY_INT_FAIL
;
7327 PyErr_Format(PyExc_LookupError
,
7328 "no settable attributes");
7332 if (VIR_ALLOC_N(params
, nparams
) < 0)
7333 return PyErr_NoMemory();
7335 LIBVIRT_BEGIN_ALLOW_THREADS
;
7336 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
7337 LIBVIRT_END_ALLOW_THREADS
;
7340 ret
= VIR_PY_INT_FAIL
;
7344 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
7348 LIBVIRT_BEGIN_ALLOW_THREADS
;
7349 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
7350 LIBVIRT_END_ALLOW_THREADS
;
7353 ret
= VIR_PY_INT_FAIL
;
7357 ret
= VIR_PY_INT_SUCCESS
;
7360 virTypedParamsFree(params
, nparams
);
7361 virTypedParamsFree(new_params
, nparams
);
7366 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
7370 PyObject
*pyobj_conn
;
7371 PyObject
*ret
= NULL
;
7375 virTypedParameterPtr params
;
7377 if (!PyArg_ParseTuple(args
, (char *)"Oi:virNodeGetMemoryParameters",
7378 &pyobj_conn
, &flags
))
7380 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7382 LIBVIRT_BEGIN_ALLOW_THREADS
;
7383 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
7384 LIBVIRT_END_ALLOW_THREADS
;
7390 return PyDict_New();
7392 if (VIR_ALLOC_N(params
, nparams
) < 0)
7393 return PyErr_NoMemory();
7395 LIBVIRT_BEGIN_ALLOW_THREADS
;
7396 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
7397 LIBVIRT_END_ALLOW_THREADS
;
7404 ret
= getPyVirTypedParameter(params
, nparams
);
7407 virTypedParamsFree(params
, nparams
);
7410 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7412 #if LIBVIR_CHECK_VERSION(1, 0, 0)
7414 libvirt_virNodeGetCPUMap(PyObject
*self ATTRIBUTE_UNUSED
,
7418 PyObject
*pyobj_conn
;
7419 PyObject
*ret
= NULL
;
7420 PyObject
*pycpumap
= NULL
;
7421 PyObject
*pyused
= NULL
;
7422 PyObject
*pycpunum
= NULL
;
7423 PyObject
*pyonline
= NULL
;
7425 unsigned char *cpumap
= NULL
;
7426 unsigned int online
= 0;
7430 if (!PyArg_ParseTuple(args
, (char *)"Oi:virNodeGetCPUMap",
7431 &pyobj_conn
, &flags
))
7433 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7435 LIBVIRT_BEGIN_ALLOW_THREADS
;
7436 i_retval
= virNodeGetCPUMap(conn
, &cpumap
, &online
, flags
);
7437 LIBVIRT_END_ALLOW_THREADS
;
7442 if ((ret
= PyTuple_New(3)) == NULL
)
7445 /* 0: number of CPUs */
7446 if ((pycpunum
= libvirt_intWrap(i_retval
)) == NULL
||
7447 PyTuple_SetItem(ret
, 0, pycpunum
) < 0)
7451 if ((pycpumap
= PyList_New(i_retval
)) == NULL
)
7454 for (i
= 0; i
< i_retval
; i
++) {
7455 if ((pyused
= PyBool_FromLong(VIR_CPU_USED(cpumap
, i
))) == NULL
)
7457 if (PyList_SetItem(pycpumap
, i
, pyused
) < 0)
7461 if (PyTuple_SetItem(ret
, 1, pycpumap
) < 0)
7464 /* 2: number of online CPUs */
7465 if ((pyonline
= libvirt_uintWrap(online
)) == NULL
||
7466 PyTuple_SetItem(ret
, 2, pyonline
) < 0)
7474 Py_XDECREF(pycpumap
);
7476 Py_XDECREF(pycpunum
);
7477 Py_XDECREF(pyonline
);
7481 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
7484 #if LIBVIR_CHECK_VERSION(1, 1, 1)
7486 libvirt_virDomainCreateWithFiles(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7487 PyObject
*py_retval
= NULL
;
7489 virDomainPtr domain
;
7490 PyObject
*pyobj_domain
;
7491 PyObject
*pyobj_files
;
7493 unsigned int nfiles
;
7497 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainCreateWithFiles",
7498 &pyobj_domain
, &pyobj_files
, &flags
))
7500 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7502 nfiles
= PyList_Size(pyobj_files
);
7504 if (VIR_ALLOC_N(files
, nfiles
) < 0)
7505 return PyErr_NoMemory();
7507 for (i
= 0; i
< nfiles
; i
++) {
7511 pyfd
= PyList_GetItem(pyobj_files
, i
);
7513 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
7519 LIBVIRT_BEGIN_ALLOW_THREADS
;
7520 c_retval
= virDomainCreateWithFiles(domain
, nfiles
, files
, flags
);
7521 LIBVIRT_END_ALLOW_THREADS
;
7522 py_retval
= libvirt_intWrap((int) c_retval
);
7531 libvirt_virDomainCreateXMLWithFiles(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7532 PyObject
*py_retval
= NULL
;
7533 virDomainPtr c_retval
;
7535 PyObject
*pyobj_conn
;
7537 PyObject
*pyobj_files
;
7539 unsigned int nfiles
;
7543 if (!PyArg_ParseTuple(args
, (char *)"OzOi:virDomainCreateXMLWithFiles",
7544 &pyobj_conn
, &xmlDesc
, &pyobj_files
, &flags
))
7546 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7548 nfiles
= PyList_Size(pyobj_files
);
7550 if (VIR_ALLOC_N(files
, nfiles
) < 0)
7551 return PyErr_NoMemory();
7553 for (i
= 0; i
< nfiles
; i
++) {
7557 pyfd
= PyList_GetItem(pyobj_files
, i
);
7559 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
7565 LIBVIRT_BEGIN_ALLOW_THREADS
;
7566 c_retval
= virDomainCreateXMLWithFiles(conn
, xmlDesc
, nfiles
, files
, flags
);
7567 LIBVIRT_END_ALLOW_THREADS
;
7568 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
7574 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
7577 #if LIBVIR_CHECK_VERSION(1, 2, 5)
7579 libvirt_virDomainFSFreeze(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7580 PyObject
*py_retval
= NULL
;
7582 virDomainPtr domain
;
7583 PyObject
*pyobj_domain
;
7584 PyObject
*pyobj_list
;
7586 unsigned int nmountpoints
= 0;
7587 char **mountpoints
= NULL
;
7590 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainFSFreeze",
7591 &pyobj_domain
, &pyobj_list
, &flags
))
7593 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7595 if (PyList_Check(pyobj_list
)) {
7596 nmountpoints
= PyList_Size(pyobj_list
);
7598 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
7599 return PyErr_NoMemory();
7601 for (i
= 0; i
< nmountpoints
; i
++) {
7602 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
7603 mountpoints
+i
) < 0 ||
7604 mountpoints
[i
] == NULL
)
7609 LIBVIRT_BEGIN_ALLOW_THREADS
;
7610 c_retval
= virDomainFSFreeze(domain
, (const char **) mountpoints
,
7611 nmountpoints
, flags
);
7612 LIBVIRT_END_ALLOW_THREADS
;
7614 py_retval
= libvirt_intWrap(c_retval
);
7617 for (j
= 0 ; j
< i
; j
++)
7618 VIR_FREE(mountpoints
[j
]);
7619 VIR_FREE(mountpoints
);
7625 libvirt_virDomainFSThaw(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7626 PyObject
*py_retval
= NULL
;
7628 virDomainPtr domain
;
7629 PyObject
*pyobj_domain
;
7630 PyObject
*pyobj_list
;
7632 unsigned int nmountpoints
= 0;
7633 char **mountpoints
= NULL
;
7636 if (!PyArg_ParseTuple(args
, (char *)"OOi:virDomainFSThaw",
7637 &pyobj_domain
, &pyobj_list
, &flags
))
7639 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7641 if (PyList_Check(pyobj_list
)) {
7642 nmountpoints
= PyList_Size(pyobj_list
);
7644 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
7645 return PyErr_NoMemory();
7647 for (i
= 0; i
< nmountpoints
; i
++) {
7648 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
7649 mountpoints
+i
) < 0 ||
7650 mountpoints
[i
] == NULL
)
7655 LIBVIRT_BEGIN_ALLOW_THREADS
;
7656 c_retval
= virDomainFSThaw(domain
, (const char **) mountpoints
,
7657 nmountpoints
, flags
);
7658 LIBVIRT_END_ALLOW_THREADS
;
7660 py_retval
= libvirt_intWrap(c_retval
);
7663 for (j
= 0 ; j
< i
; j
++)
7664 VIR_FREE(mountpoints
[j
]);
7665 VIR_FREE(mountpoints
);
7670 libvirt_virDomainGetTime(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7671 PyObject
*py_retval
= NULL
;
7672 PyObject
*dict
= NULL
;
7673 PyObject
*pyobj_domain
, *pyobj_seconds
, *pyobj_nseconds
;
7674 virDomainPtr domain
;
7676 unsigned int nseconds
;
7680 if (!PyArg_ParseTuple(args
, (char*)"Oi:virDomainGetTime",
7681 &pyobj_domain
, &flags
))
7683 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7685 if (!(dict
= PyDict_New()))
7688 LIBVIRT_BEGIN_ALLOW_THREADS
;
7689 c_retval
= virDomainGetTime(domain
, &seconds
, &nseconds
, flags
);
7690 LIBVIRT_END_ALLOW_THREADS
;
7695 if (!(pyobj_seconds
= libvirt_longlongWrap(seconds
)) ||
7696 PyDict_SetItemString(dict
, "seconds", pyobj_seconds
) < 0)
7698 Py_DECREF(pyobj_seconds
);
7700 if (!(pyobj_nseconds
= libvirt_uintWrap(nseconds
)) ||
7701 PyDict_SetItemString(dict
, "nseconds", pyobj_nseconds
) < 0)
7703 Py_DECREF(pyobj_nseconds
);
7714 libvirt_virDomainSetTime(PyObject
*self ATTRIBUTE_UNUSED
, PyObject
*args
) {
7715 PyObject
*py_retval
= NULL
;
7716 PyObject
*pyobj_domain
;
7718 virDomainPtr domain
;
7719 long long seconds
= 0;
7720 unsigned int nseconds
= 0;
7722 ssize_t py_dict_size
;
7725 if (!PyArg_ParseTuple(args
, (char*)"OOi:virDomainSetTime",
7726 &pyobj_domain
, &py_dict
, &flags
))
7728 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7730 py_dict_size
= PyDict_Size(py_dict
);
7732 if (py_dict_size
== 2) {
7733 PyObject
*pyobj_seconds
, *pyobj_nseconds
;
7735 if (!(pyobj_seconds
= PyDict_GetItemString(py_dict
, "seconds")) ||
7736 (libvirt_longlongUnwrap(pyobj_seconds
, &seconds
) < 0)) {
7737 PyErr_Format(PyExc_LookupError
, "malformed or missing 'seconds'");
7741 if (!(pyobj_nseconds
= PyDict_GetItemString(py_dict
, "nseconds")) ||
7742 (libvirt_uintUnwrap(pyobj_nseconds
, &nseconds
) < 0)) {
7743 PyErr_Format(PyExc_LookupError
, "malformed or missing 'nseconds'");
7746 } else if (py_dict_size
> 0) {
7747 PyErr_Format(PyExc_LookupError
, "Dictionary must contain "
7748 "'seconds' and 'nseconds'");
7752 LIBVIRT_BEGIN_ALLOW_THREADS
;
7753 c_retval
= virDomainSetTime(domain
, seconds
, nseconds
, flags
);
7754 LIBVIRT_END_ALLOW_THREADS
;
7756 py_retval
= libvirt_intWrap(c_retval
);
7761 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
7763 /************************************************************************
7765 * The registration stuff *
7767 ************************************************************************/
7768 static PyMethodDef libvirtMethods
[] = {
7769 #include "build/libvirt-export.c"
7770 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
7771 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
7772 #if LIBVIR_CHECK_VERSION(1, 1, 3)
7773 {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames
, METH_VARARGS
, NULL
},
7774 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
7775 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
7776 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
7777 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
7778 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
7779 #if LIBVIR_CHECK_VERSION(0, 9, 13)
7780 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
7781 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
7782 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
7783 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
7784 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
7785 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
7786 #if LIBVIR_CHECK_VERSION(1, 2, 1)
7787 {(char *) "virConnectNetworkEventRegisterAny", libvirt_virConnectNetworkEventRegisterAny
, METH_VARARGS
, NULL
},
7788 {(char *) "virConnectNetworkEventDeregisterAny", libvirt_virConnectNetworkEventDeregisterAny
, METH_VARARGS
, NULL
},
7789 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1) */
7790 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7791 {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback
, METH_VARARGS
, NULL
},
7792 {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback
, METH_VARARGS
, NULL
},
7793 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7794 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
7795 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
7796 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
7797 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
7798 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
7799 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
7800 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
7801 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
7802 {(char *) "virNodeGetSecurityModel", libvirt_virNodeGetSecurityModel
, METH_VARARGS
, NULL
},
7803 {(char *) "virDomainGetSecurityLabel", libvirt_virDomainGetSecurityLabel
, METH_VARARGS
, NULL
},
7804 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7805 {(char *) "virDomainGetSecurityLabelList", libvirt_virDomainGetSecurityLabelList
, METH_VARARGS
, NULL
},
7806 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7807 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
7808 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
7809 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
7810 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
7811 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
7812 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
7813 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
7814 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
7815 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
7816 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
7817 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7818 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
7819 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7820 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
7821 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
7822 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
7823 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
7824 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
7825 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
7826 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
7827 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
7828 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
7829 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
7830 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
7831 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
7832 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
7833 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
7834 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
7835 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
7836 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
7837 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
7838 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
7839 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
7840 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
7841 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
7842 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
7843 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
7844 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
7845 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
7846 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
7847 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
7848 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7849 {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo
, METH_VARARGS
, NULL
},
7850 {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator
, METH_VARARGS
, NULL
},
7851 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7852 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
7853 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
7854 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7855 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
7856 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7857 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
7858 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
7859 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7860 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
7861 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7862 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
7863 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
7864 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
7865 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
7866 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
7867 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
7868 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
7869 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
7870 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
7871 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
7872 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
7873 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7874 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
7875 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7876 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
7877 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
7878 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
7879 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
7880 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
7881 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7882 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
7883 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7884 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
7885 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
7886 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
7887 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
7888 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
7889 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
7890 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7891 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
7892 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7893 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
7894 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
7895 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7896 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
7897 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7898 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
7899 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
7900 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7901 {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats
, METH_VARARGS
, NULL
},
7902 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7903 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
7904 #if LIBVIR_CHECK_VERSION(0, 9, 13)
7905 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
7906 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
7907 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
7908 #if LIBVIR_CHECK_VERSION(0, 9, 13)
7909 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
7910 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
7911 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
7912 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
7913 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
7914 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
7915 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
7916 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7917 {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache
, METH_VARARGS
, NULL
},
7918 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7919 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
7920 #if LIBVIR_CHECK_VERSION(1, 1, 0)
7921 {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3
, METH_VARARGS
, NULL
},
7922 {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3
, METH_VARARGS
, NULL
},
7923 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
7924 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
7925 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
7926 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
7927 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7928 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
7929 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
7930 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7931 #if LIBVIR_CHECK_VERSION(1, 0, 0)
7932 {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap
, METH_VARARGS
, NULL
},
7933 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
7934 #if LIBVIR_CHECK_VERSION(1, 1, 1)
7935 {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles
, METH_VARARGS
, NULL
},
7936 {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles
, METH_VARARGS
, NULL
},
7937 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
7938 #if LIBVIR_CHECK_VERSION(1, 2, 5)
7939 {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze
, METH_VARARGS
, NULL
},
7940 {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw
, METH_VARARGS
, NULL
},
7941 {(char *) "virDomainGetTime", libvirt_virDomainGetTime
, METH_VARARGS
, NULL
},
7942 {(char *) "virDomainSetTime", libvirt_virDomainSetTime
, METH_VARARGS
, NULL
},
7943 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
7944 {NULL
, NULL
, 0, NULL
}
7947 #if PY_MAJOR_VERSION > 2
7948 static struct PyModuleDef moduledef
= {
7949 PyModuleDef_HEAD_INIT
,
7974 if (virInitialize() < 0)
7977 module
= PyModule_Create(&moduledef
);
7981 #else /* ! PY_MAJOR_VERSION > 2 */
7990 if (virInitialize() < 0)
7993 /* initialize the python extension module */
7994 Py_InitModule((char *)
8002 #endif /* ! PY_MAJOR_VERSION > 2 */