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-2015 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, ...) \
56 * Utility function to retrieve the number of node CPUs present.
57 * It first tries virNodeGetCPUMap, which will return the
58 * number reliably, if available.
59 * As a fallback and for compatibility with backlevel libvirt
60 * versions virNodeGetInfo will be called to calculate the
61 * CPU number, which has the potential to return a too small
62 * number if some host CPUs are offline.
65 getPyNodeCPUCount(virConnectPtr conn
)
69 #if LIBVIR_CHECK_VERSION(1, 0, 0)
70 LIBVIRT_BEGIN_ALLOW_THREADS
;
71 i_retval
= virNodeGetCPUMap(conn
, NULL
, NULL
, 0);
72 LIBVIRT_END_ALLOW_THREADS
;
73 #else /* fallback: use nodeinfo */
76 LIBVIRT_BEGIN_ALLOW_THREADS
;
77 i_retval
= virNodeGetInfo(conn
, &nodeinfo
);
78 LIBVIRT_END_ALLOW_THREADS
;
81 i_retval
= VIR_NODEINFO_MAXCPUS(nodeinfo
);
82 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
87 /************************************************************************
91 ************************************************************************/
94 libvirt_virDomainBlockStats(PyObject
*self ATTRIBUTE_UNUSED
,
98 PyObject
*pyobj_domain
;
101 virDomainBlockStatsStruct stats
;
104 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainBlockStats",
105 &pyobj_domain
, &path
))
107 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
109 LIBVIRT_BEGIN_ALLOW_THREADS
;
110 c_retval
= virDomainBlockStats(domain
, path
, &stats
, sizeof(stats
));
111 LIBVIRT_END_ALLOW_THREADS
;
116 /* convert to a Python tuple of long objects */
117 if ((info
= PyTuple_New(5)) == NULL
)
120 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_longlongWrap(stats
.rd_req
), error
);
121 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_longlongWrap(stats
.rd_bytes
), error
);
122 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_longlongWrap(stats
.wr_req
), error
);
123 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_longlongWrap(stats
.wr_bytes
), error
);
124 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_longlongWrap(stats
.errs
), error
);
134 libvirt_virDomainBlockStatsFlags(PyObject
*self ATTRIBUTE_UNUSED
,
138 PyObject
*pyobj_domain
;
139 PyObject
*ret
= NULL
;
143 virTypedParameterPtr params
;
146 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainBlockStatsFlags",
147 &pyobj_domain
, &path
, &flags
))
149 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
151 LIBVIRT_BEGIN_ALLOW_THREADS
;
152 i_retval
= virDomainBlockStatsFlags(domain
, path
, NULL
, &nparams
, flags
);
153 LIBVIRT_END_ALLOW_THREADS
;
161 if (VIR_ALLOC_N(params
, nparams
) < 0)
162 return PyErr_NoMemory();
164 LIBVIRT_BEGIN_ALLOW_THREADS
;
165 i_retval
= virDomainBlockStatsFlags(domain
, path
, params
, &nparams
, flags
);
166 LIBVIRT_END_ALLOW_THREADS
;
173 ret
= getPyVirTypedParameter(params
, nparams
);
176 virTypedParamsFree(params
, nparams
);
181 libvirt_virDomainGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
,
185 PyObject
*pyobj_domain
, *totalbool
;
186 PyObject
*ret
= NULL
;
187 PyObject
*error
= NULL
;
188 int ncpus
= -1, start_cpu
= 0;
189 int sumparams
= 0, nparams
= -1;
194 virTypedParameterPtr params
= NULL
, cpuparams
;
196 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainGetCPUStats",
197 &pyobj_domain
, &totalbool
, &flags
))
199 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
201 if (libvirt_boolUnwrap(totalbool
, &totalflag
) < 0)
204 if ((ret
= PyList_New(0)) == NULL
)
208 LIBVIRT_BEGIN_ALLOW_THREADS
;
209 ncpus
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 0, flags
);
210 LIBVIRT_END_ALLOW_THREADS
;
217 LIBVIRT_BEGIN_ALLOW_THREADS
;
218 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, 0, 1, flags
);
219 LIBVIRT_END_ALLOW_THREADS
;
226 sumparams
= nparams
* MIN(ncpus
, 128);
228 if (VIR_ALLOC_N(params
, sumparams
) < 0) {
229 error
= PyErr_NoMemory();
234 int queried_ncpus
= MIN(ncpus
, 128);
237 LIBVIRT_BEGIN_ALLOW_THREADS
;
238 i_retval
= virDomainGetCPUStats(domain
, params
,
240 queried_ncpus
, flags
);
241 LIBVIRT_END_ALLOW_THREADS
;
251 for (i
= 0; i
< queried_ncpus
; i
++) {
252 cpuparams
= ¶ms
[i
* nparams
];
253 VIR_PY_LIST_APPEND_GOTO(ret
,
254 getPyVirTypedParameter(cpuparams
,
259 start_cpu
+= queried_ncpus
;
260 ncpus
-= queried_ncpus
;
261 virTypedParamsClear(params
, sumparams
);
264 LIBVIRT_BEGIN_ALLOW_THREADS
;
265 nparams
= virDomainGetCPUStats(domain
, NULL
, 0, -1, 1, flags
);
266 LIBVIRT_END_ALLOW_THREADS
;
276 if (VIR_ALLOC_N(params
, nparams
) < 0) {
277 error
= PyErr_NoMemory();
281 LIBVIRT_BEGIN_ALLOW_THREADS
;
282 i_retval
= virDomainGetCPUStats(domain
, params
, nparams
,
284 LIBVIRT_END_ALLOW_THREADS
;
294 VIR_PY_LIST_APPEND_GOTO(ret
, getPyVirTypedParameter(params
, i_retval
),
298 virTypedParamsFree(params
, sumparams
);
302 virTypedParamsFree(params
, sumparams
);
308 libvirt_virDomainInterfaceStats(PyObject
*self ATTRIBUTE_UNUSED
,
312 PyObject
*pyobj_domain
;
315 virDomainInterfaceStatsStruct stats
;
318 if (!PyArg_ParseTuple(args
, (char *)"Oz:virDomainInterfaceStats",
319 &pyobj_domain
, &path
))
321 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
323 LIBVIRT_BEGIN_ALLOW_THREADS
;
324 c_retval
= virDomainInterfaceStats(domain
, path
, &stats
, sizeof(stats
));
325 LIBVIRT_END_ALLOW_THREADS
;
330 /* convert to a Python tuple of long objects */
331 if ((info
= PyTuple_New(8)) == NULL
)
334 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_longlongWrap(stats
.rx_bytes
), error
);
335 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_longlongWrap(stats
.rx_packets
), error
);
336 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_longlongWrap(stats
.rx_errs
), error
);
337 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_longlongWrap(stats
.rx_drop
), error
);
338 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_longlongWrap(stats
.tx_bytes
), error
);
339 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_longlongWrap(stats
.tx_packets
), error
);
340 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_longlongWrap(stats
.tx_errs
), error
);
341 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_longlongWrap(stats
.tx_drop
), error
);
351 libvirt_virDomainMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
,
355 PyObject
*pyobj_domain
;
356 unsigned int nr_stats
;
358 virDomainMemoryStatStruct stats
[VIR_DOMAIN_MEMORY_STAT_NR
];
360 PyObject
*key
= NULL
, *val
= NULL
;
362 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainMemoryStats", &pyobj_domain
))
364 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
366 nr_stats
= virDomainMemoryStats(domain
, stats
,
367 VIR_DOMAIN_MEMORY_STAT_NR
, 0);
371 /* convert to a Python dictionary */
372 if ((info
= PyDict_New()) == NULL
)
375 for (i
= 0; i
< nr_stats
; i
++) {
376 switch (stats
[i
].tag
) {
377 case VIR_DOMAIN_MEMORY_STAT_SWAP_IN
:
378 key
= libvirt_constcharPtrWrap("swap_in");
380 case VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
:
381 key
= libvirt_constcharPtrWrap("swap_out");
383 case VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
:
384 key
= libvirt_constcharPtrWrap("major_fault");
386 case VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
:
387 key
= libvirt_constcharPtrWrap("minor_fault");
389 case VIR_DOMAIN_MEMORY_STAT_UNUSED
:
390 key
= libvirt_constcharPtrWrap("unused");
392 case VIR_DOMAIN_MEMORY_STAT_AVAILABLE
:
393 key
= libvirt_constcharPtrWrap("available");
395 case VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
:
396 key
= libvirt_constcharPtrWrap("actual");
398 case VIR_DOMAIN_MEMORY_STAT_RSS
:
399 key
= libvirt_constcharPtrWrap("rss");
404 val
= libvirt_ulonglongWrap(stats
[i
].val
);
406 VIR_PY_DICT_SET_GOTO(info
, key
, val
, error
);
417 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
421 PyObject
*pyobj_domain
, *info
;
425 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
428 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
430 LIBVIRT_BEGIN_ALLOW_THREADS
;
431 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
432 LIBVIRT_END_ALLOW_THREADS
;
433 if (c_retval
== NULL
)
436 /* convert to a Python tuple of long objects */
437 if ((info
= PyTuple_New(2)) == NULL
)
440 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_constcharPtrWrap(c_retval
), error
);
441 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)nparams
), error
);
454 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
458 PyObject
*pyobj_domain
;
459 PyObject
*ret
= NULL
;
463 virTypedParameterPtr params
;
465 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
468 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
470 LIBVIRT_BEGIN_ALLOW_THREADS
;
471 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
472 LIBVIRT_END_ALLOW_THREADS
;
474 if (c_retval
== NULL
)
481 if (VIR_ALLOC_N(params
, nparams
) < 0)
482 return PyErr_NoMemory();
484 LIBVIRT_BEGIN_ALLOW_THREADS
;
485 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
486 LIBVIRT_END_ALLOW_THREADS
;
493 ret
= getPyVirTypedParameter(params
, nparams
);
496 virTypedParamsFree(params
, nparams
);
501 libvirt_virDomainGetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
505 PyObject
*pyobj_domain
;
506 PyObject
*ret
= NULL
;
511 virTypedParameterPtr params
;
513 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetScedulerParametersFlags",
514 &pyobj_domain
, &flags
))
516 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
518 LIBVIRT_BEGIN_ALLOW_THREADS
;
519 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
520 LIBVIRT_END_ALLOW_THREADS
;
522 if (c_retval
== NULL
)
529 if (VIR_ALLOC_N(params
, nparams
) < 0)
530 return PyErr_NoMemory();
532 LIBVIRT_BEGIN_ALLOW_THREADS
;
533 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
,
535 LIBVIRT_END_ALLOW_THREADS
;
542 ret
= getPyVirTypedParameter(params
, nparams
);
545 virTypedParamsFree(params
, nparams
);
550 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
554 PyObject
*pyobj_domain
, *info
;
555 PyObject
*ret
= NULL
;
560 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
562 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetScedulerParameters",
563 &pyobj_domain
, &info
))
565 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
567 if ((size
= PyDict_Size(info
)) < 0)
571 PyErr_Format(PyExc_LookupError
,
572 "Need non-empty dictionary to set attributes");
576 LIBVIRT_BEGIN_ALLOW_THREADS
;
577 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
578 LIBVIRT_END_ALLOW_THREADS
;
580 if (c_retval
== NULL
)
581 return VIR_PY_INT_FAIL
;
585 PyErr_Format(PyExc_LookupError
,
586 "Domain has no settable attributes");
590 if (VIR_ALLOC_N(params
, nparams
) < 0)
591 return PyErr_NoMemory();
593 LIBVIRT_BEGIN_ALLOW_THREADS
;
594 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
595 LIBVIRT_END_ALLOW_THREADS
;
598 ret
= VIR_PY_INT_FAIL
;
602 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
606 LIBVIRT_BEGIN_ALLOW_THREADS
;
607 i_retval
= virDomainSetSchedulerParameters(domain
, new_params
, size
);
608 LIBVIRT_END_ALLOW_THREADS
;
611 ret
= VIR_PY_INT_FAIL
;
615 ret
= VIR_PY_INT_SUCCESS
;
618 virTypedParamsFree(params
, nparams
);
619 virTypedParamsFree(new_params
, size
);
624 libvirt_virDomainSetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
628 PyObject
*pyobj_domain
, *info
;
629 PyObject
*ret
= NULL
;
635 virTypedParameterPtr params
, new_params
= NULL
;
637 if (!PyArg_ParseTuple(args
,
638 (char *)"OOI:virDomainSetScedulerParametersFlags",
639 &pyobj_domain
, &info
, &flags
))
641 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
643 if ((size
= PyDict_Size(info
)) < 0)
647 PyErr_Format(PyExc_LookupError
,
648 "Need non-empty dictionary to set attributes");
652 LIBVIRT_BEGIN_ALLOW_THREADS
;
653 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
654 LIBVIRT_END_ALLOW_THREADS
;
656 if (c_retval
== NULL
)
657 return VIR_PY_INT_FAIL
;
661 PyErr_Format(PyExc_LookupError
,
662 "Domain has no settable attributes");
666 if (VIR_ALLOC_N(params
, nparams
) < 0)
667 return PyErr_NoMemory();
669 LIBVIRT_BEGIN_ALLOW_THREADS
;
670 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
,
672 LIBVIRT_END_ALLOW_THREADS
;
675 ret
= VIR_PY_INT_FAIL
;
679 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
683 LIBVIRT_BEGIN_ALLOW_THREADS
;
684 i_retval
= virDomainSetSchedulerParametersFlags(domain
, new_params
, size
,
686 LIBVIRT_END_ALLOW_THREADS
;
689 ret
= VIR_PY_INT_FAIL
;
693 ret
= VIR_PY_INT_SUCCESS
;
696 virTypedParamsFree(params
, nparams
);
697 virTypedParamsFree(new_params
, nparams
);
702 libvirt_virDomainSetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
706 PyObject
*pyobj_domain
, *info
;
707 PyObject
*ret
= NULL
;
712 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
714 if (!PyArg_ParseTuple(args
,
715 (char *)"OOI:virDomainSetBlkioParameters",
716 &pyobj_domain
, &info
, &flags
))
718 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
720 if ((size
= PyDict_Size(info
)) < 0)
724 PyErr_Format(PyExc_LookupError
,
725 "Need non-empty dictionary to set attributes");
729 LIBVIRT_BEGIN_ALLOW_THREADS
;
730 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
731 LIBVIRT_END_ALLOW_THREADS
;
734 return VIR_PY_INT_FAIL
;
737 PyErr_Format(PyExc_LookupError
,
738 "Domain has no settable attributes");
742 if (VIR_ALLOC_N(params
, nparams
) < 0)
743 return PyErr_NoMemory();
745 LIBVIRT_BEGIN_ALLOW_THREADS
;
746 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
747 LIBVIRT_END_ALLOW_THREADS
;
750 ret
= VIR_PY_INT_FAIL
;
754 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
758 LIBVIRT_BEGIN_ALLOW_THREADS
;
759 i_retval
= virDomainSetBlkioParameters(domain
, new_params
, size
, flags
);
760 LIBVIRT_END_ALLOW_THREADS
;
763 ret
= VIR_PY_INT_FAIL
;
767 ret
= VIR_PY_INT_SUCCESS
;
770 virTypedParamsFree(params
, nparams
);
771 virTypedParamsFree(new_params
, size
);
776 libvirt_virDomainGetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
780 PyObject
*pyobj_domain
;
781 PyObject
*ret
= NULL
;
785 virTypedParameterPtr params
;
787 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetBlkioParameters",
788 &pyobj_domain
, &flags
))
790 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
792 LIBVIRT_BEGIN_ALLOW_THREADS
;
793 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
794 LIBVIRT_END_ALLOW_THREADS
;
802 if (VIR_ALLOC_N(params
, nparams
) < 0)
803 return PyErr_NoMemory();
805 LIBVIRT_BEGIN_ALLOW_THREADS
;
806 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
807 LIBVIRT_END_ALLOW_THREADS
;
814 ret
= getPyVirTypedParameter(params
, nparams
);
817 virTypedParamsFree(params
, nparams
);
822 libvirt_virDomainSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
826 PyObject
*pyobj_domain
, *info
;
827 PyObject
*ret
= NULL
;
832 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
834 if (!PyArg_ParseTuple(args
,
835 (char *)"OOI:virDomainSetMemoryParameters",
836 &pyobj_domain
, &info
, &flags
))
838 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
840 if ((size
= PyDict_Size(info
)) < 0)
844 PyErr_Format(PyExc_LookupError
,
845 "Need non-empty dictionary to set attributes");
849 LIBVIRT_BEGIN_ALLOW_THREADS
;
850 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
851 LIBVIRT_END_ALLOW_THREADS
;
854 return VIR_PY_INT_FAIL
;
857 PyErr_Format(PyExc_LookupError
,
858 "Domain has no settable attributes");
862 if (VIR_ALLOC_N(params
, nparams
) < 0)
863 return PyErr_NoMemory();
865 LIBVIRT_BEGIN_ALLOW_THREADS
;
866 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
867 LIBVIRT_END_ALLOW_THREADS
;
870 ret
= VIR_PY_INT_FAIL
;
874 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
878 LIBVIRT_BEGIN_ALLOW_THREADS
;
879 i_retval
= virDomainSetMemoryParameters(domain
, new_params
, size
, flags
);
880 LIBVIRT_END_ALLOW_THREADS
;
883 ret
= VIR_PY_INT_FAIL
;
887 ret
= VIR_PY_INT_SUCCESS
;
890 virTypedParamsFree(params
, nparams
);
891 virTypedParamsFree(new_params
, size
);
896 libvirt_virDomainGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
900 PyObject
*pyobj_domain
;
901 PyObject
*ret
= NULL
;
905 virTypedParameterPtr params
;
907 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetMemoryParameters",
908 &pyobj_domain
, &flags
))
910 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
912 LIBVIRT_BEGIN_ALLOW_THREADS
;
913 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
914 LIBVIRT_END_ALLOW_THREADS
;
922 if (VIR_ALLOC_N(params
, nparams
) < 0)
923 return PyErr_NoMemory();
925 LIBVIRT_BEGIN_ALLOW_THREADS
;
926 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
927 LIBVIRT_END_ALLOW_THREADS
;
934 ret
= getPyVirTypedParameter(params
, nparams
);
937 virTypedParamsFree(params
, nparams
);
942 libvirt_virDomainSetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
946 PyObject
*pyobj_domain
, *info
;
947 PyObject
*ret
= NULL
;
952 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
954 if (!PyArg_ParseTuple(args
,
955 (char *)"OOI:virDomainSetNumaParameters",
956 &pyobj_domain
, &info
, &flags
))
958 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
960 if ((size
= PyDict_Size(info
)) < 0)
964 PyErr_Format(PyExc_LookupError
,
965 "Need non-empty dictionary to set attributes");
969 LIBVIRT_BEGIN_ALLOW_THREADS
;
970 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
971 LIBVIRT_END_ALLOW_THREADS
;
974 return VIR_PY_INT_FAIL
;
977 PyErr_Format(PyExc_LookupError
,
978 "Domain has no settable attributes");
982 if (VIR_ALLOC_N(params
, nparams
) < 0)
983 return PyErr_NoMemory();
985 LIBVIRT_BEGIN_ALLOW_THREADS
;
986 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
987 LIBVIRT_END_ALLOW_THREADS
;
990 ret
= VIR_PY_INT_FAIL
;
994 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
998 LIBVIRT_BEGIN_ALLOW_THREADS
;
999 i_retval
= virDomainSetNumaParameters(domain
, new_params
, size
, flags
);
1000 LIBVIRT_END_ALLOW_THREADS
;
1003 ret
= VIR_PY_INT_FAIL
;
1007 ret
= VIR_PY_INT_SUCCESS
;
1010 virTypedParamsFree(params
, nparams
);
1011 virTypedParamsFree(new_params
, size
);
1016 libvirt_virDomainGetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1019 virDomainPtr domain
;
1020 PyObject
*pyobj_domain
;
1021 PyObject
*ret
= NULL
;
1025 virTypedParameterPtr params
;
1027 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetNumaParameters",
1028 &pyobj_domain
, &flags
))
1030 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1032 LIBVIRT_BEGIN_ALLOW_THREADS
;
1033 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1034 LIBVIRT_END_ALLOW_THREADS
;
1040 return PyDict_New();
1042 if (VIR_ALLOC_N(params
, nparams
) < 0)
1043 return PyErr_NoMemory();
1045 LIBVIRT_BEGIN_ALLOW_THREADS
;
1046 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1047 LIBVIRT_END_ALLOW_THREADS
;
1054 ret
= getPyVirTypedParameter(params
, nparams
);
1057 virTypedParamsFree(params
, nparams
);
1062 libvirt_virDomainSetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1065 virDomainPtr domain
;
1066 PyObject
*pyobj_domain
, *info
;
1067 PyObject
*ret
= NULL
;
1070 Py_ssize_t size
= 0;
1072 const char *device
= NULL
;
1073 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1075 if (!PyArg_ParseTuple(args
,
1076 (char *)"OzOI:virDomainSetInterfaceParameters",
1077 &pyobj_domain
, &device
, &info
, &flags
))
1079 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1081 if ((size
= PyDict_Size(info
)) < 0)
1085 PyErr_Format(PyExc_LookupError
,
1086 "Need non-empty dictionary to set attributes");
1090 LIBVIRT_BEGIN_ALLOW_THREADS
;
1091 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
,
1093 LIBVIRT_END_ALLOW_THREADS
;
1096 return VIR_PY_INT_FAIL
;
1099 PyErr_Format(PyExc_LookupError
,
1100 "Domain has no settable attributes");
1104 if (VIR_ALLOC_N(params
, nparams
) < 0)
1105 return PyErr_NoMemory();
1107 LIBVIRT_BEGIN_ALLOW_THREADS
;
1108 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
,
1110 LIBVIRT_END_ALLOW_THREADS
;
1113 ret
= VIR_PY_INT_FAIL
;
1117 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1121 LIBVIRT_BEGIN_ALLOW_THREADS
;
1122 i_retval
= virDomainSetInterfaceParameters(domain
, device
, new_params
, size
,
1124 LIBVIRT_END_ALLOW_THREADS
;
1127 ret
= VIR_PY_INT_FAIL
;
1131 ret
= VIR_PY_INT_SUCCESS
;
1134 virTypedParamsFree(params
, nparams
);
1135 virTypedParamsFree(new_params
, size
);
1140 libvirt_virDomainGetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1143 virDomainPtr domain
;
1144 PyObject
*pyobj_domain
;
1145 PyObject
*ret
= NULL
;
1149 const char *device
= NULL
;
1150 virTypedParameterPtr params
;
1152 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetInterfaceParameters",
1153 &pyobj_domain
, &device
, &flags
))
1155 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1157 LIBVIRT_BEGIN_ALLOW_THREADS
;
1158 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
,
1160 LIBVIRT_END_ALLOW_THREADS
;
1166 return PyDict_New();
1168 if (VIR_ALLOC_N(params
, nparams
) < 0)
1169 return PyErr_NoMemory();
1171 LIBVIRT_BEGIN_ALLOW_THREADS
;
1172 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
,
1174 LIBVIRT_END_ALLOW_THREADS
;
1181 ret
= getPyVirTypedParameter(params
, nparams
);
1184 virTypedParamsFree(params
, nparams
);
1189 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
1192 virDomainPtr domain
;
1193 PyObject
*pyobj_domain
, *pyretval
= NULL
;
1194 PyObject
*pycpuinfo
= NULL
, *pycpumap
= NULL
;
1195 PyObject
*error
= NULL
;
1196 virDomainInfo dominfo
;
1197 virVcpuInfoPtr cpuinfo
= NULL
;
1198 unsigned char *cpumap
= NULL
;
1199 size_t cpumaplen
, i
;
1200 int i_retval
, cpunum
;
1202 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
1205 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1207 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1210 LIBVIRT_BEGIN_ALLOW_THREADS
;
1211 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1212 LIBVIRT_END_ALLOW_THREADS
;
1216 if (VIR_ALLOC_N(cpuinfo
, dominfo
.nrVirtCpu
) < 0)
1217 return PyErr_NoMemory();
1219 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1220 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1221 VIR_ALLOC_N(cpumap
, dominfo
.nrVirtCpu
* cpumaplen
) < 0) {
1222 error
= PyErr_NoMemory();
1226 LIBVIRT_BEGIN_ALLOW_THREADS
;
1227 i_retval
= virDomainGetVcpus(domain
,
1228 cpuinfo
, dominfo
.nrVirtCpu
,
1230 LIBVIRT_END_ALLOW_THREADS
;
1232 error
= VIR_PY_NONE
;
1236 /* convert to a Python tuple of long objects */
1237 if ((pyretval
= PyTuple_New(2)) == NULL
)
1239 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1242 VIR_PY_TUPLE_SET_GOTO(pyretval
, 0, pycpuinfo
, cleanup
);
1244 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1247 VIR_PY_TUPLE_SET_GOTO(pyretval
, 1, pycpumap
, cleanup
);
1249 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1250 PyObject
*info
= PyTuple_New(4);
1255 VIR_PY_LIST_SET_GOTO(pycpuinfo
, i
, info
, cleanup
);
1257 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)cpuinfo
[i
].number
),
1259 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)cpuinfo
[i
].state
),
1261 VIR_PY_TUPLE_SET_GOTO(info
, 2,
1262 libvirt_ulonglongWrap((long)cpuinfo
[i
].cpuTime
),
1264 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)cpuinfo
[i
].cpu
),
1267 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1268 PyObject
*info
= PyTuple_New(cpunum
);
1273 VIR_PY_LIST_SET_GOTO(pycpumap
, i
, info
, cleanup
);
1275 for (j
= 0; j
< cpunum
; j
++) {
1276 VIR_PY_TUPLE_SET_GOTO(info
, j
,
1277 PyBool_FromLong(VIR_CPU_USABLE(cpumap
,
1292 Py_XDECREF(pyretval
);
1298 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
1301 virDomainPtr domain
;
1302 PyObject
*pyobj_domain
, *pycpumap
;
1303 PyObject
*ret
= NULL
;
1304 unsigned char *cpumap
;
1305 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1309 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
1310 &pyobj_domain
, &vcpu
, &pycpumap
))
1312 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1314 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1315 return VIR_PY_INT_FAIL
;
1317 if (PyTuple_Check(pycpumap
)) {
1318 tuple_size
= PyTuple_Size(pycpumap
);
1319 if (tuple_size
== -1)
1322 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1326 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1327 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1328 return PyErr_NoMemory();
1330 for (i
= 0; i
< tuple_size
; i
++) {
1331 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1334 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1338 VIR_USE_CPU(cpumap
, i
);
1340 VIR_UNUSE_CPU(cpumap
, i
);
1343 for (; i
< cpunum
; i
++)
1344 VIR_UNUSE_CPU(cpumap
, i
);
1346 LIBVIRT_BEGIN_ALLOW_THREADS
;
1347 i_retval
= virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
1348 LIBVIRT_END_ALLOW_THREADS
;
1351 ret
= VIR_PY_INT_FAIL
;
1354 ret
= VIR_PY_INT_SUCCESS
;
1362 libvirt_virDomainPinVcpuFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1365 virDomainPtr domain
;
1366 PyObject
*pyobj_domain
, *pycpumap
;
1367 PyObject
*ret
= NULL
;
1368 unsigned char *cpumap
;
1369 int cpumaplen
, vcpu
, tuple_size
, cpunum
;
1374 if (!PyArg_ParseTuple(args
, (char *)"OiOI:virDomainPinVcpuFlags",
1375 &pyobj_domain
, &vcpu
, &pycpumap
, &flags
))
1377 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1379 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1380 return VIR_PY_INT_FAIL
;
1382 if (PyTuple_Check(pycpumap
)) {
1383 tuple_size
= PyTuple_Size(pycpumap
);
1384 if (tuple_size
== -1)
1387 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1391 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1392 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1393 return PyErr_NoMemory();
1395 for (i
= 0; i
< tuple_size
; i
++) {
1396 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1399 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1403 VIR_USE_CPU(cpumap
, i
);
1405 VIR_UNUSE_CPU(cpumap
, i
);
1408 for (; i
< cpunum
; i
++)
1409 VIR_UNUSE_CPU(cpumap
, i
);
1411 LIBVIRT_BEGIN_ALLOW_THREADS
;
1412 i_retval
= virDomainPinVcpuFlags(domain
, vcpu
, cpumap
, cpumaplen
, flags
);
1413 LIBVIRT_END_ALLOW_THREADS
;
1415 ret
= VIR_PY_INT_FAIL
;
1418 ret
= VIR_PY_INT_SUCCESS
;
1426 libvirt_virDomainGetVcpuPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1429 virDomainPtr domain
;
1430 PyObject
*pyobj_domain
, *pycpumaps
= NULL
, *error
= NULL
;
1431 virDomainInfo dominfo
;
1432 unsigned char *cpumaps
= NULL
;
1433 size_t cpumaplen
, vcpu
, pcpu
;
1435 int i_retval
, cpunum
;
1437 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetVcpuPinInfo",
1438 &pyobj_domain
, &flags
))
1440 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1442 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1445 LIBVIRT_BEGIN_ALLOW_THREADS
;
1446 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1447 LIBVIRT_END_ALLOW_THREADS
;
1451 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1452 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1453 VIR_ALLOC_N(cpumaps
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1456 LIBVIRT_BEGIN_ALLOW_THREADS
;
1457 i_retval
= virDomainGetVcpuPinInfo(domain
, dominfo
.nrVirtCpu
,
1458 cpumaps
, cpumaplen
, flags
);
1459 LIBVIRT_END_ALLOW_THREADS
;
1462 error
= VIR_PY_NONE
;
1466 if ((pycpumaps
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1469 for (vcpu
= 0; vcpu
< dominfo
.nrVirtCpu
; vcpu
++) {
1470 PyObject
*mapinfo
= PyTuple_New(cpunum
);
1471 if (mapinfo
== NULL
)
1474 VIR_PY_LIST_SET_GOTO(pycpumaps
, vcpu
, mapinfo
, cleanup
);
1476 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1477 VIR_PY_TUPLE_SET_GOTO(mapinfo
,
1479 PyBool_FromLong(VIR_CPU_USABLE(cpumaps
,
1494 Py_XDECREF(pycpumaps
);
1500 #if LIBVIR_CHECK_VERSION(0, 10, 0)
1502 libvirt_virDomainPinEmulator(PyObject
*self ATTRIBUTE_UNUSED
,
1505 virDomainPtr domain
;
1506 PyObject
*pyobj_domain
, *pycpumap
;
1507 unsigned char *cpumap
= NULL
;
1508 int cpumaplen
, tuple_size
, cpunum
;
1513 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainPinEmulator",
1514 &pyobj_domain
, &pycpumap
, &flags
))
1517 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1519 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1520 return VIR_PY_INT_FAIL
;
1522 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1524 if (!PyTuple_Check(pycpumap
)) {
1525 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1529 if ((tuple_size
= PyTuple_Size(pycpumap
)) == -1)
1532 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1533 return PyErr_NoMemory();
1535 for (i
= 0; i
< tuple_size
; i
++) {
1536 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1539 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0) {
1545 VIR_USE_CPU(cpumap
, i
);
1547 VIR_UNUSE_CPU(cpumap
, i
);
1550 for (; i
< cpunum
; i
++)
1551 VIR_UNUSE_CPU(cpumap
, i
);
1553 LIBVIRT_BEGIN_ALLOW_THREADS
;
1554 i_retval
= virDomainPinEmulator(domain
, cpumap
, cpumaplen
, flags
);
1555 LIBVIRT_END_ALLOW_THREADS
;
1560 return VIR_PY_INT_FAIL
;
1562 return VIR_PY_INT_SUCCESS
;
1567 libvirt_virDomainGetEmulatorPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1570 virDomainPtr domain
;
1571 PyObject
*pyobj_domain
;
1573 unsigned char *cpumap
;
1580 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetEmulatorPinInfo",
1581 &pyobj_domain
, &flags
))
1584 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1586 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1589 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1591 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1592 return PyErr_NoMemory();
1594 LIBVIRT_BEGIN_ALLOW_THREADS
;
1595 ret
= virDomainGetEmulatorPinInfo(domain
, cpumap
, cpumaplen
, flags
);
1596 LIBVIRT_END_ALLOW_THREADS
;
1602 if (!(pycpumap
= PyTuple_New(cpunum
))) {
1607 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1608 VIR_PY_TUPLE_SET_GOTO(pycpumap
,
1610 PyBool_FromLong(VIR_CPU_USABLE(cpumap
,
1625 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
1627 #if LIBVIR_CHECK_VERSION(1, 2, 14)
1629 libvirt_virDomainGetIOThreadInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1632 virDomainPtr domain
;
1633 PyObject
*pyobj_domain
;
1634 PyObject
*py_retval
= NULL
;
1635 PyObject
*py_iothrinfo
= NULL
;
1636 virDomainIOThreadInfoPtr
*iothrinfo
= NULL
;
1639 int niothreads
, cpunum
;
1641 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetIOThreadInfo",
1642 &pyobj_domain
, &flags
))
1644 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1646 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1649 LIBVIRT_BEGIN_ALLOW_THREADS
;
1650 niothreads
= virDomainGetIOThreadInfo(domain
, &iothrinfo
, flags
);
1651 LIBVIRT_END_ALLOW_THREADS
;
1653 if (niothreads
< 0) {
1654 py_retval
= VIR_PY_NONE
;
1658 /* convert to a Python list */
1659 if ((py_iothrinfo
= PyList_New(niothreads
)) == NULL
)
1662 /* NOTE: If there are zero IOThreads we will return an empty list */
1663 for (i
= 0; i
< niothreads
; i
++) {
1664 PyObject
*iothrtpl
= NULL
;
1665 PyObject
*iothrmap
= NULL
;
1666 virDomainIOThreadInfoPtr iothr
= iothrinfo
[i
];
1668 if (iothr
== NULL
) {
1669 py_retval
= VIR_PY_NONE
;
1673 if ((iothrtpl
= PyTuple_New(2)) == NULL
)
1676 VIR_PY_LIST_SET_GOTO(py_iothrinfo
, i
, iothrtpl
, cleanup
);
1678 /* 0: IOThread ID */
1679 VIR_PY_TUPLE_SET_GOTO(iothrtpl
, 0, libvirt_uintWrap(iothr
->iothread_id
),
1683 if ((iothrmap
= PyList_New(cpunum
)) == NULL
)
1686 VIR_PY_TUPLE_SET_GOTO(iothrtpl
, 1, iothrmap
, cleanup
);
1688 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++)
1689 VIR_PY_LIST_SET_GOTO(iothrmap
, pcpu
,
1690 PyBool_FromLong(VIR_CPU_USED(iothr
->cpumap
,
1695 py_retval
= py_iothrinfo
;
1696 py_iothrinfo
= NULL
;
1699 if (niothreads
> 0) {
1700 for (i
= 0; i
< niothreads
; i
++)
1701 virDomainIOThreadInfoFree(iothrinfo
[i
]);
1703 VIR_FREE(iothrinfo
);
1704 Py_XDECREF(py_iothrinfo
);
1709 libvirt_virDomainPinIOThread(PyObject
*self ATTRIBUTE_UNUSED
,
1712 virDomainPtr domain
;
1713 PyObject
*pyobj_domain
, *pycpumap
;
1714 PyObject
*ret
= NULL
;
1715 unsigned char *cpumap
;
1716 int cpumaplen
, iothread_val
, tuple_size
, cpunum
;
1721 if (!PyArg_ParseTuple(args
, (char *)"OiOI:virDomainPinIOThread",
1722 &pyobj_domain
, &iothread_val
, &pycpumap
, &flags
))
1724 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1726 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1727 return VIR_PY_INT_FAIL
;
1729 if (PyTuple_Check(pycpumap
)) {
1730 if ((tuple_size
= PyTuple_Size(pycpumap
)) == -1)
1733 PyErr_SetString(PyExc_TypeError
, "Unexpected type, tuple is required");
1737 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1738 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1739 return PyErr_NoMemory();
1741 for (i
= 0; i
< tuple_size
; i
++) {
1742 PyObject
*flag
= PyTuple_GetItem(pycpumap
, i
);
1745 if (!flag
|| libvirt_boolUnwrap(flag
, &b
) < 0)
1749 VIR_USE_CPU(cpumap
, i
);
1751 VIR_UNUSE_CPU(cpumap
, i
);
1754 for (; i
< cpunum
; i
++)
1755 VIR_UNUSE_CPU(cpumap
, i
);
1757 LIBVIRT_BEGIN_ALLOW_THREADS
;
1758 i_retval
= virDomainPinIOThread(domain
, iothread_val
,
1759 cpumap
, cpumaplen
, flags
);
1760 LIBVIRT_END_ALLOW_THREADS
;
1762 ret
= VIR_PY_INT_FAIL
;
1765 ret
= VIR_PY_INT_SUCCESS
;
1772 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
1774 /************************************************************************
1776 * Global error handler at the Python level *
1778 ************************************************************************/
1780 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
1781 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
1784 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
,
1785 PyObject
*args ATTRIBUTE_UNUSED
)
1790 if ((err
= virGetLastError()) == NULL
)
1793 if ((info
= PyTuple_New(9)) == NULL
)
1796 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), error
);
1797 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), error
);
1798 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), error
);
1799 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), error
);
1800 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), error
);
1801 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), error
);
1802 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), error
);
1803 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), error
);
1804 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), error
);
1814 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
,
1820 PyObject
*pyobj_conn
;
1822 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
1824 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1826 LIBVIRT_BEGIN_ALLOW_THREADS
;
1827 err
= virConnGetLastError(conn
);
1828 LIBVIRT_END_ALLOW_THREADS
;
1832 if ((info
= PyTuple_New(9)) == NULL
)
1835 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), error
);
1836 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), error
);
1837 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), error
);
1838 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), error
);
1839 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), error
);
1840 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), error
);
1841 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), error
);
1842 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), error
);
1843 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), error
);
1853 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
,
1856 PyObject
*list
= NULL
, *info
= NULL
;
1859 DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
1862 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
1865 LIBVIRT_ENSURE_THREAD_STATE
;
1867 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
1868 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
1869 virDefaultErrorFunc(err
);
1871 if ((list
= PyTuple_New(2)) == NULL
)
1874 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
1875 VIR_PY_TUPLE_SET_GOTO(list
, 0, libvirt_virPythonErrorFuncCtxt
, cleanup
);
1877 if ((info
= PyTuple_New(9)) == NULL
)
1880 VIR_PY_TUPLE_SET_GOTO(list
, 1, info
, cleanup
);
1882 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), cleanup
);
1883 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), cleanup
);
1884 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), cleanup
);
1885 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), cleanup
);
1886 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), cleanup
);
1887 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), cleanup
);
1888 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), cleanup
);
1889 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), cleanup
);
1890 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), cleanup
);
1892 /* TODO pass conn and dom if available */
1893 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
1899 LIBVIRT_RELEASE_THREAD_STATE
;
1903 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
*self
,
1906 PyObject
*py_retval
;
1908 PyObject
*pyobj_ctx
;
1910 if (!PyArg_ParseTuple(args
, (char *) "OO:virRegisterErrorHandler",
1911 &pyobj_f
, &pyobj_ctx
))
1914 DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
1917 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
1919 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
1920 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
1922 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
1923 libvirt_virPythonErrorFuncHandler
= NULL
;
1924 libvirt_virPythonErrorFuncCtxt
= NULL
;
1926 Py_XINCREF(pyobj_ctx
);
1927 Py_XINCREF(pyobj_f
);
1929 /* TODO: check f is a function ! */
1930 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
1931 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
1934 py_retval
= libvirt_intWrap(1);
1939 virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
1943 PyObject
*list
= NULL
;
1945 PyObject
*pyauth
= (PyObject
*)cbdata
;
1948 PyObject
*pyret
= NULL
;
1952 LIBVIRT_ENSURE_THREAD_STATE
;
1954 pycb
= PyList_GetItem(pyauth
, 1);
1955 pycbdata
= PyList_GetItem(pyauth
, 2);
1957 if ((list
= PyTuple_New(2)) == NULL
)
1960 if ((pycred
= PyTuple_New(ncred
)) == NULL
)
1963 VIR_PY_TUPLE_SET_GOTO(list
, 0, pycred
, cleanup
);
1965 for (i
= 0; i
< ncred
; i
++) {
1966 PyObject
*pycreditem
;
1967 if ((pycreditem
= PyList_New(5)) == NULL
)
1970 VIR_PY_TUPLE_SET_GOTO(pycred
, i
, pycreditem
, cleanup
);
1972 VIR_PY_LIST_SET_GOTO(pycreditem
, 0,
1973 libvirt_intWrap((long)cred
[i
].type
), cleanup
);
1974 VIR_PY_LIST_SET_GOTO(pycreditem
, 1,
1975 libvirt_constcharPtrWrap(cred
[i
].prompt
), cleanup
);
1977 if (cred
[i
].challenge
) {
1978 VIR_PY_LIST_SET_GOTO(pycreditem
, 2,
1979 libvirt_constcharPtrWrap(cred
[i
].challenge
),
1982 VIR_PY_LIST_SET_GOTO(pycreditem
, 2, VIR_PY_NONE
, cleanup
);
1984 if (cred
[i
].defresult
) {
1985 VIR_PY_LIST_SET_GOTO(pycreditem
, 3,
1986 libvirt_constcharPtrWrap(cred
[i
].defresult
),
1989 VIR_PY_LIST_SET_GOTO(pycreditem
, 3, VIR_PY_NONE
, cleanup
);
1991 VIR_PY_LIST_SET_GOTO(pycreditem
, 4, VIR_PY_NONE
, cleanup
);
1994 Py_XINCREF(pycbdata
);
1995 VIR_PY_TUPLE_SET_GOTO(list
, 1, pycbdata
, cleanup
);
1998 pyret
= PyEval_CallObject(pycb
, list
);
1999 if (PyErr_Occurred()) {
2004 ret
= PyLong_AsLong(pyret
);
2006 for (i
= 0; i
< ncred
; i
++) {
2007 PyObject
*pycreditem
;
2009 char *result
= NULL
;
2010 pycreditem
= PyTuple_GetItem(pycred
, i
);
2011 pyresult
= PyList_GetItem(pycreditem
, 4);
2012 if (pyresult
!= Py_None
)
2013 libvirt_charPtrUnwrap(pyresult
, &result
);
2014 if (result
!= NULL
) {
2015 cred
[i
].result
= result
;
2016 cred
[i
].resultlen
= strlen(result
);
2018 cred
[i
].result
= NULL
;
2019 cred
[i
].resultlen
= 0;
2028 LIBVIRT_RELEASE_THREAD_STATE
;
2035 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
,
2038 PyObject
*py_retval
;
2039 virConnectPtr c_retval
;
2044 PyObject
*pycredtype
;
2045 virConnectAuth auth
;
2047 memset(&auth
, 0, sizeof(auth
));
2048 if (!PyArg_ParseTuple(args
, (char *)"zOI:virConnectOpenAuth",
2049 &name
, &pyauth
, &flags
))
2052 pycredtype
= PyList_GetItem(pyauth
, 0);
2053 pycredcb
= PyList_GetItem(pyauth
, 1);
2055 auth
.ncredtype
= PyList_Size(pycredtype
);
2056 if (auth
.ncredtype
) {
2058 if (VIR_ALLOC_N(auth
.credtype
, auth
.ncredtype
) < 0)
2059 return PyErr_NoMemory();
2060 for (i
= 0; i
< auth
.ncredtype
; i
++) {
2062 val
= PyList_GetItem(pycredtype
, i
);
2063 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
2066 if (pycredcb
&& pycredcb
!= Py_None
)
2067 auth
.cb
= virConnectCredCallbackWrapper
;
2068 auth
.cbdata
= pyauth
;
2070 LIBVIRT_BEGIN_ALLOW_THREADS
;
2072 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
2073 LIBVIRT_END_ALLOW_THREADS
;
2074 VIR_FREE(auth
.credtype
);
2075 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
2080 /************************************************************************
2082 * Wrappers for functions where generator fails *
2084 ************************************************************************/
2087 libvirt_virGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2091 unsigned long libVer
, typeVer
= 0;
2094 if (!PyArg_ParseTuple(args
, (char *) "|s:virGetVersion", &type
))
2097 LIBVIRT_BEGIN_ALLOW_THREADS
;
2100 c_retval
= virGetVersion(&libVer
, NULL
, NULL
);
2102 c_retval
= virGetVersion(&libVer
, type
, &typeVer
);
2104 LIBVIRT_END_ALLOW_THREADS
;
2110 return libvirt_intWrap(libVer
);
2112 return Py_BuildValue((char *) "kk", libVer
, typeVer
);
2116 libvirt_virConnectGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2119 unsigned long hvVersion
;
2122 PyObject
*pyobj_conn
;
2124 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetVersion",
2127 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2129 LIBVIRT_BEGIN_ALLOW_THREADS
;
2131 c_retval
= virConnectGetVersion(conn
, &hvVersion
);
2133 LIBVIRT_END_ALLOW_THREADS
;
2136 return VIR_PY_INT_FAIL
;
2138 return libvirt_intWrap(hvVersion
);
2141 #if LIBVIR_CHECK_VERSION(1, 1, 3)
2143 libvirt_virConnectGetCPUModelNames(PyObject
*self ATTRIBUTE_UNUSED
,
2148 PyObject
*rv
= NULL
, *pyobj_conn
;
2149 char **models
= NULL
;
2151 unsigned int flags
= 0;
2152 const char *arch
= NULL
;
2154 if (!PyArg_ParseTuple(args
, (char *)"OsI:virConnectGetCPUModelNames",
2155 &pyobj_conn
, &arch
, &flags
))
2157 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2159 LIBVIRT_BEGIN_ALLOW_THREADS
;
2161 c_retval
= virConnectGetCPUModelNames(conn
, arch
, &models
, flags
);
2163 LIBVIRT_END_ALLOW_THREADS
;
2168 if ((rv
= PyList_New(c_retval
)) == NULL
)
2171 for (i
= 0; i
< c_retval
; i
++)
2172 VIR_PY_LIST_SET_GOTO(rv
, i
, libvirt_constcharPtrWrap(models
[i
]), error
);
2176 for (i
= 0; i
< c_retval
; i
++)
2177 VIR_FREE(models
[i
]);
2187 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
2190 libvirt_virConnectGetLibVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2193 unsigned long libVer
;
2196 PyObject
*pyobj_conn
;
2198 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetLibVersion",
2201 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2203 LIBVIRT_BEGIN_ALLOW_THREADS
;
2205 c_retval
= virConnectGetLibVersion(conn
, &libVer
);
2207 LIBVIRT_END_ALLOW_THREADS
;
2210 return VIR_PY_INT_FAIL
;
2212 return libvirt_intWrap(libVer
);
2216 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
2219 PyObject
*py_retval
;
2220 int *ids
= NULL
, c_retval
;
2223 PyObject
*pyobj_conn
;
2226 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
2228 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2230 LIBVIRT_BEGIN_ALLOW_THREADS
;
2231 c_retval
= virConnectNumOfDomains(conn
);
2232 LIBVIRT_END_ALLOW_THREADS
;
2237 if (VIR_ALLOC_N(ids
, c_retval
) < 0)
2238 return PyErr_NoMemory();
2240 LIBVIRT_BEGIN_ALLOW_THREADS
;
2241 c_retval
= virConnectListDomains(conn
, ids
, c_retval
);
2242 LIBVIRT_END_ALLOW_THREADS
;
2244 py_retval
= VIR_PY_NONE
;
2249 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2253 for (i
= 0; i
< c_retval
; i
++)
2254 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_intWrap(ids
[i
]), error
);
2262 Py_XDECREF(py_retval
);
2266 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2268 libvirt_virConnectListAllDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2271 PyObject
*pyobj_conn
;
2272 PyObject
*py_retval
= NULL
;
2274 virDomainPtr
*doms
= NULL
;
2279 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllDomains",
2280 &pyobj_conn
, &flags
))
2282 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2284 LIBVIRT_BEGIN_ALLOW_THREADS
;
2285 c_retval
= virConnectListAllDomains(conn
, &doms
, flags
);
2286 LIBVIRT_END_ALLOW_THREADS
;
2290 if (!(py_retval
= PyList_New(c_retval
)))
2293 for (i
= 0; i
< c_retval
; i
++) {
2294 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_virDomainPtrWrap(doms
[i
]), error
);
2295 /* python steals the pointer */
2300 for (i
= 0; i
< c_retval
; i
++)
2302 virDomainFree(doms
[i
]);
2307 Py_CLEAR(py_retval
);
2310 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2313 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2316 PyObject
*py_retval
;
2317 char **names
= NULL
;
2321 PyObject
*pyobj_conn
;
2324 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains",
2327 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2329 LIBVIRT_BEGIN_ALLOW_THREADS
;
2330 c_retval
= virConnectNumOfDefinedDomains(conn
);
2331 LIBVIRT_END_ALLOW_THREADS
;
2336 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2337 return PyErr_NoMemory();
2338 LIBVIRT_BEGIN_ALLOW_THREADS
;
2339 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
2340 LIBVIRT_END_ALLOW_THREADS
;
2342 py_retval
= VIR_PY_NONE
;
2347 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2351 for (i
= 0; i
< c_retval
; i
++)
2352 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2353 libvirt_constcharPtrWrap(names
[i
]), error
);
2358 for (i
= 0; i
< c_retval
; i
++)
2364 Py_CLEAR(py_retval
);
2369 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2372 PyObject
*py_retval
;
2373 char **names
= NULL
;
2377 PyObject
*pyobj_dom
;
2380 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListNames",
2381 &pyobj_dom
, &flags
))
2383 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2385 LIBVIRT_BEGIN_ALLOW_THREADS
;
2386 c_retval
= virDomainSnapshotNum(dom
, flags
);
2387 LIBVIRT_END_ALLOW_THREADS
;
2392 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2393 return PyErr_NoMemory();
2394 LIBVIRT_BEGIN_ALLOW_THREADS
;
2395 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2396 LIBVIRT_END_ALLOW_THREADS
;
2398 py_retval
= VIR_PY_NONE
;
2402 py_retval
= PyList_New(c_retval
);
2406 for (i
= 0; i
< c_retval
; i
++)
2407 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2411 for (i
= 0; i
< c_retval
; i
++)
2417 Py_CLEAR(py_retval
);
2421 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2423 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2426 PyObject
*py_retval
= NULL
;
2427 virDomainSnapshotPtr
*snaps
= NULL
;
2431 PyObject
*pyobj_dom
;
2434 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainListAllSnapshots",
2435 &pyobj_dom
, &flags
))
2437 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2439 LIBVIRT_BEGIN_ALLOW_THREADS
;
2440 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2441 LIBVIRT_END_ALLOW_THREADS
;
2445 if (!(py_retval
= PyList_New(c_retval
)))
2448 for (i
= 0; i
< c_retval
; i
++) {
2449 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2450 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2455 for (i
= 0; i
< c_retval
; i
++)
2457 virDomainSnapshotFree(snaps
[i
]);
2462 Py_CLEAR(py_retval
);
2465 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2468 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2471 PyObject
*py_retval
;
2472 char **names
= NULL
;
2475 virDomainSnapshotPtr snap
;
2476 PyObject
*pyobj_snap
;
2479 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListChildrenNames",
2480 &pyobj_snap
, &flags
))
2482 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2484 LIBVIRT_BEGIN_ALLOW_THREADS
;
2485 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2486 LIBVIRT_END_ALLOW_THREADS
;
2491 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2492 return PyErr_NoMemory();
2493 LIBVIRT_BEGIN_ALLOW_THREADS
;
2494 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2496 LIBVIRT_END_ALLOW_THREADS
;
2498 py_retval
= VIR_PY_NONE
;
2503 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2506 for (i
= 0; i
< c_retval
; i
++)
2507 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2511 for (i
= 0; i
< c_retval
; i
++)
2517 Py_CLEAR(py_retval
);
2521 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2523 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2526 PyObject
*py_retval
= NULL
;
2527 virDomainSnapshotPtr
*snaps
= NULL
;
2530 virDomainSnapshotPtr parent
;
2531 PyObject
*pyobj_parent
;
2534 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListAllChildren",
2535 &pyobj_parent
, &flags
))
2537 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2539 LIBVIRT_BEGIN_ALLOW_THREADS
;
2540 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2541 LIBVIRT_END_ALLOW_THREADS
;
2545 if (!(py_retval
= PyList_New(c_retval
)))
2548 for (i
= 0; i
< c_retval
; i
++) {
2549 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2550 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2555 for (i
= 0; i
< c_retval
; i
++)
2557 virDomainSnapshotFree(snaps
[i
]);
2562 Py_CLEAR(py_retval
);
2565 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2568 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2572 virDomainSnapshotPtr snap
;
2573 PyObject
*pyobj_snap
;
2574 PyObject
*pyobj_dom
;
2577 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainRevertToSnapshot",
2578 &pyobj_dom
, &pyobj_snap
, &flags
))
2580 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2582 LIBVIRT_BEGIN_ALLOW_THREADS
;
2583 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2584 LIBVIRT_END_ALLOW_THREADS
;
2586 return VIR_PY_INT_FAIL
;
2588 return libvirt_intWrap(c_retval
);
2592 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2595 PyObject
*py_retval
;
2597 virDomainPtr domain
;
2598 PyObject
*pyobj_domain
;
2601 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2603 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2605 LIBVIRT_BEGIN_ALLOW_THREADS
;
2606 c_retval
= virDomainGetInfo(domain
, &info
);
2607 LIBVIRT_END_ALLOW_THREADS
;
2611 if ((py_retval
= PyList_New(5)) == NULL
)
2614 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap((int) info
.state
), error
);
2615 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
), error
);
2616 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_ulongWrap(info
.memory
), error
);
2617 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
2618 libvirt_intWrap((int) info
.nrVirtCpu
), error
);
2619 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
2620 libvirt_ulonglongWrap(info
.cpuTime
), error
);
2625 Py_XDECREF(py_retval
);
2630 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
,
2633 PyObject
*py_retval
;
2635 virDomainPtr domain
;
2636 PyObject
*pyobj_domain
;
2641 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetState",
2642 &pyobj_domain
, &flags
))
2645 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2647 LIBVIRT_BEGIN_ALLOW_THREADS
;
2648 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2649 LIBVIRT_END_ALLOW_THREADS
;
2653 if ((py_retval
= PyList_New(2)) == NULL
)
2656 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(state
), error
);
2657 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(reason
), error
);
2662 Py_XDECREF(py_retval
);
2667 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2670 PyObject
*py_retval
;
2672 virDomainPtr domain
;
2673 PyObject
*pyobj_domain
;
2674 virDomainControlInfo info
;
2677 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetControlInfo",
2678 &pyobj_domain
, &flags
))
2680 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2682 LIBVIRT_BEGIN_ALLOW_THREADS
;
2683 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2684 LIBVIRT_END_ALLOW_THREADS
;
2688 if ((py_retval
= PyList_New(3)) == NULL
)
2691 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(info
.state
), error
);
2692 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(info
.details
), error
);
2693 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2694 libvirt_ulonglongWrap(info
.stateTime
), error
);
2699 Py_XDECREF(py_retval
);
2704 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2707 PyObject
*py_retval
;
2709 virDomainPtr domain
;
2710 PyObject
*pyobj_domain
;
2711 virDomainBlockInfo info
;
2715 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockInfo",
2716 &pyobj_domain
, &path
, &flags
))
2718 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2720 LIBVIRT_BEGIN_ALLOW_THREADS
;
2721 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2722 LIBVIRT_END_ALLOW_THREADS
;
2726 if ((py_retval
= PyList_New(3)) == NULL
)
2729 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2730 libvirt_ulonglongWrap(info
.capacity
), error
);
2731 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2732 libvirt_ulonglongWrap(info
.allocation
), error
);
2733 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2734 libvirt_ulonglongWrap(info
.physical
), error
);
2739 Py_XDECREF(py_retval
);
2744 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2747 PyObject
*py_retval
;
2750 PyObject
*pyobj_conn
;
2753 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeGetInfo", &pyobj_conn
))
2755 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2757 LIBVIRT_BEGIN_ALLOW_THREADS
;
2758 c_retval
= virNodeGetInfo(conn
, &info
);
2759 LIBVIRT_END_ALLOW_THREADS
;
2763 if ((py_retval
= PyList_New(8)) == NULL
)
2766 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2767 libvirt_constcharPtrWrap(&info
.model
[0]), error
);
2768 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2769 libvirt_longWrap((long) info
.memory
>> 10), error
);
2770 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_intWrap((int) info
.cpus
), error
);
2771 VIR_PY_LIST_SET_GOTO(py_retval
, 3, libvirt_intWrap((int) info
.mhz
), error
);
2772 VIR_PY_LIST_SET_GOTO(py_retval
, 4, libvirt_intWrap((int) info
.nodes
), error
);
2773 VIR_PY_LIST_SET_GOTO(py_retval
, 5, libvirt_intWrap((int) info
.sockets
), error
);
2774 VIR_PY_LIST_SET_GOTO(py_retval
, 6, libvirt_intWrap((int) info
.cores
), error
);
2775 VIR_PY_LIST_SET_GOTO(py_retval
, 7, libvirt_intWrap((int) info
.threads
), error
);
2780 Py_XDECREF(py_retval
);
2785 libvirt_virNodeGetSecurityModel(PyObject
*self ATTRIBUTE_UNUSED
,
2788 PyObject
*py_retval
;
2791 PyObject
*pyobj_conn
;
2792 virSecurityModel model
;
2794 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityModel",
2797 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2799 LIBVIRT_BEGIN_ALLOW_THREADS
;
2800 c_retval
= virNodeGetSecurityModel(conn
, &model
);
2801 LIBVIRT_END_ALLOW_THREADS
;
2805 if ((py_retval
= PyList_New(2)) == NULL
)
2808 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2809 libvirt_constcharPtrWrap(&model
.model
[0]), error
);
2810 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2811 libvirt_constcharPtrWrap(&model
.doi
[0]), error
);
2816 Py_XDECREF(py_retval
);
2821 libvirt_virDomainGetSecurityLabel(PyObject
*self ATTRIBUTE_UNUSED
,
2824 PyObject
*py_retval
;
2827 PyObject
*pyobj_dom
;
2828 virSecurityLabel label
;
2830 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabel",
2833 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2835 LIBVIRT_BEGIN_ALLOW_THREADS
;
2836 c_retval
= virDomainGetSecurityLabel(dom
, &label
);
2837 LIBVIRT_END_ALLOW_THREADS
;
2841 if ((py_retval
= PyList_New(2)) == NULL
)
2844 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2845 libvirt_constcharPtrWrap(&label
.label
[0]), error
);
2846 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2847 libvirt_boolWrap(label
.enforcing
), error
);
2852 Py_XDECREF(py_retval
);
2856 #if LIBVIR_CHECK_VERSION(0, 10, 0)
2858 libvirt_virDomainGetSecurityLabelList(PyObject
*self ATTRIBUTE_UNUSED
,
2861 PyObject
*py_retval
;
2864 PyObject
*pyobj_dom
;
2865 virSecurityLabel
*labels
= NULL
;
2868 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabelList",
2872 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2874 LIBVIRT_BEGIN_ALLOW_THREADS
;
2875 c_retval
= virDomainGetSecurityLabelList(dom
, &labels
);
2876 LIBVIRT_END_ALLOW_THREADS
;
2881 if (!(py_retval
= PyList_New(0)))
2884 for (i
= 0 ; i
< c_retval
; i
++) {
2887 if (!(entry
= PyList_New(2)))
2890 VIR_PY_LIST_APPEND_GOTO(py_retval
, entry
, error
);
2892 VIR_PY_LIST_SET_GOTO(entry
, 0,
2893 libvirt_constcharPtrWrap(&labels
[i
].label
[0]),
2895 VIR_PY_LIST_SET_GOTO(entry
, 1,
2896 libvirt_boolWrap(labels
[i
].enforcing
), error
);
2904 Py_CLEAR(py_retval
);
2907 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
2910 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
2913 unsigned char uuid
[VIR_UUID_BUFLEN
];
2914 virDomainPtr domain
;
2915 PyObject
*pyobj_domain
;
2918 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2920 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2924 LIBVIRT_BEGIN_ALLOW_THREADS
;
2925 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
2926 LIBVIRT_END_ALLOW_THREADS
;
2931 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
2935 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
2938 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
2940 PyObject
*pyobj_dom
;
2943 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
2946 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2950 LIBVIRT_BEGIN_ALLOW_THREADS
;
2951 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
2952 LIBVIRT_END_ALLOW_THREADS
;
2957 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
2961 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
2964 virDomainPtr c_retval
;
2966 PyObject
*pyobj_conn
;
2967 unsigned char * uuid
;
2970 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID",
2971 &pyobj_conn
, &uuid
, &len
))
2973 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2975 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
2978 LIBVIRT_BEGIN_ALLOW_THREADS
;
2979 c_retval
= virDomainLookupByUUID(conn
, uuid
);
2980 LIBVIRT_END_ALLOW_THREADS
;
2982 return libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
2987 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2990 PyObject
*py_retval
;
2991 char **names
= NULL
;
2995 PyObject
*pyobj_conn
;
2998 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks",
3001 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3003 LIBVIRT_BEGIN_ALLOW_THREADS
;
3004 c_retval
= virConnectNumOfNetworks(conn
);
3005 LIBVIRT_END_ALLOW_THREADS
;
3010 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3011 return PyErr_NoMemory();
3012 LIBVIRT_BEGIN_ALLOW_THREADS
;
3013 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
3014 LIBVIRT_END_ALLOW_THREADS
;
3016 py_retval
= VIR_PY_NONE
;
3021 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3025 for (i
= 0; i
< c_retval
; i
++)
3026 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3027 libvirt_constcharPtrWrap(names
[i
]), error
);
3031 for (i
= 0; i
< c_retval
; i
++)
3037 Py_CLEAR(py_retval
);
3043 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3046 PyObject
*py_retval
;
3047 char **names
= NULL
;
3051 PyObject
*pyobj_conn
;
3054 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks",
3057 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3059 LIBVIRT_BEGIN_ALLOW_THREADS
;
3060 c_retval
= virConnectNumOfDefinedNetworks(conn
);
3061 LIBVIRT_END_ALLOW_THREADS
;
3066 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3067 return PyErr_NoMemory();
3068 LIBVIRT_BEGIN_ALLOW_THREADS
;
3069 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
3070 LIBVIRT_END_ALLOW_THREADS
;
3072 py_retval
= VIR_PY_NONE
;
3077 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3080 for (i
= 0; i
< c_retval
; i
++)
3081 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3082 libvirt_constcharPtrWrap(names
[i
]), error
);
3086 for (i
= 0; i
< c_retval
; i
++)
3092 Py_CLEAR(py_retval
);
3096 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3098 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3101 PyObject
*pyobj_conn
;
3102 PyObject
*py_retval
= NULL
;
3104 virNetworkPtr
*nets
= NULL
;
3109 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNetworks",
3110 &pyobj_conn
, &flags
))
3112 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3114 LIBVIRT_BEGIN_ALLOW_THREADS
;
3115 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
3116 LIBVIRT_END_ALLOW_THREADS
;
3120 if (!(py_retval
= PyList_New(c_retval
)))
3123 for (i
= 0; i
< c_retval
; i
++) {
3124 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3125 libvirt_virNetworkPtrWrap(nets
[i
]), error
);
3130 for (i
= 0; i
< c_retval
; i
++)
3132 virNetworkFree(nets
[i
]);
3137 Py_CLEAR(py_retval
);
3140 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3144 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3147 unsigned char uuid
[VIR_UUID_BUFLEN
];
3148 virNetworkPtr domain
;
3149 PyObject
*pyobj_domain
;
3152 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
3154 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
3158 LIBVIRT_BEGIN_ALLOW_THREADS
;
3159 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
3160 LIBVIRT_END_ALLOW_THREADS
;
3165 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3169 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3172 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3174 PyObject
*pyobj_net
;
3177 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
3180 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
3184 LIBVIRT_BEGIN_ALLOW_THREADS
;
3185 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
3186 LIBVIRT_END_ALLOW_THREADS
;
3191 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3195 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3198 virNetworkPtr c_retval
;
3200 PyObject
*pyobj_conn
;
3201 unsigned char * uuid
;
3204 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID",
3205 &pyobj_conn
, &uuid
, &len
))
3207 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3209 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3212 LIBVIRT_BEGIN_ALLOW_THREADS
;
3213 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
3214 LIBVIRT_END_ALLOW_THREADS
;
3216 return libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
3221 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3224 int c_retval
, autostart
;
3225 virDomainPtr domain
;
3226 PyObject
*pyobj_domain
;
3228 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart",
3232 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3234 LIBVIRT_BEGIN_ALLOW_THREADS
;
3235 c_retval
= virDomainGetAutostart(domain
, &autostart
);
3236 LIBVIRT_END_ALLOW_THREADS
;
3239 return VIR_PY_INT_FAIL
;
3241 return libvirt_intWrap(autostart
);
3246 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3249 int c_retval
, autostart
;
3250 virNetworkPtr network
;
3251 PyObject
*pyobj_network
;
3253 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart",
3257 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
3259 LIBVIRT_BEGIN_ALLOW_THREADS
;
3260 c_retval
= virNetworkGetAutostart(network
, &autostart
);
3261 LIBVIRT_END_ALLOW_THREADS
;
3264 return VIR_PY_INT_FAIL
;
3266 return libvirt_intWrap(autostart
);
3270 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
,
3273 PyObject
*py_retval
;
3274 PyObject
*pyobj_conn
;
3275 int startCell
, maxCells
, c_retval
;
3278 unsigned long long *freeMems
;
3280 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory",
3281 &pyobj_conn
, &startCell
, &maxCells
))
3284 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
3287 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3288 if (VIR_ALLOC_N(freeMems
, maxCells
) < 0)
3289 return PyErr_NoMemory();
3291 LIBVIRT_BEGIN_ALLOW_THREADS
;
3292 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
3293 LIBVIRT_END_ALLOW_THREADS
;
3296 py_retval
= VIR_PY_NONE
;
3300 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3303 for (i
= 0; i
< c_retval
; i
++)
3304 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3305 libvirt_ulonglongWrap(freeMems
[i
]), error
);
3312 Py_CLEAR(py_retval
);
3317 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
,
3320 PyObject
*ret
= NULL
;
3321 PyObject
*key
= NULL
;
3322 PyObject
*val
= NULL
;
3323 PyObject
*pyobj_conn
;
3326 int cpuNum
, c_retval
;
3329 virNodeCPUStatsPtr stats
= NULL
;
3331 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetCPUStats",
3332 &pyobj_conn
, &cpuNum
, &flags
))
3334 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3336 LIBVIRT_BEGIN_ALLOW_THREADS
;
3337 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
3338 LIBVIRT_END_ALLOW_THREADS
;
3343 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3344 return PyErr_NoMemory();
3346 LIBVIRT_BEGIN_ALLOW_THREADS
;
3347 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
3348 LIBVIRT_END_ALLOW_THREADS
;
3355 if (!(ret
= PyDict_New()))
3358 for (i
= 0; i
< nparams
; i
++) {
3359 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3360 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3362 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3375 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
,
3378 PyObject
*ret
= NULL
;
3379 PyObject
*key
= NULL
;
3380 PyObject
*val
= NULL
;
3381 PyObject
*pyobj_conn
;
3384 int cellNum
, c_retval
;
3387 virNodeMemoryStatsPtr stats
= NULL
;
3389 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetMemoryStats",
3390 &pyobj_conn
, &cellNum
, &flags
))
3392 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3394 LIBVIRT_BEGIN_ALLOW_THREADS
;
3395 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
3396 LIBVIRT_END_ALLOW_THREADS
;
3401 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3402 return PyErr_NoMemory();
3404 LIBVIRT_BEGIN_ALLOW_THREADS
;
3405 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
3406 LIBVIRT_END_ALLOW_THREADS
;
3413 if (!(ret
= PyDict_New()))
3416 for (i
= 0; i
< nparams
; i
++) {
3417 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3418 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3420 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3433 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3436 PyObject
*py_retval
;
3437 char **names
= NULL
;
3441 PyObject
*pyobj_conn
;
3443 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools",
3446 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3448 LIBVIRT_BEGIN_ALLOW_THREADS
;
3449 c_retval
= virConnectNumOfStoragePools(conn
);
3450 LIBVIRT_END_ALLOW_THREADS
;
3455 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3456 return PyErr_NoMemory();
3457 LIBVIRT_BEGIN_ALLOW_THREADS
;
3458 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
3459 LIBVIRT_END_ALLOW_THREADS
;
3461 py_retval
= VIR_PY_NONE
;
3466 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3469 for (i
= 0; i
< c_retval
; i
++)
3470 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3471 libvirt_constcharPtrWrap(names
[i
]), error
);
3475 for (i
= 0; i
< c_retval
; i
++)
3481 Py_CLEAR(py_retval
);
3487 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3490 PyObject
*py_retval
;
3491 char **names
= NULL
;
3495 PyObject
*pyobj_conn
;
3497 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools",
3500 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3502 LIBVIRT_BEGIN_ALLOW_THREADS
;
3503 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3504 LIBVIRT_END_ALLOW_THREADS
;
3509 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3510 return PyErr_NoMemory();
3511 LIBVIRT_BEGIN_ALLOW_THREADS
;
3512 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3513 LIBVIRT_END_ALLOW_THREADS
;
3515 py_retval
= VIR_PY_NONE
;
3520 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3524 for (i
= 0; i
< c_retval
; i
++)
3525 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3526 libvirt_constcharPtrWrap(names
[i
]), error
);
3531 for (i
= 0; i
< c_retval
; i
++)
3537 Py_CLEAR(py_retval
);
3541 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3543 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3546 PyObject
*pyobj_conn
;
3547 PyObject
*py_retval
= NULL
;
3549 virStoragePoolPtr
*pools
= NULL
;
3554 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllStoragePools",
3555 &pyobj_conn
, &flags
))
3557 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3559 LIBVIRT_BEGIN_ALLOW_THREADS
;
3560 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3561 LIBVIRT_END_ALLOW_THREADS
;
3565 if (!(py_retval
= PyList_New(c_retval
)))
3568 for (i
= 0; i
< c_retval
; i
++) {
3569 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3570 libvirt_virStoragePoolPtrWrap(pools
[i
]), error
);
3571 /* python steals the pointer */
3576 for (i
= 0; i
< c_retval
; i
++)
3578 virStoragePoolFree(pools
[i
]);
3583 Py_CLEAR(py_retval
);
3586 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3589 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3592 PyObject
*py_retval
;
3593 char **names
= NULL
;
3596 virStoragePoolPtr pool
;
3597 PyObject
*pyobj_pool
;
3599 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes",
3602 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3604 LIBVIRT_BEGIN_ALLOW_THREADS
;
3605 c_retval
= virStoragePoolNumOfVolumes(pool
);
3606 LIBVIRT_END_ALLOW_THREADS
;
3611 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3612 return PyErr_NoMemory();
3614 LIBVIRT_BEGIN_ALLOW_THREADS
;
3615 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3616 LIBVIRT_END_ALLOW_THREADS
;
3618 py_retval
= VIR_PY_NONE
;
3623 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3627 for (i
= 0; i
< c_retval
; i
++)
3628 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3629 libvirt_constcharPtrWrap(names
[i
]), error
);
3633 for (i
= 0; i
< c_retval
; i
++)
3639 Py_CLEAR(py_retval
);
3643 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3645 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3648 PyObject
*py_retval
= NULL
;
3649 virStoragePoolPtr pool
;
3650 virStorageVolPtr
*vols
= NULL
;
3654 PyObject
*pyobj_pool
;
3656 if (!PyArg_ParseTuple(args
, (char *)"OI:virStoragePoolListAllVolumes",
3657 &pyobj_pool
, &flags
))
3660 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3662 LIBVIRT_BEGIN_ALLOW_THREADS
;
3663 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3664 LIBVIRT_END_ALLOW_THREADS
;
3668 if (!(py_retval
= PyList_New(c_retval
)))
3671 for (i
= 0; i
< c_retval
; i
++) {
3672 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3673 libvirt_virStorageVolPtrWrap(vols
[i
]), error
);
3674 /* python steals the pointer */
3679 for (i
= 0; i
< c_retval
; i
++)
3681 virStorageVolFree(vols
[i
]);
3686 Py_CLEAR(py_retval
);
3689 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3693 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3696 int c_retval
, autostart
;
3697 virStoragePoolPtr pool
;
3698 PyObject
*pyobj_pool
;
3700 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart",
3704 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3706 LIBVIRT_BEGIN_ALLOW_THREADS
;
3707 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3708 LIBVIRT_END_ALLOW_THREADS
;
3711 return VIR_PY_INT_FAIL
;
3713 return libvirt_intWrap(autostart
);
3717 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3720 PyObject
*py_retval
;
3722 virStoragePoolPtr pool
;
3723 PyObject
*pyobj_pool
;
3724 virStoragePoolInfo info
;
3726 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3728 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3730 LIBVIRT_BEGIN_ALLOW_THREADS
;
3731 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3732 LIBVIRT_END_ALLOW_THREADS
;
3736 if ((py_retval
= PyList_New(4)) == NULL
)
3739 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3740 libvirt_intWrap((int) info
.state
), error
);
3741 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3742 libvirt_ulonglongWrap(info
.capacity
), error
);
3743 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3744 libvirt_ulonglongWrap(info
.allocation
), error
);
3745 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
3746 libvirt_ulonglongWrap(info
.available
), error
);
3751 Py_XDECREF(py_retval
);
3757 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3760 PyObject
*py_retval
;
3762 virStorageVolPtr pool
;
3763 PyObject
*pyobj_pool
;
3764 virStorageVolInfo info
;
3766 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3768 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3770 LIBVIRT_BEGIN_ALLOW_THREADS
;
3771 c_retval
= virStorageVolGetInfo(pool
, &info
);
3772 LIBVIRT_END_ALLOW_THREADS
;
3776 if ((py_retval
= PyList_New(3)) == NULL
)
3779 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3780 libvirt_intWrap((int) info
.type
), error
);
3781 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3782 libvirt_ulonglongWrap(info
.capacity
), error
);
3783 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3784 libvirt_ulonglongWrap(info
.allocation
), error
);
3789 Py_DECREF(py_retval
);
3794 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3797 unsigned char uuid
[VIR_UUID_BUFLEN
];
3798 virStoragePoolPtr pool
;
3799 PyObject
*pyobj_pool
;
3802 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3804 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3808 LIBVIRT_BEGIN_ALLOW_THREADS
;
3809 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3810 LIBVIRT_END_ALLOW_THREADS
;
3815 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3819 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3822 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3823 virStoragePoolPtr pool
;
3824 PyObject
*pyobj_pool
;
3827 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString",
3830 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3834 LIBVIRT_BEGIN_ALLOW_THREADS
;
3835 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3836 LIBVIRT_END_ALLOW_THREADS
;
3841 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3845 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3848 virStoragePoolPtr c_retval
;
3850 PyObject
*pyobj_conn
;
3851 unsigned char * uuid
;
3854 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID",
3855 &pyobj_conn
, &uuid
, &len
))
3857 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3859 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3862 LIBVIRT_BEGIN_ALLOW_THREADS
;
3863 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
3864 LIBVIRT_END_ALLOW_THREADS
;
3866 return libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
3870 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3873 PyObject
*py_retval
;
3874 char **names
= NULL
;
3878 PyObject
*pyobj_conn
;
3882 if (!PyArg_ParseTuple(args
, (char *)"OzI:virNodeListDevices",
3883 &pyobj_conn
, &cap
, &flags
))
3885 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3887 LIBVIRT_BEGIN_ALLOW_THREADS
;
3888 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
3889 LIBVIRT_END_ALLOW_THREADS
;
3894 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3895 return PyErr_NoMemory();
3897 LIBVIRT_BEGIN_ALLOW_THREADS
;
3898 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
3899 LIBVIRT_END_ALLOW_THREADS
;
3902 py_retval
= VIR_PY_NONE
;
3907 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3911 for (i
= 0; i
< c_retval
; i
++)
3912 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3913 libvirt_constcharPtrWrap(names
[i
]), error
);
3917 for (i
= 0; i
< c_retval
; i
++)
3923 Py_CLEAR(py_retval
);
3927 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3929 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3932 PyObject
*pyobj_conn
;
3933 PyObject
*py_retval
= NULL
;
3935 virNodeDevicePtr
*devices
= NULL
;
3940 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNodeDevices",
3941 &pyobj_conn
, &flags
))
3943 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3945 LIBVIRT_BEGIN_ALLOW_THREADS
;
3946 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
3947 LIBVIRT_END_ALLOW_THREADS
;
3951 if (!(py_retval
= PyList_New(c_retval
)))
3954 for (i
= 0; i
< c_retval
; i
++) {
3955 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3956 libvirt_virNodeDevicePtrWrap(devices
[i
]), error
);
3957 /* python steals the pointer */
3962 for (i
= 0; i
< c_retval
; i
++)
3964 virNodeDeviceFree(devices
[i
]);
3969 Py_CLEAR(py_retval
);
3972 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3975 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
3978 PyObject
*py_retval
;
3979 char **names
= NULL
;
3982 virNodeDevicePtr dev
;
3983 PyObject
*pyobj_dev
;
3985 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
3987 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
3989 LIBVIRT_BEGIN_ALLOW_THREADS
;
3990 c_retval
= virNodeDeviceNumOfCaps(dev
);
3991 LIBVIRT_END_ALLOW_THREADS
;
3996 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3997 return PyErr_NoMemory();
3998 LIBVIRT_BEGIN_ALLOW_THREADS
;
3999 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
4000 LIBVIRT_END_ALLOW_THREADS
;
4002 py_retval
= VIR_PY_NONE
;
4007 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4011 for (i
= 0; i
< c_retval
; i
++)
4012 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4013 libvirt_constcharPtrWrap(names
[i
]), error
);
4017 for (i
= 0; i
< c_retval
; i
++)
4023 Py_CLEAR(py_retval
);
4028 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4031 unsigned char uuid
[VIR_UUID_BUFLEN
];
4032 virSecretPtr secret
;
4033 PyObject
*pyobj_secret
;
4036 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
4038 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4042 LIBVIRT_BEGIN_ALLOW_THREADS
;
4043 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
4044 LIBVIRT_END_ALLOW_THREADS
;
4049 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4053 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4056 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4058 PyObject
*pyobj_dom
;
4061 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
4064 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
4068 LIBVIRT_BEGIN_ALLOW_THREADS
;
4069 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
4070 LIBVIRT_END_ALLOW_THREADS
;
4075 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4079 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4082 virSecretPtr c_retval
;
4084 PyObject
*pyobj_conn
;
4085 unsigned char * uuid
;
4088 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID",
4089 &pyobj_conn
, &uuid
, &len
))
4091 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4093 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4096 LIBVIRT_BEGIN_ALLOW_THREADS
;
4097 c_retval
= virSecretLookupByUUID(conn
, uuid
);
4098 LIBVIRT_END_ALLOW_THREADS
;
4100 return libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
4105 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4108 PyObject
*py_retval
;
4109 char **uuids
= NULL
;
4113 PyObject
*pyobj_conn
;
4115 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
4117 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4119 LIBVIRT_BEGIN_ALLOW_THREADS
;
4120 c_retval
= virConnectNumOfSecrets(conn
);
4121 LIBVIRT_END_ALLOW_THREADS
;
4126 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4127 return PyErr_NoMemory();
4128 LIBVIRT_BEGIN_ALLOW_THREADS
;
4129 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
4130 LIBVIRT_END_ALLOW_THREADS
;
4132 py_retval
= VIR_PY_NONE
;
4137 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4141 for (i
= 0; i
< c_retval
; i
++)
4142 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4143 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4148 for (i
= 0; i
< c_retval
; i
++)
4154 Py_CLEAR(py_retval
);
4158 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4160 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4163 PyObject
*pyobj_conn
;
4164 PyObject
*py_retval
= NULL
;
4166 virSecretPtr
*secrets
= NULL
;
4171 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllSecrets",
4172 &pyobj_conn
, &flags
))
4174 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4176 LIBVIRT_BEGIN_ALLOW_THREADS
;
4177 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
4178 LIBVIRT_END_ALLOW_THREADS
;
4182 if (!(py_retval
= PyList_New(c_retval
)))
4185 for (i
= 0; i
< c_retval
; i
++) {
4186 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4187 libvirt_virSecretPtrWrap(secrets
[i
]), error
);
4188 /* python steals the pointer */
4193 for (i
= 0; i
< c_retval
; i
++)
4195 virSecretFree(secrets
[i
]);
4200 Py_CLEAR(py_retval
);
4203 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4206 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4209 PyObject
*py_retval
;
4210 unsigned char *c_retval
;
4212 virSecretPtr secret
;
4213 PyObject
*pyobj_secret
;
4216 if (!PyArg_ParseTuple(args
, (char *)"OI:virSecretGetValue", &pyobj_secret
,
4219 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4221 LIBVIRT_BEGIN_ALLOW_THREADS
;
4222 c_retval
= virSecretGetValue(secret
, &size
, flags
);
4223 LIBVIRT_END_ALLOW_THREADS
;
4225 if (c_retval
== NULL
)
4228 py_retval
= libvirt_charPtrSizeWrap((char*)c_retval
, size
);
4235 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4239 virSecretPtr secret
;
4240 PyObject
*pyobj_secret
;
4245 if (!PyArg_ParseTuple(args
, (char *)"Oz#I:virSecretSetValue", &pyobj_secret
,
4246 &value
, &size
, &flags
))
4248 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4250 LIBVIRT_BEGIN_ALLOW_THREADS
;
4251 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
4253 LIBVIRT_END_ALLOW_THREADS
;
4255 return libvirt_intWrap(c_retval
);
4259 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4262 unsigned char uuid
[VIR_UUID_BUFLEN
];
4263 virNWFilterPtr nwfilter
;
4264 PyObject
*pyobj_nwfilter
;
4267 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID",
4270 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4272 if (nwfilter
== NULL
)
4274 LIBVIRT_BEGIN_ALLOW_THREADS
;
4275 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
4276 LIBVIRT_END_ALLOW_THREADS
;
4281 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4285 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4288 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4289 virNWFilterPtr nwfilter
;
4290 PyObject
*pyobj_nwfilter
;
4293 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
4296 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4298 if (nwfilter
== NULL
)
4300 LIBVIRT_BEGIN_ALLOW_THREADS
;
4301 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
4302 LIBVIRT_END_ALLOW_THREADS
;
4307 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4311 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4314 virNWFilterPtr c_retval
;
4316 PyObject
*pyobj_conn
;
4317 unsigned char * uuid
;
4320 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID",
4321 &pyobj_conn
, &uuid
, &len
))
4323 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4325 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4328 LIBVIRT_BEGIN_ALLOW_THREADS
;
4329 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
4330 LIBVIRT_END_ALLOW_THREADS
;
4332 return libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
4337 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4340 PyObject
*py_retval
;
4341 char **uuids
= NULL
;
4345 PyObject
*pyobj_conn
;
4347 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters",
4350 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4352 LIBVIRT_BEGIN_ALLOW_THREADS
;
4353 c_retval
= virConnectNumOfNWFilters(conn
);
4354 LIBVIRT_END_ALLOW_THREADS
;
4359 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4360 return PyErr_NoMemory();
4362 LIBVIRT_BEGIN_ALLOW_THREADS
;
4363 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
4364 LIBVIRT_END_ALLOW_THREADS
;
4366 py_retval
= VIR_PY_NONE
;
4371 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4375 for (i
= 0; i
< c_retval
; i
++)
4376 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4377 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4381 for (i
= 0; i
< c_retval
; i
++)
4387 Py_CLEAR(py_retval
);
4391 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4393 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4396 PyObject
*pyobj_conn
;
4397 PyObject
*py_retval
= NULL
;
4399 virNWFilterPtr
*filters
= NULL
;
4404 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNWFilters",
4405 &pyobj_conn
, &flags
))
4407 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4409 LIBVIRT_BEGIN_ALLOW_THREADS
;
4410 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
4411 LIBVIRT_END_ALLOW_THREADS
;
4415 if (!(py_retval
= PyList_New(c_retval
)))
4418 for (i
= 0; i
< c_retval
; i
++) {
4419 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4420 libvirt_virNWFilterPtrWrap(filters
[i
]), error
);
4421 /* python steals the pointer */
4426 for (i
= 0; i
< c_retval
; i
++)
4428 virNWFilterFree(filters
[i
]);
4433 Py_CLEAR(py_retval
);
4436 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4439 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4442 PyObject
*py_retval
;
4443 char **names
= NULL
;
4447 PyObject
*pyobj_conn
;
4450 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces",
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)
4463 return PyErr_NoMemory();
4465 LIBVIRT_BEGIN_ALLOW_THREADS
;
4466 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
4467 LIBVIRT_END_ALLOW_THREADS
;
4469 py_retval
= VIR_PY_NONE
;
4474 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4478 for (i
= 0; i
< c_retval
; i
++)
4479 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4480 libvirt_constcharPtrWrap(names
[i
]), error
);
4484 for (i
= 0; i
< c_retval
; i
++)
4490 Py_CLEAR(py_retval
);
4496 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4499 PyObject
*py_retval
;
4500 char **names
= NULL
;
4504 PyObject
*pyobj_conn
;
4507 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
4510 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4512 LIBVIRT_BEGIN_ALLOW_THREADS
;
4513 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
4514 LIBVIRT_END_ALLOW_THREADS
;
4519 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4520 return PyErr_NoMemory();
4522 LIBVIRT_BEGIN_ALLOW_THREADS
;
4523 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
4524 LIBVIRT_END_ALLOW_THREADS
;
4526 py_retval
= VIR_PY_NONE
;
4531 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4535 for (i
= 0; i
< c_retval
; i
++)
4536 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4537 libvirt_constcharPtrWrap(names
[i
]), error
);
4542 for (i
= 0; i
< c_retval
; i
++)
4548 Py_CLEAR(py_retval
);
4553 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4555 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4558 PyObject
*pyobj_conn
;
4559 PyObject
*py_retval
= NULL
;
4561 virInterfacePtr
*ifaces
= NULL
;
4566 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllInterfaces",
4567 &pyobj_conn
, &flags
))
4569 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4571 LIBVIRT_BEGIN_ALLOW_THREADS
;
4572 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
4573 LIBVIRT_END_ALLOW_THREADS
;
4577 if (!(py_retval
= PyList_New(c_retval
)))
4580 for (i
= 0; i
< c_retval
; i
++) {
4581 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4582 libvirt_virInterfacePtrWrap(ifaces
[i
]), error
);
4583 /* python steals the pointer */
4588 for (i
= 0; i
< c_retval
; i
++)
4590 virInterfaceFree(ifaces
[i
]);
4595 Py_CLEAR(py_retval
);
4598 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4601 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4604 PyObject
*pyobj_conn
;
4608 char **xmlcpus
= NULL
;
4611 PyObject
*pybase_cpu
;
4614 if (!PyArg_ParseTuple(args
, (char *)"OOI:virConnectBaselineCPU",
4615 &pyobj_conn
, &list
, &flags
))
4617 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4619 if (PyList_Check(list
)) {
4620 ncpus
= PyList_Size(list
);
4621 if (VIR_ALLOC_N(xmlcpus
, ncpus
) < 0)
4622 return PyErr_NoMemory();
4624 for (i
= 0; i
< ncpus
; i
++) {
4625 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
),
4626 &(xmlcpus
[i
])) < 0 ||
4627 xmlcpus
[i
] == NULL
) {
4628 for (j
= 0 ; j
< i
; j
++)
4629 VIR_FREE(xmlcpus
[j
]);
4636 LIBVIRT_BEGIN_ALLOW_THREADS
;
4637 base_cpu
= virConnectBaselineCPU(conn
, (const char **)xmlcpus
, ncpus
, flags
);
4638 LIBVIRT_END_ALLOW_THREADS
;
4640 for (i
= 0 ; i
< ncpus
; i
++)
4641 VIR_FREE(xmlcpus
[i
]);
4644 if (base_cpu
== NULL
)
4647 pybase_cpu
= libvirt_constcharPtrWrap(base_cpu
);
4655 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4658 PyObject
*py_retval
;
4660 virDomainPtr domain
;
4661 PyObject
*pyobj_domain
;
4662 virDomainJobInfo info
;
4664 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4666 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4668 LIBVIRT_BEGIN_ALLOW_THREADS
;
4669 c_retval
= virDomainGetJobInfo(domain
, &info
);
4670 LIBVIRT_END_ALLOW_THREADS
;
4674 if ((py_retval
= PyList_New(12)) == NULL
)
4677 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
4678 libvirt_intWrap((int) info
.type
), error
);
4679 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
4680 libvirt_ulonglongWrap(info
.timeElapsed
), error
);
4681 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
4682 libvirt_ulonglongWrap(info
.timeRemaining
), error
);
4683 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
4684 libvirt_ulonglongWrap(info
.dataTotal
), error
);
4685 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
4686 libvirt_ulonglongWrap(info
.dataProcessed
), error
);
4687 VIR_PY_LIST_SET_GOTO(py_retval
, 5,
4688 libvirt_ulonglongWrap(info
.dataRemaining
), error
);
4689 VIR_PY_LIST_SET_GOTO(py_retval
, 6,
4690 libvirt_ulonglongWrap(info
.memTotal
), error
);
4691 VIR_PY_LIST_SET_GOTO(py_retval
, 7,
4692 libvirt_ulonglongWrap(info
.memProcessed
), error
);
4693 VIR_PY_LIST_SET_GOTO(py_retval
, 8,
4694 libvirt_ulonglongWrap(info
.memRemaining
), error
);
4695 VIR_PY_LIST_SET_GOTO(py_retval
, 9,
4696 libvirt_ulonglongWrap(info
.fileTotal
), error
);
4697 VIR_PY_LIST_SET_GOTO(py_retval
, 10,
4698 libvirt_ulonglongWrap(info
.fileProcessed
), error
);
4699 VIR_PY_LIST_SET_GOTO(py_retval
, 11,
4700 libvirt_ulonglongWrap(info
.fileRemaining
), error
);
4705 Py_DECREF(py_retval
);
4709 #if LIBVIR_CHECK_VERSION(1, 0, 3)
4711 libvirt_virDomainGetJobStats(PyObject
*self ATTRIBUTE_UNUSED
,
4714 PyObject
*pyobj_domain
;
4715 virDomainPtr domain
;
4717 virTypedParameterPtr params
= NULL
;
4720 PyObject
*dict
= NULL
;
4723 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetJobStats",
4724 &pyobj_domain
, &flags
))
4726 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4728 LIBVIRT_BEGIN_ALLOW_THREADS
;
4729 rc
= virDomainGetJobStats(domain
, &type
, ¶ms
, &nparams
, flags
);
4730 LIBVIRT_END_ALLOW_THREADS
;
4734 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
4737 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4738 libvirt_intWrap(type
), error
);
4741 virTypedParamsFree(params
, nparams
);
4748 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
4751 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4754 virDomainPtr domain
;
4755 PyObject
*pyobj_domain
;
4758 virDomainBlockJobInfo info
;
4762 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockJobInfo",
4763 &pyobj_domain
, &path
, &flags
))
4765 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4767 LIBVIRT_BEGIN_ALLOW_THREADS
;
4768 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4769 LIBVIRT_END_ALLOW_THREADS
;
4774 if ((dict
= PyDict_New()) == NULL
)
4780 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4781 libvirt_intWrap(info
.type
), error
);
4782 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("bandwidth"),
4783 libvirt_ulongWrap(info
.bandwidth
), error
);
4784 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("cur"),
4785 libvirt_ulonglongWrap(info
.cur
), error
);
4786 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("end"),
4787 libvirt_ulonglongWrap(info
.end
), error
);
4797 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4800 virDomainPtr domain
;
4801 PyObject
*pyobj_domain
, *info
;
4802 PyObject
*ret
= NULL
;
4805 Py_ssize_t size
= 0;
4808 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
4810 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainSetBlockIoTune",
4811 &pyobj_domain
, &disk
, &info
, &flags
))
4813 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4815 if ((size
= PyDict_Size(info
)) < 0)
4819 PyErr_Format(PyExc_LookupError
,
4820 "Need non-empty dictionary to set attributes");
4824 LIBVIRT_BEGIN_ALLOW_THREADS
;
4825 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4826 LIBVIRT_END_ALLOW_THREADS
;
4829 return VIR_PY_INT_FAIL
;
4832 PyErr_Format(PyExc_LookupError
,
4833 "Domain has no settable attributes");
4837 if (VIR_ALLOC_N(params
, nparams
) < 0)
4838 return PyErr_NoMemory();
4840 LIBVIRT_BEGIN_ALLOW_THREADS
;
4841 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4842 LIBVIRT_END_ALLOW_THREADS
;
4845 ret
= VIR_PY_INT_FAIL
;
4849 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
4853 LIBVIRT_BEGIN_ALLOW_THREADS
;
4854 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
4855 LIBVIRT_END_ALLOW_THREADS
;
4858 ret
= VIR_PY_INT_FAIL
;
4862 ret
= VIR_PY_INT_SUCCESS
;
4865 virTypedParamsFree(params
, nparams
);
4866 virTypedParamsFree(new_params
, size
);
4871 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4874 virDomainPtr domain
;
4875 PyObject
*pyobj_domain
;
4876 PyObject
*ret
= NULL
;
4881 virTypedParameterPtr params
;
4883 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockIoTune",
4884 &pyobj_domain
, &disk
, &flags
))
4886 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4888 LIBVIRT_BEGIN_ALLOW_THREADS
;
4889 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4890 LIBVIRT_END_ALLOW_THREADS
;
4896 return PyDict_New();
4898 if (VIR_ALLOC_N(params
, nparams
) < 0)
4899 return PyErr_NoMemory();
4901 LIBVIRT_BEGIN_ALLOW_THREADS
;
4902 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4903 LIBVIRT_END_ALLOW_THREADS
;
4910 ret
= getPyVirTypedParameter(params
, nparams
);
4913 virTypedParamsFree(params
, nparams
);
4918 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
4921 PyObject
*py_retval
= VIR_PY_NONE
;
4922 virDomainPtr domain
;
4923 PyObject
*pyobj_domain
;
4925 virDomainDiskErrorPtr disks
= NULL
;
4926 unsigned int ndisks
;
4930 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetDiskErrors",
4931 &pyobj_domain
, &flags
))
4934 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4936 if ((count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0)) < 0)
4941 if (VIR_ALLOC_N(disks
, ndisks
) < 0)
4942 return PyErr_NoMemory();
4944 LIBVIRT_BEGIN_ALLOW_THREADS
;
4945 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
4946 LIBVIRT_END_ALLOW_THREADS
;
4949 py_retval
= VIR_PY_NONE
;
4954 if (!(py_retval
= PyDict_New()))
4957 for (i
= 0; i
< count
; i
++) {
4958 VIR_PY_DICT_SET_GOTO(py_retval
,
4959 libvirt_constcharPtrWrap(disks
[i
].disk
),
4960 libvirt_intWrap(disks
[i
].error
),
4966 for (i
= 0; i
< count
; i
++)
4967 VIR_FREE(disks
[i
].disk
);
4972 Py_CLEAR(py_retval
);
4977 #if LIBVIR_CHECK_VERSION(1, 2, 14)
4979 libvirt_virDomainInterfaceAddresses(PyObject
*self ATTRIBUTE_UNUSED
,
4982 PyObject
*py_retval
= VIR_PY_NONE
;
4983 PyObject
*pyobj_domain
;
4984 virDomainPtr domain
;
4985 virDomainInterfacePtr
*ifaces
= NULL
;
4986 unsigned int source
;
4988 int ifaces_count
= 0;
4991 if (!PyArg_ParseTuple(args
, (char *) "OII:virDomainInterfaceAddresses",
4992 &pyobj_domain
, &source
, &flags
))
4995 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4997 LIBVIRT_BEGIN_ALLOW_THREADS
;
4998 ifaces_count
= virDomainInterfaceAddresses(domain
, &ifaces
, source
, flags
);
4999 LIBVIRT_END_ALLOW_THREADS
;
5001 if (ifaces_count
< 0)
5004 if (!(py_retval
= PyDict_New()))
5007 for (i
= 0; i
< ifaces_count
; i
++) {
5008 virDomainInterfacePtr iface
= ifaces
[i
];
5009 PyObject
*py_addrs
= NULL
;
5010 PyObject
*py_iface
= NULL
;
5012 if (!(py_iface
= PyDict_New()))
5015 VIR_PY_DICT_SET_GOTO(py_retval
, libvirt_charPtrWrap(iface
->name
),
5018 if (iface
->naddrs
) {
5019 if (!(py_addrs
= PyList_New(iface
->naddrs
))) {
5023 py_addrs
= VIR_PY_NONE
;
5026 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("addrs"),
5029 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("hwaddr"),
5030 libvirt_constcharPtrWrap(iface
->hwaddr
), error
);
5032 for (j
= 0; j
< iface
->naddrs
; j
++) {
5033 virDomainIPAddressPtr addr
= &(iface
->addrs
[j
]);
5034 PyObject
*py_addr
= PyDict_New();
5039 VIR_PY_LIST_SET_GOTO(py_addrs
, j
, py_addr
, error
);
5041 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("addr"),
5042 libvirt_constcharPtrWrap(addr
->addr
), error
);
5043 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("prefix"),
5044 libvirt_uintWrap(addr
->prefix
), error
);
5045 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("type"),
5046 libvirt_intWrap(addr
->type
), error
);
5051 if (ifaces
&& ifaces_count
> 0) {
5052 for (i
= 0; i
< ifaces_count
; i
++) {
5053 virDomainInterfaceFree(ifaces
[i
]);
5061 Py_CLEAR(py_retval
);
5064 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
5067 /*******************************************
5068 * Helper functions to avoid importing modules
5069 * for every callback
5070 *******************************************/
5071 static PyObject
*libvirt_module
= NULL
;
5072 static PyObject
*libvirt_dict
= NULL
;
5075 getLibvirtModuleObject(void)
5078 return libvirt_module
;
5080 // PyImport_ImportModule returns a new reference
5081 /* Bogus (char *) cast for RHEL-5 python API brokenness */
5082 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
5083 if (!libvirt_module
) {
5084 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
5089 return libvirt_module
;
5093 getLibvirtDictObject(void)
5096 return libvirt_dict
;
5098 // PyModule_GetDict returns a borrowed reference
5099 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
5100 if (!libvirt_dict
) {
5101 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
5106 Py_INCREF(libvirt_dict
);
5107 return libvirt_dict
;
5112 libvirt_lookupPythonFunc(const char *funcname
)
5114 PyObject
*python_cb
;
5116 /* Lookup the python callback */
5117 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
5120 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
5126 if (!PyCallable_Check(python_cb
)) {
5127 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
5134 /*******************************************
5136 *******************************************/
5139 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5145 PyObject
*pyobj_ret
= NULL
;
5147 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5148 PyObject
*pyobj_dom
;
5152 LIBVIRT_ENSURE_THREAD_STATE
;
5154 /* Create a python instance of this virDomainPtr */
5156 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5161 /* Call the Callback Dispatcher */
5162 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5163 (char*)"_dispatchDomainEventCallbacks",
5168 Py_DECREF(pyobj_dom
);
5172 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5175 Py_DECREF(pyobj_ret
);
5179 LIBVIRT_RELEASE_THREAD_STATE
;
5184 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
*self
,
5187 PyObject
*pyobj_conn
; /* virConnectPtr */
5188 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
5193 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventRegister",
5194 &pyobj_conn
, &pyobj_conn_inst
))
5197 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
5198 pyobj_conn
, pyobj_conn_inst
);
5199 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5201 Py_INCREF(pyobj_conn_inst
);
5203 LIBVIRT_BEGIN_ALLOW_THREADS
;
5205 ret
= virConnectDomainEventRegister(conn
,
5206 libvirt_virConnectDomainEventCallback
,
5207 pyobj_conn_inst
, NULL
);
5209 LIBVIRT_END_ALLOW_THREADS
;
5211 return libvirt_intWrap(ret
);
5215 libvirt_virConnectDomainEventDeregister(PyObject
*self ATTRIBUTE_UNUSED
,
5218 PyObject
*pyobj_conn
;
5219 PyObject
*pyobj_conn_inst
;
5224 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventDeregister",
5225 &pyobj_conn
, &pyobj_conn_inst
))
5228 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
5230 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5232 LIBVIRT_BEGIN_ALLOW_THREADS
;
5234 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
5236 LIBVIRT_END_ALLOW_THREADS
;
5238 Py_DECREF(pyobj_conn_inst
);
5239 return libvirt_intWrap(ret
);
5242 /*******************************************
5244 *******************************************/
5245 static PyObject
*addHandleObj
;
5246 static char *addHandleName
;
5247 static PyObject
*updateHandleObj
;
5248 static char *updateHandleName
;
5249 static PyObject
*removeHandleObj
;
5250 static char *removeHandleName
;
5251 static PyObject
*addTimeoutObj
;
5252 static char *addTimeoutName
;
5253 static PyObject
*updateTimeoutObj
;
5254 static char *updateTimeoutName
;
5255 static PyObject
*removeTimeoutObj
;
5256 static char *removeTimeoutName
;
5258 #define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
5261 libvirt_virEventAddHandleFunc(int fd
,
5263 virEventHandleCallback cb
,
5268 PyObject
*python_cb
= NULL
;
5269 PyObject
*cb_args
= NULL
;
5270 PyObject
*pyobj_args
= NULL
;
5273 LIBVIRT_ENSURE_THREAD_STATE
;
5275 if ((pyobj_args
= PyTuple_New(4)) == NULL
)
5278 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(fd
), cleanup
);
5279 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5281 /* Lookup the python callback */
5282 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
5286 Py_INCREF(python_cb
);
5288 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, python_cb
, cleanup
);
5290 if ((cb_args
= PyTuple_New(3)) == NULL
)
5293 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 3, cb_args
, cleanup
);
5295 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventHandleCallbackWrap(cb
), cleanup
);
5296 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5297 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5299 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
5304 libvirt_intUnwrap(result
, &retval
);
5310 Py_XDECREF(pyobj_args
);
5312 LIBVIRT_RELEASE_THREAD_STATE
;
5318 libvirt_virEventUpdateHandleFunc(int watch
,
5321 PyObject
*result
= NULL
;
5322 PyObject
*pyobj_args
;
5324 LIBVIRT_ENSURE_THREAD_STATE
;
5326 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5329 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5330 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5332 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
5340 Py_XDECREF(pyobj_args
);
5342 LIBVIRT_RELEASE_THREAD_STATE
;
5347 libvirt_virEventRemoveHandleFunc(int watch
)
5349 PyObject
*result
= NULL
;
5350 PyObject
*pyobj_args
;
5354 virFreeCallback cff
;
5356 LIBVIRT_ENSURE_THREAD_STATE
;
5358 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5361 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5363 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
5367 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5368 DEBUG("%s: %s must return opaque obj registered with %s"
5369 "to avoid leaking libvirt memory\n",
5370 __FUNCTION__
, NAME(removeHandle
), NAME(addHandle
));
5372 opaque
= PyTuple_GetItem(result
, 1);
5373 ff
= PyTuple_GetItem(result
, 2);
5374 cff
= PyvirFreeCallback_Get(ff
);
5376 (*cff
)(PyvirVoidPtr_Get(opaque
));
5382 Py_XDECREF(pyobj_args
);
5384 LIBVIRT_RELEASE_THREAD_STATE
;
5391 libvirt_virEventAddTimeoutFunc(int timeout
,
5392 virEventTimeoutCallback cb
,
5396 PyObject
*result
= NULL
;
5397 PyObject
*python_cb
= NULL
;
5398 PyObject
*cb_args
= NULL
;
5399 PyObject
*pyobj_args
= NULL
;
5402 LIBVIRT_ENSURE_THREAD_STATE
;
5404 if ((pyobj_args
= PyTuple_New(3)) == NULL
)
5407 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timeout
), cleanup
);
5409 /* Lookup the python callback */
5410 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
5414 Py_INCREF(python_cb
);
5415 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, python_cb
, cleanup
);
5417 if ((cb_args
= PyTuple_New(3)) == NULL
)
5420 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, cb_args
, cleanup
);
5422 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventTimeoutCallbackWrap(cb
), cleanup
);
5423 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5424 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5426 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
5431 libvirt_intUnwrap(result
, &retval
);
5436 Py_XDECREF(pyobj_args
);
5438 LIBVIRT_RELEASE_THREAD_STATE
;
5443 libvirt_virEventUpdateTimeoutFunc(int timer
,
5446 PyObject
*result
= NULL
;
5447 PyObject
*pyobj_args
;
5449 LIBVIRT_ENSURE_THREAD_STATE
;
5451 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5454 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5455 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(timeout
), cleanup
);
5457 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
5465 Py_XDECREF(pyobj_args
);
5467 LIBVIRT_RELEASE_THREAD_STATE
;
5471 libvirt_virEventRemoveTimeoutFunc(int timer
)
5473 PyObject
*result
= NULL
;
5474 PyObject
*pyobj_args
;
5478 virFreeCallback cff
;
5480 LIBVIRT_ENSURE_THREAD_STATE
;
5482 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5485 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5487 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
5491 } else if (!PyTuple_Check(result
) || PyTuple_Size(result
) != 3) {
5492 DEBUG("%s: %s must return opaque obj registered with %s"
5493 "to avoid leaking libvirt memory\n",
5494 __FUNCTION__
, NAME(removeTimeout
), NAME(addTimeout
));
5496 opaque
= PyTuple_GetItem(result
, 1);
5497 ff
= PyTuple_GetItem(result
, 2);
5498 cff
= PyvirFreeCallback_Get(ff
);
5500 (*cff
)(PyvirVoidPtr_Get(opaque
));
5506 Py_XDECREF(pyobj_args
);
5508 LIBVIRT_RELEASE_THREAD_STATE
;
5514 libvirt_virEventRegisterImpl(PyObject
*self ATTRIBUTE_UNUSED
,
5517 /* Unref the previously-registered impl (if any) */
5518 Py_XDECREF(addHandleObj
);
5519 Py_XDECREF(updateHandleObj
);
5520 Py_XDECREF(removeHandleObj
);
5521 Py_XDECREF(addTimeoutObj
);
5522 Py_XDECREF(updateTimeoutObj
);
5523 Py_XDECREF(removeTimeoutObj
);
5524 VIR_FREE(addHandleName
);
5525 VIR_FREE(updateHandleName
);
5526 VIR_FREE(removeHandleName
);
5527 VIR_FREE(addTimeoutName
);
5528 VIR_FREE(updateTimeoutName
);
5529 VIR_FREE(removeTimeoutName
);
5531 /* Parse and check arguments */
5532 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
5533 &addHandleObj
, &updateHandleObj
,
5534 &removeHandleObj
, &addTimeoutObj
,
5535 &updateTimeoutObj
, &removeTimeoutObj
) ||
5536 !PyCallable_Check(addHandleObj
) ||
5537 !PyCallable_Check(updateHandleObj
) ||
5538 !PyCallable_Check(removeHandleObj
) ||
5539 !PyCallable_Check(addTimeoutObj
) ||
5540 !PyCallable_Check(updateTimeoutObj
) ||
5541 !PyCallable_Check(removeTimeoutObj
))
5544 /* Get argument string representations (for error reporting) */
5545 addHandleName
= py_str(addHandleObj
);
5546 updateHandleName
= py_str(updateHandleObj
);
5547 removeHandleName
= py_str(removeHandleObj
);
5548 addTimeoutName
= py_str(addTimeoutObj
);
5549 updateTimeoutName
= py_str(updateTimeoutObj
);
5550 removeTimeoutName
= py_str(removeTimeoutObj
);
5552 /* Inc refs since we're holding on to these objects until
5553 * the next call (if any) to this function.
5555 Py_INCREF(addHandleObj
);
5556 Py_INCREF(updateHandleObj
);
5557 Py_INCREF(removeHandleObj
);
5558 Py_INCREF(addTimeoutObj
);
5559 Py_INCREF(updateTimeoutObj
);
5560 Py_INCREF(removeTimeoutObj
);
5562 LIBVIRT_BEGIN_ALLOW_THREADS
;
5564 /* Now register our C EventImpl, which will dispatch
5565 * to the Python callbacks passed in as args.
5567 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
5568 libvirt_virEventUpdateHandleFunc
,
5569 libvirt_virEventRemoveHandleFunc
,
5570 libvirt_virEventAddTimeoutFunc
,
5571 libvirt_virEventUpdateTimeoutFunc
,
5572 libvirt_virEventRemoveTimeoutFunc
);
5574 LIBVIRT_END_ALLOW_THREADS
;
5576 return VIR_PY_INT_SUCCESS
;
5580 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5583 int watch
, fd
, event
;
5585 PyObject
*py_opaque
;
5586 virEventHandleCallback cb
;
5589 if (!PyArg_ParseTuple(args
, (char *) "iiiOO:virEventInvokeHandleCallback",
5590 &watch
, &fd
, &event
, &py_f
, &py_opaque
))
5593 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
5594 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5597 LIBVIRT_BEGIN_ALLOW_THREADS
;
5598 cb(watch
, fd
, event
, opaque
);
5599 LIBVIRT_END_ALLOW_THREADS
;
5602 return VIR_PY_INT_SUCCESS
;
5606 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5611 PyObject
*py_opaque
;
5612 virEventTimeoutCallback cb
;
5615 if (!PyArg_ParseTuple(args
, (char *) "iOO:virEventInvokeTimeoutCallback",
5616 &timer
, &py_f
, &py_opaque
))
5619 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
5620 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5622 LIBVIRT_BEGIN_ALLOW_THREADS
;
5624 LIBVIRT_END_ALLOW_THREADS
;
5627 return VIR_PY_INT_SUCCESS
;
5631 libvirt_virEventHandleCallback(int watch
,
5636 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5637 PyObject
*pyobj_ret
;
5638 PyObject
*python_cb
;
5640 LIBVIRT_ENSURE_THREAD_STATE
;
5642 /* Lookup the python callback */
5643 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
5648 Py_INCREF(pyobj_cbData
);
5650 /* Call the pure python dispatcher */
5651 pyobj_ret
= PyObject_CallFunction(python_cb
,
5653 watch
, fd
, events
, pyobj_cbData
);
5655 Py_DECREF(pyobj_cbData
);
5658 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5661 Py_DECREF(pyobj_ret
);
5665 LIBVIRT_RELEASE_THREAD_STATE
;
5669 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
5672 PyObject
*pyobj_cbData
;
5673 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
5678 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
5679 &fd
, &events
, &pyobj_cbData
))
5682 Py_INCREF(pyobj_cbData
);
5684 LIBVIRT_BEGIN_ALLOW_THREADS
;
5685 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
5686 LIBVIRT_END_ALLOW_THREADS
;
5689 Py_DECREF(pyobj_cbData
);
5692 return libvirt_intWrap(ret
);
5696 libvirt_virEventTimeoutCallback(int timer
,
5699 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5700 PyObject
*pyobj_ret
;
5701 PyObject
*python_cb
;
5703 LIBVIRT_ENSURE_THREAD_STATE
;
5705 /* Lookup the python callback */
5706 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5711 Py_INCREF(pyobj_cbData
);
5713 /* Call the pure python dispatcher */
5714 pyobj_ret
= PyObject_CallFunction(python_cb
,
5716 timer
, pyobj_cbData
);
5718 Py_DECREF(pyobj_cbData
);
5721 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5724 Py_DECREF(pyobj_ret
);
5728 LIBVIRT_RELEASE_THREAD_STATE
;
5732 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5735 PyObject
*pyobj_cbData
;
5736 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5740 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5741 &timeout
, &pyobj_cbData
))
5744 Py_INCREF(pyobj_cbData
);
5746 LIBVIRT_BEGIN_ALLOW_THREADS
;
5747 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5748 LIBVIRT_END_ALLOW_THREADS
;
5751 Py_DECREF(pyobj_cbData
);
5754 return libvirt_intWrap(ret
);
5758 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5760 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5761 LIBVIRT_ENSURE_THREAD_STATE
;
5762 Py_DECREF(pyobj_conn
);
5763 LIBVIRT_RELEASE_THREAD_STATE
;
5767 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5773 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5774 PyObject
*pyobj_dom
;
5775 PyObject
*pyobj_ret
= NULL
;
5776 PyObject
*pyobj_conn
;
5780 LIBVIRT_ENSURE_THREAD_STATE
;
5782 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5784 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5787 /* Create a python instance of this virDomainPtr */
5789 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5793 Py_INCREF(pyobj_cbData
);
5795 /* Call the Callback Dispatcher */
5796 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5797 (char*)"_dispatchDomainEventLifecycleCallback",
5803 Py_DECREF(pyobj_cbData
);
5804 Py_DECREF(pyobj_dom
);
5808 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5811 Py_DECREF(pyobj_ret
);
5815 LIBVIRT_RELEASE_THREAD_STATE
;
5820 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5824 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5825 PyObject
*pyobj_dom
;
5826 PyObject
*pyobj_ret
= NULL
;
5827 PyObject
*pyobj_conn
;
5831 LIBVIRT_ENSURE_THREAD_STATE
;
5833 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5835 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5838 /* Create a python instance of this virDomainPtr */
5840 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5844 Py_INCREF(pyobj_cbData
);
5846 /* Call the Callback Dispatcher */
5847 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5848 (char*)"_dispatchDomainEventGenericCallback",
5850 pyobj_dom
, pyobj_cbData
);
5852 Py_DECREF(pyobj_cbData
);
5853 Py_DECREF(pyobj_dom
);
5857 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5860 Py_DECREF(pyobj_ret
);
5864 LIBVIRT_RELEASE_THREAD_STATE
;
5869 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5871 long long utcoffset
,
5874 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5875 PyObject
*pyobj_dom
;
5876 PyObject
*pyobj_ret
= NULL
;
5877 PyObject
*pyobj_conn
;
5881 LIBVIRT_ENSURE_THREAD_STATE
;
5883 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5885 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5888 /* Create a python instance of this virDomainPtr */
5890 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5894 Py_INCREF(pyobj_cbData
);
5896 /* Call the Callback Dispatcher */
5897 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5898 (char*)"_dispatchDomainEventRTCChangeCallback",
5901 (PY_LONG_LONG
)utcoffset
,
5904 Py_DECREF(pyobj_cbData
);
5905 Py_DECREF(pyobj_dom
);
5909 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5912 Py_DECREF(pyobj_ret
);
5916 LIBVIRT_RELEASE_THREAD_STATE
;
5921 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5926 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5927 PyObject
*pyobj_dom
;
5928 PyObject
*pyobj_ret
= NULL
;
5929 PyObject
*pyobj_conn
;
5933 LIBVIRT_ENSURE_THREAD_STATE
;
5935 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5937 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5940 /* Create a python instance of this virDomainPtr */
5942 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5946 Py_INCREF(pyobj_cbData
);
5948 /* Call the Callback Dispatcher */
5949 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5950 (char*)"_dispatchDomainEventWatchdogCallback",
5956 Py_DECREF(pyobj_cbData
);
5957 Py_DECREF(pyobj_dom
);
5961 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5964 Py_DECREF(pyobj_ret
);
5968 LIBVIRT_RELEASE_THREAD_STATE
;
5973 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5975 const char *srcPath
,
5976 const char *devAlias
,
5980 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5981 PyObject
*pyobj_dom
;
5982 PyObject
*pyobj_ret
= NULL
;
5983 PyObject
*pyobj_conn
;
5987 LIBVIRT_ENSURE_THREAD_STATE
;
5989 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5991 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5994 /* Create a python instance of this virDomainPtr */
5996 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6000 Py_INCREF(pyobj_cbData
);
6002 /* Call the Callback Dispatcher */
6003 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6004 (char*)"_dispatchDomainEventIOErrorCallback",
6007 srcPath
, devAlias
, action
,
6010 Py_DECREF(pyobj_cbData
);
6011 Py_DECREF(pyobj_dom
);
6015 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6018 Py_DECREF(pyobj_ret
);
6022 LIBVIRT_RELEASE_THREAD_STATE
;
6027 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6029 const char *srcPath
,
6030 const char *devAlias
,
6035 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6036 PyObject
*pyobj_dom
;
6037 PyObject
*pyobj_ret
= NULL
;
6038 PyObject
*pyobj_conn
;
6042 LIBVIRT_ENSURE_THREAD_STATE
;
6044 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6046 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6049 /* Create a python instance of this virDomainPtr */
6051 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6055 Py_INCREF(pyobj_cbData
);
6057 /* Call the Callback Dispatcher */
6058 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6059 (char*)"_dispatchDomainEventIOErrorReasonCallback",
6062 srcPath
, devAlias
, action
, reason
,
6065 Py_DECREF(pyobj_cbData
);
6066 Py_DECREF(pyobj_dom
);
6070 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6073 Py_DECREF(pyobj_ret
);
6077 LIBVIRT_RELEASE_THREAD_STATE
;
6082 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6085 virDomainEventGraphicsAddressPtr local
,
6086 virDomainEventGraphicsAddressPtr remote
,
6087 const char *authScheme
,
6088 virDomainEventGraphicsSubjectPtr subject
,
6091 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6092 PyObject
*pyobj_dom
= NULL
;
6093 PyObject
*pyobj_ret
= NULL
;
6094 PyObject
*pyobj_conn
;
6096 PyObject
*pyobj_local
= NULL
;
6097 PyObject
*pyobj_remote
= NULL
;
6098 PyObject
*pyobj_subject
= NULL
;
6102 LIBVIRT_ENSURE_THREAD_STATE
;
6104 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6106 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6109 /* Create a python instance of this virDomainPtr */
6111 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6115 Py_INCREF(pyobj_cbData
);
6117 if ((pyobj_local
= PyDict_New()) == NULL
)
6120 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6121 libvirt_constcharPtrWrap("family"),
6122 libvirt_intWrap(local
->family
),
6124 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6125 libvirt_constcharPtrWrap("node"),
6126 libvirt_constcharPtrWrap(local
->node
),
6128 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6129 libvirt_constcharPtrWrap("service"),
6130 libvirt_constcharPtrWrap(local
->service
),
6133 if ((pyobj_remote
= PyDict_New()) == NULL
)
6136 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6137 libvirt_constcharPtrWrap("family"),
6138 libvirt_intWrap(remote
->family
),
6140 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6141 libvirt_constcharPtrWrap("node"),
6142 libvirt_constcharPtrWrap(remote
->node
),
6144 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6145 libvirt_constcharPtrWrap("service"),
6146 libvirt_constcharPtrWrap(remote
->service
),
6149 if ((pyobj_subject
= PyList_New(subject
->nidentity
)) == NULL
)
6152 for (i
= 0; i
< subject
->nidentity
; i
++) {
6153 PyObject
*pair
= PyTuple_New(2);
6157 VIR_PY_LIST_SET_GOTO(pyobj_subject
, i
, pair
, cleanup
);
6159 VIR_PY_TUPLE_SET_GOTO(pair
, 0,
6160 libvirt_constcharPtrWrap(subject
->identities
[i
].type
),
6162 VIR_PY_TUPLE_SET_GOTO(pair
, 1,
6163 libvirt_constcharPtrWrap(subject
->identities
[i
].name
),
6167 /* Call the Callback Dispatcher */
6168 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6169 (char*)"_dispatchDomainEventGraphicsCallback",
6172 phase
, pyobj_local
, pyobj_remote
,
6173 authScheme
, pyobj_subject
,
6177 Py_DECREF(pyobj_cbData
);
6178 Py_XDECREF(pyobj_dom
);
6181 Py_XDECREF(pyobj_local
);
6182 Py_XDECREF(pyobj_remote
);
6183 Py_XDECREF(pyobj_subject
);
6184 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6187 Py_DECREF(pyobj_ret
);
6191 LIBVIRT_RELEASE_THREAD_STATE
;
6196 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6203 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6204 PyObject
*pyobj_dom
;
6205 PyObject
*pyobj_ret
= NULL
;
6206 PyObject
*pyobj_conn
;
6210 LIBVIRT_ENSURE_THREAD_STATE
;
6212 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6214 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6217 /* Create a python instance of this virDomainPtr */
6219 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6223 Py_INCREF(pyobj_cbData
);
6225 /* Call the Callback Dispatcher */
6226 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6227 (char*)"_dispatchDomainEventBlockJobCallback",
6229 pyobj_dom
, disk
, type
, status
, pyobj_cbData
);
6231 Py_DECREF(pyobj_cbData
);
6232 Py_DECREF(pyobj_dom
);
6236 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6239 Py_DECREF(pyobj_ret
);
6243 LIBVIRT_RELEASE_THREAD_STATE
;
6248 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6250 const char *oldSrcPath
,
6251 const char *newSrcPath
,
6252 const char *devAlias
,
6256 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6257 PyObject
*pyobj_dom
;
6258 PyObject
*pyobj_ret
= NULL
;
6259 PyObject
*pyobj_conn
;
6263 LIBVIRT_ENSURE_THREAD_STATE
;
6265 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6267 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6270 /* Create a python instance of this virDomainPtr */
6272 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6276 Py_INCREF(pyobj_cbData
);
6278 /* Call the Callback Dispatcher */
6279 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6280 (char*)"_dispatchDomainEventDiskChangeCallback",
6283 oldSrcPath
, newSrcPath
,
6284 devAlias
, reason
, pyobj_cbData
);
6286 Py_DECREF(pyobj_cbData
);
6287 Py_DECREF(pyobj_dom
);
6291 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6294 Py_DECREF(pyobj_ret
);
6298 LIBVIRT_RELEASE_THREAD_STATE
;
6303 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6305 const char *devAlias
,
6309 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6310 PyObject
*pyobj_dom
;
6311 PyObject
*pyobj_ret
= NULL
;
6312 PyObject
*pyobj_conn
;
6316 LIBVIRT_ENSURE_THREAD_STATE
;
6318 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6320 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6323 /* Create a python instance of this virDomainPtr */
6325 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6329 Py_INCREF(pyobj_cbData
);
6331 /* Call the Callback Dispatcher */
6332 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6333 (char*)"_dispatchDomainEventTrayChangeCallback",
6336 devAlias
, reason
, pyobj_cbData
);
6338 Py_DECREF(pyobj_cbData
);
6339 Py_DECREF(pyobj_dom
);
6343 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6346 Py_DECREF(pyobj_ret
);
6350 LIBVIRT_RELEASE_THREAD_STATE
;
6355 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6360 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6361 PyObject
*pyobj_dom
;
6362 PyObject
*pyobj_ret
= NULL
;
6363 PyObject
*pyobj_conn
;
6367 LIBVIRT_ENSURE_THREAD_STATE
;
6369 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6371 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6374 /* Create a python instance of this virDomainPtr */
6376 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6380 Py_INCREF(pyobj_cbData
);
6382 /* Call the Callback Dispatcher */
6383 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6384 (char*)"_dispatchDomainEventPMWakeupCallback",
6390 Py_DECREF(pyobj_cbData
);
6391 Py_DECREF(pyobj_dom
);
6395 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6398 Py_DECREF(pyobj_ret
);
6402 LIBVIRT_RELEASE_THREAD_STATE
;
6407 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6412 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6413 PyObject
*pyobj_dom
;
6414 PyObject
*pyobj_ret
= NULL
;
6415 PyObject
*pyobj_conn
;
6419 LIBVIRT_ENSURE_THREAD_STATE
;
6421 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6423 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6426 /* Create a python instance of this virDomainPtr */
6428 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6432 Py_INCREF(pyobj_cbData
);
6434 /* Call the Callback Dispatcher */
6435 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6436 (char*)"_dispatchDomainEventPMSuspendCallback",
6442 Py_DECREF(pyobj_cbData
);
6443 Py_DECREF(pyobj_dom
);
6447 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6450 Py_DECREF(pyobj_ret
);
6454 LIBVIRT_RELEASE_THREAD_STATE
;
6459 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
6461 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6463 unsigned long long actual
,
6466 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6467 PyObject
*pyobj_dom
;
6468 PyObject
*pyobj_ret
= NULL
;
6469 PyObject
*pyobj_conn
;
6473 LIBVIRT_ENSURE_THREAD_STATE
;
6475 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6477 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6480 /* Create a python instance of this virDomainPtr */
6482 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6486 Py_INCREF(pyobj_cbData
);
6488 /* Call the Callback Dispatcher */
6489 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6490 (char*)"_dispatchDomainEventBalloonChangeCallback",
6493 (PY_LONG_LONG
)actual
,
6496 Py_DECREF(pyobj_cbData
);
6497 Py_DECREF(pyobj_dom
);
6501 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6504 Py_DECREF(pyobj_ret
);
6508 LIBVIRT_RELEASE_THREAD_STATE
;
6511 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
6513 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
6515 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6520 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6521 PyObject
*pyobj_dom
;
6522 PyObject
*pyobj_ret
= NULL
;
6523 PyObject
*pyobj_conn
;
6527 LIBVIRT_ENSURE_THREAD_STATE
;
6529 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6531 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6534 /* Create a python instance of this virDomainPtr */
6536 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6540 Py_INCREF(pyobj_cbData
);
6542 /* Call the Callback Dispatcher */
6543 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6544 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
6550 Py_DECREF(pyobj_cbData
);
6551 Py_DECREF(pyobj_dom
);
6555 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6558 Py_DECREF(pyobj_ret
);
6562 LIBVIRT_RELEASE_THREAD_STATE
;
6565 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
6567 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
6569 libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6571 const char *devAlias
,
6574 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6575 PyObject
*pyobj_dom
;
6576 PyObject
*pyobj_ret
= NULL
;
6577 PyObject
*pyobj_conn
;
6581 LIBVIRT_ENSURE_THREAD_STATE
;
6583 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6585 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6588 /* Create a python instance of this virDomainPtr */
6590 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6594 Py_INCREF(pyobj_cbData
);
6596 /* Call the Callback Dispatcher */
6597 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6598 (char*)"_dispatchDomainEventDeviceRemovedCallback",
6600 pyobj_dom
, devAlias
, pyobj_cbData
);
6602 Py_DECREF(pyobj_cbData
);
6603 Py_DECREF(pyobj_dom
);
6607 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6610 Py_DECREF(pyobj_ret
);
6614 LIBVIRT_RELEASE_THREAD_STATE
;
6617 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
6619 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
6621 libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6623 virTypedParameterPtr params
,
6627 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6628 PyObject
*pyobj_dom
;
6629 PyObject
*pyobj_ret
= NULL
;
6630 PyObject
*pyobj_conn
;
6632 PyObject
*pyobj_dict
= NULL
;
6635 LIBVIRT_ENSURE_THREAD_STATE
;
6637 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
6641 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6643 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6646 /* Create a python instance of this virDomainPtr */
6648 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6652 Py_INCREF(pyobj_cbData
);
6654 /* Call the Callback Dispatcher */
6655 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6656 (char*)"_dispatchDomainEventTunableCallback",
6658 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
6660 Py_DECREF(pyobj_cbData
);
6661 Py_DECREF(pyobj_dom
);
6665 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6667 Py_XDECREF(pyobj_dict
);
6669 Py_DECREF(pyobj_ret
);
6673 LIBVIRT_RELEASE_THREAD_STATE
;
6677 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
6679 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
6681 libvirt_virConnectDomainEventAgentLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6687 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6688 PyObject
*pyobj_dom
;
6689 PyObject
*pyobj_ret
= NULL
;
6690 PyObject
*pyobj_conn
;
6694 LIBVIRT_ENSURE_THREAD_STATE
;
6696 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6698 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6701 /* Create a python instance of this virDomainPtr */
6703 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6707 Py_INCREF(pyobj_cbData
);
6709 /* Call the Callback Dispatcher */
6710 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6711 (char*)"_dispatchDomainEventAgentLifecycleCallback",
6713 pyobj_dom
, state
, reason
, pyobj_cbData
);
6715 Py_DECREF(pyobj_cbData
);
6716 Py_DECREF(pyobj_dom
);
6720 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6723 Py_DECREF(pyobj_ret
);
6727 LIBVIRT_RELEASE_THREAD_STATE
;
6731 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
6733 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
6735 libvirt_virConnectDomainEventDeviceAddedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6737 const char *devAlias
,
6740 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6741 PyObject
*pyobj_dom
;
6742 PyObject
*pyobj_ret
= NULL
;
6743 PyObject
*pyobj_conn
;
6747 LIBVIRT_ENSURE_THREAD_STATE
;
6749 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6751 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6754 /* Create a python instance of this virDomainPtr */
6756 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6760 Py_INCREF(pyobj_cbData
);
6762 /* Call the Callback Dispatcher */
6763 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6764 (char*)"_dispatchDomainEventDeviceAddedCallback",
6766 pyobj_dom
, devAlias
, pyobj_cbData
);
6768 Py_DECREF(pyobj_cbData
);
6769 Py_DECREF(pyobj_dom
);
6773 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6776 Py_DECREF(pyobj_ret
);
6780 LIBVIRT_RELEASE_THREAD_STATE
;
6784 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
6786 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
6788 libvirt_virConnectDomainEventMigrationIterationCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6793 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6794 PyObject
*pyobj_dom
;
6795 PyObject
*pyobj_ret
= NULL
;
6796 PyObject
*pyobj_conn
;
6800 LIBVIRT_ENSURE_THREAD_STATE
;
6802 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6804 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6807 /* Create a python instance of this virDomainPtr */
6809 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6813 Py_INCREF(pyobj_cbData
);
6815 /* Call the Callback Dispatcher */
6816 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6817 (char*)"_dispatchDomainEventMigrationIterationCallback",
6819 pyobj_dom
, iteration
, pyobj_cbData
);
6821 Py_DECREF(pyobj_cbData
);
6822 Py_DECREF(pyobj_dom
);
6826 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6829 Py_DECREF(pyobj_ret
);
6833 LIBVIRT_RELEASE_THREAD_STATE
;
6836 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
6838 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
6840 libvirt_virConnectDomainEventJobCompletedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6842 virTypedParameterPtr params
,
6846 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6847 PyObject
*pyobj_dom
;
6848 PyObject
*pyobj_ret
= NULL
;
6849 PyObject
*pyobj_conn
;
6851 PyObject
*pyobj_dict
= NULL
;
6854 LIBVIRT_ENSURE_THREAD_STATE
;
6856 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
6860 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6862 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6865 /* Create a python instance of this virDomainPtr */
6867 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6871 Py_INCREF(pyobj_cbData
);
6873 /* Call the Callback Dispatcher */
6874 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6875 (char*)"_dispatchDomainEventJobCompletedCallback",
6877 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
6879 Py_DECREF(pyobj_cbData
);
6880 Py_DECREF(pyobj_dom
);
6884 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6886 Py_XDECREF(pyobj_dict
);
6888 Py_DECREF(pyobj_ret
);
6892 LIBVIRT_RELEASE_THREAD_STATE
;
6895 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
6898 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
6900 libvirt_virConnectDomainEventDeviceRemovalFailedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6902 const char *devAlias
,
6905 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6906 PyObject
*pyobj_dom
;
6907 PyObject
*pyobj_ret
= NULL
;
6908 PyObject
*pyobj_conn
;
6912 LIBVIRT_ENSURE_THREAD_STATE
;
6914 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6916 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6919 /* Create a python instance of this virDomainPtr */
6921 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6925 Py_INCREF(pyobj_cbData
);
6927 /* Call the Callback Dispatcher */
6928 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6929 (char*)"_dispatchDomainEventDeviceRemovalFailedCallback",
6931 pyobj_dom
, devAlias
, pyobj_cbData
);
6933 Py_DECREF(pyobj_cbData
);
6934 Py_DECREF(pyobj_dom
);
6938 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6941 Py_DECREF(pyobj_ret
);
6945 LIBVIRT_RELEASE_THREAD_STATE
;
6949 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
6953 libvirt_virConnectDomainEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
6956 PyObject
*py_retval
; /* return value */
6957 PyObject
*pyobj_conn
; /* virConnectPtr */
6958 PyObject
*pyobj_dom
;
6959 PyObject
*pyobj_cbData
; /* hash of callback data */
6963 virConnectDomainEventGenericCallback cb
= NULL
;
6966 if (!PyArg_ParseTuple(args
,
6967 (char *) "OOiO:virConnectDomainEventRegisterAny",
6968 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
))
6971 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
6972 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
6973 conn
= PyvirConnect_Get(pyobj_conn
);
6974 if (pyobj_dom
== Py_None
)
6977 dom
= PyvirDomain_Get(pyobj_dom
);
6979 switch ((virDomainEventID
) eventID
) {
6980 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
6981 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
6983 case VIR_DOMAIN_EVENT_ID_REBOOT
:
6984 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
6986 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
6987 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
6989 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
6990 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
6992 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
6993 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
6995 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
6996 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
6998 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
6999 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
7001 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
7002 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
7004 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
7005 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
7006 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
:
7007 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 */
7008 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
7010 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
7011 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
7013 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
7014 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
7016 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
7017 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
7019 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
7020 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
7022 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
7023 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
7024 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
7026 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
7027 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
7028 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
7029 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
7031 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
7032 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
7033 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
:
7034 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback
);
7036 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
7037 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
7038 case VIR_DOMAIN_EVENT_ID_TUNABLE
:
7039 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTunableCallback
);
7041 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
7042 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
7043 case VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
:
7044 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventAgentLifecycleCallback
);
7046 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
7047 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
7048 case VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
:
7049 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceAddedCallback
);
7051 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
7052 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
7053 case VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
:
7054 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMigrationIterationCallback
);
7056 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
7057 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
7058 case VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
:
7059 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventJobCompletedCallback
);
7061 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
7062 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
7063 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
:
7064 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovalFailedCallback
);
7066 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
7067 case VIR_DOMAIN_EVENT_ID_LAST
:
7072 return VIR_PY_INT_FAIL
;
7075 Py_INCREF(pyobj_cbData
);
7077 LIBVIRT_BEGIN_ALLOW_THREADS
;
7078 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
7080 libvirt_virConnectDomainEventFreeFunc
);
7081 LIBVIRT_END_ALLOW_THREADS
;
7084 Py_DECREF(pyobj_cbData
);
7087 py_retval
= libvirt_intWrap(ret
);
7092 libvirt_virConnectDomainEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7095 PyObject
*pyobj_conn
;
7100 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectDomainEventDeregister",
7101 &pyobj_conn
, &callbackID
))
7104 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
7106 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7108 LIBVIRT_BEGIN_ALLOW_THREADS
;
7110 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
7112 LIBVIRT_END_ALLOW_THREADS
;
7114 return libvirt_intWrap(ret
);
7117 #if LIBVIR_CHECK_VERSION(1, 2, 1)
7119 libvirt_virConnectNetworkEventFreeFunc(void *opaque
)
7121 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
7122 LIBVIRT_ENSURE_THREAD_STATE
;
7123 Py_DECREF(pyobj_conn
);
7124 LIBVIRT_RELEASE_THREAD_STATE
;
7128 libvirt_virConnectNetworkEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7134 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7135 PyObject
*pyobj_net
;
7136 PyObject
*pyobj_ret
= NULL
;
7137 PyObject
*pyobj_conn
;
7141 LIBVIRT_ENSURE_THREAD_STATE
;
7143 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7145 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7148 /* Create a python instance of this virNetworkPtr */
7150 if (!(pyobj_net
= libvirt_virNetworkPtrWrap(net
))) {
7151 virNetworkFree(net
);
7154 Py_INCREF(pyobj_cbData
);
7156 /* Call the Callback Dispatcher */
7157 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7158 (char*)"_dispatchNetworkEventLifecycleCallback",
7165 Py_DECREF(pyobj_cbData
);
7166 Py_DECREF(pyobj_net
);
7170 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7173 Py_DECREF(pyobj_ret
);
7177 LIBVIRT_RELEASE_THREAD_STATE
;
7182 libvirt_virConnectNetworkEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7185 PyObject
*pyobj_conn
; /* virConnectPtr */
7186 PyObject
*pyobj_net
;
7187 PyObject
*pyobj_cbData
; /* hash of callback data */
7191 virConnectNetworkEventGenericCallback cb
= NULL
;
7194 if (!PyArg_ParseTuple(args
,
7195 (char *) "OOiO:virConnectNetworkEventRegisterAny",
7196 &pyobj_conn
, &pyobj_net
, &eventID
, &pyobj_cbData
))
7199 DEBUG("libvirt_virConnectNetworkEventRegister(%p %p %d %p) called\n",
7200 pyobj_conn
, pyobj_net
, eventID
, pyobj_cbData
);
7201 conn
= PyvirConnect_Get(pyobj_conn
);
7202 if (pyobj_net
== Py_None
)
7205 net
= PyvirNetwork_Get(pyobj_net
);
7207 switch ((virNetworkEventID
) eventID
) {
7208 case VIR_NETWORK_EVENT_ID_LIFECYCLE
:
7209 cb
= VIR_NETWORK_EVENT_CALLBACK(libvirt_virConnectNetworkEventLifecycleCallback
);
7212 case VIR_NETWORK_EVENT_ID_LAST
:
7217 return VIR_PY_INT_FAIL
;
7220 Py_INCREF(pyobj_cbData
);
7222 LIBVIRT_BEGIN_ALLOW_THREADS
;
7223 ret
= virConnectNetworkEventRegisterAny(conn
, net
, eventID
,
7225 libvirt_virConnectNetworkEventFreeFunc
);
7226 LIBVIRT_END_ALLOW_THREADS
;
7229 Py_DECREF(pyobj_cbData
);
7232 return libvirt_intWrap(ret
);
7236 libvirt_virConnectNetworkEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7239 PyObject
*pyobj_conn
;
7244 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNetworkEventDeregister",
7245 &pyobj_conn
, &callbackID
))
7248 DEBUG("libvirt_virConnectNetworkEventDeregister(%p) called\n", pyobj_conn
);
7250 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7252 LIBVIRT_BEGIN_ALLOW_THREADS
;
7254 ret
= virConnectNetworkEventDeregisterAny(conn
, callbackID
);
7256 LIBVIRT_END_ALLOW_THREADS
;
7258 return libvirt_intWrap(ret
);
7260 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1)*/
7262 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7264 libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED
,
7268 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7269 PyObject
*pyobj_ret
;
7270 PyObject
*pyobj_conn
;
7273 LIBVIRT_ENSURE_THREAD_STATE
;
7275 Py_INCREF(pyobj_cbData
);
7277 dictKey
= libvirt_constcharPtrWrap("conn");
7278 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7281 /* Call the Callback Dispatcher */
7282 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7283 (char*)"_dispatchCloseCallback",
7288 Py_DECREF(pyobj_cbData
);
7291 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7294 Py_DECREF(pyobj_ret
);
7297 LIBVIRT_RELEASE_THREAD_STATE
;
7301 libvirt_virConnectRegisterCloseCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7304 PyObject
*pyobj_conn
; /* virConnectPtr */
7305 PyObject
*pyobj_cbData
; /* hash of callback data */
7309 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectRegisterCloseCallback",
7310 &pyobj_conn
, &pyobj_cbData
))
7313 DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
7314 pyobj_conn
, pyobj_cbData
);
7315 conn
= PyvirConnect_Get(pyobj_conn
);
7317 Py_INCREF(pyobj_cbData
);
7319 LIBVIRT_BEGIN_ALLOW_THREADS
;
7320 ret
= virConnectRegisterCloseCallback(conn
,
7321 libvirt_virConnectCloseCallbackDispatch
,
7323 libvirt_virConnectDomainEventFreeFunc
);
7324 LIBVIRT_END_ALLOW_THREADS
;
7327 Py_DECREF(pyobj_cbData
);
7330 return libvirt_intWrap(ret
);
7334 libvirt_virConnectUnregisterCloseCallback(PyObject
* self ATTRIBUTE_UNUSED
,
7337 PyObject
*pyobj_conn
;
7341 if (!PyArg_ParseTuple(args
, (char *) "O:virConnectUnregisterCloseCallback",
7345 DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
7348 conn
= PyvirConnect_Get(pyobj_conn
);
7350 LIBVIRT_BEGIN_ALLOW_THREADS
;
7352 ret
= virConnectUnregisterCloseCallback(conn
,
7353 libvirt_virConnectCloseCallbackDispatch
);
7355 LIBVIRT_END_ALLOW_THREADS
;
7357 return libvirt_intWrap(ret
);
7359 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7362 libvirt_virStreamEventFreeFunc(void *opaque
)
7364 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
7365 LIBVIRT_ENSURE_THREAD_STATE
;
7366 Py_DECREF(pyobj_stream
);
7367 LIBVIRT_RELEASE_THREAD_STATE
;
7371 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
7375 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7376 PyObject
*pyobj_stream
;
7377 PyObject
*pyobj_ret
;
7380 LIBVIRT_ENSURE_THREAD_STATE
;
7382 Py_INCREF(pyobj_cbData
);
7383 dictKey
= libvirt_constcharPtrWrap("stream");
7384 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7387 /* Call the pure python dispatcher */
7388 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
7389 (char *)"_dispatchStreamEventCallback",
7391 events
, pyobj_cbData
);
7393 Py_DECREF(pyobj_cbData
);
7396 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7399 Py_DECREF(pyobj_ret
);
7402 LIBVIRT_RELEASE_THREAD_STATE
;
7406 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7409 PyObject
*pyobj_stream
;
7410 PyObject
*pyobj_cbData
;
7411 virStreamPtr stream
;
7412 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
7416 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
7417 &pyobj_stream
, &events
, &pyobj_cbData
))
7420 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
7421 pyobj_stream
, events
, pyobj_cbData
);
7422 stream
= PyvirStream_Get(pyobj_stream
);
7424 Py_INCREF(pyobj_cbData
);
7426 LIBVIRT_BEGIN_ALLOW_THREADS
;
7427 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
7428 libvirt_virStreamEventFreeFunc
);
7429 LIBVIRT_END_ALLOW_THREADS
;
7432 Py_DECREF(pyobj_cbData
);
7435 return libvirt_intWrap(ret
);
7439 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
7442 PyObject
*pyobj_stream
;
7444 virStreamPtr stream
;
7449 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
7450 &pyobj_stream
, &nbytes
)) {
7453 stream
= PyvirStream_Get(pyobj_stream
);
7455 if (VIR_ALLOC_N(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
7456 return PyErr_NoMemory();
7458 LIBVIRT_BEGIN_ALLOW_THREADS
;
7459 ret
= virStreamRecv(stream
, buf
, nbytes
);
7460 LIBVIRT_END_ALLOW_THREADS
;
7462 buf
[ret
> -1 ? ret
: 0] = '\0';
7463 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
7466 return libvirt_intWrap(ret
);
7469 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
7475 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
7478 PyObject
*pyobj_stream
;
7479 PyObject
*pyobj_data
;
7480 virStreamPtr stream
;
7485 if (!PyArg_ParseTuple(args
, (char *) "OO:virStreamSend",
7486 &pyobj_stream
, &pyobj_data
))
7489 stream
= PyvirStream_Get(pyobj_stream
);
7490 libvirt_charPtrSizeUnwrap(pyobj_data
, &data
, &datalen
);
7492 LIBVIRT_BEGIN_ALLOW_THREADS
;
7493 ret
= virStreamSend(stream
, data
, datalen
);
7494 LIBVIRT_END_ALLOW_THREADS
;
7496 DEBUG("StreamSend ret=%d\n", ret
);
7498 return libvirt_intWrap(ret
);
7502 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
7505 virDomainPtr domain
;
7506 PyObject
*pyobj_domain
;
7507 PyObject
*pyobj_list
;
7513 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
7514 unsigned int nkeycodes
;
7516 if (!PyArg_ParseTuple(args
, (char *)"OiiOII:virDomainSendKey",
7517 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
7518 &nkeycodes
, &flags
))
7521 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7523 if (!PyList_Check(pyobj_list
)) {
7524 return VIR_PY_INT_FAIL
;
7527 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
7528 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
7529 return VIR_PY_INT_FAIL
;
7532 for (i
= 0; i
< nkeycodes
; i
++) {
7533 if (libvirt_uintUnwrap(PyList_GetItem(pyobj_list
, i
), &keycodes
[i
]) < 0)
7537 LIBVIRT_BEGIN_ALLOW_THREADS
;
7538 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
7539 LIBVIRT_END_ALLOW_THREADS
;
7541 DEBUG("virDomainSendKey ret=%d\n", ret
);
7543 return libvirt_intWrap(ret
);
7546 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7548 libvirt_virDomainMigrateGetCompressionCache(PyObject
*self ATTRIBUTE_UNUSED
,
7551 PyObject
*pyobj_domain
;
7552 virDomainPtr domain
;
7554 unsigned long long cacheSize
;
7557 if (!PyArg_ParseTuple(args
,
7558 (char *) "OI:virDomainMigrateGetCompressionCache",
7559 &pyobj_domain
, &flags
))
7562 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7564 LIBVIRT_BEGIN_ALLOW_THREADS
;
7565 rc
= virDomainMigrateGetCompressionCache(domain
, &cacheSize
, flags
);
7566 LIBVIRT_END_ALLOW_THREADS
;
7571 return libvirt_ulonglongWrap(cacheSize
);
7573 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7576 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
,
7580 unsigned long bandwidth
;
7581 virDomainPtr domain
;
7582 PyObject
*pyobj_domain
;
7583 unsigned int flags
= 0;
7585 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainMigrateGetMaxSpeed",
7586 &pyobj_domain
, &flags
))
7589 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7591 LIBVIRT_BEGIN_ALLOW_THREADS
;
7592 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
7593 LIBVIRT_END_ALLOW_THREADS
;
7596 return VIR_PY_INT_FAIL
;
7598 return libvirt_ulongWrap(bandwidth
);
7601 #if LIBVIR_CHECK_VERSION(1, 1, 0)
7603 libvirt_virDomainMigrate3(PyObject
*self ATTRIBUTE_UNUSED
,
7606 PyObject
*pyobj_domain
;
7607 virDomainPtr domain
;
7608 PyObject
*pyobj_dconn
;
7609 virConnectPtr dconn
;
7612 virTypedParameterPtr params
;
7614 virDomainPtr ddom
= NULL
;
7616 if (!PyArg_ParseTuple(args
, (char *) "OOOI:virDomainMigrate3",
7617 &pyobj_domain
, &pyobj_dconn
, &dict
, &flags
))
7620 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7621 dconn
= (virConnectPtr
) PyvirConnect_Get(pyobj_dconn
);
7623 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
7626 LIBVIRT_BEGIN_ALLOW_THREADS
;
7627 ddom
= virDomainMigrate3(domain
, dconn
, params
, nparams
, flags
);
7628 LIBVIRT_END_ALLOW_THREADS
;
7630 virTypedParamsFree(params
, nparams
);
7631 return libvirt_virDomainPtrWrap(ddom
);
7635 libvirt_virDomainMigrateToURI3(PyObject
*self ATTRIBUTE_UNUSED
,
7638 PyObject
*pyobj_domain
;
7639 virDomainPtr domain
;
7643 virTypedParameterPtr params
;
7647 if (!PyArg_ParseTuple(args
, (char *) "OzOI:virDomainMigrate3",
7648 &pyobj_domain
, &dconnuri
, &dict
, &flags
))
7651 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7653 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
7656 LIBVIRT_BEGIN_ALLOW_THREADS
;
7657 ret
= virDomainMigrateToURI3(domain
, dconnuri
, params
, nparams
, flags
);
7658 LIBVIRT_END_ALLOW_THREADS
;
7660 virTypedParamsFree(params
, nparams
);
7661 return libvirt_intWrap(ret
);
7663 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
7666 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
7669 PyObject
*py_retval
= NULL
;
7671 virDomainPtr domain
;
7672 PyObject
*pyobj_domain
;
7674 unsigned long long offset
;
7679 if (!PyArg_ParseTuple(args
, (char *)"OzKkI:virDomainBlockPeek",
7680 &pyobj_domain
, &disk
, &offset
, &size
, &flags
))
7683 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7685 if (VIR_ALLOC_N(buf
, size
) < 0)
7686 return PyErr_NoMemory();
7688 LIBVIRT_BEGIN_ALLOW_THREADS
;
7689 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
7690 LIBVIRT_END_ALLOW_THREADS
;
7693 py_retval
= VIR_PY_NONE
;
7697 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
7705 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
7708 PyObject
*py_retval
= NULL
;
7710 virDomainPtr domain
;
7711 PyObject
*pyobj_domain
;
7712 unsigned long long start
;
7717 if (!PyArg_ParseTuple(args
, (char *)"OKkI:virDomainMemoryPeek",
7718 &pyobj_domain
, &start
, &size
, &flags
))
7721 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7723 if (VIR_ALLOC_N(buf
, size
) < 0)
7724 return PyErr_NoMemory();
7726 LIBVIRT_BEGIN_ALLOW_THREADS
;
7727 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
7728 LIBVIRT_END_ALLOW_THREADS
;
7731 py_retval
= VIR_PY_NONE
;
7735 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
7742 #if LIBVIR_CHECK_VERSION(0, 10, 2)
7744 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
7748 PyObject
*pyobj_conn
, *info
;
7749 PyObject
*ret
= NULL
;
7752 Py_ssize_t size
= 0;
7754 virTypedParameterPtr params
, new_params
= NULL
;
7756 if (!PyArg_ParseTuple(args
,
7757 (char *)"OOI:virNodeSetMemoryParameters",
7758 &pyobj_conn
, &info
, &flags
))
7760 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7762 if ((size
= PyDict_Size(info
)) < 0)
7766 PyErr_Format(PyExc_LookupError
,
7767 "Need non-empty dictionary to set attributes");
7771 LIBVIRT_BEGIN_ALLOW_THREADS
;
7772 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
7773 LIBVIRT_END_ALLOW_THREADS
;
7776 return VIR_PY_INT_FAIL
;
7779 PyErr_Format(PyExc_LookupError
,
7780 "no settable attributes");
7784 if (VIR_ALLOC_N(params
, nparams
) < 0)
7785 return PyErr_NoMemory();
7787 LIBVIRT_BEGIN_ALLOW_THREADS
;
7788 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
7789 LIBVIRT_END_ALLOW_THREADS
;
7792 ret
= VIR_PY_INT_FAIL
;
7796 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
7800 LIBVIRT_BEGIN_ALLOW_THREADS
;
7801 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
7802 LIBVIRT_END_ALLOW_THREADS
;
7805 ret
= VIR_PY_INT_FAIL
;
7809 ret
= VIR_PY_INT_SUCCESS
;
7812 virTypedParamsFree(params
, nparams
);
7813 virTypedParamsFree(new_params
, nparams
);
7818 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
7822 PyObject
*pyobj_conn
;
7823 PyObject
*ret
= NULL
;
7827 virTypedParameterPtr params
;
7829 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetMemoryParameters",
7830 &pyobj_conn
, &flags
))
7832 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7834 LIBVIRT_BEGIN_ALLOW_THREADS
;
7835 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
7836 LIBVIRT_END_ALLOW_THREADS
;
7842 return PyDict_New();
7844 if (VIR_ALLOC_N(params
, nparams
) < 0)
7845 return PyErr_NoMemory();
7847 LIBVIRT_BEGIN_ALLOW_THREADS
;
7848 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
7849 LIBVIRT_END_ALLOW_THREADS
;
7856 ret
= getPyVirTypedParameter(params
, nparams
);
7859 virTypedParamsFree(params
, nparams
);
7862 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
7864 #if LIBVIR_CHECK_VERSION(1, 0, 0)
7866 libvirt_virNodeGetCPUMap(PyObject
*self ATTRIBUTE_UNUSED
,
7870 PyObject
*pyobj_conn
;
7871 PyObject
*ret
= NULL
;
7872 PyObject
*pycpumap
= NULL
;
7874 unsigned char *cpumap
= NULL
;
7875 unsigned int online
= 0;
7879 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetCPUMap",
7880 &pyobj_conn
, &flags
))
7882 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7884 LIBVIRT_BEGIN_ALLOW_THREADS
;
7885 i_retval
= virNodeGetCPUMap(conn
, &cpumap
, &online
, flags
);
7886 LIBVIRT_END_ALLOW_THREADS
;
7891 if ((ret
= PyTuple_New(3)) == NULL
)
7894 /* 0: number of CPUs */
7895 VIR_PY_TUPLE_SET_GOTO(ret
, 0, libvirt_intWrap(i_retval
), error
);
7898 if ((pycpumap
= PyList_New(i_retval
)) == NULL
)
7901 VIR_PY_TUPLE_SET_GOTO(ret
, 1, pycpumap
, error
);
7903 for (i
= 0; i
< i_retval
; i
++)
7904 VIR_PY_LIST_SET_GOTO(pycpumap
, i
,
7905 PyBool_FromLong(VIR_CPU_USED(cpumap
, i
)), error
);
7907 /* 2: number of online CPUs */
7908 VIR_PY_TUPLE_SET_GOTO(ret
, 2, libvirt_uintWrap(online
), error
);
7918 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
7921 #if LIBVIR_CHECK_VERSION(1, 1, 1)
7923 libvirt_virDomainCreateWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
7926 PyObject
*py_retval
= NULL
;
7928 virDomainPtr domain
;
7929 PyObject
*pyobj_domain
;
7930 PyObject
*pyobj_files
;
7932 unsigned int nfiles
;
7936 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainCreateWithFiles",
7937 &pyobj_domain
, &pyobj_files
, &flags
))
7939 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7941 nfiles
= PyList_Size(pyobj_files
);
7943 if (VIR_ALLOC_N(files
, nfiles
) < 0)
7944 return PyErr_NoMemory();
7946 for (i
= 0; i
< nfiles
; i
++) {
7950 pyfd
= PyList_GetItem(pyobj_files
, i
);
7952 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
7958 LIBVIRT_BEGIN_ALLOW_THREADS
;
7959 c_retval
= virDomainCreateWithFiles(domain
, nfiles
, files
, flags
);
7960 LIBVIRT_END_ALLOW_THREADS
;
7961 py_retval
= libvirt_intWrap((int) c_retval
);
7970 libvirt_virDomainCreateXMLWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
7973 PyObject
*py_retval
= NULL
;
7974 virDomainPtr c_retval
;
7976 PyObject
*pyobj_conn
;
7978 PyObject
*pyobj_files
;
7980 unsigned int nfiles
;
7984 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainCreateXMLWithFiles",
7985 &pyobj_conn
, &xmlDesc
, &pyobj_files
, &flags
))
7987 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7989 nfiles
= PyList_Size(pyobj_files
);
7991 if (VIR_ALLOC_N(files
, nfiles
) < 0)
7992 return PyErr_NoMemory();
7994 for (i
= 0; i
< nfiles
; i
++) {
7998 pyfd
= PyList_GetItem(pyobj_files
, i
);
8000 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
8006 LIBVIRT_BEGIN_ALLOW_THREADS
;
8007 c_retval
= virDomainCreateXMLWithFiles(conn
, xmlDesc
, nfiles
, files
, flags
);
8008 LIBVIRT_END_ALLOW_THREADS
;
8009 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
8015 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
8018 #if LIBVIR_CHECK_VERSION(1, 2, 5)
8020 libvirt_virDomainFSFreeze(PyObject
*self ATTRIBUTE_UNUSED
,
8023 PyObject
*py_retval
= NULL
;
8025 virDomainPtr domain
;
8026 PyObject
*pyobj_domain
;
8027 PyObject
*pyobj_list
;
8029 unsigned int nmountpoints
= 0;
8030 char **mountpoints
= NULL
;
8033 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSFreeze",
8034 &pyobj_domain
, &pyobj_list
, &flags
))
8036 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8038 if (PyList_Check(pyobj_list
)) {
8039 nmountpoints
= PyList_Size(pyobj_list
);
8041 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8042 return PyErr_NoMemory();
8044 for (i
= 0; i
< nmountpoints
; i
++) {
8045 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8046 mountpoints
+i
) < 0 ||
8047 mountpoints
[i
] == NULL
)
8052 LIBVIRT_BEGIN_ALLOW_THREADS
;
8053 c_retval
= virDomainFSFreeze(domain
, (const char **) mountpoints
,
8054 nmountpoints
, flags
);
8055 LIBVIRT_END_ALLOW_THREADS
;
8057 py_retval
= libvirt_intWrap(c_retval
);
8060 for (j
= 0 ; j
< i
; j
++)
8061 VIR_FREE(mountpoints
[j
]);
8062 VIR_FREE(mountpoints
);
8068 libvirt_virDomainFSThaw(PyObject
*self ATTRIBUTE_UNUSED
,
8071 PyObject
*py_retval
= NULL
;
8073 virDomainPtr domain
;
8074 PyObject
*pyobj_domain
;
8075 PyObject
*pyobj_list
;
8077 unsigned int nmountpoints
= 0;
8078 char **mountpoints
= NULL
;
8081 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSThaw",
8082 &pyobj_domain
, &pyobj_list
, &flags
))
8084 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8086 if (PyList_Check(pyobj_list
)) {
8087 nmountpoints
= PyList_Size(pyobj_list
);
8089 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8090 return PyErr_NoMemory();
8092 for (i
= 0; i
< nmountpoints
; i
++) {
8093 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8094 mountpoints
+i
) < 0 ||
8095 mountpoints
[i
] == NULL
)
8100 LIBVIRT_BEGIN_ALLOW_THREADS
;
8101 c_retval
= virDomainFSThaw(domain
, (const char **) mountpoints
,
8102 nmountpoints
, flags
);
8103 LIBVIRT_END_ALLOW_THREADS
;
8105 py_retval
= libvirt_intWrap(c_retval
);
8108 for (j
= 0 ; j
< i
; j
++)
8109 VIR_FREE(mountpoints
[j
]);
8110 VIR_FREE(mountpoints
);
8115 libvirt_virDomainGetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8118 PyObject
*py_retval
= NULL
;
8119 PyObject
*dict
= NULL
;
8120 PyObject
*pyobj_domain
;
8121 virDomainPtr domain
;
8123 unsigned int nseconds
;
8127 if (!PyArg_ParseTuple(args
, (char*)"OI:virDomainGetTime",
8128 &pyobj_domain
, &flags
))
8130 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8132 if (!(dict
= PyDict_New()))
8135 LIBVIRT_BEGIN_ALLOW_THREADS
;
8136 c_retval
= virDomainGetTime(domain
, &seconds
, &nseconds
, flags
);
8137 LIBVIRT_END_ALLOW_THREADS
;
8140 py_retval
= VIR_PY_NONE
;
8144 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("seconds"),
8145 libvirt_longlongWrap(seconds
), cleanup
);
8146 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("nseconds"),
8147 libvirt_longlongWrap(nseconds
), cleanup
);
8158 libvirt_virDomainSetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8161 PyObject
*pyobj_domain
;
8162 PyObject
*pyobj_seconds
;
8163 PyObject
*pyobj_nseconds
;
8165 virDomainPtr domain
;
8166 long long seconds
= 0;
8167 unsigned int nseconds
= 0;
8169 ssize_t py_dict_size
= 0;
8172 if (!PyArg_ParseTuple(args
, (char*)"OOI:virDomainSetTime",
8173 &pyobj_domain
, &py_dict
, &flags
))
8175 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8177 if (PyDict_Check(py_dict
)) {
8178 py_dict_size
= PyDict_Size(py_dict
);
8179 if ((pyobj_seconds
= PyDict_GetItemString(py_dict
, "seconds"))) {
8180 if (libvirt_longlongUnwrap(pyobj_seconds
, &seconds
) < 0)
8183 PyErr_Format(PyExc_LookupError
, "Dictionary must contains 'seconds'");
8187 if ((pyobj_nseconds
= PyDict_GetItemString(py_dict
, "nseconds"))) {
8188 if (libvirt_uintUnwrap(pyobj_nseconds
, &nseconds
) < 0)
8190 } else if (py_dict_size
> 1) {
8191 PyErr_Format(PyExc_LookupError
, "Dictionary contains unknown key");
8194 } else if (py_dict
!= Py_None
|| !flags
) {
8195 PyErr_Format(PyExc_TypeError
, "time must be a dictionary "
8196 "or None with flags set");
8200 LIBVIRT_BEGIN_ALLOW_THREADS
;
8201 c_retval
= virDomainSetTime(domain
, seconds
, nseconds
, flags
);
8202 LIBVIRT_END_ALLOW_THREADS
;
8204 return libvirt_intWrap(c_retval
);
8206 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
8209 #if LIBVIR_CHECK_VERSION(1, 2, 6)
8211 libvirt_virNodeGetFreePages(PyObject
*self ATTRIBUTE_UNUSED
,
8214 PyObject
*py_retval
= NULL
;
8215 PyObject
*pyobj_conn
;
8216 PyObject
*pyobj_pagesize
;
8217 PyObject
*pyobj_counts
= NULL
;
8219 unsigned int *pages
= NULL
;
8221 unsigned int cellCount
;
8223 unsigned long long *counts
= NULL
;
8225 ssize_t pyobj_pagesize_size
, i
, j
;
8227 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeGetFreePages",
8228 &pyobj_conn
, &pyobj_pagesize
, &startCell
,
8229 &cellCount
, &flags
))
8232 if (!PyList_Check(pyobj_pagesize
)) {
8233 PyErr_Format(PyExc_TypeError
, "pagesize must be list");
8237 if (cellCount
== 0) {
8238 PyErr_Format(PyExc_LookupError
, "cellCount must not be zero");
8242 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8244 pyobj_pagesize_size
= PyList_Size(pyobj_pagesize
);
8245 if (VIR_ALLOC_N(pages
, pyobj_pagesize_size
) < 0 ||
8246 VIR_ALLOC_N(counts
, pyobj_pagesize_size
* cellCount
) < 0) {
8251 if (!(pyobj_counts
= PyDict_New()))
8254 for (i
= 0; i
< pyobj_pagesize_size
; i
++) {
8255 PyObject
*tmp
= PyList_GetItem(pyobj_pagesize
, i
);
8257 if (libvirt_uintUnwrap(tmp
, &pages
[i
]) < 0)
8261 LIBVIRT_BEGIN_ALLOW_THREADS
;
8262 c_retval
= virNodeGetFreePages(conn
,
8263 pyobj_pagesize_size
, pages
,
8264 startCell
, cellCount
,
8266 LIBVIRT_END_ALLOW_THREADS
;
8269 py_retval
= VIR_PY_NONE
;
8273 for (i
= 0; i
< c_retval
;) {
8274 PyObject
*per_node
= NULL
;
8276 if (!(per_node
= PyDict_New()))
8279 VIR_PY_DICT_SET_GOTO(pyobj_counts
,
8280 libvirt_intWrap(startCell
+ i
/pyobj_pagesize_size
),
8283 for (j
= 0; j
< pyobj_pagesize_size
; j
++)
8284 VIR_PY_DICT_SET_GOTO(per_node
, libvirt_intWrap(pages
[j
]),
8285 libvirt_intWrap(counts
[i
+ j
]), cleanup
);
8287 i
+= pyobj_pagesize_size
;
8290 py_retval
= pyobj_counts
;
8291 pyobj_counts
= NULL
;
8293 Py_XDECREF(pyobj_counts
);
8301 libvirt_virNetworkGetDHCPLeases(PyObject
*self ATTRIBUTE_UNUSED
,
8304 PyObject
*py_retval
= NULL
;
8305 PyObject
*py_lease
= NULL
;
8306 virNetworkPtr network
;
8307 PyObject
*pyobj_network
;
8309 virNetworkDHCPLeasePtr
*leases
= NULL
;
8314 if (!PyArg_ParseTuple(args
, (char *) "OzI:virNetworkGetDHCPLeases",
8315 &pyobj_network
, &mac
, &flags
))
8318 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
8320 LIBVIRT_BEGIN_ALLOW_THREADS
;
8321 leases_count
= virNetworkGetDHCPLeases(network
, mac
, &leases
, flags
);
8322 LIBVIRT_END_ALLOW_THREADS
;
8324 if (leases_count
< 0) {
8325 py_retval
= VIR_PY_NONE
;
8329 if (!(py_retval
= PyList_New(leases_count
)))
8332 for (i
= 0; i
< leases_count
; i
++) {
8333 virNetworkDHCPLeasePtr lease
= leases
[i
];
8335 if ((py_lease
= PyDict_New()) == NULL
)
8338 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_lease
, error
);
8340 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iface"),
8341 libvirt_charPtrWrap(lease
->iface
), error
);
8342 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("expirytime"),
8343 libvirt_longlongWrap(lease
->expirytime
), error
);
8344 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("type"),
8345 libvirt_intWrap(lease
->type
), error
);
8346 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("mac"),
8347 libvirt_charPtrWrap(lease
->mac
), error
);
8348 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("ipaddr"),
8349 libvirt_charPtrWrap(lease
->ipaddr
), error
);
8350 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("prefix"),
8351 libvirt_uintWrap(lease
->prefix
), error
);
8352 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("hostname"),
8353 libvirt_charPtrWrap(lease
->hostname
), error
);
8354 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("clientid"),
8355 libvirt_charPtrWrap(lease
->clientid
), error
);
8356 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iaid"),
8357 libvirt_charPtrWrap(lease
->iaid
), error
);
8361 if (leases_count
> 0)
8362 for (i
= 0; i
< leases_count
; i
++)
8363 virNetworkDHCPLeaseFree(leases
[i
]);
8369 Py_CLEAR(py_retval
);
8373 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
8375 #if LIBVIR_CHECK_VERSION(1, 2, 8)
8378 convertDomainStatsRecord(virDomainStatsRecordPtr
*records
,
8381 PyObject
*py_retval
;
8382 PyObject
*py_record
;
8383 PyObject
*py_record_stats
= NULL
;
8384 virDomainPtr dom
= NULL
;
8387 if (!(py_retval
= PyList_New(nrecords
)))
8390 for (i
= 0; i
< nrecords
; i
++) {
8391 if (!(py_record
= PyTuple_New(2)))
8394 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_record
, error
);
8396 dom
= records
[i
]->dom
;
8398 VIR_PY_TUPLE_SET_GOTO(py_record
, 0,
8399 libvirt_virDomainPtrWrap(dom
),
8403 if (!(py_record_stats
= getPyVirTypedParameter(records
[i
]->params
,
8404 records
[i
]->nparams
)))
8406 VIR_PY_TUPLE_SET_GOTO(py_record
, 1, py_record_stats
, error
);
8415 Py_XDECREF(py_retval
);
8421 libvirt_virConnectGetAllDomainStats(PyObject
*self ATTRIBUTE_UNUSED
,
8424 PyObject
*pyobj_conn
;
8425 PyObject
*py_retval
;
8427 virDomainStatsRecordPtr
*records
;
8432 if (!PyArg_ParseTuple(args
, (char *)"OII:virConnectGetAllDomainStats",
8433 &pyobj_conn
, &stats
, &flags
))
8435 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8437 LIBVIRT_BEGIN_ALLOW_THREADS
;
8438 nrecords
= virConnectGetAllDomainStats(conn
, stats
, &records
, flags
);
8439 LIBVIRT_END_ALLOW_THREADS
;
8444 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8446 virDomainStatsRecordListFree(records
);
8453 libvirt_virDomainListGetStats(PyObject
*self ATTRIBUTE_UNUSED
,
8456 PyObject
*pyobj_conn
;
8457 PyObject
*py_retval
;
8458 PyObject
*py_domlist
;
8459 virDomainStatsRecordPtr
*records
= NULL
;
8460 virDomainPtr
*doms
= NULL
;
8467 if (!PyArg_ParseTuple(args
, (char *)"OOII:virDomainListGetStats",
8468 &pyobj_conn
, &py_domlist
, &stats
, &flags
))
8471 if (PyList_Check(py_domlist
)) {
8472 ndoms
= PyList_Size(py_domlist
);
8474 if (VIR_ALLOC_N(doms
, ndoms
+ 1) < 0)
8475 return PyErr_NoMemory();
8477 for (i
= 0; i
< ndoms
; i
++)
8478 doms
[i
] = PyvirDomain_Get(PyList_GetItem(py_domlist
, i
));
8481 LIBVIRT_BEGIN_ALLOW_THREADS
;
8482 nrecords
= virDomainListGetStats(doms
, stats
, &records
, flags
);
8483 LIBVIRT_END_ALLOW_THREADS
;
8486 py_retval
= VIR_PY_NONE
;
8490 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8493 virDomainStatsRecordListFree(records
);
8501 libvirt_virDomainBlockCopy(PyObject
*self ATTRIBUTE_UNUSED
,
8504 PyObject
*pyobj_dom
= NULL
;
8505 PyObject
*pyobj_dict
= NULL
;
8509 char *destxml
= NULL
;
8510 virTypedParameterPtr params
= NULL
;
8512 unsigned int flags
= 0;
8515 if (!PyArg_ParseTuple(args
, (char *) "Ozz|OI:virDomainBlockCopy",
8516 &pyobj_dom
, &disk
, &destxml
, &pyobj_dict
, &flags
))
8519 if (PyDict_Check(pyobj_dict
)) {
8520 if (virPyDictToTypedParams(pyobj_dict
, ¶ms
, &nparams
, NULL
, 0) < 0)
8524 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
8526 LIBVIRT_BEGIN_ALLOW_THREADS
;
8527 c_retval
= virDomainBlockCopy(dom
, disk
, destxml
, params
, nparams
, flags
);
8528 LIBVIRT_END_ALLOW_THREADS
;
8530 return libvirt_intWrap(c_retval
);
8533 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
8535 #if LIBVIR_CHECK_VERSION(1, 2, 9)
8537 libvirt_virNodeAllocPages(PyObject
*self ATTRIBUTE_UNUSED
,
8540 PyObject
*pyobj_conn
;
8541 PyObject
*pyobj_pages
;
8542 Py_ssize_t size
= 0;
8544 PyObject
*key
, *value
;
8546 unsigned int npages
= 0;
8547 unsigned int *pageSizes
= NULL
;
8548 unsigned long long *pageCounts
= NULL
;
8550 unsigned int cellCount
= 1;
8551 unsigned int flags
= VIR_NODE_ALLOC_PAGES_ADD
;
8554 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeAllocPages",
8555 &pyobj_conn
, &pyobj_pages
,
8556 &startCell
, &cellCount
, &flags
))
8558 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8560 if ((size
= PyDict_Size(pyobj_pages
)) < 0)
8564 PyErr_Format(PyExc_LookupError
,
8565 "Need non-empty dictionary to pages attribute");
8569 if (VIR_ALLOC_N(pageSizes
, size
) < 0 ||
8570 VIR_ALLOC_N(pageCounts
, size
) < 0) {
8575 while (PyDict_Next(pyobj_pages
, &pos
, &key
, &value
)) {
8576 if (libvirt_uintUnwrap(key
, &pageSizes
[npages
]) < 0 ||
8577 libvirt_ulonglongUnwrap(value
, &pageCounts
[npages
]) < 0)
8582 LIBVIRT_BEGIN_ALLOW_THREADS
;
8583 c_retval
= virNodeAllocPages(conn
, npages
, pageSizes
,
8584 pageCounts
, startCell
, cellCount
, flags
);
8585 LIBVIRT_END_ALLOW_THREADS
;
8587 VIR_FREE(pageSizes
);
8588 VIR_FREE(pageCounts
);
8590 return libvirt_intWrap(c_retval
);
8593 VIR_FREE(pageSizes
);
8594 VIR_FREE(pageCounts
);
8597 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
8599 #if LIBVIR_CHECK_VERSION(1, 2, 11)
8602 libvirt_virDomainGetFSInfo(PyObject
*self ATTRIBUTE_UNUSED
,
8605 virDomainPtr domain
;
8606 PyObject
*pyobj_domain
;
8608 virDomainFSInfoPtr
*fsinfo
= NULL
;
8611 PyObject
*py_retval
= NULL
;
8613 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetFSInfo",
8614 &pyobj_domain
, &flags
))
8616 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8618 LIBVIRT_BEGIN_ALLOW_THREADS
;
8619 c_retval
= virDomainGetFSInfo(domain
, &fsinfo
, flags
);
8620 LIBVIRT_END_ALLOW_THREADS
;
8623 py_retval
= VIR_PY_NONE
;
8627 /* convert to a Python list */
8628 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
8631 for (i
= 0; i
< c_retval
; i
++) {
8632 virDomainFSInfoPtr fs
= fsinfo
[i
];
8633 PyObject
*info
, *alias
;
8638 info
= PyTuple_New(4);
8642 VIR_PY_LIST_SET_GOTO(py_retval
, i
, info
, error
);
8644 VIR_PY_TUPLE_SET_GOTO(info
, 0,
8645 libvirt_constcharPtrWrap(fs
->mountpoint
), error
);
8646 VIR_PY_TUPLE_SET_GOTO(info
, 1,
8647 libvirt_constcharPtrWrap(fs
->name
), error
);
8648 VIR_PY_TUPLE_SET_GOTO(info
, 2,
8649 libvirt_constcharPtrWrap(fs
->fstype
), error
);
8651 alias
= PyList_New(0);
8654 VIR_PY_TUPLE_SET_GOTO(info
, 3, alias
, error
);
8656 for (j
= 0; j
< fs
->ndevAlias
; j
++)
8657 VIR_PY_LIST_APPEND_GOTO(alias
,
8658 libvirt_constcharPtrWrap(fs
->devAlias
[j
]),
8664 for (i
= 0; i
< c_retval
; i
++)
8665 virDomainFSInfoFree(fsinfo
[i
]);
8670 Py_CLEAR(py_retval
);
8674 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
8676 #if LIBVIR_CHECK_VERSION(1, 3, 3)
8678 libvirt_virDomainGetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
8681 PyObject
*pyobj_domain
;
8682 virDomainPtr domain
;
8683 virTypedParameterPtr params
= NULL
;
8685 PyObject
*dict
= NULL
;
8689 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetPerfEvents",
8690 &pyobj_domain
, &flags
))
8692 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8694 LIBVIRT_BEGIN_ALLOW_THREADS
;
8695 rc
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
8696 LIBVIRT_END_ALLOW_THREADS
;
8700 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
8704 virTypedParamsFree(params
, nparams
);
8709 libvirt_virDomainSetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
8712 virDomainPtr domain
;
8713 PyObject
*pyobj_domain
, *info
;
8714 PyObject
*ret
= NULL
;
8717 Py_ssize_t size
= 0;
8719 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
8721 if (!PyArg_ParseTuple(args
,
8722 (char *)"OOI:virDomainSetPerfEvents",
8723 &pyobj_domain
, &info
, &flags
))
8725 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8727 if ((size
= PyDict_Size(info
)) < 0)
8731 PyErr_Format(PyExc_LookupError
,
8732 "Need non-empty dictionary to set attributes");
8736 LIBVIRT_BEGIN_ALLOW_THREADS
;
8737 i_retval
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
8738 LIBVIRT_END_ALLOW_THREADS
;
8741 return VIR_PY_INT_FAIL
;
8744 PyErr_Format(PyExc_LookupError
,
8745 "Domain has no settable attributes");
8749 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
8753 LIBVIRT_BEGIN_ALLOW_THREADS
;
8754 i_retval
= virDomainSetPerfEvents(domain
, new_params
, size
, flags
);
8755 LIBVIRT_END_ALLOW_THREADS
;
8758 ret
= VIR_PY_INT_FAIL
;
8762 ret
= VIR_PY_INT_SUCCESS
;
8765 virTypedParamsFree(params
, nparams
);
8766 virTypedParamsFree(new_params
, size
);
8769 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
8771 #if LIBVIR_CHECK_VERSION(2, 0, 0)
8773 libvirt_virConnectStoragePoolEventFreeFunc(void *opaque
)
8775 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
8776 LIBVIRT_ENSURE_THREAD_STATE
;
8777 Py_DECREF(pyobj_conn
);
8778 LIBVIRT_RELEASE_THREAD_STATE
;
8782 libvirt_virConnectStoragePoolEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
8783 virStoragePoolPtr pool
,
8788 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
8789 PyObject
*pyobj_pool
;
8790 PyObject
*pyobj_ret
= NULL
;
8791 PyObject
*pyobj_conn
;
8795 LIBVIRT_ENSURE_THREAD_STATE
;
8797 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
8799 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
8802 /* Create a python instance of this virStoragePoolPtr */
8803 virStoragePoolRef(pool
);
8804 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
8805 virStoragePoolFree(pool
);
8808 Py_INCREF(pyobj_cbData
);
8810 /* Call the Callback Dispatcher */
8811 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
8812 (char*)"_dispatchStoragePoolEventLifecycleCallback",
8819 Py_DECREF(pyobj_cbData
);
8820 Py_DECREF(pyobj_pool
);
8824 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
8827 Py_DECREF(pyobj_ret
);
8831 LIBVIRT_RELEASE_THREAD_STATE
;
8836 libvirt_virConnectStoragePoolEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
8837 virStoragePoolPtr pool
,
8840 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
8841 PyObject
*pyobj_pool
;
8842 PyObject
*pyobj_ret
= NULL
;
8843 PyObject
*pyobj_conn
;
8847 LIBVIRT_ENSURE_THREAD_STATE
;
8849 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
8851 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
8854 /* Create a python instance of this virStoragePoolPtr */
8855 virStoragePoolRef(pool
);
8856 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
8857 virStoragePoolFree(pool
);
8860 Py_INCREF(pyobj_cbData
);
8862 /* Call the Callback Dispatcher */
8863 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
8864 (char*)"_dispatchStoragePoolEventGenericCallback",
8869 Py_DECREF(pyobj_cbData
);
8870 Py_DECREF(pyobj_pool
);
8874 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
8877 Py_DECREF(pyobj_ret
);
8881 LIBVIRT_RELEASE_THREAD_STATE
;
8886 libvirt_virConnectStoragePoolEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
8889 PyObject
*pyobj_conn
; /* virConnectPtr */
8890 PyObject
*pyobj_pool
;
8891 PyObject
*pyobj_cbData
; /* hash of callback data */
8895 virConnectStoragePoolEventGenericCallback cb
= NULL
;
8896 virStoragePoolPtr pool
;
8898 if (!PyArg_ParseTuple(args
,
8899 (char *) "OOiO:virConnectStoragePoolEventRegisterAny",
8900 &pyobj_conn
, &pyobj_pool
, &eventID
, &pyobj_cbData
))
8903 DEBUG("libvirt_virConnectStoragePoolEventRegister(%p %p %d %p) called\n",
8904 pyobj_conn
, pyobj_pool
, eventID
, pyobj_cbData
);
8905 conn
= PyvirConnect_Get(pyobj_conn
);
8906 if (pyobj_pool
== Py_None
)
8909 pool
= PyvirStoragePool_Get(pyobj_pool
);
8911 switch ((virStoragePoolEventID
) eventID
) {
8912 case VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE
:
8913 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventLifecycleCallback
);
8916 case VIR_STORAGE_POOL_EVENT_ID_REFRESH
:
8917 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventGenericCallback
);
8920 case VIR_STORAGE_POOL_EVENT_ID_LAST
:
8925 return VIR_PY_INT_FAIL
;
8928 Py_INCREF(pyobj_cbData
);
8930 LIBVIRT_BEGIN_ALLOW_THREADS
;
8931 ret
= virConnectStoragePoolEventRegisterAny(conn
,
8936 libvirt_virConnectStoragePoolEventFreeFunc
);
8937 LIBVIRT_END_ALLOW_THREADS
;
8940 Py_DECREF(pyobj_cbData
);
8943 return libvirt_intWrap(ret
);
8947 libvirt_virConnectStoragePoolEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
8950 PyObject
*pyobj_conn
;
8955 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectStoragePoolEventDeregisterAny",
8956 &pyobj_conn
, &callbackID
))
8959 DEBUG("libvirt_virConnectStoragePoolEventDeregister(%p) called\n",
8962 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8964 LIBVIRT_BEGIN_ALLOW_THREADS
;
8966 ret
= virConnectStoragePoolEventDeregisterAny(conn
, callbackID
);
8968 LIBVIRT_END_ALLOW_THREADS
;
8970 return libvirt_intWrap(ret
);
8974 libvirt_virDomainGetGuestVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
8977 PyObject
*pyobj_domain
;
8978 virDomainPtr domain
;
8979 virTypedParameterPtr params
= NULL
;
8980 unsigned int nparams
= 0;
8983 PyObject
*ret
= NULL
;
8985 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetGuestVcpus",
8986 &pyobj_domain
, &flags
))
8988 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8990 LIBVIRT_BEGIN_ALLOW_THREADS
;
8991 i_retval
= virDomainGetGuestVcpus(domain
, ¶ms
, &nparams
, flags
);
8992 LIBVIRT_END_ALLOW_THREADS
;
8999 ret
= getPyVirTypedParameter(params
, nparams
);
9001 virTypedParamsFree(params
, nparams
);
9004 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0)*/
9006 #if LIBVIR_CHECK_VERSION(2, 2, 0)
9008 libvirt_virConnectNodeDeviceEventFreeFunc(void *opaque
)
9010 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9011 LIBVIRT_ENSURE_THREAD_STATE
;
9012 Py_DECREF(pyobj_conn
);
9013 LIBVIRT_RELEASE_THREAD_STATE
;
9017 libvirt_virConnectNodeDeviceEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9018 virNodeDevicePtr dev
,
9023 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9024 PyObject
*pyobj_dev
;
9025 PyObject
*pyobj_ret
= NULL
;
9026 PyObject
*pyobj_conn
;
9030 LIBVIRT_ENSURE_THREAD_STATE
;
9032 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9034 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9037 /* Create a python instance of this virNodeDevicePtr */
9038 virNodeDeviceRef(dev
);
9039 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9040 virNodeDeviceFree(dev
);
9043 Py_INCREF(pyobj_cbData
);
9045 /* Call the Callback Dispatcher */
9046 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9047 (char*)"_dispatchNodeDeviceEventLifecycleCallback",
9054 Py_DECREF(pyobj_cbData
);
9055 Py_DECREF(pyobj_dev
);
9059 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9062 Py_DECREF(pyobj_ret
);
9066 LIBVIRT_RELEASE_THREAD_STATE
;
9071 libvirt_virConnectNodeDeviceEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9072 virNodeDevicePtr dev
,
9075 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9076 PyObject
*pyobj_dev
;
9077 PyObject
*pyobj_ret
= NULL
;
9078 PyObject
*pyobj_conn
;
9082 LIBVIRT_ENSURE_THREAD_STATE
;
9084 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9086 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9089 /* Create a python instance of this virNodeDevicePtr */
9090 virNodeDeviceRef(dev
);
9091 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9092 virNodeDeviceFree(dev
);
9095 Py_INCREF(pyobj_cbData
);
9097 /* Call the Callback Dispatcher */
9098 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9099 (char*)"_dispatchNodeDeviceEventGenericCallback",
9104 Py_DECREF(pyobj_cbData
);
9105 Py_DECREF(pyobj_dev
);
9109 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9112 Py_DECREF(pyobj_ret
);
9116 LIBVIRT_RELEASE_THREAD_STATE
;
9121 libvirt_virConnectNodeDeviceEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9124 PyObject
*pyobj_conn
; /* virConnectPtr */
9125 PyObject
*pyobj_dev
;
9126 PyObject
*pyobj_cbData
; /* hash of callback data */
9130 virConnectNodeDeviceEventGenericCallback cb
= NULL
;
9131 virNodeDevicePtr dev
;
9133 if (!PyArg_ParseTuple(args
,
9134 (char *) "OOiO:virConnectNodeDeviceEventRegisterAny",
9135 &pyobj_conn
, &pyobj_dev
, &eventID
, &pyobj_cbData
))
9138 DEBUG("libvirt_virConnectNodeDeviceEventRegister(%p %p %d %p) called\n",
9139 pyobj_conn
, pyobj_dev
, eventID
, pyobj_cbData
);
9140 conn
= PyvirConnect_Get(pyobj_conn
);
9141 if (pyobj_dev
== Py_None
)
9144 dev
= PyvirNodeDevice_Get(pyobj_dev
);
9146 switch ((virNodeDeviceEventID
) eventID
) {
9147 case VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE
:
9148 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventLifecycleCallback
);
9151 case VIR_NODE_DEVICE_EVENT_ID_UPDATE
:
9152 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventGenericCallback
);
9155 case VIR_NODE_DEVICE_EVENT_ID_LAST
:
9160 return VIR_PY_INT_FAIL
;
9163 Py_INCREF(pyobj_cbData
);
9165 LIBVIRT_BEGIN_ALLOW_THREADS
;
9166 ret
= virConnectNodeDeviceEventRegisterAny(conn
,
9171 libvirt_virConnectNodeDeviceEventFreeFunc
);
9172 LIBVIRT_END_ALLOW_THREADS
;
9175 Py_DECREF(pyobj_cbData
);
9178 return libvirt_intWrap(ret
);
9182 libvirt_virConnectNodeDeviceEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9185 PyObject
*pyobj_conn
;
9190 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNodeDeviceEventDeregister",
9191 &pyobj_conn
, &callbackID
))
9194 DEBUG("libvirt_virConnectNodeDeviceEventDeregister(%p) called\n",
9197 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9199 LIBVIRT_BEGIN_ALLOW_THREADS
;
9201 ret
= virConnectNodeDeviceEventDeregisterAny(conn
, callbackID
);
9203 LIBVIRT_END_ALLOW_THREADS
;
9205 return libvirt_intWrap(ret
);
9208 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0)*/
9210 /************************************************************************
9212 * The registration stuff *
9214 ************************************************************************/
9215 static PyMethodDef libvirtMethods
[] = {
9216 #include "build/libvirt-export.c"
9217 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
9218 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
9219 #if LIBVIR_CHECK_VERSION(1, 1, 3)
9220 {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames
, METH_VARARGS
, NULL
},
9221 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
9222 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
9223 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
9224 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
9225 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
9226 #if LIBVIR_CHECK_VERSION(0, 9, 13)
9227 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
9228 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
9229 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
9230 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
9231 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
9232 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
9233 #if LIBVIR_CHECK_VERSION(1, 2, 1)
9234 {(char *) "virConnectNetworkEventRegisterAny", libvirt_virConnectNetworkEventRegisterAny
, METH_VARARGS
, NULL
},
9235 {(char *) "virConnectNetworkEventDeregisterAny", libvirt_virConnectNetworkEventDeregisterAny
, METH_VARARGS
, NULL
},
9236 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1) */
9237 #if LIBVIR_CHECK_VERSION(0, 10, 0)
9238 {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback
, METH_VARARGS
, NULL
},
9239 {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback
, METH_VARARGS
, NULL
},
9240 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
9241 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
9242 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
9243 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
9244 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
9245 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
9246 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
9247 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
9248 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
9249 {(char *) "virNodeGetSecurityModel", libvirt_virNodeGetSecurityModel
, METH_VARARGS
, NULL
},
9250 {(char *) "virDomainGetSecurityLabel", libvirt_virDomainGetSecurityLabel
, METH_VARARGS
, NULL
},
9251 #if LIBVIR_CHECK_VERSION(0, 10, 0)
9252 {(char *) "virDomainGetSecurityLabelList", libvirt_virDomainGetSecurityLabelList
, METH_VARARGS
, NULL
},
9253 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
9254 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
9255 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
9256 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
9257 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
9258 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
9259 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
9260 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
9261 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
9262 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
9263 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
9264 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9265 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
9266 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9267 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
9268 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
9269 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
9270 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
9271 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
9272 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
9273 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
9274 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
9275 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
9276 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
9277 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
9278 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
9279 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
9280 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
9281 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
9282 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
9283 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
9284 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
9285 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
9286 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
9287 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
9288 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
9289 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
9290 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
9291 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
9292 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
9293 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
9294 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
9295 #if LIBVIR_CHECK_VERSION(0, 10, 0)
9296 {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo
, METH_VARARGS
, NULL
},
9297 {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator
, METH_VARARGS
, NULL
},
9298 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
9299 #if LIBVIR_CHECK_VERSION(1, 2, 14)
9300 {(char *) "virDomainGetIOThreadInfo", libvirt_virDomainGetIOThreadInfo
, METH_VARARGS
, NULL
},
9301 {(char *) "virDomainPinIOThread", libvirt_virDomainPinIOThread
, METH_VARARGS
, NULL
},
9302 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
9303 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
9304 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
9305 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9306 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
9307 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9308 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
9309 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
9310 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9311 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
9312 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9313 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
9314 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
9315 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
9316 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
9317 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
9318 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
9319 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
9320 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
9321 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
9322 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
9323 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
9324 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9325 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
9326 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9327 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
9328 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
9329 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
9330 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
9331 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
9332 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9333 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
9334 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9335 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
9336 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
9337 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
9338 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
9339 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
9340 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
9341 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9342 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
9343 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9344 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
9345 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
9346 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9347 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
9348 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9349 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
9350 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
9351 #if LIBVIR_CHECK_VERSION(1, 0, 3)
9352 {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats
, METH_VARARGS
, NULL
},
9353 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
9354 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
9355 #if LIBVIR_CHECK_VERSION(0, 9, 13)
9356 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
9357 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
9358 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
9359 #if LIBVIR_CHECK_VERSION(0, 9, 13)
9360 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
9361 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
9362 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
9363 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
9364 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
9365 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
9366 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
9367 #if LIBVIR_CHECK_VERSION(1, 0, 3)
9368 {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache
, METH_VARARGS
, NULL
},
9369 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
9370 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
9371 #if LIBVIR_CHECK_VERSION(1, 1, 0)
9372 {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3
, METH_VARARGS
, NULL
},
9373 {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3
, METH_VARARGS
, NULL
},
9374 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
9375 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
9376 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
9377 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
9378 #if LIBVIR_CHECK_VERSION(0, 10, 2)
9379 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
9380 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
9381 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
9382 #if LIBVIR_CHECK_VERSION(1, 0, 0)
9383 {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap
, METH_VARARGS
, NULL
},
9384 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
9385 #if LIBVIR_CHECK_VERSION(1, 1, 1)
9386 {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles
, METH_VARARGS
, NULL
},
9387 {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles
, METH_VARARGS
, NULL
},
9388 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
9389 #if LIBVIR_CHECK_VERSION(1, 2, 5)
9390 {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze
, METH_VARARGS
, NULL
},
9391 {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw
, METH_VARARGS
, NULL
},
9392 {(char *) "virDomainGetTime", libvirt_virDomainGetTime
, METH_VARARGS
, NULL
},
9393 {(char *) "virDomainSetTime", libvirt_virDomainSetTime
, METH_VARARGS
, NULL
},
9394 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
9395 #if LIBVIR_CHECK_VERSION(1, 2, 6)
9396 {(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages
, METH_VARARGS
, NULL
},
9397 {(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases
, METH_VARARGS
, NULL
},
9398 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
9399 #if LIBVIR_CHECK_VERSION(1, 2, 8)
9400 {(char *) "virConnectGetAllDomainStats", libvirt_virConnectGetAllDomainStats
, METH_VARARGS
, NULL
},
9401 {(char *) "virDomainListGetStats", libvirt_virDomainListGetStats
, METH_VARARGS
, NULL
},
9402 {(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy
, METH_VARARGS
, NULL
},
9403 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
9404 #if LIBVIR_CHECK_VERSION(1, 2, 9)
9405 {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages
, METH_VARARGS
, NULL
},
9406 #endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
9407 #if LIBVIR_CHECK_VERSION(1, 2, 11)
9408 {(char *) "virDomainGetFSInfo", libvirt_virDomainGetFSInfo
, METH_VARARGS
, NULL
},
9409 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
9410 #if LIBVIR_CHECK_VERSION(1, 2, 14)
9411 {(char *) "virDomainInterfaceAddresses", libvirt_virDomainInterfaceAddresses
, METH_VARARGS
, NULL
},
9412 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
9413 #if LIBVIR_CHECK_VERSION(1, 3, 3)
9414 {(char *) "virDomainGetPerfEvents", libvirt_virDomainGetPerfEvents
, METH_VARARGS
, NULL
},
9415 {(char *) "virDomainSetPerfEvents", libvirt_virDomainSetPerfEvents
, METH_VARARGS
, NULL
},
9416 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
9417 #if LIBVIR_CHECK_VERSION(2, 0, 0)
9418 {(char *) "virConnectStoragePoolEventRegisterAny", libvirt_virConnectStoragePoolEventRegisterAny
, METH_VARARGS
, NULL
},
9419 {(char *) "virConnectStoragePoolEventDeregisterAny", libvirt_virConnectStoragePoolEventDeregisterAny
, METH_VARARGS
, NULL
},
9420 {(char *) "virDomainGetGuestVcpus", libvirt_virDomainGetGuestVcpus
, METH_VARARGS
, NULL
},
9421 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0) */
9422 #if LIBVIR_CHECK_VERSION(2, 2, 0)
9423 {(char *) "virConnectNodeDeviceEventRegisterAny", libvirt_virConnectNodeDeviceEventRegisterAny
, METH_VARARGS
, NULL
},
9424 {(char *) "virConnectNodeDeviceEventDeregisterAny", libvirt_virConnectNodeDeviceEventDeregisterAny
, METH_VARARGS
, NULL
},
9425 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0) */
9426 {NULL
, NULL
, 0, NULL
}
9429 #if PY_MAJOR_VERSION > 2
9430 static struct PyModuleDef moduledef
= {
9431 PyModuleDef_HEAD_INIT
,
9456 if (virInitialize() < 0)
9459 module
= PyModule_Create(&moduledef
);
9463 #else /* ! PY_MAJOR_VERSION > 2 */
9472 if (virInitialize() < 0)
9475 /* initialize the python extension module */
9476 Py_InitModule((char *)
9484 #endif /* ! PY_MAJOR_VERSION > 2 */