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 LIBVIRT_BEGIN_ALLOW_THREADS
;
367 nr_stats
= virDomainMemoryStats(domain
, stats
,
368 VIR_DOMAIN_MEMORY_STAT_NR
, 0);
369 LIBVIRT_END_ALLOW_THREADS
;
371 if (nr_stats
== (unsigned int)-1)
374 /* convert to a Python dictionary */
375 if ((info
= PyDict_New()) == NULL
)
378 for (i
= 0; i
< nr_stats
; i
++) {
379 switch (stats
[i
].tag
) {
380 case VIR_DOMAIN_MEMORY_STAT_SWAP_IN
:
381 key
= libvirt_constcharPtrWrap("swap_in");
383 case VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
:
384 key
= libvirt_constcharPtrWrap("swap_out");
386 case VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
:
387 key
= libvirt_constcharPtrWrap("major_fault");
389 case VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
:
390 key
= libvirt_constcharPtrWrap("minor_fault");
392 case VIR_DOMAIN_MEMORY_STAT_UNUSED
:
393 key
= libvirt_constcharPtrWrap("unused");
395 case VIR_DOMAIN_MEMORY_STAT_AVAILABLE
:
396 key
= libvirt_constcharPtrWrap("available");
398 case VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
:
399 key
= libvirt_constcharPtrWrap("actual");
401 case VIR_DOMAIN_MEMORY_STAT_RSS
:
402 key
= libvirt_constcharPtrWrap("rss");
404 #if LIBVIR_CHECK_VERSION(2, 1, 0)
405 case VIR_DOMAIN_MEMORY_STAT_USABLE
:
406 key
= libvirt_constcharPtrWrap("usable");
408 case VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE
:
409 key
= libvirt_constcharPtrWrap("last_update");
411 #endif /* LIBVIR_CHECK_VERSION(2, 1, 0) */
415 val
= libvirt_ulonglongWrap(stats
[i
].val
);
417 VIR_PY_DICT_SET_GOTO(info
, key
, val
, error
);
428 libvirt_virDomainGetSchedulerType(PyObject
*self ATTRIBUTE_UNUSED
,
432 PyObject
*pyobj_domain
, *info
;
436 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerType",
439 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
441 LIBVIRT_BEGIN_ALLOW_THREADS
;
442 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
443 LIBVIRT_END_ALLOW_THREADS
;
445 if (c_retval
== NULL
)
448 /* convert to a Python tuple of long objects */
449 if ((info
= PyTuple_New(2)) == NULL
)
452 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_constcharPtrWrap(c_retval
), error
);
453 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)nparams
), error
);
466 libvirt_virDomainGetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
470 PyObject
*pyobj_domain
;
471 PyObject
*ret
= NULL
;
475 virTypedParameterPtr params
;
477 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetScedulerParameters",
480 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
482 LIBVIRT_BEGIN_ALLOW_THREADS
;
483 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
484 LIBVIRT_END_ALLOW_THREADS
;
486 if (c_retval
== NULL
)
493 if (VIR_ALLOC_N(params
, nparams
) < 0)
494 return PyErr_NoMemory();
496 LIBVIRT_BEGIN_ALLOW_THREADS
;
497 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
498 LIBVIRT_END_ALLOW_THREADS
;
505 ret
= getPyVirTypedParameter(params
, nparams
);
508 virTypedParamsFree(params
, nparams
);
513 libvirt_virDomainGetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
517 PyObject
*pyobj_domain
;
518 PyObject
*ret
= NULL
;
523 virTypedParameterPtr params
;
525 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetScedulerParametersFlags",
526 &pyobj_domain
, &flags
))
528 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
530 LIBVIRT_BEGIN_ALLOW_THREADS
;
531 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
532 LIBVIRT_END_ALLOW_THREADS
;
534 if (c_retval
== NULL
)
541 if (VIR_ALLOC_N(params
, nparams
) < 0)
542 return PyErr_NoMemory();
544 LIBVIRT_BEGIN_ALLOW_THREADS
;
545 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
,
547 LIBVIRT_END_ALLOW_THREADS
;
554 ret
= getPyVirTypedParameter(params
, nparams
);
557 virTypedParamsFree(params
, nparams
);
562 libvirt_virDomainSetSchedulerParameters(PyObject
*self ATTRIBUTE_UNUSED
,
566 PyObject
*pyobj_domain
, *info
;
567 PyObject
*ret
= NULL
;
572 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
574 if (!PyArg_ParseTuple(args
, (char *)"OO:virDomainSetSchedulerParameters",
575 &pyobj_domain
, &info
))
577 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
579 if ((size
= PyDict_Size(info
)) < 0)
583 PyErr_Format(PyExc_LookupError
,
584 "Need non-empty dictionary to set attributes");
588 LIBVIRT_BEGIN_ALLOW_THREADS
;
589 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
590 LIBVIRT_END_ALLOW_THREADS
;
592 if (c_retval
== NULL
)
593 return VIR_PY_INT_FAIL
;
597 PyErr_Format(PyExc_LookupError
,
598 "Domain has no settable attributes");
602 if (VIR_ALLOC_N(params
, nparams
) < 0)
603 return PyErr_NoMemory();
605 LIBVIRT_BEGIN_ALLOW_THREADS
;
606 i_retval
= virDomainGetSchedulerParameters(domain
, params
, &nparams
);
607 LIBVIRT_END_ALLOW_THREADS
;
610 ret
= VIR_PY_INT_FAIL
;
614 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
618 LIBVIRT_BEGIN_ALLOW_THREADS
;
619 i_retval
= virDomainSetSchedulerParameters(domain
, new_params
, size
);
620 LIBVIRT_END_ALLOW_THREADS
;
623 ret
= VIR_PY_INT_FAIL
;
627 ret
= VIR_PY_INT_SUCCESS
;
630 virTypedParamsFree(params
, nparams
);
631 virTypedParamsFree(new_params
, size
);
636 libvirt_virDomainSetSchedulerParametersFlags(PyObject
*self ATTRIBUTE_UNUSED
,
640 PyObject
*pyobj_domain
, *info
;
641 PyObject
*ret
= NULL
;
647 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
649 if (!PyArg_ParseTuple(args
,
650 (char *)"OOI:virDomainSetSchedulerParametersFlags",
651 &pyobj_domain
, &info
, &flags
))
653 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
655 if ((size
= PyDict_Size(info
)) < 0)
659 PyErr_Format(PyExc_LookupError
,
660 "Need non-empty dictionary to set attributes");
664 LIBVIRT_BEGIN_ALLOW_THREADS
;
665 c_retval
= virDomainGetSchedulerType(domain
, &nparams
);
666 LIBVIRT_END_ALLOW_THREADS
;
668 if (c_retval
== NULL
)
669 return VIR_PY_INT_FAIL
;
673 PyErr_Format(PyExc_LookupError
,
674 "Domain has no settable attributes");
678 if (VIR_ALLOC_N(params
, nparams
) < 0)
679 return PyErr_NoMemory();
681 LIBVIRT_BEGIN_ALLOW_THREADS
;
682 i_retval
= virDomainGetSchedulerParametersFlags(domain
, params
, &nparams
,
684 LIBVIRT_END_ALLOW_THREADS
;
687 ret
= VIR_PY_INT_FAIL
;
691 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
695 LIBVIRT_BEGIN_ALLOW_THREADS
;
696 i_retval
= virDomainSetSchedulerParametersFlags(domain
, new_params
, size
,
698 LIBVIRT_END_ALLOW_THREADS
;
701 ret
= VIR_PY_INT_FAIL
;
705 ret
= VIR_PY_INT_SUCCESS
;
708 virTypedParamsFree(params
, nparams
);
709 virTypedParamsFree(new_params
, size
);
714 libvirt_virDomainSetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
718 PyObject
*pyobj_domain
, *info
;
719 PyObject
*ret
= NULL
;
724 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
726 if (!PyArg_ParseTuple(args
,
727 (char *)"OOI:virDomainSetBlkioParameters",
728 &pyobj_domain
, &info
, &flags
))
730 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
732 if ((size
= PyDict_Size(info
)) < 0)
736 PyErr_Format(PyExc_LookupError
,
737 "Need non-empty dictionary to set attributes");
741 LIBVIRT_BEGIN_ALLOW_THREADS
;
742 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
743 LIBVIRT_END_ALLOW_THREADS
;
746 return VIR_PY_INT_FAIL
;
749 PyErr_Format(PyExc_LookupError
,
750 "Domain has no settable attributes");
754 if (VIR_ALLOC_N(params
, nparams
) < 0)
755 return PyErr_NoMemory();
757 LIBVIRT_BEGIN_ALLOW_THREADS
;
758 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
759 LIBVIRT_END_ALLOW_THREADS
;
762 ret
= VIR_PY_INT_FAIL
;
766 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
770 LIBVIRT_BEGIN_ALLOW_THREADS
;
771 i_retval
= virDomainSetBlkioParameters(domain
, new_params
, size
, flags
);
772 LIBVIRT_END_ALLOW_THREADS
;
775 ret
= VIR_PY_INT_FAIL
;
779 ret
= VIR_PY_INT_SUCCESS
;
782 virTypedParamsFree(params
, nparams
);
783 virTypedParamsFree(new_params
, size
);
788 libvirt_virDomainGetBlkioParameters(PyObject
*self ATTRIBUTE_UNUSED
,
792 PyObject
*pyobj_domain
;
793 PyObject
*ret
= NULL
;
797 virTypedParameterPtr params
;
799 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetBlkioParameters",
800 &pyobj_domain
, &flags
))
802 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
804 LIBVIRT_BEGIN_ALLOW_THREADS
;
805 i_retval
= virDomainGetBlkioParameters(domain
, NULL
, &nparams
, flags
);
806 LIBVIRT_END_ALLOW_THREADS
;
814 if (VIR_ALLOC_N(params
, nparams
) < 0)
815 return PyErr_NoMemory();
817 LIBVIRT_BEGIN_ALLOW_THREADS
;
818 i_retval
= virDomainGetBlkioParameters(domain
, params
, &nparams
, flags
);
819 LIBVIRT_END_ALLOW_THREADS
;
826 ret
= getPyVirTypedParameter(params
, nparams
);
829 virTypedParamsFree(params
, nparams
);
834 libvirt_virDomainSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
838 PyObject
*pyobj_domain
, *info
;
839 PyObject
*ret
= NULL
;
844 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
846 if (!PyArg_ParseTuple(args
,
847 (char *)"OOI:virDomainSetMemoryParameters",
848 &pyobj_domain
, &info
, &flags
))
850 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
852 if ((size
= PyDict_Size(info
)) < 0)
856 PyErr_Format(PyExc_LookupError
,
857 "Need non-empty dictionary to set attributes");
861 LIBVIRT_BEGIN_ALLOW_THREADS
;
862 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
863 LIBVIRT_END_ALLOW_THREADS
;
866 return VIR_PY_INT_FAIL
;
869 PyErr_Format(PyExc_LookupError
,
870 "Domain has no settable attributes");
874 if (VIR_ALLOC_N(params
, nparams
) < 0)
875 return PyErr_NoMemory();
877 LIBVIRT_BEGIN_ALLOW_THREADS
;
878 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
879 LIBVIRT_END_ALLOW_THREADS
;
882 ret
= VIR_PY_INT_FAIL
;
886 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
890 LIBVIRT_BEGIN_ALLOW_THREADS
;
891 i_retval
= virDomainSetMemoryParameters(domain
, new_params
, size
, flags
);
892 LIBVIRT_END_ALLOW_THREADS
;
895 ret
= VIR_PY_INT_FAIL
;
899 ret
= VIR_PY_INT_SUCCESS
;
902 virTypedParamsFree(params
, nparams
);
903 virTypedParamsFree(new_params
, size
);
908 libvirt_virDomainGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
912 PyObject
*pyobj_domain
;
913 PyObject
*ret
= NULL
;
917 virTypedParameterPtr params
;
919 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetMemoryParameters",
920 &pyobj_domain
, &flags
))
922 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
924 LIBVIRT_BEGIN_ALLOW_THREADS
;
925 i_retval
= virDomainGetMemoryParameters(domain
, NULL
, &nparams
, flags
);
926 LIBVIRT_END_ALLOW_THREADS
;
934 if (VIR_ALLOC_N(params
, nparams
) < 0)
935 return PyErr_NoMemory();
937 LIBVIRT_BEGIN_ALLOW_THREADS
;
938 i_retval
= virDomainGetMemoryParameters(domain
, params
, &nparams
, flags
);
939 LIBVIRT_END_ALLOW_THREADS
;
946 ret
= getPyVirTypedParameter(params
, nparams
);
949 virTypedParamsFree(params
, nparams
);
954 libvirt_virDomainSetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
958 PyObject
*pyobj_domain
, *info
;
959 PyObject
*ret
= NULL
;
964 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
966 if (!PyArg_ParseTuple(args
,
967 (char *)"OOI:virDomainSetNumaParameters",
968 &pyobj_domain
, &info
, &flags
))
970 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
972 if ((size
= PyDict_Size(info
)) < 0)
976 PyErr_Format(PyExc_LookupError
,
977 "Need non-empty dictionary to set attributes");
981 LIBVIRT_BEGIN_ALLOW_THREADS
;
982 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
983 LIBVIRT_END_ALLOW_THREADS
;
986 return VIR_PY_INT_FAIL
;
989 PyErr_Format(PyExc_LookupError
,
990 "Domain has no settable attributes");
994 if (VIR_ALLOC_N(params
, nparams
) < 0)
995 return PyErr_NoMemory();
997 LIBVIRT_BEGIN_ALLOW_THREADS
;
998 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
999 LIBVIRT_END_ALLOW_THREADS
;
1002 ret
= VIR_PY_INT_FAIL
;
1006 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1010 LIBVIRT_BEGIN_ALLOW_THREADS
;
1011 i_retval
= virDomainSetNumaParameters(domain
, new_params
, size
, flags
);
1012 LIBVIRT_END_ALLOW_THREADS
;
1015 ret
= VIR_PY_INT_FAIL
;
1019 ret
= VIR_PY_INT_SUCCESS
;
1022 virTypedParamsFree(params
, nparams
);
1023 virTypedParamsFree(new_params
, size
);
1028 libvirt_virDomainGetNumaParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1031 virDomainPtr domain
;
1032 PyObject
*pyobj_domain
;
1033 PyObject
*ret
= NULL
;
1037 virTypedParameterPtr params
;
1039 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetNumaParameters",
1040 &pyobj_domain
, &flags
))
1042 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1044 LIBVIRT_BEGIN_ALLOW_THREADS
;
1045 i_retval
= virDomainGetNumaParameters(domain
, NULL
, &nparams
, flags
);
1046 LIBVIRT_END_ALLOW_THREADS
;
1052 return PyDict_New();
1054 if (VIR_ALLOC_N(params
, nparams
) < 0)
1055 return PyErr_NoMemory();
1057 LIBVIRT_BEGIN_ALLOW_THREADS
;
1058 i_retval
= virDomainGetNumaParameters(domain
, params
, &nparams
, flags
);
1059 LIBVIRT_END_ALLOW_THREADS
;
1066 ret
= getPyVirTypedParameter(params
, nparams
);
1069 virTypedParamsFree(params
, nparams
);
1074 libvirt_virDomainSetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1077 virDomainPtr domain
;
1078 PyObject
*pyobj_domain
, *info
;
1079 PyObject
*ret
= NULL
;
1082 Py_ssize_t size
= 0;
1084 const char *device
= NULL
;
1085 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
1087 if (!PyArg_ParseTuple(args
,
1088 (char *)"OzOI:virDomainSetInterfaceParameters",
1089 &pyobj_domain
, &device
, &info
, &flags
))
1091 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1093 if ((size
= PyDict_Size(info
)) < 0)
1097 PyErr_Format(PyExc_LookupError
,
1098 "Need non-empty dictionary to set attributes");
1102 LIBVIRT_BEGIN_ALLOW_THREADS
;
1103 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
,
1105 LIBVIRT_END_ALLOW_THREADS
;
1108 return VIR_PY_INT_FAIL
;
1111 PyErr_Format(PyExc_LookupError
,
1112 "Domain has no settable attributes");
1116 if (VIR_ALLOC_N(params
, nparams
) < 0)
1117 return PyErr_NoMemory();
1119 LIBVIRT_BEGIN_ALLOW_THREADS
;
1120 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
,
1122 LIBVIRT_END_ALLOW_THREADS
;
1125 ret
= VIR_PY_INT_FAIL
;
1129 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
1133 LIBVIRT_BEGIN_ALLOW_THREADS
;
1134 i_retval
= virDomainSetInterfaceParameters(domain
, device
, new_params
, size
,
1136 LIBVIRT_END_ALLOW_THREADS
;
1139 ret
= VIR_PY_INT_FAIL
;
1143 ret
= VIR_PY_INT_SUCCESS
;
1146 virTypedParamsFree(params
, nparams
);
1147 virTypedParamsFree(new_params
, size
);
1152 libvirt_virDomainGetInterfaceParameters(PyObject
*self ATTRIBUTE_UNUSED
,
1155 virDomainPtr domain
;
1156 PyObject
*pyobj_domain
;
1157 PyObject
*ret
= NULL
;
1161 const char *device
= NULL
;
1162 virTypedParameterPtr params
;
1164 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetInterfaceParameters",
1165 &pyobj_domain
, &device
, &flags
))
1167 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1169 LIBVIRT_BEGIN_ALLOW_THREADS
;
1170 i_retval
= virDomainGetInterfaceParameters(domain
, device
, NULL
, &nparams
,
1172 LIBVIRT_END_ALLOW_THREADS
;
1178 return PyDict_New();
1180 if (VIR_ALLOC_N(params
, nparams
) < 0)
1181 return PyErr_NoMemory();
1183 LIBVIRT_BEGIN_ALLOW_THREADS
;
1184 i_retval
= virDomainGetInterfaceParameters(domain
, device
, params
, &nparams
,
1186 LIBVIRT_END_ALLOW_THREADS
;
1193 ret
= getPyVirTypedParameter(params
, nparams
);
1196 virTypedParamsFree(params
, nparams
);
1201 libvirt_virDomainGetVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
1204 virDomainPtr domain
;
1205 PyObject
*pyobj_domain
, *pyretval
= NULL
;
1206 PyObject
*pycpuinfo
= NULL
, *pycpumap
= NULL
;
1207 PyObject
*error
= NULL
;
1208 virDomainInfo dominfo
;
1209 virVcpuInfoPtr cpuinfo
= NULL
;
1210 unsigned char *cpumap
= NULL
;
1211 ssize_t cpumaplen
, i
;
1212 int i_retval
, cpunum
;
1214 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetVcpus",
1217 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1219 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1222 LIBVIRT_BEGIN_ALLOW_THREADS
;
1223 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1224 LIBVIRT_END_ALLOW_THREADS
;
1229 if (VIR_ALLOC_N(cpuinfo
, dominfo
.nrVirtCpu
) < 0)
1230 return PyErr_NoMemory();
1232 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1233 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1234 VIR_ALLOC_N(cpumap
, dominfo
.nrVirtCpu
* cpumaplen
) < 0) {
1235 error
= PyErr_NoMemory();
1239 LIBVIRT_BEGIN_ALLOW_THREADS
;
1240 i_retval
= virDomainGetVcpus(domain
,
1241 cpuinfo
, dominfo
.nrVirtCpu
,
1243 LIBVIRT_END_ALLOW_THREADS
;
1246 error
= VIR_PY_NONE
;
1250 /* convert to a Python tuple of long objects */
1251 if ((pyretval
= PyTuple_New(2)) == NULL
)
1253 if ((pycpuinfo
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1256 VIR_PY_TUPLE_SET_GOTO(pyretval
, 0, pycpuinfo
, cleanup
);
1258 if ((pycpumap
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1261 VIR_PY_TUPLE_SET_GOTO(pyretval
, 1, pycpumap
, cleanup
);
1263 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1264 PyObject
*info
= PyTuple_New(4);
1269 VIR_PY_LIST_SET_GOTO(pycpuinfo
, i
, info
, cleanup
);
1271 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)cpuinfo
[i
].number
),
1273 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)cpuinfo
[i
].state
),
1275 VIR_PY_TUPLE_SET_GOTO(info
, 2,
1276 libvirt_ulonglongWrap((long)cpuinfo
[i
].cpuTime
),
1278 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)cpuinfo
[i
].cpu
),
1281 for (i
= 0; i
< dominfo
.nrVirtCpu
; i
++) {
1282 PyObject
*info
= PyTuple_New(cpunum
);
1287 VIR_PY_LIST_SET_GOTO(pycpumap
, i
, info
, cleanup
);
1289 for (j
= 0; j
< cpunum
; j
++) {
1290 VIR_PY_TUPLE_SET_GOTO(info
, j
,
1291 PyBool_FromLong(VIR_CPU_USABLE(cpumap
,
1306 Py_XDECREF(pyretval
);
1312 libvirt_virDomainPinVcpu(PyObject
*self ATTRIBUTE_UNUSED
,
1315 virDomainPtr domain
;
1316 PyObject
*pyobj_domain
, *pycpumap
;
1317 PyObject
*ret
= NULL
;
1318 unsigned char *cpumap
;
1319 int cpumaplen
, vcpu
, cpunum
;
1322 if (!PyArg_ParseTuple(args
, (char *)"OiO:virDomainPinVcpu",
1323 &pyobj_domain
, &vcpu
, &pycpumap
))
1325 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1327 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1328 return VIR_PY_INT_FAIL
;
1330 if (virPyCpumapConvert(cpunum
, pycpumap
, &cpumap
, &cpumaplen
) < 0)
1333 LIBVIRT_BEGIN_ALLOW_THREADS
;
1334 i_retval
= virDomainPinVcpu(domain
, vcpu
, cpumap
, cpumaplen
);
1335 LIBVIRT_END_ALLOW_THREADS
;
1338 ret
= VIR_PY_INT_FAIL
;
1341 ret
= VIR_PY_INT_SUCCESS
;
1349 libvirt_virDomainPinVcpuFlags(PyObject
*self ATTRIBUTE_UNUSED
,
1352 virDomainPtr domain
;
1353 PyObject
*pyobj_domain
, *pycpumap
;
1354 PyObject
*ret
= NULL
;
1355 unsigned char *cpumap
;
1356 int cpumaplen
, vcpu
, cpunum
;
1360 if (!PyArg_ParseTuple(args
, (char *)"OiOI:virDomainPinVcpuFlags",
1361 &pyobj_domain
, &vcpu
, &pycpumap
, &flags
))
1363 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1365 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1366 return VIR_PY_INT_FAIL
;
1368 if (virPyCpumapConvert(cpunum
, pycpumap
, &cpumap
, &cpumaplen
) < 0)
1371 LIBVIRT_BEGIN_ALLOW_THREADS
;
1372 i_retval
= virDomainPinVcpuFlags(domain
, vcpu
, cpumap
, cpumaplen
, flags
);
1373 LIBVIRT_END_ALLOW_THREADS
;
1375 ret
= VIR_PY_INT_FAIL
;
1378 ret
= VIR_PY_INT_SUCCESS
;
1386 libvirt_virDomainGetVcpuPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1389 virDomainPtr domain
;
1390 PyObject
*pyobj_domain
, *pycpumaps
= NULL
, *error
= NULL
;
1391 virDomainInfo dominfo
;
1392 unsigned char *cpumaps
= NULL
;
1393 ssize_t cpumaplen
, vcpu
, pcpu
;
1395 int i_retval
, cpunum
;
1397 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetVcpuPinInfo",
1398 &pyobj_domain
, &flags
))
1400 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1402 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1405 LIBVIRT_BEGIN_ALLOW_THREADS
;
1406 i_retval
= virDomainGetInfo(domain
, &dominfo
);
1407 LIBVIRT_END_ALLOW_THREADS
;
1412 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1413 if (xalloc_oversized(dominfo
.nrVirtCpu
, cpumaplen
) ||
1414 VIR_ALLOC_N(cpumaps
, dominfo
.nrVirtCpu
* cpumaplen
) < 0)
1417 LIBVIRT_BEGIN_ALLOW_THREADS
;
1418 i_retval
= virDomainGetVcpuPinInfo(domain
, dominfo
.nrVirtCpu
,
1419 cpumaps
, cpumaplen
, flags
);
1420 LIBVIRT_END_ALLOW_THREADS
;
1423 error
= VIR_PY_NONE
;
1427 if ((pycpumaps
= PyList_New(dominfo
.nrVirtCpu
)) == NULL
)
1430 for (vcpu
= 0; vcpu
< dominfo
.nrVirtCpu
; vcpu
++) {
1431 PyObject
*mapinfo
= PyTuple_New(cpunum
);
1432 if (mapinfo
== NULL
)
1435 VIR_PY_LIST_SET_GOTO(pycpumaps
, vcpu
, mapinfo
, cleanup
);
1437 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1438 VIR_PY_TUPLE_SET_GOTO(mapinfo
,
1440 PyBool_FromLong(VIR_CPU_USABLE(cpumaps
,
1455 Py_XDECREF(pycpumaps
);
1461 #if LIBVIR_CHECK_VERSION(0, 10, 0)
1463 libvirt_virDomainPinEmulator(PyObject
*self ATTRIBUTE_UNUSED
,
1466 virDomainPtr domain
;
1467 PyObject
*pyobj_domain
, *pycpumap
;
1468 unsigned char *cpumap
= NULL
;
1469 int cpumaplen
, cpunum
;
1473 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainPinEmulator",
1474 &pyobj_domain
, &pycpumap
, &flags
))
1477 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1479 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1480 return VIR_PY_INT_FAIL
;
1482 if (virPyCpumapConvert(cpunum
, pycpumap
, &cpumap
, &cpumaplen
) < 0)
1485 LIBVIRT_BEGIN_ALLOW_THREADS
;
1486 i_retval
= virDomainPinEmulator(domain
, cpumap
, cpumaplen
, flags
);
1487 LIBVIRT_END_ALLOW_THREADS
;
1492 return VIR_PY_INT_FAIL
;
1494 return VIR_PY_INT_SUCCESS
;
1499 libvirt_virDomainGetEmulatorPinInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1502 virDomainPtr domain
;
1503 PyObject
*pyobj_domain
;
1505 unsigned char *cpumap
;
1512 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetEmulatorPinInfo",
1513 &pyobj_domain
, &flags
))
1516 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1518 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1521 cpumaplen
= VIR_CPU_MAPLEN(cpunum
);
1523 if (VIR_ALLOC_N(cpumap
, cpumaplen
) < 0)
1524 return PyErr_NoMemory();
1526 LIBVIRT_BEGIN_ALLOW_THREADS
;
1527 ret
= virDomainGetEmulatorPinInfo(domain
, cpumap
, cpumaplen
, flags
);
1528 LIBVIRT_END_ALLOW_THREADS
;
1535 if (!(pycpumap
= PyTuple_New(cpunum
))) {
1540 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++) {
1541 VIR_PY_TUPLE_SET_GOTO(pycpumap
,
1543 PyBool_FromLong(VIR_CPU_USABLE(cpumap
,
1558 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
1560 #if LIBVIR_CHECK_VERSION(1, 2, 14)
1562 libvirt_virDomainGetIOThreadInfo(PyObject
*self ATTRIBUTE_UNUSED
,
1565 virDomainPtr domain
;
1566 PyObject
*pyobj_domain
;
1567 PyObject
*py_retval
= NULL
;
1568 PyObject
*py_iothrinfo
= NULL
;
1569 virDomainIOThreadInfoPtr
*iothrinfo
= NULL
;
1572 int niothreads
, cpunum
;
1574 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetIOThreadInfo",
1575 &pyobj_domain
, &flags
))
1577 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1579 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1582 LIBVIRT_BEGIN_ALLOW_THREADS
;
1583 niothreads
= virDomainGetIOThreadInfo(domain
, &iothrinfo
, flags
);
1584 LIBVIRT_END_ALLOW_THREADS
;
1586 if (niothreads
< 0) {
1587 py_retval
= VIR_PY_NONE
;
1591 /* convert to a Python list */
1592 if ((py_iothrinfo
= PyList_New(niothreads
)) == NULL
)
1595 /* NOTE: If there are zero IOThreads we will return an empty list */
1596 for (i
= 0; i
< niothreads
; i
++) {
1597 PyObject
*iothrtpl
= NULL
;
1598 PyObject
*iothrmap
= NULL
;
1599 virDomainIOThreadInfoPtr iothr
= iothrinfo
[i
];
1601 if (iothr
== NULL
) {
1602 py_retval
= VIR_PY_NONE
;
1606 if ((iothrtpl
= PyTuple_New(2)) == NULL
)
1609 VIR_PY_LIST_SET_GOTO(py_iothrinfo
, i
, iothrtpl
, cleanup
);
1611 /* 0: IOThread ID */
1612 VIR_PY_TUPLE_SET_GOTO(iothrtpl
, 0, libvirt_uintWrap(iothr
->iothread_id
),
1616 if ((iothrmap
= PyList_New(cpunum
)) == NULL
)
1619 VIR_PY_TUPLE_SET_GOTO(iothrtpl
, 1, iothrmap
, cleanup
);
1621 for (pcpu
= 0; pcpu
< cpunum
; pcpu
++)
1622 VIR_PY_LIST_SET_GOTO(iothrmap
, pcpu
,
1623 PyBool_FromLong(VIR_CPU_USED(iothr
->cpumap
,
1628 py_retval
= py_iothrinfo
;
1629 py_iothrinfo
= NULL
;
1632 if (niothreads
> 0) {
1633 for (i
= 0; i
< niothreads
; i
++)
1634 virDomainIOThreadInfoFree(iothrinfo
[i
]);
1636 VIR_FREE(iothrinfo
);
1637 Py_XDECREF(py_iothrinfo
);
1642 libvirt_virDomainPinIOThread(PyObject
*self ATTRIBUTE_UNUSED
,
1645 virDomainPtr domain
;
1646 PyObject
*pyobj_domain
, *pycpumap
;
1647 PyObject
*ret
= NULL
;
1648 unsigned char *cpumap
;
1649 int cpumaplen
, iothread_val
, cpunum
;
1653 if (!PyArg_ParseTuple(args
, (char *)"OiOI:virDomainPinIOThread",
1654 &pyobj_domain
, &iothread_val
, &pycpumap
, &flags
))
1656 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
1658 if ((cpunum
= getPyNodeCPUCount(virDomainGetConnect(domain
))) < 0)
1659 return VIR_PY_INT_FAIL
;
1661 if (virPyCpumapConvert(cpunum
, pycpumap
, &cpumap
, &cpumaplen
) < 0)
1664 LIBVIRT_BEGIN_ALLOW_THREADS
;
1665 i_retval
= virDomainPinIOThread(domain
, iothread_val
,
1666 cpumap
, cpumaplen
, flags
);
1667 LIBVIRT_END_ALLOW_THREADS
;
1670 ret
= VIR_PY_INT_FAIL
;
1673 ret
= VIR_PY_INT_SUCCESS
;
1680 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
1682 #if LIBVIR_CHECK_VERSION(4, 10, 0)
1684 static virPyTypedParamsHint virPyDomainSetIOThreadParams
[] = {
1685 { VIR_DOMAIN_IOTHREAD_POLL_MAX_NS
, VIR_TYPED_PARAM_ULLONG
},
1686 { VIR_DOMAIN_IOTHREAD_POLL_GROW
, VIR_TYPED_PARAM_UINT
},
1687 { VIR_DOMAIN_IOTHREAD_POLL_SHRINK
, VIR_TYPED_PARAM_UINT
},
1691 libvirt_virDomainSetIOThreadParams(PyObject
*self ATTRIBUTE_UNUSED
,
1694 PyObject
*pyobj_dom
= NULL
;
1695 PyObject
*pyobj_dict
= NULL
;
1699 virTypedParameterPtr params
= NULL
;
1704 if (!PyArg_ParseTuple(args
, (char *)"OiOI:virDomainSetIOThreadParams",
1705 &pyobj_dom
, &iothread_val
, &pyobj_dict
, &flags
))
1708 if (PyDict_Check(pyobj_dict
)) {
1709 if (virPyDictToTypedParams(pyobj_dict
, ¶ms
, &nparams
,
1710 virPyDomainSetIOThreadParams
,
1711 VIR_N_ELEMENTS(virPyDomainSetIOThreadParams
)) < 0) {
1715 PyErr_Format(PyExc_TypeError
, "IOThread polling params must be "
1720 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
1722 LIBVIRT_BEGIN_ALLOW_THREADS
;
1723 c_retval
= virDomainSetIOThreadParams(dom
, iothread_val
,
1724 params
, nparams
, flags
);
1725 LIBVIRT_END_ALLOW_THREADS
;
1727 virTypedParamsFree(params
, nparams
);
1729 return libvirt_intWrap(c_retval
);
1731 #endif /* LIBVIR_CHECK_VERSION(4, 10, 0) */
1733 /************************************************************************
1735 * Global error handler at the Python level *
1737 ************************************************************************/
1739 static PyObject
*libvirt_virPythonErrorFuncHandler
= NULL
;
1740 static PyObject
*libvirt_virPythonErrorFuncCtxt
= NULL
;
1743 libvirt_virGetLastError(PyObject
*self ATTRIBUTE_UNUSED
,
1744 PyObject
*args ATTRIBUTE_UNUSED
)
1749 if ((err
= virGetLastError()) == NULL
)
1752 if ((info
= PyTuple_New(9)) == NULL
)
1755 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), error
);
1756 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), error
);
1757 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), error
);
1758 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), error
);
1759 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), error
);
1760 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), error
);
1761 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), error
);
1762 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), error
);
1763 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), error
);
1773 libvirt_virConnGetLastError(PyObject
*self ATTRIBUTE_UNUSED
,
1779 PyObject
*pyobj_conn
;
1781 if (!PyArg_ParseTuple(args
, (char *)"O:virConGetLastError", &pyobj_conn
))
1783 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
1785 LIBVIRT_BEGIN_ALLOW_THREADS
;
1786 err
= virConnGetLastError(conn
);
1787 LIBVIRT_END_ALLOW_THREADS
;
1792 if ((info
= PyTuple_New(9)) == NULL
)
1795 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), error
);
1796 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), error
);
1797 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), error
);
1798 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), error
);
1799 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), error
);
1800 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), error
);
1801 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), error
);
1802 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), error
);
1803 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), error
);
1813 libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED
void *ctx
,
1816 PyObject
*list
= NULL
, *info
= NULL
;
1819 DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx
,
1822 if ((err
== NULL
) || (err
->code
== VIR_ERR_OK
))
1825 LIBVIRT_ENSURE_THREAD_STATE
;
1827 if ((libvirt_virPythonErrorFuncHandler
== NULL
) ||
1828 (libvirt_virPythonErrorFuncHandler
== Py_None
)) {
1829 virDefaultErrorFunc(err
);
1831 if ((list
= PyTuple_New(2)) == NULL
)
1834 Py_XINCREF(libvirt_virPythonErrorFuncCtxt
);
1835 VIR_PY_TUPLE_SET_GOTO(list
, 0, libvirt_virPythonErrorFuncCtxt
, cleanup
);
1837 if ((info
= PyTuple_New(9)) == NULL
)
1840 VIR_PY_TUPLE_SET_GOTO(list
, 1, info
, cleanup
);
1842 VIR_PY_TUPLE_SET_GOTO(info
, 0, libvirt_intWrap((long)err
->code
), cleanup
);
1843 VIR_PY_TUPLE_SET_GOTO(info
, 1, libvirt_intWrap((long)err
->domain
), cleanup
);
1844 VIR_PY_TUPLE_SET_GOTO(info
, 2, libvirt_constcharPtrWrap(err
->message
), cleanup
);
1845 VIR_PY_TUPLE_SET_GOTO(info
, 3, libvirt_intWrap((long)err
->level
), cleanup
);
1846 VIR_PY_TUPLE_SET_GOTO(info
, 4, libvirt_constcharPtrWrap(err
->str1
), cleanup
);
1847 VIR_PY_TUPLE_SET_GOTO(info
, 5, libvirt_constcharPtrWrap(err
->str2
), cleanup
);
1848 VIR_PY_TUPLE_SET_GOTO(info
, 6, libvirt_constcharPtrWrap(err
->str3
), cleanup
);
1849 VIR_PY_TUPLE_SET_GOTO(info
, 7, libvirt_intWrap((long)err
->int1
), cleanup
);
1850 VIR_PY_TUPLE_SET_GOTO(info
, 8, libvirt_intWrap((long)err
->int2
), cleanup
);
1852 /* TODO pass conn and dom if available */
1853 result
= PyEval_CallObject(libvirt_virPythonErrorFuncHandler
, list
);
1859 LIBVIRT_RELEASE_THREAD_STATE
;
1863 libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject
*self
,
1866 PyObject
*py_retval
;
1868 PyObject
*pyobj_ctx
;
1870 if (!PyArg_ParseTuple(args
, (char *) "OO:virRegisterErrorHandler",
1871 &pyobj_f
, &pyobj_ctx
))
1874 DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx
,
1877 virSetErrorFunc(NULL
, libvirt_virErrorFuncHandler
);
1879 Py_XDECREF(libvirt_virPythonErrorFuncHandler
);
1880 Py_XDECREF(libvirt_virPythonErrorFuncCtxt
);
1882 if ((pyobj_f
== Py_None
) && (pyobj_ctx
== Py_None
)) {
1883 libvirt_virPythonErrorFuncHandler
= NULL
;
1884 libvirt_virPythonErrorFuncCtxt
= NULL
;
1886 Py_XINCREF(pyobj_ctx
);
1887 Py_XINCREF(pyobj_f
);
1889 /* TODO: check f is a function ! */
1890 libvirt_virPythonErrorFuncHandler
= pyobj_f
;
1891 libvirt_virPythonErrorFuncCtxt
= pyobj_ctx
;
1894 py_retval
= libvirt_intWrap(1);
1899 virConnectCredCallbackWrapper(virConnectCredentialPtr cred
,
1903 PyObject
*list
= NULL
;
1905 PyObject
*pyauth
= (PyObject
*)cbdata
;
1908 PyObject
*pyret
= NULL
;
1912 LIBVIRT_ENSURE_THREAD_STATE
;
1914 pycb
= PyList_GetItem(pyauth
, 1);
1915 pycbdata
= PyList_GetItem(pyauth
, 2);
1917 if ((list
= PyTuple_New(2)) == NULL
)
1920 if ((pycred
= PyTuple_New(ncred
)) == NULL
)
1923 VIR_PY_TUPLE_SET_GOTO(list
, 0, pycred
, cleanup
);
1925 for (i
= 0; i
< ncred
; i
++) {
1926 PyObject
*pycreditem
;
1927 if ((pycreditem
= PyList_New(5)) == NULL
)
1930 VIR_PY_TUPLE_SET_GOTO(pycred
, i
, pycreditem
, cleanup
);
1932 VIR_PY_LIST_SET_GOTO(pycreditem
, 0,
1933 libvirt_intWrap((long)cred
[i
].type
), cleanup
);
1934 VIR_PY_LIST_SET_GOTO(pycreditem
, 1,
1935 libvirt_constcharPtrWrap(cred
[i
].prompt
), cleanup
);
1937 if (cred
[i
].challenge
) {
1938 VIR_PY_LIST_SET_GOTO(pycreditem
, 2,
1939 libvirt_constcharPtrWrap(cred
[i
].challenge
),
1942 VIR_PY_LIST_SET_GOTO(pycreditem
, 2, VIR_PY_NONE
, cleanup
);
1944 if (cred
[i
].defresult
) {
1945 VIR_PY_LIST_SET_GOTO(pycreditem
, 3,
1946 libvirt_constcharPtrWrap(cred
[i
].defresult
),
1949 VIR_PY_LIST_SET_GOTO(pycreditem
, 3, VIR_PY_NONE
, cleanup
);
1951 VIR_PY_LIST_SET_GOTO(pycreditem
, 4, VIR_PY_NONE
, cleanup
);
1954 Py_XINCREF(pycbdata
);
1955 VIR_PY_TUPLE_SET_GOTO(list
, 1, pycbdata
, cleanup
);
1958 pyret
= PyEval_CallObject(pycb
, list
);
1959 if (PyErr_Occurred()) {
1964 ret
= PyLong_AsLong(pyret
);
1966 for (i
= 0; i
< ncred
; i
++) {
1967 PyObject
*pycreditem
;
1969 char *result
= NULL
;
1970 pycreditem
= PyTuple_GetItem(pycred
, i
);
1971 pyresult
= PyList_GetItem(pycreditem
, 4);
1972 if (pyresult
!= Py_None
) {
1973 libvirt_charPtrUnwrap(pyresult
, &result
);
1976 if (result
!= NULL
) {
1977 cred
[i
].result
= result
;
1978 cred
[i
].resultlen
= strlen(result
);
1980 cred
[i
].result
= NULL
;
1981 cred
[i
].resultlen
= 0;
1990 LIBVIRT_RELEASE_THREAD_STATE
;
1997 libvirt_virConnectOpenAuth(PyObject
*self ATTRIBUTE_UNUSED
,
2000 PyObject
*py_retval
;
2001 virConnectPtr c_retval
;
2006 PyObject
*pycredtype
;
2007 virConnectAuth auth
;
2009 memset(&auth
, 0, sizeof(auth
));
2010 if (!PyArg_ParseTuple(args
, (char *)"zOI:virConnectOpenAuth",
2011 &name
, &pyauth
, &flags
))
2014 pycredtype
= PyList_GetItem(pyauth
, 0);
2015 pycredcb
= PyList_GetItem(pyauth
, 1);
2017 auth
.ncredtype
= PyList_Size(pycredtype
);
2018 if (auth
.ncredtype
) {
2020 if (VIR_ALLOC_N(auth
.credtype
, auth
.ncredtype
) < 0)
2021 return PyErr_NoMemory();
2022 for (i
= 0; i
< auth
.ncredtype
; i
++) {
2024 val
= PyList_GetItem(pycredtype
, i
);
2025 auth
.credtype
[i
] = (int)PyLong_AsLong(val
);
2028 if (pycredcb
&& pycredcb
!= Py_None
)
2029 auth
.cb
= virConnectCredCallbackWrapper
;
2030 auth
.cbdata
= pyauth
;
2032 LIBVIRT_BEGIN_ALLOW_THREADS
;
2033 c_retval
= virConnectOpenAuth(name
, &auth
, flags
);
2034 LIBVIRT_END_ALLOW_THREADS
;
2036 VIR_FREE(auth
.credtype
);
2037 py_retval
= libvirt_virConnectPtrWrap((virConnectPtr
) c_retval
);
2042 /************************************************************************
2044 * Wrappers for functions where generator fails *
2046 ************************************************************************/
2049 libvirt_virGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2053 unsigned long libVer
, typeVer
= 0;
2056 if (!PyArg_ParseTuple(args
, (char *) "|s:virGetVersion", &type
))
2059 LIBVIRT_BEGIN_ALLOW_THREADS
;
2061 c_retval
= virGetVersion(&libVer
, NULL
, NULL
);
2063 c_retval
= virGetVersion(&libVer
, type
, &typeVer
);
2064 LIBVIRT_END_ALLOW_THREADS
;
2070 return libvirt_intWrap(libVer
);
2072 return Py_BuildValue((char *) "kk", libVer
, typeVer
);
2076 libvirt_virConnectGetVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2079 unsigned long hvVersion
;
2082 PyObject
*pyobj_conn
;
2084 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetVersion",
2087 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2089 LIBVIRT_BEGIN_ALLOW_THREADS
;
2090 c_retval
= virConnectGetVersion(conn
, &hvVersion
);
2091 LIBVIRT_END_ALLOW_THREADS
;
2094 return VIR_PY_INT_FAIL
;
2096 return libvirt_intWrap(hvVersion
);
2099 #if LIBVIR_CHECK_VERSION(1, 1, 3)
2101 libvirt_virConnectGetCPUModelNames(PyObject
*self ATTRIBUTE_UNUSED
,
2106 PyObject
*rv
= NULL
, *pyobj_conn
;
2107 char **models
= NULL
;
2109 unsigned int flags
= 0;
2110 const char *arch
= NULL
;
2112 if (!PyArg_ParseTuple(args
, (char *)"OsI:virConnectGetCPUModelNames",
2113 &pyobj_conn
, &arch
, &flags
))
2115 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2117 LIBVIRT_BEGIN_ALLOW_THREADS
;
2118 c_retval
= virConnectGetCPUModelNames(conn
, arch
, &models
, flags
);
2119 LIBVIRT_END_ALLOW_THREADS
;
2124 if ((rv
= PyList_New(c_retval
)) == NULL
)
2127 for (i
= 0; i
< c_retval
; i
++)
2128 VIR_PY_LIST_SET_GOTO(rv
, i
, libvirt_constcharPtrWrap(models
[i
]), error
);
2132 for (i
= 0; i
< c_retval
; i
++)
2133 VIR_FREE(models
[i
]);
2143 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
2146 libvirt_virConnectGetLibVersion(PyObject
*self ATTRIBUTE_UNUSED
,
2149 unsigned long libVer
;
2152 PyObject
*pyobj_conn
;
2154 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectGetLibVersion",
2157 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2159 LIBVIRT_BEGIN_ALLOW_THREADS
;
2160 c_retval
= virConnectGetLibVersion(conn
, &libVer
);
2161 LIBVIRT_END_ALLOW_THREADS
;
2164 return VIR_PY_INT_FAIL
;
2166 return libvirt_intWrap(libVer
);
2170 libvirt_virConnectListDomainsID(PyObject
*self ATTRIBUTE_UNUSED
,
2173 PyObject
*py_retval
;
2174 int *ids
= NULL
, c_retval
;
2177 PyObject
*pyobj_conn
;
2180 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDomains", &pyobj_conn
))
2182 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2184 LIBVIRT_BEGIN_ALLOW_THREADS
;
2185 c_retval
= virConnectNumOfDomains(conn
);
2186 LIBVIRT_END_ALLOW_THREADS
;
2192 if (VIR_ALLOC_N(ids
, c_retval
) < 0)
2193 return PyErr_NoMemory();
2195 LIBVIRT_BEGIN_ALLOW_THREADS
;
2196 c_retval
= virConnectListDomains(conn
, ids
, c_retval
);
2197 LIBVIRT_END_ALLOW_THREADS
;
2200 py_retval
= VIR_PY_NONE
;
2205 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2209 for (i
= 0; i
< c_retval
; i
++)
2210 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_intWrap(ids
[i
]), error
);
2218 Py_XDECREF(py_retval
);
2222 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2224 libvirt_virConnectListAllDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2227 PyObject
*pyobj_conn
;
2228 PyObject
*py_retval
= NULL
;
2230 virDomainPtr
*doms
= NULL
;
2235 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllDomains",
2236 &pyobj_conn
, &flags
))
2238 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2240 LIBVIRT_BEGIN_ALLOW_THREADS
;
2241 c_retval
= virConnectListAllDomains(conn
, &doms
, flags
);
2242 LIBVIRT_END_ALLOW_THREADS
;
2247 if (!(py_retval
= PyList_New(c_retval
)))
2250 for (i
= 0; i
< c_retval
; i
++) {
2251 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_virDomainPtrWrap(doms
[i
]), error
);
2252 /* python steals the pointer */
2257 for (i
= 0; i
< c_retval
; i
++)
2259 virDomainFree(doms
[i
]);
2264 Py_CLEAR(py_retval
);
2267 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2270 libvirt_virConnectListDefinedDomains(PyObject
*self ATTRIBUTE_UNUSED
,
2273 PyObject
*py_retval
;
2274 char **names
= NULL
;
2278 PyObject
*pyobj_conn
;
2281 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedDomains",
2284 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2286 LIBVIRT_BEGIN_ALLOW_THREADS
;
2287 c_retval
= virConnectNumOfDefinedDomains(conn
);
2288 LIBVIRT_END_ALLOW_THREADS
;
2294 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2295 return PyErr_NoMemory();
2297 LIBVIRT_BEGIN_ALLOW_THREADS
;
2298 c_retval
= virConnectListDefinedDomains(conn
, names
, c_retval
);
2299 LIBVIRT_END_ALLOW_THREADS
;
2302 py_retval
= VIR_PY_NONE
;
2307 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2311 for (i
= 0; i
< c_retval
; i
++)
2312 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2313 libvirt_constcharPtrWrap(names
[i
]), error
);
2318 for (i
= 0; i
< c_retval
; i
++)
2324 Py_CLEAR(py_retval
);
2328 #if LIBVIR_CHECK_VERSION(5, 1, 0)
2330 libvirt_virDomainListAllCheckpoints(PyObject
*self ATTRIBUTE_UNUSED
,
2333 PyObject
*py_retval
= NULL
;
2334 virDomainCheckpointPtr
*chks
= NULL
;
2338 PyObject
*pyobj_dom
;
2341 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainListAllCheckpoints",
2342 &pyobj_dom
, &flags
))
2344 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2346 LIBVIRT_BEGIN_ALLOW_THREADS
;
2347 c_retval
= virDomainListAllCheckpoints(dom
, &chks
, flags
);
2348 LIBVIRT_END_ALLOW_THREADS
;
2353 if (!(py_retval
= PyList_New(c_retval
)))
2356 for (i
= 0; i
< c_retval
; i
++) {
2357 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2358 libvirt_virDomainCheckpointPtrWrap(chks
[i
]), error
);
2363 for (i
= 0; i
< c_retval
; i
++)
2365 virDomainCheckpointFree(chks
[i
]);
2370 Py_CLEAR(py_retval
);
2375 libvirt_virDomainCheckpointListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2378 PyObject
*py_retval
= NULL
;
2379 virDomainCheckpointPtr
*chks
= NULL
;
2382 virDomainCheckpointPtr parent
;
2383 PyObject
*pyobj_parent
;
2386 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainCheckpointListAllChildren",
2387 &pyobj_parent
, &flags
))
2389 parent
= (virDomainCheckpointPtr
) PyvirDomainCheckpoint_Get(pyobj_parent
);
2391 LIBVIRT_BEGIN_ALLOW_THREADS
;
2392 c_retval
= virDomainCheckpointListAllChildren(parent
, &chks
, flags
);
2393 LIBVIRT_END_ALLOW_THREADS
;
2398 if (!(py_retval
= PyList_New(c_retval
)))
2401 for (i
= 0; i
< c_retval
; i
++) {
2402 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2403 libvirt_virDomainCheckpointPtrWrap(chks
[i
]), error
);
2408 for (i
= 0; i
< c_retval
; i
++)
2410 virDomainCheckpointFree(chks
[i
]);
2415 Py_CLEAR(py_retval
);
2418 #endif /* LIBVIR_CHECK_VERSION(5, 1, 0) */
2421 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2424 PyObject
*py_retval
;
2425 char **names
= NULL
;
2429 PyObject
*pyobj_dom
;
2432 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListNames",
2433 &pyobj_dom
, &flags
))
2435 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2437 LIBVIRT_BEGIN_ALLOW_THREADS
;
2438 c_retval
= virDomainSnapshotNum(dom
, flags
);
2439 LIBVIRT_END_ALLOW_THREADS
;
2445 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2446 return PyErr_NoMemory();
2448 LIBVIRT_BEGIN_ALLOW_THREADS
;
2449 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2450 LIBVIRT_END_ALLOW_THREADS
;
2453 py_retval
= VIR_PY_NONE
;
2457 py_retval
= PyList_New(c_retval
);
2461 for (i
= 0; i
< c_retval
; i
++)
2462 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2466 for (i
= 0; i
< c_retval
; i
++)
2472 Py_CLEAR(py_retval
);
2476 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2478 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2481 PyObject
*py_retval
= NULL
;
2482 virDomainSnapshotPtr
*snaps
= NULL
;
2486 PyObject
*pyobj_dom
;
2489 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainListAllSnapshots",
2490 &pyobj_dom
, &flags
))
2492 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2494 LIBVIRT_BEGIN_ALLOW_THREADS
;
2495 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2496 LIBVIRT_END_ALLOW_THREADS
;
2501 if (!(py_retval
= PyList_New(c_retval
)))
2504 for (i
= 0; i
< c_retval
; i
++) {
2505 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2506 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2511 for (i
= 0; i
< c_retval
; i
++)
2513 virDomainSnapshotFree(snaps
[i
]);
2518 Py_CLEAR(py_retval
);
2521 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2524 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2527 PyObject
*py_retval
;
2528 char **names
= NULL
;
2531 virDomainSnapshotPtr snap
;
2532 PyObject
*pyobj_snap
;
2535 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListChildrenNames",
2536 &pyobj_snap
, &flags
))
2538 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2540 LIBVIRT_BEGIN_ALLOW_THREADS
;
2541 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2542 LIBVIRT_END_ALLOW_THREADS
;
2548 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2549 return PyErr_NoMemory();
2551 LIBVIRT_BEGIN_ALLOW_THREADS
;
2552 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2554 LIBVIRT_END_ALLOW_THREADS
;
2557 py_retval
= VIR_PY_NONE
;
2562 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2565 for (i
= 0; i
< c_retval
; i
++)
2566 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2570 for (i
= 0; i
< c_retval
; i
++)
2576 Py_CLEAR(py_retval
);
2580 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2582 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2585 PyObject
*py_retval
= NULL
;
2586 virDomainSnapshotPtr
*snaps
= NULL
;
2589 virDomainSnapshotPtr parent
;
2590 PyObject
*pyobj_parent
;
2593 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListAllChildren",
2594 &pyobj_parent
, &flags
))
2596 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2598 LIBVIRT_BEGIN_ALLOW_THREADS
;
2599 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2600 LIBVIRT_END_ALLOW_THREADS
;
2605 if (!(py_retval
= PyList_New(c_retval
)))
2608 for (i
= 0; i
< c_retval
; i
++) {
2609 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2610 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2615 for (i
= 0; i
< c_retval
; i
++)
2617 virDomainSnapshotFree(snaps
[i
]);
2622 Py_CLEAR(py_retval
);
2625 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2628 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2632 virDomainSnapshotPtr snap
;
2633 PyObject
*pyobj_snap
;
2634 PyObject
*pyobj_dom
;
2637 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainRevertToSnapshot",
2638 &pyobj_dom
, &pyobj_snap
, &flags
))
2640 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2642 LIBVIRT_BEGIN_ALLOW_THREADS
;
2643 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2644 LIBVIRT_END_ALLOW_THREADS
;
2647 return VIR_PY_INT_FAIL
;
2649 return libvirt_intWrap(c_retval
);
2653 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2656 PyObject
*py_retval
;
2658 virDomainPtr domain
;
2659 PyObject
*pyobj_domain
;
2662 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2664 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2666 LIBVIRT_BEGIN_ALLOW_THREADS
;
2667 c_retval
= virDomainGetInfo(domain
, &info
);
2668 LIBVIRT_END_ALLOW_THREADS
;
2673 if ((py_retval
= PyList_New(5)) == NULL
)
2676 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap((int) info
.state
), error
);
2677 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
), error
);
2678 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_ulongWrap(info
.memory
), error
);
2679 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
2680 libvirt_intWrap((int) info
.nrVirtCpu
), error
);
2681 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
2682 libvirt_ulonglongWrap(info
.cpuTime
), error
);
2687 Py_XDECREF(py_retval
);
2692 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
,
2695 PyObject
*py_retval
;
2697 virDomainPtr domain
;
2698 PyObject
*pyobj_domain
;
2703 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetState",
2704 &pyobj_domain
, &flags
))
2707 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2709 LIBVIRT_BEGIN_ALLOW_THREADS
;
2710 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2711 LIBVIRT_END_ALLOW_THREADS
;
2716 if ((py_retval
= PyList_New(2)) == NULL
)
2719 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(state
), error
);
2720 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(reason
), error
);
2725 Py_XDECREF(py_retval
);
2730 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2733 PyObject
*py_retval
;
2735 virDomainPtr domain
;
2736 PyObject
*pyobj_domain
;
2737 virDomainControlInfo info
;
2740 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetControlInfo",
2741 &pyobj_domain
, &flags
))
2743 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2745 LIBVIRT_BEGIN_ALLOW_THREADS
;
2746 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2747 LIBVIRT_END_ALLOW_THREADS
;
2752 if ((py_retval
= PyList_New(3)) == NULL
)
2755 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(info
.state
), error
);
2756 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(info
.details
), error
);
2757 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2758 libvirt_ulonglongWrap(info
.stateTime
), error
);
2763 Py_XDECREF(py_retval
);
2768 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2771 PyObject
*py_retval
;
2773 virDomainPtr domain
;
2774 PyObject
*pyobj_domain
;
2775 virDomainBlockInfo info
;
2779 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockInfo",
2780 &pyobj_domain
, &path
, &flags
))
2782 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2784 LIBVIRT_BEGIN_ALLOW_THREADS
;
2785 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2786 LIBVIRT_END_ALLOW_THREADS
;
2791 if ((py_retval
= PyList_New(3)) == NULL
)
2794 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2795 libvirt_ulonglongWrap(info
.capacity
), error
);
2796 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2797 libvirt_ulonglongWrap(info
.allocation
), error
);
2798 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2799 libvirt_ulonglongWrap(info
.physical
), error
);
2804 Py_XDECREF(py_retval
);
2809 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2812 PyObject
*py_retval
;
2815 PyObject
*pyobj_conn
;
2818 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeGetInfo", &pyobj_conn
))
2820 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2822 LIBVIRT_BEGIN_ALLOW_THREADS
;
2823 c_retval
= virNodeGetInfo(conn
, &info
);
2824 LIBVIRT_END_ALLOW_THREADS
;
2829 if ((py_retval
= PyList_New(8)) == NULL
)
2832 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2833 libvirt_constcharPtrWrap(&info
.model
[0]), error
);
2834 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2835 libvirt_longWrap((long) info
.memory
>> 10), error
);
2836 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_intWrap((int) info
.cpus
), error
);
2837 VIR_PY_LIST_SET_GOTO(py_retval
, 3, libvirt_intWrap((int) info
.mhz
), error
);
2838 VIR_PY_LIST_SET_GOTO(py_retval
, 4, libvirt_intWrap((int) info
.nodes
), error
);
2839 VIR_PY_LIST_SET_GOTO(py_retval
, 5, libvirt_intWrap((int) info
.sockets
), error
);
2840 VIR_PY_LIST_SET_GOTO(py_retval
, 6, libvirt_intWrap((int) info
.cores
), error
);
2841 VIR_PY_LIST_SET_GOTO(py_retval
, 7, libvirt_intWrap((int) info
.threads
), error
);
2846 Py_XDECREF(py_retval
);
2851 libvirt_virNodeGetSecurityModel(PyObject
*self ATTRIBUTE_UNUSED
,
2854 PyObject
*py_retval
;
2857 PyObject
*pyobj_conn
;
2858 virSecurityModel model
;
2860 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityModel",
2863 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2865 LIBVIRT_BEGIN_ALLOW_THREADS
;
2866 c_retval
= virNodeGetSecurityModel(conn
, &model
);
2867 LIBVIRT_END_ALLOW_THREADS
;
2872 if ((py_retval
= PyList_New(2)) == NULL
)
2875 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2876 libvirt_constcharPtrWrap(&model
.model
[0]), error
);
2877 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2878 libvirt_constcharPtrWrap(&model
.doi
[0]), error
);
2883 Py_XDECREF(py_retval
);
2888 libvirt_virDomainGetSecurityLabel(PyObject
*self ATTRIBUTE_UNUSED
,
2891 PyObject
*py_retval
;
2894 PyObject
*pyobj_dom
;
2895 virSecurityLabel label
;
2897 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabel",
2900 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2902 LIBVIRT_BEGIN_ALLOW_THREADS
;
2903 c_retval
= virDomainGetSecurityLabel(dom
, &label
);
2904 LIBVIRT_END_ALLOW_THREADS
;
2909 if ((py_retval
= PyList_New(2)) == NULL
)
2912 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2913 libvirt_constcharPtrWrap(&label
.label
[0]), error
);
2914 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2915 libvirt_boolWrap(label
.enforcing
), error
);
2920 Py_XDECREF(py_retval
);
2924 #if LIBVIR_CHECK_VERSION(0, 10, 0)
2926 libvirt_virDomainGetSecurityLabelList(PyObject
*self ATTRIBUTE_UNUSED
,
2929 PyObject
*py_retval
;
2932 PyObject
*pyobj_dom
;
2933 virSecurityLabel
*labels
= NULL
;
2936 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabelList",
2940 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2942 LIBVIRT_BEGIN_ALLOW_THREADS
;
2943 c_retval
= virDomainGetSecurityLabelList(dom
, &labels
);
2944 LIBVIRT_END_ALLOW_THREADS
;
2949 if (!(py_retval
= PyList_New(0)))
2952 for (i
= 0 ; i
< c_retval
; i
++) {
2955 if (!(entry
= PyList_New(2)))
2958 VIR_PY_LIST_APPEND_GOTO(py_retval
, entry
, error
);
2960 VIR_PY_LIST_SET_GOTO(entry
, 0,
2961 libvirt_constcharPtrWrap(&labels
[i
].label
[0]),
2963 VIR_PY_LIST_SET_GOTO(entry
, 1,
2964 libvirt_boolWrap(labels
[i
].enforcing
), error
);
2972 Py_CLEAR(py_retval
);
2975 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
2978 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
2981 unsigned char uuid
[VIR_UUID_BUFLEN
];
2982 virDomainPtr domain
;
2983 PyObject
*pyobj_domain
;
2986 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2988 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2993 LIBVIRT_BEGIN_ALLOW_THREADS
;
2994 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
2995 LIBVIRT_END_ALLOW_THREADS
;
3000 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3004 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3007 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3009 PyObject
*pyobj_dom
;
3012 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
3015 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
3020 LIBVIRT_BEGIN_ALLOW_THREADS
;
3021 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
3022 LIBVIRT_END_ALLOW_THREADS
;
3027 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3031 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3034 virDomainPtr c_retval
;
3036 PyObject
*pyobj_conn
;
3037 unsigned char * uuid
;
3040 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID",
3041 &pyobj_conn
, &uuid
, &len
))
3043 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3045 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3048 LIBVIRT_BEGIN_ALLOW_THREADS
;
3049 c_retval
= virDomainLookupByUUID(conn
, uuid
);
3050 LIBVIRT_END_ALLOW_THREADS
;
3052 return libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
3057 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3060 PyObject
*py_retval
;
3061 char **names
= NULL
;
3065 PyObject
*pyobj_conn
;
3068 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks",
3071 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3073 LIBVIRT_BEGIN_ALLOW_THREADS
;
3074 c_retval
= virConnectNumOfNetworks(conn
);
3075 LIBVIRT_END_ALLOW_THREADS
;
3081 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3082 return PyErr_NoMemory();
3084 LIBVIRT_BEGIN_ALLOW_THREADS
;
3085 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
3086 LIBVIRT_END_ALLOW_THREADS
;
3089 py_retval
= VIR_PY_NONE
;
3094 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3098 for (i
= 0; i
< c_retval
; i
++)
3099 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3100 libvirt_constcharPtrWrap(names
[i
]), error
);
3104 for (i
= 0; i
< c_retval
; i
++)
3110 Py_CLEAR(py_retval
);
3116 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3119 PyObject
*py_retval
;
3120 char **names
= NULL
;
3124 PyObject
*pyobj_conn
;
3127 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks",
3130 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3132 LIBVIRT_BEGIN_ALLOW_THREADS
;
3133 c_retval
= virConnectNumOfDefinedNetworks(conn
);
3134 LIBVIRT_END_ALLOW_THREADS
;
3140 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3141 return PyErr_NoMemory();
3143 LIBVIRT_BEGIN_ALLOW_THREADS
;
3144 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
3145 LIBVIRT_END_ALLOW_THREADS
;
3148 py_retval
= VIR_PY_NONE
;
3153 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3156 for (i
= 0; i
< c_retval
; i
++)
3157 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3158 libvirt_constcharPtrWrap(names
[i
]), error
);
3162 for (i
= 0; i
< c_retval
; i
++)
3168 Py_CLEAR(py_retval
);
3172 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3174 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3177 PyObject
*pyobj_conn
;
3178 PyObject
*py_retval
= NULL
;
3180 virNetworkPtr
*nets
= NULL
;
3185 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNetworks",
3186 &pyobj_conn
, &flags
))
3188 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3190 LIBVIRT_BEGIN_ALLOW_THREADS
;
3191 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
3192 LIBVIRT_END_ALLOW_THREADS
;
3197 if (!(py_retval
= PyList_New(c_retval
)))
3200 for (i
= 0; i
< c_retval
; i
++) {
3201 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3202 libvirt_virNetworkPtrWrap(nets
[i
]), error
);
3207 for (i
= 0; i
< c_retval
; i
++)
3209 virNetworkFree(nets
[i
]);
3214 Py_CLEAR(py_retval
);
3217 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3221 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3224 unsigned char uuid
[VIR_UUID_BUFLEN
];
3225 virNetworkPtr domain
;
3226 PyObject
*pyobj_domain
;
3229 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
3231 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
3236 LIBVIRT_BEGIN_ALLOW_THREADS
;
3237 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
3238 LIBVIRT_END_ALLOW_THREADS
;
3243 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3247 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3250 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3252 PyObject
*pyobj_net
;
3255 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
3258 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
3263 LIBVIRT_BEGIN_ALLOW_THREADS
;
3264 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
3265 LIBVIRT_END_ALLOW_THREADS
;
3270 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3274 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3277 virNetworkPtr c_retval
;
3279 PyObject
*pyobj_conn
;
3280 unsigned char * uuid
;
3283 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID",
3284 &pyobj_conn
, &uuid
, &len
))
3286 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3288 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3291 LIBVIRT_BEGIN_ALLOW_THREADS
;
3292 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
3293 LIBVIRT_END_ALLOW_THREADS
;
3295 return libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
3300 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3303 int c_retval
, autostart
;
3304 virDomainPtr domain
;
3305 PyObject
*pyobj_domain
;
3307 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart",
3311 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3313 LIBVIRT_BEGIN_ALLOW_THREADS
;
3314 c_retval
= virDomainGetAutostart(domain
, &autostart
);
3315 LIBVIRT_END_ALLOW_THREADS
;
3318 return VIR_PY_INT_FAIL
;
3320 return libvirt_intWrap(autostart
);
3325 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3328 int c_retval
, autostart
;
3329 virNetworkPtr network
;
3330 PyObject
*pyobj_network
;
3332 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart",
3336 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
3338 LIBVIRT_BEGIN_ALLOW_THREADS
;
3339 c_retval
= virNetworkGetAutostart(network
, &autostart
);
3340 LIBVIRT_END_ALLOW_THREADS
;
3343 return VIR_PY_INT_FAIL
;
3345 return libvirt_intWrap(autostart
);
3349 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
,
3352 PyObject
*py_retval
;
3353 PyObject
*pyobj_conn
;
3354 int startCell
, maxCells
, c_retval
;
3357 unsigned long long *freeMems
;
3359 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory",
3360 &pyobj_conn
, &startCell
, &maxCells
))
3363 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
3366 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3367 if (VIR_ALLOC_N(freeMems
, maxCells
) < 0)
3368 return PyErr_NoMemory();
3370 LIBVIRT_BEGIN_ALLOW_THREADS
;
3371 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
3372 LIBVIRT_END_ALLOW_THREADS
;
3375 py_retval
= VIR_PY_NONE
;
3379 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3382 for (i
= 0; i
< c_retval
; i
++)
3383 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3384 libvirt_ulonglongWrap(freeMems
[i
]), error
);
3391 Py_CLEAR(py_retval
);
3396 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
,
3399 PyObject
*ret
= NULL
;
3400 PyObject
*key
= NULL
;
3401 PyObject
*val
= NULL
;
3402 PyObject
*pyobj_conn
;
3405 int cpuNum
, c_retval
;
3408 virNodeCPUStatsPtr stats
= NULL
;
3410 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetCPUStats",
3411 &pyobj_conn
, &cpuNum
, &flags
))
3413 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3415 LIBVIRT_BEGIN_ALLOW_THREADS
;
3416 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
3417 LIBVIRT_END_ALLOW_THREADS
;
3423 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3424 return PyErr_NoMemory();
3426 LIBVIRT_BEGIN_ALLOW_THREADS
;
3427 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
3428 LIBVIRT_END_ALLOW_THREADS
;
3436 if (!(ret
= PyDict_New()))
3439 for (i
= 0; i
< nparams
; i
++) {
3440 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3441 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3443 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3456 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
,
3459 PyObject
*ret
= NULL
;
3460 PyObject
*key
= NULL
;
3461 PyObject
*val
= NULL
;
3462 PyObject
*pyobj_conn
;
3465 int cellNum
, c_retval
;
3468 virNodeMemoryStatsPtr stats
= NULL
;
3470 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetMemoryStats",
3471 &pyobj_conn
, &cellNum
, &flags
))
3473 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3475 LIBVIRT_BEGIN_ALLOW_THREADS
;
3476 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
3477 LIBVIRT_END_ALLOW_THREADS
;
3483 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3484 return PyErr_NoMemory();
3486 LIBVIRT_BEGIN_ALLOW_THREADS
;
3487 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
3488 LIBVIRT_END_ALLOW_THREADS
;
3496 if (!(ret
= PyDict_New()))
3499 for (i
= 0; i
< nparams
; i
++) {
3500 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3501 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3503 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3516 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3519 PyObject
*py_retval
;
3520 char **names
= NULL
;
3524 PyObject
*pyobj_conn
;
3526 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools",
3529 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3531 LIBVIRT_BEGIN_ALLOW_THREADS
;
3532 c_retval
= virConnectNumOfStoragePools(conn
);
3533 LIBVIRT_END_ALLOW_THREADS
;
3539 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3540 return PyErr_NoMemory();
3542 LIBVIRT_BEGIN_ALLOW_THREADS
;
3543 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
3544 LIBVIRT_END_ALLOW_THREADS
;
3547 py_retval
= VIR_PY_NONE
;
3552 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3555 for (i
= 0; i
< c_retval
; i
++)
3556 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3557 libvirt_constcharPtrWrap(names
[i
]), error
);
3561 for (i
= 0; i
< c_retval
; i
++)
3567 Py_CLEAR(py_retval
);
3573 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3576 PyObject
*py_retval
;
3577 char **names
= NULL
;
3581 PyObject
*pyobj_conn
;
3583 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools",
3586 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3588 LIBVIRT_BEGIN_ALLOW_THREADS
;
3589 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3590 LIBVIRT_END_ALLOW_THREADS
;
3596 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3597 return PyErr_NoMemory();
3599 LIBVIRT_BEGIN_ALLOW_THREADS
;
3600 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3601 LIBVIRT_END_ALLOW_THREADS
;
3604 py_retval
= VIR_PY_NONE
;
3609 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3613 for (i
= 0; i
< c_retval
; i
++)
3614 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3615 libvirt_constcharPtrWrap(names
[i
]), error
);
3620 for (i
= 0; i
< c_retval
; i
++)
3626 Py_CLEAR(py_retval
);
3630 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3632 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3635 PyObject
*pyobj_conn
;
3636 PyObject
*py_retval
= NULL
;
3638 virStoragePoolPtr
*pools
= NULL
;
3643 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllStoragePools",
3644 &pyobj_conn
, &flags
))
3646 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3648 LIBVIRT_BEGIN_ALLOW_THREADS
;
3649 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3650 LIBVIRT_END_ALLOW_THREADS
;
3655 if (!(py_retval
= PyList_New(c_retval
)))
3658 for (i
= 0; i
< c_retval
; i
++) {
3659 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3660 libvirt_virStoragePoolPtrWrap(pools
[i
]), error
);
3661 /* python steals the pointer */
3666 for (i
= 0; i
< c_retval
; i
++)
3668 virStoragePoolFree(pools
[i
]);
3673 Py_CLEAR(py_retval
);
3676 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3679 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3682 PyObject
*py_retval
;
3683 char **names
= NULL
;
3686 virStoragePoolPtr pool
;
3687 PyObject
*pyobj_pool
;
3689 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes",
3692 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3694 LIBVIRT_BEGIN_ALLOW_THREADS
;
3695 c_retval
= virStoragePoolNumOfVolumes(pool
);
3696 LIBVIRT_END_ALLOW_THREADS
;
3702 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3703 return PyErr_NoMemory();
3705 LIBVIRT_BEGIN_ALLOW_THREADS
;
3706 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3707 LIBVIRT_END_ALLOW_THREADS
;
3710 py_retval
= VIR_PY_NONE
;
3715 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3719 for (i
= 0; i
< c_retval
; i
++)
3720 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3721 libvirt_constcharPtrWrap(names
[i
]), error
);
3725 for (i
= 0; i
< c_retval
; i
++)
3731 Py_CLEAR(py_retval
);
3735 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3737 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3740 PyObject
*py_retval
= NULL
;
3741 virStoragePoolPtr pool
;
3742 virStorageVolPtr
*vols
= NULL
;
3746 PyObject
*pyobj_pool
;
3748 if (!PyArg_ParseTuple(args
, (char *)"OI:virStoragePoolListAllVolumes",
3749 &pyobj_pool
, &flags
))
3752 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3754 LIBVIRT_BEGIN_ALLOW_THREADS
;
3755 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3756 LIBVIRT_END_ALLOW_THREADS
;
3761 if (!(py_retval
= PyList_New(c_retval
)))
3764 for (i
= 0; i
< c_retval
; i
++) {
3765 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3766 libvirt_virStorageVolPtrWrap(vols
[i
]), error
);
3767 /* python steals the pointer */
3772 for (i
= 0; i
< c_retval
; i
++)
3774 virStorageVolFree(vols
[i
]);
3779 Py_CLEAR(py_retval
);
3782 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3786 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3789 int c_retval
, autostart
;
3790 virStoragePoolPtr pool
;
3791 PyObject
*pyobj_pool
;
3793 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart",
3797 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3799 LIBVIRT_BEGIN_ALLOW_THREADS
;
3800 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3801 LIBVIRT_END_ALLOW_THREADS
;
3804 return VIR_PY_INT_FAIL
;
3806 return libvirt_intWrap(autostart
);
3810 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3813 PyObject
*py_retval
;
3815 virStoragePoolPtr pool
;
3816 PyObject
*pyobj_pool
;
3817 virStoragePoolInfo info
;
3819 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3821 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3823 LIBVIRT_BEGIN_ALLOW_THREADS
;
3824 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3825 LIBVIRT_END_ALLOW_THREADS
;
3830 if ((py_retval
= PyList_New(4)) == NULL
)
3833 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3834 libvirt_intWrap((int) info
.state
), error
);
3835 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3836 libvirt_ulonglongWrap(info
.capacity
), error
);
3837 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3838 libvirt_ulonglongWrap(info
.allocation
), error
);
3839 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
3840 libvirt_ulonglongWrap(info
.available
), error
);
3845 Py_XDECREF(py_retval
);
3851 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3854 PyObject
*py_retval
;
3856 virStorageVolPtr pool
;
3857 PyObject
*pyobj_pool
;
3858 virStorageVolInfo info
;
3860 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3862 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3864 LIBVIRT_BEGIN_ALLOW_THREADS
;
3865 c_retval
= virStorageVolGetInfo(pool
, &info
);
3866 LIBVIRT_END_ALLOW_THREADS
;
3871 if ((py_retval
= PyList_New(3)) == NULL
)
3874 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3875 libvirt_intWrap((int) info
.type
), error
);
3876 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3877 libvirt_ulonglongWrap(info
.capacity
), error
);
3878 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3879 libvirt_ulonglongWrap(info
.allocation
), error
);
3884 Py_DECREF(py_retval
);
3888 #if LIBVIR_CHECK_VERSION(3, 0, 0)
3890 libvirt_virStorageVolGetInfoFlags(PyObject
*self ATTRIBUTE_UNUSED
,
3893 PyObject
*py_retval
;
3895 virStorageVolPtr pool
;
3896 PyObject
*pyobj_pool
;
3897 virStorageVolInfo info
;
3900 if (!PyArg_ParseTuple(args
, (char *)"OI:virStorageVolGetInfoFlags", &pyobj_pool
, &flags
))
3902 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3904 LIBVIRT_BEGIN_ALLOW_THREADS
;
3905 c_retval
= virStorageVolGetInfoFlags(pool
, &info
, flags
);
3906 LIBVIRT_END_ALLOW_THREADS
;
3911 if ((py_retval
= PyList_New(3)) == NULL
)
3914 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3915 libvirt_intWrap((int) info
.type
), error
);
3916 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3917 libvirt_ulonglongWrap(info
.capacity
), error
);
3918 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3919 libvirt_ulonglongWrap(info
.allocation
), error
);
3924 Py_DECREF(py_retval
);
3930 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3933 unsigned char uuid
[VIR_UUID_BUFLEN
];
3934 virStoragePoolPtr pool
;
3935 PyObject
*pyobj_pool
;
3938 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3940 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3945 LIBVIRT_BEGIN_ALLOW_THREADS
;
3946 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3947 LIBVIRT_END_ALLOW_THREADS
;
3952 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3956 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3959 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3960 virStoragePoolPtr pool
;
3961 PyObject
*pyobj_pool
;
3964 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString",
3967 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3972 LIBVIRT_BEGIN_ALLOW_THREADS
;
3973 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3974 LIBVIRT_END_ALLOW_THREADS
;
3979 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3983 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3986 virStoragePoolPtr c_retval
;
3988 PyObject
*pyobj_conn
;
3989 unsigned char * uuid
;
3992 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID",
3993 &pyobj_conn
, &uuid
, &len
))
3995 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3997 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4000 LIBVIRT_BEGIN_ALLOW_THREADS
;
4001 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
4002 LIBVIRT_END_ALLOW_THREADS
;
4004 return libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
4008 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
4011 PyObject
*py_retval
;
4012 char **names
= NULL
;
4016 PyObject
*pyobj_conn
;
4020 if (!PyArg_ParseTuple(args
, (char *)"OzI:virNodeListDevices",
4021 &pyobj_conn
, &cap
, &flags
))
4023 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4025 LIBVIRT_BEGIN_ALLOW_THREADS
;
4026 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
4027 LIBVIRT_END_ALLOW_THREADS
;
4033 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4034 return PyErr_NoMemory();
4036 LIBVIRT_BEGIN_ALLOW_THREADS
;
4037 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
4038 LIBVIRT_END_ALLOW_THREADS
;
4041 py_retval
= VIR_PY_NONE
;
4046 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4050 for (i
= 0; i
< c_retval
; i
++)
4051 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4052 libvirt_constcharPtrWrap(names
[i
]), error
);
4056 for (i
= 0; i
< c_retval
; i
++)
4062 Py_CLEAR(py_retval
);
4066 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4068 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
4071 PyObject
*pyobj_conn
;
4072 PyObject
*py_retval
= NULL
;
4074 virNodeDevicePtr
*devices
= NULL
;
4079 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNodeDevices",
4080 &pyobj_conn
, &flags
))
4082 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4084 LIBVIRT_BEGIN_ALLOW_THREADS
;
4085 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
4086 LIBVIRT_END_ALLOW_THREADS
;
4091 if (!(py_retval
= PyList_New(c_retval
)))
4094 for (i
= 0; i
< c_retval
; i
++) {
4095 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4096 libvirt_virNodeDevicePtrWrap(devices
[i
]), error
);
4097 /* python steals the pointer */
4102 for (i
= 0; i
< c_retval
; i
++)
4104 virNodeDeviceFree(devices
[i
]);
4109 Py_CLEAR(py_retval
);
4112 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4115 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
4118 PyObject
*py_retval
;
4119 char **names
= NULL
;
4122 virNodeDevicePtr dev
;
4123 PyObject
*pyobj_dev
;
4125 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
4127 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
4129 LIBVIRT_BEGIN_ALLOW_THREADS
;
4130 c_retval
= virNodeDeviceNumOfCaps(dev
);
4131 LIBVIRT_END_ALLOW_THREADS
;
4137 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4138 return PyErr_NoMemory();
4140 LIBVIRT_BEGIN_ALLOW_THREADS
;
4141 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
4142 LIBVIRT_END_ALLOW_THREADS
;
4145 py_retval
= VIR_PY_NONE
;
4150 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4154 for (i
= 0; i
< c_retval
; i
++)
4155 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4156 libvirt_constcharPtrWrap(names
[i
]), error
);
4160 for (i
= 0; i
< c_retval
; i
++)
4166 Py_CLEAR(py_retval
);
4171 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4174 unsigned char uuid
[VIR_UUID_BUFLEN
];
4175 virSecretPtr secret
;
4176 PyObject
*pyobj_secret
;
4179 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
4181 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4186 LIBVIRT_BEGIN_ALLOW_THREADS
;
4187 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
4188 LIBVIRT_END_ALLOW_THREADS
;
4193 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4197 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4200 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4202 PyObject
*pyobj_dom
;
4205 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
4208 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
4213 LIBVIRT_BEGIN_ALLOW_THREADS
;
4214 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
4215 LIBVIRT_END_ALLOW_THREADS
;
4220 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4224 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4227 virSecretPtr c_retval
;
4229 PyObject
*pyobj_conn
;
4230 unsigned char * uuid
;
4233 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID",
4234 &pyobj_conn
, &uuid
, &len
))
4236 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4238 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4241 LIBVIRT_BEGIN_ALLOW_THREADS
;
4242 c_retval
= virSecretLookupByUUID(conn
, uuid
);
4243 LIBVIRT_END_ALLOW_THREADS
;
4245 return libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
4250 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4253 PyObject
*py_retval
;
4254 char **uuids
= NULL
;
4258 PyObject
*pyobj_conn
;
4260 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
4262 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4264 LIBVIRT_BEGIN_ALLOW_THREADS
;
4265 c_retval
= virConnectNumOfSecrets(conn
);
4266 LIBVIRT_END_ALLOW_THREADS
;
4272 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4273 return PyErr_NoMemory();
4275 LIBVIRT_BEGIN_ALLOW_THREADS
;
4276 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
4277 LIBVIRT_END_ALLOW_THREADS
;
4280 py_retval
= VIR_PY_NONE
;
4285 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4289 for (i
= 0; i
< c_retval
; i
++)
4290 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4291 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4296 for (i
= 0; i
< c_retval
; i
++)
4302 Py_CLEAR(py_retval
);
4306 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4308 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4311 PyObject
*pyobj_conn
;
4312 PyObject
*py_retval
= NULL
;
4314 virSecretPtr
*secrets
= NULL
;
4319 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllSecrets",
4320 &pyobj_conn
, &flags
))
4322 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4324 LIBVIRT_BEGIN_ALLOW_THREADS
;
4325 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
4326 LIBVIRT_END_ALLOW_THREADS
;
4331 if (!(py_retval
= PyList_New(c_retval
)))
4334 for (i
= 0; i
< c_retval
; i
++) {
4335 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4336 libvirt_virSecretPtrWrap(secrets
[i
]), error
);
4337 /* python steals the pointer */
4342 for (i
= 0; i
< c_retval
; i
++)
4344 virSecretFree(secrets
[i
]);
4349 Py_CLEAR(py_retval
);
4352 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4355 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4358 PyObject
*py_retval
;
4359 unsigned char *c_retval
;
4361 virSecretPtr secret
;
4362 PyObject
*pyobj_secret
;
4365 if (!PyArg_ParseTuple(args
, (char *)"OI:virSecretGetValue", &pyobj_secret
,
4368 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4370 LIBVIRT_BEGIN_ALLOW_THREADS
;
4371 c_retval
= virSecretGetValue(secret
, &size
, flags
);
4372 LIBVIRT_END_ALLOW_THREADS
;
4374 if (c_retval
== NULL
)
4377 py_retval
= libvirt_charPtrSizeWrap((char*)c_retval
, size
);
4384 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4388 virSecretPtr secret
;
4389 PyObject
*pyobj_secret
;
4394 if (!PyArg_ParseTuple(args
, (char *)"Oz#I:virSecretSetValue", &pyobj_secret
,
4395 &value
, &size
, &flags
))
4397 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4399 LIBVIRT_BEGIN_ALLOW_THREADS
;
4400 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
4402 LIBVIRT_END_ALLOW_THREADS
;
4404 return libvirt_intWrap(c_retval
);
4408 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4411 unsigned char uuid
[VIR_UUID_BUFLEN
];
4412 virNWFilterPtr nwfilter
;
4413 PyObject
*pyobj_nwfilter
;
4416 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID",
4419 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4421 if (nwfilter
== NULL
)
4424 LIBVIRT_BEGIN_ALLOW_THREADS
;
4425 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
4426 LIBVIRT_END_ALLOW_THREADS
;
4431 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4435 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4438 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4439 virNWFilterPtr nwfilter
;
4440 PyObject
*pyobj_nwfilter
;
4443 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
4446 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4448 if (nwfilter
== NULL
)
4451 LIBVIRT_BEGIN_ALLOW_THREADS
;
4452 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
4453 LIBVIRT_END_ALLOW_THREADS
;
4458 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4462 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4465 virNWFilterPtr c_retval
;
4467 PyObject
*pyobj_conn
;
4468 unsigned char * uuid
;
4471 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID",
4472 &pyobj_conn
, &uuid
, &len
))
4474 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4476 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4479 LIBVIRT_BEGIN_ALLOW_THREADS
;
4480 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
4481 LIBVIRT_END_ALLOW_THREADS
;
4483 return libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
4488 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4491 PyObject
*py_retval
;
4492 char **uuids
= NULL
;
4496 PyObject
*pyobj_conn
;
4498 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters",
4501 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4503 LIBVIRT_BEGIN_ALLOW_THREADS
;
4504 c_retval
= virConnectNumOfNWFilters(conn
);
4505 LIBVIRT_END_ALLOW_THREADS
;
4511 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4512 return PyErr_NoMemory();
4514 LIBVIRT_BEGIN_ALLOW_THREADS
;
4515 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
4516 LIBVIRT_END_ALLOW_THREADS
;
4519 py_retval
= VIR_PY_NONE
;
4524 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4528 for (i
= 0; i
< c_retval
; i
++)
4529 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4530 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4534 for (i
= 0; i
< c_retval
; i
++)
4540 Py_CLEAR(py_retval
);
4544 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4546 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4549 PyObject
*pyobj_conn
;
4550 PyObject
*py_retval
= NULL
;
4552 virNWFilterPtr
*filters
= NULL
;
4557 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNWFilters",
4558 &pyobj_conn
, &flags
))
4560 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4562 LIBVIRT_BEGIN_ALLOW_THREADS
;
4563 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
4564 LIBVIRT_END_ALLOW_THREADS
;
4569 if (!(py_retval
= PyList_New(c_retval
)))
4572 for (i
= 0; i
< c_retval
; i
++) {
4573 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4574 libvirt_virNWFilterPtrWrap(filters
[i
]), error
);
4575 /* python steals the pointer */
4580 for (i
= 0; i
< c_retval
; i
++)
4582 virNWFilterFree(filters
[i
]);
4587 Py_CLEAR(py_retval
);
4590 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4592 #if LIBVIR_CHECK_VERSION(4, 5, 0)
4594 libvirt_virConnectListAllNWFilterBindings(PyObject
*self ATTRIBUTE_UNUSED
,
4597 PyObject
*pyobj_conn
;
4598 PyObject
*py_retval
= NULL
;
4600 virNWFilterBindingPtr
*bindings
= NULL
;
4605 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNWFilterBindings",
4606 &pyobj_conn
, &flags
))
4608 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4610 LIBVIRT_BEGIN_ALLOW_THREADS
;
4611 c_retval
= virConnectListAllNWFilterBindings(conn
, &bindings
, flags
);
4612 LIBVIRT_END_ALLOW_THREADS
;
4617 if (!(py_retval
= PyList_New(c_retval
)))
4620 for (i
= 0; i
< c_retval
; i
++) {
4621 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4622 libvirt_virNWFilterBindingPtrWrap(bindings
[i
]), error
);
4623 /* python steals the pointer */
4628 for (i
= 0; i
< c_retval
; i
++)
4630 virNWFilterBindingFree(bindings
[i
]);
4635 Py_CLEAR(py_retval
);
4638 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
4641 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4644 PyObject
*py_retval
;
4645 char **names
= NULL
;
4649 PyObject
*pyobj_conn
;
4652 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces",
4655 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4657 LIBVIRT_BEGIN_ALLOW_THREADS
;
4658 c_retval
= virConnectNumOfInterfaces(conn
);
4659 LIBVIRT_END_ALLOW_THREADS
;
4665 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4666 return PyErr_NoMemory();
4668 LIBVIRT_BEGIN_ALLOW_THREADS
;
4669 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
4670 LIBVIRT_END_ALLOW_THREADS
;
4673 py_retval
= VIR_PY_NONE
;
4678 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4682 for (i
= 0; i
< c_retval
; i
++)
4683 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4684 libvirt_constcharPtrWrap(names
[i
]), error
);
4688 for (i
= 0; i
< c_retval
; i
++)
4694 Py_CLEAR(py_retval
);
4700 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4703 PyObject
*py_retval
;
4704 char **names
= NULL
;
4708 PyObject
*pyobj_conn
;
4711 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
4714 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4716 LIBVIRT_BEGIN_ALLOW_THREADS
;
4717 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
4718 LIBVIRT_END_ALLOW_THREADS
;
4724 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4725 return PyErr_NoMemory();
4727 LIBVIRT_BEGIN_ALLOW_THREADS
;
4728 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
4729 LIBVIRT_END_ALLOW_THREADS
;
4732 py_retval
= VIR_PY_NONE
;
4737 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4741 for (i
= 0; i
< c_retval
; i
++)
4742 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4743 libvirt_constcharPtrWrap(names
[i
]), error
);
4748 for (i
= 0; i
< c_retval
; i
++)
4754 Py_CLEAR(py_retval
);
4759 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4761 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4764 PyObject
*pyobj_conn
;
4765 PyObject
*py_retval
= NULL
;
4767 virInterfacePtr
*ifaces
= NULL
;
4772 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllInterfaces",
4773 &pyobj_conn
, &flags
))
4775 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4777 LIBVIRT_BEGIN_ALLOW_THREADS
;
4778 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
4779 LIBVIRT_END_ALLOW_THREADS
;
4784 if (!(py_retval
= PyList_New(c_retval
)))
4787 for (i
= 0; i
< c_retval
; i
++) {
4788 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4789 libvirt_virInterfacePtrWrap(ifaces
[i
]), error
);
4790 /* python steals the pointer */
4795 for (i
= 0; i
< c_retval
; i
++)
4797 virInterfaceFree(ifaces
[i
]);
4802 Py_CLEAR(py_retval
);
4805 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4808 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4811 PyObject
*pyobj_conn
;
4815 char **xmlcpus
= NULL
;
4818 PyObject
*pybase_cpu
;
4821 if (!PyArg_ParseTuple(args
, (char *)"OOI:virConnectBaselineCPU",
4822 &pyobj_conn
, &list
, &flags
))
4824 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4826 if (PyList_Check(list
)) {
4827 ncpus
= PyList_Size(list
);
4828 if (VIR_ALLOC_N(xmlcpus
, ncpus
) < 0)
4829 return PyErr_NoMemory();
4831 for (i
= 0; i
< ncpus
; i
++) {
4832 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
),
4833 &(xmlcpus
[i
])) < 0) {
4834 for (j
= 0 ; j
< i
; j
++)
4835 VIR_FREE(xmlcpus
[j
]);
4842 LIBVIRT_BEGIN_ALLOW_THREADS
;
4843 base_cpu
= virConnectBaselineCPU(conn
, (const char **)xmlcpus
, ncpus
, flags
);
4844 LIBVIRT_END_ALLOW_THREADS
;
4846 for (i
= 0 ; i
< ncpus
; i
++)
4847 VIR_FREE(xmlcpus
[i
]);
4850 if (base_cpu
== NULL
)
4853 pybase_cpu
= libvirt_constcharPtrWrap(base_cpu
);
4861 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4864 PyObject
*py_retval
;
4866 virDomainPtr domain
;
4867 PyObject
*pyobj_domain
;
4868 virDomainJobInfo info
;
4870 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4872 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4874 LIBVIRT_BEGIN_ALLOW_THREADS
;
4875 c_retval
= virDomainGetJobInfo(domain
, &info
);
4876 LIBVIRT_END_ALLOW_THREADS
;
4881 if ((py_retval
= PyList_New(12)) == NULL
)
4884 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
4885 libvirt_intWrap((int) info
.type
), error
);
4886 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
4887 libvirt_ulonglongWrap(info
.timeElapsed
), error
);
4888 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
4889 libvirt_ulonglongWrap(info
.timeRemaining
), error
);
4890 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
4891 libvirt_ulonglongWrap(info
.dataTotal
), error
);
4892 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
4893 libvirt_ulonglongWrap(info
.dataProcessed
), error
);
4894 VIR_PY_LIST_SET_GOTO(py_retval
, 5,
4895 libvirt_ulonglongWrap(info
.dataRemaining
), error
);
4896 VIR_PY_LIST_SET_GOTO(py_retval
, 6,
4897 libvirt_ulonglongWrap(info
.memTotal
), error
);
4898 VIR_PY_LIST_SET_GOTO(py_retval
, 7,
4899 libvirt_ulonglongWrap(info
.memProcessed
), error
);
4900 VIR_PY_LIST_SET_GOTO(py_retval
, 8,
4901 libvirt_ulonglongWrap(info
.memRemaining
), error
);
4902 VIR_PY_LIST_SET_GOTO(py_retval
, 9,
4903 libvirt_ulonglongWrap(info
.fileTotal
), error
);
4904 VIR_PY_LIST_SET_GOTO(py_retval
, 10,
4905 libvirt_ulonglongWrap(info
.fileProcessed
), error
);
4906 VIR_PY_LIST_SET_GOTO(py_retval
, 11,
4907 libvirt_ulonglongWrap(info
.fileRemaining
), error
);
4912 Py_DECREF(py_retval
);
4916 #if LIBVIR_CHECK_VERSION(1, 0, 3)
4918 libvirt_virDomainGetJobStats(PyObject
*self ATTRIBUTE_UNUSED
,
4921 PyObject
*pyobj_domain
;
4922 virDomainPtr domain
;
4924 virTypedParameterPtr params
= NULL
;
4927 PyObject
*dict
= NULL
;
4930 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetJobStats",
4931 &pyobj_domain
, &flags
))
4933 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4935 LIBVIRT_BEGIN_ALLOW_THREADS
;
4936 rc
= virDomainGetJobStats(domain
, &type
, ¶ms
, &nparams
, flags
);
4937 LIBVIRT_END_ALLOW_THREADS
;
4942 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
4945 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4946 libvirt_intWrap(type
), error
);
4949 virTypedParamsFree(params
, nparams
);
4956 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
4959 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4962 virDomainPtr domain
;
4963 PyObject
*pyobj_domain
;
4966 virDomainBlockJobInfo info
;
4970 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockJobInfo",
4971 &pyobj_domain
, &path
, &flags
))
4973 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4975 LIBVIRT_BEGIN_ALLOW_THREADS
;
4976 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4977 LIBVIRT_END_ALLOW_THREADS
;
4982 if ((dict
= PyDict_New()) == NULL
)
4988 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4989 libvirt_intWrap(info
.type
), error
);
4990 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("bandwidth"),
4991 libvirt_ulongWrap(info
.bandwidth
), error
);
4992 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("cur"),
4993 libvirt_ulonglongWrap(info
.cur
), error
);
4994 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("end"),
4995 libvirt_ulonglongWrap(info
.end
), error
);
5005 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
5008 virDomainPtr domain
;
5009 PyObject
*pyobj_domain
, *info
;
5010 PyObject
*ret
= NULL
;
5013 Py_ssize_t size
= 0;
5016 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
5018 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainSetBlockIoTune",
5019 &pyobj_domain
, &disk
, &info
, &flags
))
5021 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5023 if ((size
= PyDict_Size(info
)) < 0)
5027 PyErr_Format(PyExc_LookupError
,
5028 "Need non-empty dictionary to set attributes");
5032 LIBVIRT_BEGIN_ALLOW_THREADS
;
5033 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
5034 LIBVIRT_END_ALLOW_THREADS
;
5037 return VIR_PY_INT_FAIL
;
5040 PyErr_Format(PyExc_LookupError
,
5041 "Domain has no settable attributes");
5045 if (VIR_ALLOC_N(params
, nparams
) < 0)
5046 return PyErr_NoMemory();
5048 LIBVIRT_BEGIN_ALLOW_THREADS
;
5049 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
5050 LIBVIRT_END_ALLOW_THREADS
;
5053 ret
= VIR_PY_INT_FAIL
;
5057 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
5061 LIBVIRT_BEGIN_ALLOW_THREADS
;
5062 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
5063 LIBVIRT_END_ALLOW_THREADS
;
5066 ret
= VIR_PY_INT_FAIL
;
5070 ret
= VIR_PY_INT_SUCCESS
;
5073 virTypedParamsFree(params
, nparams
);
5074 virTypedParamsFree(new_params
, size
);
5079 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
5082 virDomainPtr domain
;
5083 PyObject
*pyobj_domain
;
5084 PyObject
*ret
= NULL
;
5089 virTypedParameterPtr params
;
5091 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockIoTune",
5092 &pyobj_domain
, &disk
, &flags
))
5094 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5096 LIBVIRT_BEGIN_ALLOW_THREADS
;
5097 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
5098 LIBVIRT_END_ALLOW_THREADS
;
5104 return PyDict_New();
5106 if (VIR_ALLOC_N(params
, nparams
) < 0)
5107 return PyErr_NoMemory();
5109 LIBVIRT_BEGIN_ALLOW_THREADS
;
5110 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
5111 LIBVIRT_END_ALLOW_THREADS
;
5118 ret
= getPyVirTypedParameter(params
, nparams
);
5121 virTypedParamsFree(params
, nparams
);
5126 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
5129 PyObject
*py_retval
= VIR_PY_NONE
;
5130 virDomainPtr domain
;
5131 PyObject
*pyobj_domain
;
5133 virDomainDiskErrorPtr disks
= NULL
;
5134 unsigned int ndisks
;
5138 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetDiskErrors",
5139 &pyobj_domain
, &flags
))
5142 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5144 LIBVIRT_BEGIN_ALLOW_THREADS
;
5145 count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0);
5146 LIBVIRT_END_ALLOW_THREADS
;
5153 if (VIR_ALLOC_N(disks
, ndisks
) < 0)
5154 return PyErr_NoMemory();
5156 LIBVIRT_BEGIN_ALLOW_THREADS
;
5157 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
5158 LIBVIRT_END_ALLOW_THREADS
;
5161 py_retval
= VIR_PY_NONE
;
5166 if (!(py_retval
= PyDict_New()))
5169 for (i
= 0; i
< count
; i
++) {
5170 VIR_PY_DICT_SET_GOTO(py_retval
,
5171 libvirt_constcharPtrWrap(disks
[i
].disk
),
5172 libvirt_intWrap(disks
[i
].error
),
5178 for (i
= 0; i
< count
; i
++)
5179 VIR_FREE(disks
[i
].disk
);
5184 Py_CLEAR(py_retval
);
5189 #if LIBVIR_CHECK_VERSION(1, 2, 14)
5191 libvirt_virDomainInterfaceAddresses(PyObject
*self ATTRIBUTE_UNUSED
,
5194 PyObject
*py_retval
= VIR_PY_NONE
;
5195 PyObject
*pyobj_domain
;
5196 virDomainPtr domain
;
5197 virDomainInterfacePtr
*ifaces
= NULL
;
5198 unsigned int source
;
5200 int ifaces_count
= 0;
5203 if (!PyArg_ParseTuple(args
, (char *) "OII:virDomainInterfaceAddresses",
5204 &pyobj_domain
, &source
, &flags
))
5207 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5209 LIBVIRT_BEGIN_ALLOW_THREADS
;
5210 ifaces_count
= virDomainInterfaceAddresses(domain
, &ifaces
, source
, flags
);
5211 LIBVIRT_END_ALLOW_THREADS
;
5213 if (ifaces_count
< 0)
5216 if (!(py_retval
= PyDict_New()))
5219 for (i
= 0; i
< ifaces_count
; i
++) {
5220 virDomainInterfacePtr iface
= ifaces
[i
];
5221 PyObject
*py_addrs
= NULL
;
5222 PyObject
*py_iface
= NULL
;
5224 if (!(py_iface
= PyDict_New()))
5227 VIR_PY_DICT_SET_GOTO(py_retval
, libvirt_charPtrWrap(iface
->name
),
5230 if (iface
->naddrs
) {
5231 if (!(py_addrs
= PyList_New(iface
->naddrs
))) {
5235 py_addrs
= VIR_PY_NONE
;
5238 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("addrs"),
5241 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("hwaddr"),
5242 libvirt_constcharPtrWrap(iface
->hwaddr
), error
);
5244 for (j
= 0; j
< iface
->naddrs
; j
++) {
5245 virDomainIPAddressPtr addr
= &(iface
->addrs
[j
]);
5246 PyObject
*py_addr
= PyDict_New();
5251 VIR_PY_LIST_SET_GOTO(py_addrs
, j
, py_addr
, error
);
5253 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("addr"),
5254 libvirt_constcharPtrWrap(addr
->addr
), error
);
5255 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("prefix"),
5256 libvirt_uintWrap(addr
->prefix
), error
);
5257 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("type"),
5258 libvirt_intWrap(addr
->type
), error
);
5263 if (ifaces
&& ifaces_count
> 0) {
5264 for (i
= 0; i
< ifaces_count
; i
++) {
5265 virDomainInterfaceFree(ifaces
[i
]);
5273 Py_CLEAR(py_retval
);
5276 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
5279 /*******************************************
5280 * Helper functions to avoid importing modules
5281 * for every callback
5282 *******************************************/
5283 static PyObject
*libvirt_module
= NULL
;
5284 static PyObject
*libvirt_dict
= NULL
;
5287 getLibvirtModuleObject(void)
5290 return libvirt_module
;
5292 // PyImport_ImportModule returns a new reference
5293 /* Bogus (char *) cast for RHEL-5 python API brokenness */
5294 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
5295 if (!libvirt_module
) {
5296 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
5301 return libvirt_module
;
5305 getLibvirtDictObject(void)
5308 return libvirt_dict
;
5310 // PyModule_GetDict returns a borrowed reference
5311 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
5312 if (!libvirt_dict
) {
5313 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
5318 Py_INCREF(libvirt_dict
);
5319 return libvirt_dict
;
5324 libvirt_lookupPythonFunc(const char *funcname
)
5326 PyObject
*python_cb
;
5328 /* Lookup the python callback */
5329 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
5332 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
5338 if (!PyCallable_Check(python_cb
)) {
5339 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
5346 /*******************************************
5348 *******************************************/
5351 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5357 PyObject
*pyobj_ret
= NULL
;
5359 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5360 PyObject
*pyobj_dom
;
5364 LIBVIRT_ENSURE_THREAD_STATE
;
5366 /* Create a python instance of this virDomainPtr */
5368 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5373 /* Call the Callback Dispatcher */
5374 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5375 (char*)"_dispatchDomainEventCallbacks",
5380 Py_DECREF(pyobj_dom
);
5384 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5387 Py_DECREF(pyobj_ret
);
5391 LIBVIRT_RELEASE_THREAD_STATE
;
5396 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
*self
,
5399 PyObject
*pyobj_conn
; /* virConnectPtr */
5400 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
5405 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventRegister",
5406 &pyobj_conn
, &pyobj_conn_inst
))
5409 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
5410 pyobj_conn
, pyobj_conn_inst
);
5411 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5413 Py_INCREF(pyobj_conn_inst
);
5415 LIBVIRT_BEGIN_ALLOW_THREADS
;
5416 ret
= virConnectDomainEventRegister(conn
,
5417 libvirt_virConnectDomainEventCallback
,
5418 pyobj_conn_inst
, NULL
);
5419 LIBVIRT_END_ALLOW_THREADS
;
5421 return libvirt_intWrap(ret
);
5425 libvirt_virConnectDomainEventDeregister(PyObject
*self ATTRIBUTE_UNUSED
,
5428 PyObject
*pyobj_conn
;
5429 PyObject
*pyobj_conn_inst
;
5434 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventDeregister",
5435 &pyobj_conn
, &pyobj_conn_inst
))
5438 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
5440 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5442 LIBVIRT_BEGIN_ALLOW_THREADS
;
5443 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
5444 LIBVIRT_END_ALLOW_THREADS
;
5446 Py_DECREF(pyobj_conn_inst
);
5447 return libvirt_intWrap(ret
);
5450 /*******************************************
5452 *******************************************/
5453 static PyObject
*addHandleObj
;
5454 static PyObject
*updateHandleObj
;
5455 static PyObject
*removeHandleObj
;
5456 static PyObject
*addTimeoutObj
;
5457 static PyObject
*updateTimeoutObj
;
5458 static PyObject
*removeTimeoutObj
;
5461 libvirt_virEventAddHandleFunc(int fd
,
5463 virEventHandleCallback cb
,
5468 PyObject
*python_cb
= NULL
;
5469 PyObject
*cb_args
= NULL
;
5470 PyObject
*pyobj_args
= NULL
;
5473 LIBVIRT_ENSURE_THREAD_STATE
;
5475 if ((pyobj_args
= PyTuple_New(4)) == NULL
)
5478 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(fd
), cleanup
);
5479 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5481 /* Lookup the python callback */
5482 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
5486 Py_INCREF(python_cb
);
5488 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, python_cb
, cleanup
);
5490 if ((cb_args
= PyTuple_New(3)) == NULL
)
5493 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 3, cb_args
, cleanup
);
5495 /* If changing contents of the opaque object, please also change
5496 * virEventInvokeFreeCallback() in libvirt-override.py
5498 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventHandleCallbackWrap(cb
), cleanup
);
5499 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5500 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5502 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
5507 libvirt_intUnwrap(result
, &retval
);
5513 Py_XDECREF(pyobj_args
);
5515 LIBVIRT_RELEASE_THREAD_STATE
;
5521 libvirt_virEventUpdateHandleFunc(int watch
,
5524 PyObject
*result
= NULL
;
5525 PyObject
*pyobj_args
;
5527 LIBVIRT_ENSURE_THREAD_STATE
;
5529 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5532 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5533 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5535 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
5543 Py_XDECREF(pyobj_args
);
5545 LIBVIRT_RELEASE_THREAD_STATE
;
5550 libvirt_virEventRemoveHandleFunc(int watch
)
5552 PyObject
*result
= NULL
;
5553 PyObject
*pyobj_args
;
5556 LIBVIRT_ENSURE_THREAD_STATE
;
5558 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5561 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5563 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
5573 Py_XDECREF(pyobj_args
);
5575 LIBVIRT_RELEASE_THREAD_STATE
;
5582 libvirt_virEventAddTimeoutFunc(int timeout
,
5583 virEventTimeoutCallback cb
,
5587 PyObject
*result
= NULL
;
5588 PyObject
*python_cb
= NULL
;
5589 PyObject
*cb_args
= NULL
;
5590 PyObject
*pyobj_args
= NULL
;
5593 LIBVIRT_ENSURE_THREAD_STATE
;
5595 if ((pyobj_args
= PyTuple_New(3)) == NULL
)
5598 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timeout
), cleanup
);
5600 /* Lookup the python callback */
5601 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
5605 Py_INCREF(python_cb
);
5606 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, python_cb
, cleanup
);
5608 if ((cb_args
= PyTuple_New(3)) == NULL
)
5611 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, cb_args
, cleanup
);
5613 /* If changing contents of the opaque object, please also change
5614 * virEventInvokeFreeCallback() in libvirt-override.py
5616 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventTimeoutCallbackWrap(cb
), cleanup
);
5617 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5618 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5620 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
5625 libvirt_intUnwrap(result
, &retval
);
5630 Py_XDECREF(pyobj_args
);
5632 LIBVIRT_RELEASE_THREAD_STATE
;
5637 libvirt_virEventUpdateTimeoutFunc(int timer
,
5640 PyObject
*result
= NULL
;
5641 PyObject
*pyobj_args
;
5643 LIBVIRT_ENSURE_THREAD_STATE
;
5645 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5648 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5649 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(timeout
), cleanup
);
5651 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
5659 Py_XDECREF(pyobj_args
);
5661 LIBVIRT_RELEASE_THREAD_STATE
;
5665 libvirt_virEventRemoveTimeoutFunc(int timer
)
5667 PyObject
*result
= NULL
;
5668 PyObject
*pyobj_args
;
5671 LIBVIRT_ENSURE_THREAD_STATE
;
5673 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5676 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5678 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
5688 Py_XDECREF(pyobj_args
);
5690 LIBVIRT_RELEASE_THREAD_STATE
;
5696 libvirt_virEventRegisterImpl(PyObject
*self ATTRIBUTE_UNUSED
,
5699 if (addHandleObj
|| updateHandleObj
|| removeHandleObj
||
5700 addTimeoutObj
|| updateTimeoutObj
|| removeTimeoutObj
) {
5701 PyErr_SetString(PyExc_RuntimeError
,
5702 "Event loop is already registered");
5706 /* Parse and check arguments */
5707 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
5708 &addHandleObj
, &updateHandleObj
,
5709 &removeHandleObj
, &addTimeoutObj
,
5710 &updateTimeoutObj
, &removeTimeoutObj
) ||
5711 !PyCallable_Check(addHandleObj
) ||
5712 !PyCallable_Check(updateHandleObj
) ||
5713 !PyCallable_Check(removeHandleObj
) ||
5714 !PyCallable_Check(addTimeoutObj
) ||
5715 !PyCallable_Check(updateTimeoutObj
) ||
5716 !PyCallable_Check(removeTimeoutObj
))
5719 /* Inc refs since we're holding on to these objects until
5720 * the next call (if any) to this function.
5722 Py_INCREF(addHandleObj
);
5723 Py_INCREF(updateHandleObj
);
5724 Py_INCREF(removeHandleObj
);
5725 Py_INCREF(addTimeoutObj
);
5726 Py_INCREF(updateTimeoutObj
);
5727 Py_INCREF(removeTimeoutObj
);
5729 /* Now register our C EventImpl, which will dispatch
5730 * to the Python callbacks passed in as args.
5732 LIBVIRT_BEGIN_ALLOW_THREADS
;
5733 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
5734 libvirt_virEventUpdateHandleFunc
,
5735 libvirt_virEventRemoveHandleFunc
,
5736 libvirt_virEventAddTimeoutFunc
,
5737 libvirt_virEventUpdateTimeoutFunc
,
5738 libvirt_virEventRemoveTimeoutFunc
);
5739 LIBVIRT_END_ALLOW_THREADS
;
5741 return VIR_PY_INT_SUCCESS
;
5745 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5748 int watch
, fd
, event
;
5750 PyObject
*py_opaque
;
5751 virEventHandleCallback cb
;
5754 if (!PyArg_ParseTuple(args
, (char *) "iiiOO:virEventInvokeHandleCallback",
5755 &watch
, &fd
, &event
, &py_f
, &py_opaque
))
5758 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
5759 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5762 LIBVIRT_BEGIN_ALLOW_THREADS
;
5763 cb(watch
, fd
, event
, opaque
);
5764 LIBVIRT_END_ALLOW_THREADS
;
5767 return VIR_PY_INT_SUCCESS
;
5771 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5776 PyObject
*py_opaque
;
5777 virEventTimeoutCallback cb
;
5780 if (!PyArg_ParseTuple(args
, (char *) "iOO:virEventInvokeTimeoutCallback",
5781 &timer
, &py_f
, &py_opaque
))
5784 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
5785 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5787 LIBVIRT_BEGIN_ALLOW_THREADS
;
5789 LIBVIRT_END_ALLOW_THREADS
;
5792 return VIR_PY_INT_SUCCESS
;
5796 libvirt_virEventInvokeFreeCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5800 PyObject
*py_opaque
;
5804 if (!PyArg_ParseTuple(args
, (char *) "OO:virEventInvokeFreeCallback",
5808 cb
= (virFreeCallback
) PyvirEventHandleCallback_Get(py_f
);
5809 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5812 LIBVIRT_BEGIN_ALLOW_THREADS
;
5814 LIBVIRT_END_ALLOW_THREADS
;
5817 return VIR_PY_INT_SUCCESS
;
5821 libvirt_virEventHandleCallback(int watch
,
5826 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5827 PyObject
*pyobj_ret
;
5828 PyObject
*python_cb
;
5830 LIBVIRT_ENSURE_THREAD_STATE
;
5832 /* Lookup the python callback */
5833 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
5838 Py_INCREF(pyobj_cbData
);
5840 /* Call the pure python dispatcher */
5841 pyobj_ret
= PyObject_CallFunction(python_cb
,
5843 watch
, fd
, events
, pyobj_cbData
);
5845 Py_DECREF(pyobj_cbData
);
5848 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5851 Py_DECREF(pyobj_ret
);
5855 LIBVIRT_RELEASE_THREAD_STATE
;
5859 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
5862 PyObject
*pyobj_cbData
;
5863 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
5868 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
5869 &fd
, &events
, &pyobj_cbData
))
5872 Py_INCREF(pyobj_cbData
);
5874 LIBVIRT_BEGIN_ALLOW_THREADS
;
5875 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
5876 LIBVIRT_END_ALLOW_THREADS
;
5879 Py_DECREF(pyobj_cbData
);
5882 return libvirt_intWrap(ret
);
5886 libvirt_virEventTimeoutCallback(int timer
,
5889 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5890 PyObject
*pyobj_ret
;
5891 PyObject
*python_cb
;
5893 LIBVIRT_ENSURE_THREAD_STATE
;
5895 /* Lookup the python callback */
5896 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5901 Py_INCREF(pyobj_cbData
);
5903 /* Call the pure python dispatcher */
5904 pyobj_ret
= PyObject_CallFunction(python_cb
,
5906 timer
, pyobj_cbData
);
5908 Py_DECREF(pyobj_cbData
);
5911 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5914 Py_DECREF(pyobj_ret
);
5918 LIBVIRT_RELEASE_THREAD_STATE
;
5922 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5925 PyObject
*pyobj_cbData
;
5926 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5930 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5931 &timeout
, &pyobj_cbData
))
5934 Py_INCREF(pyobj_cbData
);
5936 LIBVIRT_BEGIN_ALLOW_THREADS
;
5937 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5938 LIBVIRT_END_ALLOW_THREADS
;
5941 Py_DECREF(pyobj_cbData
);
5944 return libvirt_intWrap(ret
);
5948 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5950 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5951 LIBVIRT_ENSURE_THREAD_STATE
;
5952 Py_DECREF(pyobj_conn
);
5953 LIBVIRT_RELEASE_THREAD_STATE
;
5957 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5963 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5964 PyObject
*pyobj_dom
;
5965 PyObject
*pyobj_ret
= NULL
;
5966 PyObject
*pyobj_conn
;
5970 LIBVIRT_ENSURE_THREAD_STATE
;
5972 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5974 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5977 /* Create a python instance of this virDomainPtr */
5979 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5983 Py_INCREF(pyobj_cbData
);
5985 /* Call the Callback Dispatcher */
5986 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5987 (char*)"_dispatchDomainEventLifecycleCallback",
5993 Py_DECREF(pyobj_cbData
);
5994 Py_DECREF(pyobj_dom
);
5998 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6001 Py_DECREF(pyobj_ret
);
6005 LIBVIRT_RELEASE_THREAD_STATE
;
6010 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6014 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6015 PyObject
*pyobj_dom
;
6016 PyObject
*pyobj_ret
= NULL
;
6017 PyObject
*pyobj_conn
;
6021 LIBVIRT_ENSURE_THREAD_STATE
;
6023 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6025 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6028 /* Create a python instance of this virDomainPtr */
6030 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6034 Py_INCREF(pyobj_cbData
);
6036 /* Call the Callback Dispatcher */
6037 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6038 (char*)"_dispatchDomainEventGenericCallback",
6040 pyobj_dom
, pyobj_cbData
);
6042 Py_DECREF(pyobj_cbData
);
6043 Py_DECREF(pyobj_dom
);
6047 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6050 Py_DECREF(pyobj_ret
);
6054 LIBVIRT_RELEASE_THREAD_STATE
;
6059 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6061 long long utcoffset
,
6064 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6065 PyObject
*pyobj_dom
;
6066 PyObject
*pyobj_ret
= NULL
;
6067 PyObject
*pyobj_conn
;
6071 LIBVIRT_ENSURE_THREAD_STATE
;
6073 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6075 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6078 /* Create a python instance of this virDomainPtr */
6080 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6084 Py_INCREF(pyobj_cbData
);
6086 /* Call the Callback Dispatcher */
6087 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6088 (char*)"_dispatchDomainEventRTCChangeCallback",
6091 (PY_LONG_LONG
)utcoffset
,
6094 Py_DECREF(pyobj_cbData
);
6095 Py_DECREF(pyobj_dom
);
6099 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6102 Py_DECREF(pyobj_ret
);
6106 LIBVIRT_RELEASE_THREAD_STATE
;
6111 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6116 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6117 PyObject
*pyobj_dom
;
6118 PyObject
*pyobj_ret
= NULL
;
6119 PyObject
*pyobj_conn
;
6123 LIBVIRT_ENSURE_THREAD_STATE
;
6125 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6127 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6130 /* Create a python instance of this virDomainPtr */
6132 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6136 Py_INCREF(pyobj_cbData
);
6138 /* Call the Callback Dispatcher */
6139 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6140 (char*)"_dispatchDomainEventWatchdogCallback",
6146 Py_DECREF(pyobj_cbData
);
6147 Py_DECREF(pyobj_dom
);
6151 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6154 Py_DECREF(pyobj_ret
);
6158 LIBVIRT_RELEASE_THREAD_STATE
;
6163 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6165 const char *srcPath
,
6166 const char *devAlias
,
6170 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6171 PyObject
*pyobj_dom
;
6172 PyObject
*pyobj_ret
= NULL
;
6173 PyObject
*pyobj_conn
;
6177 LIBVIRT_ENSURE_THREAD_STATE
;
6179 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6181 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6184 /* Create a python instance of this virDomainPtr */
6186 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6190 Py_INCREF(pyobj_cbData
);
6192 /* Call the Callback Dispatcher */
6193 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6194 (char*)"_dispatchDomainEventIOErrorCallback",
6197 srcPath
, devAlias
, action
,
6200 Py_DECREF(pyobj_cbData
);
6201 Py_DECREF(pyobj_dom
);
6205 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6208 Py_DECREF(pyobj_ret
);
6212 LIBVIRT_RELEASE_THREAD_STATE
;
6217 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6219 const char *srcPath
,
6220 const char *devAlias
,
6225 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6226 PyObject
*pyobj_dom
;
6227 PyObject
*pyobj_ret
= NULL
;
6228 PyObject
*pyobj_conn
;
6232 LIBVIRT_ENSURE_THREAD_STATE
;
6234 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6236 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6239 /* Create a python instance of this virDomainPtr */
6241 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6245 Py_INCREF(pyobj_cbData
);
6247 /* Call the Callback Dispatcher */
6248 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6249 (char*)"_dispatchDomainEventIOErrorReasonCallback",
6252 srcPath
, devAlias
, action
, reason
,
6255 Py_DECREF(pyobj_cbData
);
6256 Py_DECREF(pyobj_dom
);
6260 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6263 Py_DECREF(pyobj_ret
);
6267 LIBVIRT_RELEASE_THREAD_STATE
;
6272 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6275 virDomainEventGraphicsAddressPtr local
,
6276 virDomainEventGraphicsAddressPtr remote
,
6277 const char *authScheme
,
6278 virDomainEventGraphicsSubjectPtr subject
,
6281 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6282 PyObject
*pyobj_dom
= NULL
;
6283 PyObject
*pyobj_ret
= NULL
;
6284 PyObject
*pyobj_conn
;
6286 PyObject
*pyobj_local
= NULL
;
6287 PyObject
*pyobj_remote
= NULL
;
6288 PyObject
*pyobj_subject
= NULL
;
6292 LIBVIRT_ENSURE_THREAD_STATE
;
6294 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6296 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6299 /* Create a python instance of this virDomainPtr */
6301 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6305 Py_INCREF(pyobj_cbData
);
6307 if ((pyobj_local
= PyDict_New()) == NULL
)
6310 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6311 libvirt_constcharPtrWrap("family"),
6312 libvirt_intWrap(local
->family
),
6314 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6315 libvirt_constcharPtrWrap("node"),
6316 libvirt_constcharPtrWrap(local
->node
),
6318 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6319 libvirt_constcharPtrWrap("service"),
6320 libvirt_constcharPtrWrap(local
->service
),
6323 if ((pyobj_remote
= PyDict_New()) == NULL
)
6326 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6327 libvirt_constcharPtrWrap("family"),
6328 libvirt_intWrap(remote
->family
),
6330 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6331 libvirt_constcharPtrWrap("node"),
6332 libvirt_constcharPtrWrap(remote
->node
),
6334 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6335 libvirt_constcharPtrWrap("service"),
6336 libvirt_constcharPtrWrap(remote
->service
),
6339 if ((pyobj_subject
= PyList_New(subject
->nidentity
)) == NULL
)
6342 for (i
= 0; i
< subject
->nidentity
; i
++) {
6343 PyObject
*pair
= PyTuple_New(2);
6347 VIR_PY_LIST_SET_GOTO(pyobj_subject
, i
, pair
, cleanup
);
6349 VIR_PY_TUPLE_SET_GOTO(pair
, 0,
6350 libvirt_constcharPtrWrap(subject
->identities
[i
].type
),
6352 VIR_PY_TUPLE_SET_GOTO(pair
, 1,
6353 libvirt_constcharPtrWrap(subject
->identities
[i
].name
),
6357 /* Call the Callback Dispatcher */
6358 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6359 (char*)"_dispatchDomainEventGraphicsCallback",
6362 phase
, pyobj_local
, pyobj_remote
,
6363 authScheme
, pyobj_subject
,
6367 Py_DECREF(pyobj_cbData
);
6368 Py_XDECREF(pyobj_dom
);
6371 Py_XDECREF(pyobj_local
);
6372 Py_XDECREF(pyobj_remote
);
6373 Py_XDECREF(pyobj_subject
);
6374 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6377 Py_DECREF(pyobj_ret
);
6381 LIBVIRT_RELEASE_THREAD_STATE
;
6386 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6393 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6394 PyObject
*pyobj_dom
;
6395 PyObject
*pyobj_ret
= NULL
;
6396 PyObject
*pyobj_conn
;
6400 LIBVIRT_ENSURE_THREAD_STATE
;
6402 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6404 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6407 /* Create a python instance of this virDomainPtr */
6409 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6413 Py_INCREF(pyobj_cbData
);
6415 /* Call the Callback Dispatcher */
6416 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6417 (char*)"_dispatchDomainEventBlockJobCallback",
6419 pyobj_dom
, disk
, type
, status
, pyobj_cbData
);
6421 Py_DECREF(pyobj_cbData
);
6422 Py_DECREF(pyobj_dom
);
6426 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6429 Py_DECREF(pyobj_ret
);
6433 LIBVIRT_RELEASE_THREAD_STATE
;
6438 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6440 const char *oldSrcPath
,
6441 const char *newSrcPath
,
6442 const char *devAlias
,
6446 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6447 PyObject
*pyobj_dom
;
6448 PyObject
*pyobj_ret
= NULL
;
6449 PyObject
*pyobj_conn
;
6453 LIBVIRT_ENSURE_THREAD_STATE
;
6455 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6457 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6460 /* Create a python instance of this virDomainPtr */
6462 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6466 Py_INCREF(pyobj_cbData
);
6468 /* Call the Callback Dispatcher */
6469 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6470 (char*)"_dispatchDomainEventDiskChangeCallback",
6473 oldSrcPath
, newSrcPath
,
6474 devAlias
, reason
, pyobj_cbData
);
6476 Py_DECREF(pyobj_cbData
);
6477 Py_DECREF(pyobj_dom
);
6481 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6484 Py_DECREF(pyobj_ret
);
6488 LIBVIRT_RELEASE_THREAD_STATE
;
6493 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6495 const char *devAlias
,
6499 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6500 PyObject
*pyobj_dom
;
6501 PyObject
*pyobj_ret
= NULL
;
6502 PyObject
*pyobj_conn
;
6506 LIBVIRT_ENSURE_THREAD_STATE
;
6508 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6510 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6513 /* Create a python instance of this virDomainPtr */
6515 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6519 Py_INCREF(pyobj_cbData
);
6521 /* Call the Callback Dispatcher */
6522 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6523 (char*)"_dispatchDomainEventTrayChangeCallback",
6526 devAlias
, reason
, pyobj_cbData
);
6528 Py_DECREF(pyobj_cbData
);
6529 Py_DECREF(pyobj_dom
);
6533 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6536 Py_DECREF(pyobj_ret
);
6540 LIBVIRT_RELEASE_THREAD_STATE
;
6545 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6550 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6551 PyObject
*pyobj_dom
;
6552 PyObject
*pyobj_ret
= NULL
;
6553 PyObject
*pyobj_conn
;
6557 LIBVIRT_ENSURE_THREAD_STATE
;
6559 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6561 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6564 /* Create a python instance of this virDomainPtr */
6566 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6570 Py_INCREF(pyobj_cbData
);
6572 /* Call the Callback Dispatcher */
6573 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6574 (char*)"_dispatchDomainEventPMWakeupCallback",
6580 Py_DECREF(pyobj_cbData
);
6581 Py_DECREF(pyobj_dom
);
6585 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6588 Py_DECREF(pyobj_ret
);
6592 LIBVIRT_RELEASE_THREAD_STATE
;
6597 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6602 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6603 PyObject
*pyobj_dom
;
6604 PyObject
*pyobj_ret
= NULL
;
6605 PyObject
*pyobj_conn
;
6609 LIBVIRT_ENSURE_THREAD_STATE
;
6611 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6613 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6616 /* Create a python instance of this virDomainPtr */
6618 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6622 Py_INCREF(pyobj_cbData
);
6624 /* Call the Callback Dispatcher */
6625 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6626 (char*)"_dispatchDomainEventPMSuspendCallback",
6632 Py_DECREF(pyobj_cbData
);
6633 Py_DECREF(pyobj_dom
);
6637 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6640 Py_DECREF(pyobj_ret
);
6644 LIBVIRT_RELEASE_THREAD_STATE
;
6649 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
6651 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6653 unsigned long long actual
,
6656 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6657 PyObject
*pyobj_dom
;
6658 PyObject
*pyobj_ret
= NULL
;
6659 PyObject
*pyobj_conn
;
6663 LIBVIRT_ENSURE_THREAD_STATE
;
6665 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6667 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6670 /* Create a python instance of this virDomainPtr */
6672 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6676 Py_INCREF(pyobj_cbData
);
6678 /* Call the Callback Dispatcher */
6679 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6680 (char*)"_dispatchDomainEventBalloonChangeCallback",
6683 (PY_LONG_LONG
)actual
,
6686 Py_DECREF(pyobj_cbData
);
6687 Py_DECREF(pyobj_dom
);
6691 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6694 Py_DECREF(pyobj_ret
);
6698 LIBVIRT_RELEASE_THREAD_STATE
;
6701 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
6703 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
6705 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6710 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6711 PyObject
*pyobj_dom
;
6712 PyObject
*pyobj_ret
= NULL
;
6713 PyObject
*pyobj_conn
;
6717 LIBVIRT_ENSURE_THREAD_STATE
;
6719 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6721 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6724 /* Create a python instance of this virDomainPtr */
6726 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6730 Py_INCREF(pyobj_cbData
);
6732 /* Call the Callback Dispatcher */
6733 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6734 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
6740 Py_DECREF(pyobj_cbData
);
6741 Py_DECREF(pyobj_dom
);
6745 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6748 Py_DECREF(pyobj_ret
);
6752 LIBVIRT_RELEASE_THREAD_STATE
;
6755 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
6757 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
6759 libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6761 const char *devAlias
,
6764 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6765 PyObject
*pyobj_dom
;
6766 PyObject
*pyobj_ret
= NULL
;
6767 PyObject
*pyobj_conn
;
6771 LIBVIRT_ENSURE_THREAD_STATE
;
6773 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6775 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6778 /* Create a python instance of this virDomainPtr */
6780 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6784 Py_INCREF(pyobj_cbData
);
6786 /* Call the Callback Dispatcher */
6787 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6788 (char*)"_dispatchDomainEventDeviceRemovedCallback",
6790 pyobj_dom
, devAlias
, pyobj_cbData
);
6792 Py_DECREF(pyobj_cbData
);
6793 Py_DECREF(pyobj_dom
);
6797 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6800 Py_DECREF(pyobj_ret
);
6804 LIBVIRT_RELEASE_THREAD_STATE
;
6807 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
6809 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
6811 libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6813 virTypedParameterPtr params
,
6817 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6818 PyObject
*pyobj_dom
;
6819 PyObject
*pyobj_ret
= NULL
;
6820 PyObject
*pyobj_conn
;
6822 PyObject
*pyobj_dict
= NULL
;
6825 LIBVIRT_ENSURE_THREAD_STATE
;
6827 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
6831 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6833 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6836 /* Create a python instance of this virDomainPtr */
6838 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6842 Py_INCREF(pyobj_cbData
);
6844 /* Call the Callback Dispatcher */
6845 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6846 (char*)"_dispatchDomainEventTunableCallback",
6848 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
6850 Py_DECREF(pyobj_cbData
);
6851 Py_DECREF(pyobj_dom
);
6855 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6858 Py_DECREF(pyobj_ret
);
6861 Py_XDECREF(pyobj_dict
);
6863 LIBVIRT_RELEASE_THREAD_STATE
;
6867 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
6869 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
6871 libvirt_virConnectDomainEventAgentLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6877 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6878 PyObject
*pyobj_dom
;
6879 PyObject
*pyobj_ret
= NULL
;
6880 PyObject
*pyobj_conn
;
6884 LIBVIRT_ENSURE_THREAD_STATE
;
6886 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6888 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6891 /* Create a python instance of this virDomainPtr */
6893 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6897 Py_INCREF(pyobj_cbData
);
6899 /* Call the Callback Dispatcher */
6900 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6901 (char*)"_dispatchDomainEventAgentLifecycleCallback",
6903 pyobj_dom
, state
, reason
, pyobj_cbData
);
6905 Py_DECREF(pyobj_cbData
);
6906 Py_DECREF(pyobj_dom
);
6910 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6913 Py_DECREF(pyobj_ret
);
6917 LIBVIRT_RELEASE_THREAD_STATE
;
6921 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
6923 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
6925 libvirt_virConnectDomainEventDeviceAddedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6927 const char *devAlias
,
6930 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6931 PyObject
*pyobj_dom
;
6932 PyObject
*pyobj_ret
= NULL
;
6933 PyObject
*pyobj_conn
;
6937 LIBVIRT_ENSURE_THREAD_STATE
;
6939 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6941 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6944 /* Create a python instance of this virDomainPtr */
6946 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6950 Py_INCREF(pyobj_cbData
);
6952 /* Call the Callback Dispatcher */
6953 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6954 (char*)"_dispatchDomainEventDeviceAddedCallback",
6956 pyobj_dom
, devAlias
, pyobj_cbData
);
6958 Py_DECREF(pyobj_cbData
);
6959 Py_DECREF(pyobj_dom
);
6963 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6966 Py_DECREF(pyobj_ret
);
6970 LIBVIRT_RELEASE_THREAD_STATE
;
6974 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
6976 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
6978 libvirt_virConnectDomainEventMigrationIterationCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6983 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6984 PyObject
*pyobj_dom
;
6985 PyObject
*pyobj_ret
= NULL
;
6986 PyObject
*pyobj_conn
;
6990 LIBVIRT_ENSURE_THREAD_STATE
;
6992 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6994 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6997 /* Create a python instance of this virDomainPtr */
6999 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7003 Py_INCREF(pyobj_cbData
);
7005 /* Call the Callback Dispatcher */
7006 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7007 (char*)"_dispatchDomainEventMigrationIterationCallback",
7009 pyobj_dom
, iteration
, pyobj_cbData
);
7011 Py_DECREF(pyobj_cbData
);
7012 Py_DECREF(pyobj_dom
);
7016 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7019 Py_DECREF(pyobj_ret
);
7023 LIBVIRT_RELEASE_THREAD_STATE
;
7026 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
7028 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
7030 libvirt_virConnectDomainEventJobCompletedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7032 virTypedParameterPtr params
,
7036 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7037 PyObject
*pyobj_dom
;
7038 PyObject
*pyobj_ret
= NULL
;
7039 PyObject
*pyobj_conn
;
7041 PyObject
*pyobj_dict
= NULL
;
7044 LIBVIRT_ENSURE_THREAD_STATE
;
7046 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
7050 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7052 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7055 /* Create a python instance of this virDomainPtr */
7057 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7061 Py_INCREF(pyobj_cbData
);
7063 /* Call the Callback Dispatcher */
7064 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7065 (char*)"_dispatchDomainEventJobCompletedCallback",
7067 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
7069 Py_DECREF(pyobj_cbData
);
7070 Py_DECREF(pyobj_dom
);
7074 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7076 Py_XDECREF(pyobj_dict
);
7078 Py_DECREF(pyobj_ret
);
7082 LIBVIRT_RELEASE_THREAD_STATE
;
7085 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
7088 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
7090 libvirt_virConnectDomainEventDeviceRemovalFailedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7092 const char *devAlias
,
7095 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7096 PyObject
*pyobj_dom
;
7097 PyObject
*pyobj_ret
= NULL
;
7098 PyObject
*pyobj_conn
;
7102 LIBVIRT_ENSURE_THREAD_STATE
;
7104 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7106 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7109 /* Create a python instance of this virDomainPtr */
7111 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7115 Py_INCREF(pyobj_cbData
);
7117 /* Call the Callback Dispatcher */
7118 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7119 (char*)"_dispatchDomainEventDeviceRemovalFailedCallback",
7121 pyobj_dom
, devAlias
, pyobj_cbData
);
7123 Py_DECREF(pyobj_cbData
);
7124 Py_DECREF(pyobj_dom
);
7128 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7131 Py_DECREF(pyobj_ret
);
7135 LIBVIRT_RELEASE_THREAD_STATE
;
7139 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
7141 #ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
7143 libvirt_virConnectDomainEventMetadataChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7149 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7150 PyObject
*pyobj_dom
;
7151 PyObject
*pyobj_ret
= NULL
;
7152 PyObject
*pyobj_conn
;
7156 LIBVIRT_ENSURE_THREAD_STATE
;
7158 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7160 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7163 /* Create a python instance of this virDomainPtr */
7165 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7169 Py_INCREF(pyobj_cbData
);
7171 /* Call the Callback Dispatcher */
7172 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7173 (char*)"_dispatchDomainEventMetadataChangeCallback",
7175 pyobj_dom
, type
, nsuri
, pyobj_cbData
);
7177 Py_DECREF(pyobj_cbData
);
7178 Py_DECREF(pyobj_dom
);
7182 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7185 Py_DECREF(pyobj_ret
);
7189 LIBVIRT_RELEASE_THREAD_STATE
;
7192 #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */
7194 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
7196 libvirt_virConnectDomainEventBlockThresholdCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7200 unsigned long long threshold
,
7201 unsigned long long excess
,
7204 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7205 PyObject
*pyobj_dom
;
7206 PyObject
*pyobj_ret
= NULL
;
7207 PyObject
*pyobj_conn
;
7211 LIBVIRT_ENSURE_THREAD_STATE
;
7213 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7215 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7218 /* Create a python instance of this virDomainPtr */
7220 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7224 Py_INCREF(pyobj_cbData
);
7226 /* Call the Callback Dispatcher */
7227 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7228 (char*)"_dispatchDomainEventBlockThresholdCallback",
7230 pyobj_dom
, dev
, path
, threshold
, excess
,
7233 Py_DECREF(pyobj_cbData
);
7234 Py_DECREF(pyobj_dom
);
7238 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7241 Py_DECREF(pyobj_ret
);
7245 LIBVIRT_RELEASE_THREAD_STATE
;
7248 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */
7252 libvirt_virConnectDomainEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7255 PyObject
*py_retval
; /* return value */
7256 PyObject
*pyobj_conn
; /* virConnectPtr */
7257 PyObject
*pyobj_dom
;
7258 PyObject
*pyobj_cbData
; /* hash of callback data */
7262 virConnectDomainEventGenericCallback cb
= NULL
;
7265 if (!PyArg_ParseTuple(args
,
7266 (char *) "OOiO:virConnectDomainEventRegisterAny",
7267 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
))
7270 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
7271 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
7272 conn
= PyvirConnect_Get(pyobj_conn
);
7273 if (pyobj_dom
== Py_None
)
7276 dom
= PyvirDomain_Get(pyobj_dom
);
7278 switch ((virDomainEventID
) eventID
) {
7279 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
7280 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
7282 case VIR_DOMAIN_EVENT_ID_REBOOT
:
7283 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
7285 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
7286 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
7288 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
7289 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
7291 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
7292 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
7294 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
7295 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
7297 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
7298 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
7300 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
7301 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
7303 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
7304 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
7305 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
:
7306 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 */
7307 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
7309 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
7310 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
7312 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
7313 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
7315 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
7316 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
7318 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
7319 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
7321 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
7322 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
7323 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
7325 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
7326 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
7327 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
7328 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
7330 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
7331 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
7332 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
:
7333 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback
);
7335 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
7336 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
7337 case VIR_DOMAIN_EVENT_ID_TUNABLE
:
7338 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTunableCallback
);
7340 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
7341 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
7342 case VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
:
7343 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventAgentLifecycleCallback
);
7345 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
7346 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
7347 case VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
:
7348 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceAddedCallback
);
7350 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
7351 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
7352 case VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
:
7353 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMigrationIterationCallback
);
7355 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
7356 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
7357 case VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
:
7358 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventJobCompletedCallback
);
7360 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
7361 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
7362 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
:
7363 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovalFailedCallback
);
7365 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
7366 #ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
7367 case VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
:
7368 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMetadataChangeCallback
);
7370 #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */
7371 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
7372 case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
:
7373 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockThresholdCallback
);
7375 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */
7376 case VIR_DOMAIN_EVENT_ID_LAST
:
7381 return VIR_PY_INT_FAIL
;
7384 Py_INCREF(pyobj_cbData
);
7386 LIBVIRT_BEGIN_ALLOW_THREADS
;
7387 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
7389 libvirt_virConnectDomainEventFreeFunc
);
7390 LIBVIRT_END_ALLOW_THREADS
;
7393 Py_DECREF(pyobj_cbData
);
7396 py_retval
= libvirt_intWrap(ret
);
7401 libvirt_virConnectDomainEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7404 PyObject
*pyobj_conn
;
7409 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectDomainEventDeregister",
7410 &pyobj_conn
, &callbackID
))
7413 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
7415 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7417 LIBVIRT_BEGIN_ALLOW_THREADS
;
7418 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
7419 LIBVIRT_END_ALLOW_THREADS
;
7421 return libvirt_intWrap(ret
);
7424 #if LIBVIR_CHECK_VERSION(1, 2, 1)
7426 libvirt_virConnectNetworkEventFreeFunc(void *opaque
)
7428 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
7429 LIBVIRT_ENSURE_THREAD_STATE
;
7430 Py_DECREF(pyobj_conn
);
7431 LIBVIRT_RELEASE_THREAD_STATE
;
7435 libvirt_virConnectNetworkEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7441 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7442 PyObject
*pyobj_net
;
7443 PyObject
*pyobj_ret
= NULL
;
7444 PyObject
*pyobj_conn
;
7448 LIBVIRT_ENSURE_THREAD_STATE
;
7450 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7452 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7455 /* Create a python instance of this virNetworkPtr */
7457 if (!(pyobj_net
= libvirt_virNetworkPtrWrap(net
))) {
7458 virNetworkFree(net
);
7461 Py_INCREF(pyobj_cbData
);
7463 /* Call the Callback Dispatcher */
7464 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7465 (char*)"_dispatchNetworkEventLifecycleCallback",
7472 Py_DECREF(pyobj_cbData
);
7473 Py_DECREF(pyobj_net
);
7477 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7480 Py_DECREF(pyobj_ret
);
7484 LIBVIRT_RELEASE_THREAD_STATE
;
7489 libvirt_virConnectNetworkEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7492 PyObject
*pyobj_conn
; /* virConnectPtr */
7493 PyObject
*pyobj_net
;
7494 PyObject
*pyobj_cbData
; /* hash of callback data */
7498 virConnectNetworkEventGenericCallback cb
= NULL
;
7501 if (!PyArg_ParseTuple(args
,
7502 (char *) "OOiO:virConnectNetworkEventRegisterAny",
7503 &pyobj_conn
, &pyobj_net
, &eventID
, &pyobj_cbData
))
7506 DEBUG("libvirt_virConnectNetworkEventRegister(%p %p %d %p) called\n",
7507 pyobj_conn
, pyobj_net
, eventID
, pyobj_cbData
);
7508 conn
= PyvirConnect_Get(pyobj_conn
);
7509 if (pyobj_net
== Py_None
)
7512 net
= PyvirNetwork_Get(pyobj_net
);
7514 switch ((virNetworkEventID
) eventID
) {
7515 case VIR_NETWORK_EVENT_ID_LIFECYCLE
:
7516 cb
= VIR_NETWORK_EVENT_CALLBACK(libvirt_virConnectNetworkEventLifecycleCallback
);
7519 case VIR_NETWORK_EVENT_ID_LAST
:
7524 return VIR_PY_INT_FAIL
;
7527 Py_INCREF(pyobj_cbData
);
7529 LIBVIRT_BEGIN_ALLOW_THREADS
;
7530 ret
= virConnectNetworkEventRegisterAny(conn
, net
, eventID
,
7532 libvirt_virConnectNetworkEventFreeFunc
);
7533 LIBVIRT_END_ALLOW_THREADS
;
7536 Py_DECREF(pyobj_cbData
);
7539 return libvirt_intWrap(ret
);
7543 libvirt_virConnectNetworkEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7546 PyObject
*pyobj_conn
;
7551 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNetworkEventDeregister",
7552 &pyobj_conn
, &callbackID
))
7555 DEBUG("libvirt_virConnectNetworkEventDeregister(%p) called\n", pyobj_conn
);
7557 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7559 LIBVIRT_BEGIN_ALLOW_THREADS
;
7560 ret
= virConnectNetworkEventDeregisterAny(conn
, callbackID
);
7561 LIBVIRT_END_ALLOW_THREADS
;
7563 return libvirt_intWrap(ret
);
7565 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1)*/
7567 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7569 libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED
,
7573 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7574 PyObject
*pyobj_ret
;
7575 PyObject
*pyobj_conn
;
7578 LIBVIRT_ENSURE_THREAD_STATE
;
7580 Py_INCREF(pyobj_cbData
);
7582 dictKey
= libvirt_constcharPtrWrap("conn");
7583 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7586 /* Call the Callback Dispatcher */
7587 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7588 (char*)"_dispatchCloseCallback",
7593 Py_DECREF(pyobj_cbData
);
7596 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7599 Py_DECREF(pyobj_ret
);
7602 LIBVIRT_RELEASE_THREAD_STATE
;
7606 libvirt_virConnectRegisterCloseCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7609 PyObject
*pyobj_conn
; /* virConnectPtr */
7610 PyObject
*pyobj_cbData
; /* hash of callback data */
7614 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectRegisterCloseCallback",
7615 &pyobj_conn
, &pyobj_cbData
))
7618 DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
7619 pyobj_conn
, pyobj_cbData
);
7620 conn
= PyvirConnect_Get(pyobj_conn
);
7622 Py_INCREF(pyobj_cbData
);
7624 LIBVIRT_BEGIN_ALLOW_THREADS
;
7625 ret
= virConnectRegisterCloseCallback(conn
,
7626 libvirt_virConnectCloseCallbackDispatch
,
7628 libvirt_virConnectDomainEventFreeFunc
);
7629 LIBVIRT_END_ALLOW_THREADS
;
7632 Py_DECREF(pyobj_cbData
);
7635 return libvirt_intWrap(ret
);
7639 libvirt_virConnectUnregisterCloseCallback(PyObject
* self ATTRIBUTE_UNUSED
,
7642 PyObject
*pyobj_conn
;
7646 if (!PyArg_ParseTuple(args
, (char *) "O:virConnectUnregisterCloseCallback",
7650 DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
7653 conn
= PyvirConnect_Get(pyobj_conn
);
7655 LIBVIRT_BEGIN_ALLOW_THREADS
;
7656 ret
= virConnectUnregisterCloseCallback(conn
,
7657 libvirt_virConnectCloseCallbackDispatch
);
7658 LIBVIRT_END_ALLOW_THREADS
;
7660 return libvirt_intWrap(ret
);
7662 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7665 libvirt_virStreamEventFreeFunc(void *opaque
)
7667 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
7668 LIBVIRT_ENSURE_THREAD_STATE
;
7669 Py_DECREF(pyobj_stream
);
7670 LIBVIRT_RELEASE_THREAD_STATE
;
7674 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
7678 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7679 PyObject
*pyobj_stream
;
7680 PyObject
*pyobj_ret
;
7683 LIBVIRT_ENSURE_THREAD_STATE
;
7685 Py_INCREF(pyobj_cbData
);
7686 dictKey
= libvirt_constcharPtrWrap("stream");
7687 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7690 /* Call the pure python dispatcher */
7691 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
7692 (char *)"_dispatchStreamEventCallback",
7694 events
, pyobj_cbData
);
7696 Py_DECREF(pyobj_cbData
);
7699 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7702 Py_DECREF(pyobj_ret
);
7705 LIBVIRT_RELEASE_THREAD_STATE
;
7709 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7712 PyObject
*pyobj_stream
;
7713 PyObject
*pyobj_cbData
;
7714 virStreamPtr stream
;
7715 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
7719 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
7720 &pyobj_stream
, &events
, &pyobj_cbData
))
7723 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
7724 pyobj_stream
, events
, pyobj_cbData
);
7725 stream
= PyvirStream_Get(pyobj_stream
);
7727 Py_INCREF(pyobj_cbData
);
7729 LIBVIRT_BEGIN_ALLOW_THREADS
;
7730 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
7731 libvirt_virStreamEventFreeFunc
);
7732 LIBVIRT_END_ALLOW_THREADS
;
7735 Py_DECREF(pyobj_cbData
);
7738 return libvirt_intWrap(ret
);
7742 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
7745 PyObject
*pyobj_stream
;
7747 virStreamPtr stream
;
7752 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
7753 &pyobj_stream
, &nbytes
)) {
7756 stream
= PyvirStream_Get(pyobj_stream
);
7758 if (VIR_ALLOC_N(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
7759 return PyErr_NoMemory();
7761 LIBVIRT_BEGIN_ALLOW_THREADS
;
7762 ret
= virStreamRecv(stream
, buf
, nbytes
);
7763 LIBVIRT_END_ALLOW_THREADS
;
7765 buf
[ret
> -1 ? ret
: 0] = '\0';
7766 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
7769 return libvirt_intWrap(ret
);
7772 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
7778 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
7781 PyObject
*pyobj_stream
;
7782 PyObject
*pyobj_data
;
7783 virStreamPtr stream
;
7788 if (!PyArg_ParseTuple(args
, (char *) "OO:virStreamSend",
7789 &pyobj_stream
, &pyobj_data
))
7792 stream
= PyvirStream_Get(pyobj_stream
);
7793 libvirt_charPtrSizeUnwrap(pyobj_data
, &data
, &datalen
);
7795 LIBVIRT_BEGIN_ALLOW_THREADS
;
7796 ret
= virStreamSend(stream
, data
, datalen
);
7797 LIBVIRT_END_ALLOW_THREADS
;
7799 DEBUG("StreamSend ret=%d\n", ret
);
7801 return libvirt_intWrap(ret
);
7805 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
7808 virDomainPtr domain
;
7809 PyObject
*pyobj_domain
;
7810 PyObject
*pyobj_list
;
7816 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
7817 unsigned int nkeycodes
;
7819 if (!PyArg_ParseTuple(args
, (char *)"OiiOII:virDomainSendKey",
7820 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
7821 &nkeycodes
, &flags
))
7824 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7826 if (!PyList_Check(pyobj_list
)) {
7827 return VIR_PY_INT_FAIL
;
7830 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
7831 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
7832 return VIR_PY_INT_FAIL
;
7835 for (i
= 0; i
< nkeycodes
; i
++) {
7836 if (libvirt_uintUnwrap(PyList_GetItem(pyobj_list
, i
), &keycodes
[i
]) < 0)
7840 LIBVIRT_BEGIN_ALLOW_THREADS
;
7841 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
7842 LIBVIRT_END_ALLOW_THREADS
;
7844 DEBUG("virDomainSendKey ret=%d\n", ret
);
7846 return libvirt_intWrap(ret
);
7849 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7851 libvirt_virDomainMigrateGetCompressionCache(PyObject
*self ATTRIBUTE_UNUSED
,
7854 PyObject
*pyobj_domain
;
7855 virDomainPtr domain
;
7857 unsigned long long cacheSize
;
7860 if (!PyArg_ParseTuple(args
,
7861 (char *) "OI:virDomainMigrateGetCompressionCache",
7862 &pyobj_domain
, &flags
))
7865 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7867 LIBVIRT_BEGIN_ALLOW_THREADS
;
7868 rc
= virDomainMigrateGetCompressionCache(domain
, &cacheSize
, flags
);
7869 LIBVIRT_END_ALLOW_THREADS
;
7874 return libvirt_ulonglongWrap(cacheSize
);
7876 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7879 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
,
7883 unsigned long bandwidth
;
7884 virDomainPtr domain
;
7885 PyObject
*pyobj_domain
;
7886 unsigned int flags
= 0;
7888 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainMigrateGetMaxSpeed",
7889 &pyobj_domain
, &flags
))
7892 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7894 LIBVIRT_BEGIN_ALLOW_THREADS
;
7895 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
7896 LIBVIRT_END_ALLOW_THREADS
;
7899 return VIR_PY_INT_FAIL
;
7901 return libvirt_ulongWrap(bandwidth
);
7904 #if LIBVIR_CHECK_VERSION(3, 7, 0)
7906 libvirt_virDomainMigrateGetMaxDowntime(PyObject
*self ATTRIBUTE_UNUSED
,
7909 PyObject
*pyobj_domain
;
7910 virDomainPtr domain
;
7912 unsigned long long downtime
;
7915 if (!PyArg_ParseTuple(args
,
7916 (char *) "OI:virDomainMigrateGetMaxDowntime",
7917 &pyobj_domain
, &flags
))
7920 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7922 LIBVIRT_BEGIN_ALLOW_THREADS
;
7923 rc
= virDomainMigrateGetMaxDowntime(domain
, &downtime
, flags
);
7924 LIBVIRT_END_ALLOW_THREADS
;
7929 return libvirt_ulonglongWrap(downtime
);
7931 #endif /* LIBVIR_CHECK_VERSION(3, 7, 0) */
7933 #if LIBVIR_CHECK_VERSION(1, 1, 0)
7934 static virPyTypedParamsHint virPyDomainMigrate3Params
[] = {
7935 # ifdef VIR_MIGRATE_PARAM_URI
7936 { VIR_MIGRATE_PARAM_URI
, VIR_TYPED_PARAM_STRING
},
7938 # ifdef VIR_MIGRATE_PARAM_DEST_NAME
7939 { VIR_MIGRATE_PARAM_DEST_NAME
, VIR_TYPED_PARAM_STRING
},
7941 # ifdef VIR_MIGRATE_PARAM_DEST_XML
7942 { VIR_MIGRATE_PARAM_DEST_XML
, VIR_TYPED_PARAM_STRING
},
7944 # ifdef VIR_MIGRATE_PARAM_PERSIST_XML
7945 { VIR_MIGRATE_PARAM_PERSIST_XML
, VIR_TYPED_PARAM_STRING
},
7947 # ifdef VIR_MIGRATE_PARAM_BANDWIDTH
7948 { VIR_MIGRATE_PARAM_BANDWIDTH
, VIR_TYPED_PARAM_ULLONG
},
7950 # ifdef VIR_MIGRATE_PARAM_GRAPHICS_URI
7951 { VIR_MIGRATE_PARAM_GRAPHICS_URI
, VIR_TYPED_PARAM_STRING
},
7953 # ifdef VIR_MIGRATE_PARAM_LISTEN_ADDRESS
7954 { VIR_MIGRATE_PARAM_LISTEN_ADDRESS
, VIR_TYPED_PARAM_STRING
},
7956 # ifdef VIR_MIGRATE_PARAM_MIGRATE_DISKS
7957 { VIR_MIGRATE_PARAM_MIGRATE_DISKS
, VIR_TYPED_PARAM_STRING
},
7959 # ifdef VIR_MIGRATE_PARAM_DISKS_PORT
7960 { VIR_MIGRATE_PARAM_DISKS_PORT
, VIR_TYPED_PARAM_INT
},
7962 # ifdef VIR_MIGRATE_PARAM_COMPRESSION
7963 { VIR_MIGRATE_PARAM_COMPRESSION
, VIR_TYPED_PARAM_STRING
},
7965 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL
7966 { VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL
, VIR_TYPED_PARAM_INT
},
7968 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS
7969 { VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS
, VIR_TYPED_PARAM_INT
},
7971 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS
7972 { VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS
, VIR_TYPED_PARAM_INT
},
7974 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE
7975 { VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE
, VIR_TYPED_PARAM_ULLONG
},
7977 # ifdef VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL
7978 { VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL
, VIR_TYPED_PARAM_INT
},
7980 # ifdef VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT
7981 { VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT
, VIR_TYPED_PARAM_INT
},
7987 libvirt_virDomainMigrate3(PyObject
*self ATTRIBUTE_UNUSED
,
7990 PyObject
*pyobj_domain
;
7991 virDomainPtr domain
;
7992 PyObject
*pyobj_dconn
;
7993 virConnectPtr dconn
;
7996 virTypedParameterPtr params
;
7998 virDomainPtr ddom
= NULL
;
8000 if (!PyArg_ParseTuple(args
, (char *) "OOOI:virDomainMigrate3",
8001 &pyobj_domain
, &pyobj_dconn
, &dict
, &flags
))
8004 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8005 dconn
= (virConnectPtr
) PyvirConnect_Get(pyobj_dconn
);
8007 if (!PyDict_Check(dict
)) {
8008 PyErr_Format(PyExc_TypeError
, "migration params must be a dictionary");
8012 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
,
8013 virPyDomainMigrate3Params
,
8014 VIR_N_ELEMENTS(virPyDomainMigrate3Params
)) < 0) {
8018 LIBVIRT_BEGIN_ALLOW_THREADS
;
8019 ddom
= virDomainMigrate3(domain
, dconn
, params
, nparams
, flags
);
8020 LIBVIRT_END_ALLOW_THREADS
;
8022 virTypedParamsFree(params
, nparams
);
8023 return libvirt_virDomainPtrWrap(ddom
);
8027 libvirt_virDomainMigrateToURI3(PyObject
*self ATTRIBUTE_UNUSED
,
8030 PyObject
*pyobj_domain
;
8031 virDomainPtr domain
;
8035 virTypedParameterPtr params
;
8039 if (!PyArg_ParseTuple(args
, (char *) "OzOI:virDomainMigrate3",
8040 &pyobj_domain
, &dconnuri
, &dict
, &flags
))
8043 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8045 if (!PyDict_Check(dict
)) {
8046 PyErr_Format(PyExc_TypeError
, "migration params must be a dictionary");
8050 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
,
8051 virPyDomainMigrate3Params
,
8052 VIR_N_ELEMENTS(virPyDomainMigrate3Params
)) < 0) {
8056 LIBVIRT_BEGIN_ALLOW_THREADS
;
8057 ret
= virDomainMigrateToURI3(domain
, dconnuri
, params
, nparams
, flags
);
8058 LIBVIRT_END_ALLOW_THREADS
;
8060 virTypedParamsFree(params
, nparams
);
8061 return libvirt_intWrap(ret
);
8063 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
8066 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
8069 PyObject
*py_retval
= NULL
;
8071 virDomainPtr domain
;
8072 PyObject
*pyobj_domain
;
8074 unsigned long long offset
;
8079 if (!PyArg_ParseTuple(args
, (char *)"OzKkI:virDomainBlockPeek",
8080 &pyobj_domain
, &disk
, &offset
, &size
, &flags
))
8083 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8085 if (VIR_ALLOC_N(buf
, size
) < 0)
8086 return PyErr_NoMemory();
8088 LIBVIRT_BEGIN_ALLOW_THREADS
;
8089 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
8090 LIBVIRT_END_ALLOW_THREADS
;
8093 py_retval
= VIR_PY_NONE
;
8097 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
8105 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
8108 PyObject
*py_retval
= NULL
;
8110 virDomainPtr domain
;
8111 PyObject
*pyobj_domain
;
8112 unsigned long long start
;
8117 if (!PyArg_ParseTuple(args
, (char *)"OKkI:virDomainMemoryPeek",
8118 &pyobj_domain
, &start
, &size
, &flags
))
8121 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8123 if (VIR_ALLOC_N(buf
, size
) < 0)
8124 return PyErr_NoMemory();
8126 LIBVIRT_BEGIN_ALLOW_THREADS
;
8127 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
8128 LIBVIRT_END_ALLOW_THREADS
;
8131 py_retval
= VIR_PY_NONE
;
8135 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
8142 #if LIBVIR_CHECK_VERSION(0, 10, 2)
8144 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
8148 PyObject
*pyobj_conn
, *info
;
8149 PyObject
*ret
= NULL
;
8152 Py_ssize_t size
= 0;
8154 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
8156 if (!PyArg_ParseTuple(args
,
8157 (char *)"OOI:virNodeSetMemoryParameters",
8158 &pyobj_conn
, &info
, &flags
))
8160 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8162 if ((size
= PyDict_Size(info
)) < 0)
8166 PyErr_Format(PyExc_LookupError
,
8167 "Need non-empty dictionary to set attributes");
8171 LIBVIRT_BEGIN_ALLOW_THREADS
;
8172 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
8173 LIBVIRT_END_ALLOW_THREADS
;
8176 return VIR_PY_INT_FAIL
;
8179 PyErr_Format(PyExc_LookupError
,
8180 "no settable attributes");
8184 if (VIR_ALLOC_N(params
, nparams
) < 0)
8185 return PyErr_NoMemory();
8187 LIBVIRT_BEGIN_ALLOW_THREADS
;
8188 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
8189 LIBVIRT_END_ALLOW_THREADS
;
8192 ret
= VIR_PY_INT_FAIL
;
8196 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
8200 LIBVIRT_BEGIN_ALLOW_THREADS
;
8201 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
8202 LIBVIRT_END_ALLOW_THREADS
;
8205 ret
= VIR_PY_INT_FAIL
;
8209 ret
= VIR_PY_INT_SUCCESS
;
8212 virTypedParamsFree(params
, nparams
);
8213 virTypedParamsFree(new_params
, size
);
8218 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
8222 PyObject
*pyobj_conn
;
8223 PyObject
*ret
= NULL
;
8227 virTypedParameterPtr params
;
8229 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetMemoryParameters",
8230 &pyobj_conn
, &flags
))
8232 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8234 LIBVIRT_BEGIN_ALLOW_THREADS
;
8235 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
8236 LIBVIRT_END_ALLOW_THREADS
;
8242 return PyDict_New();
8244 if (VIR_ALLOC_N(params
, nparams
) < 0)
8245 return PyErr_NoMemory();
8247 LIBVIRT_BEGIN_ALLOW_THREADS
;
8248 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
8249 LIBVIRT_END_ALLOW_THREADS
;
8256 ret
= getPyVirTypedParameter(params
, nparams
);
8259 virTypedParamsFree(params
, nparams
);
8262 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
8264 #if LIBVIR_CHECK_VERSION(1, 0, 0)
8266 libvirt_virNodeGetCPUMap(PyObject
*self ATTRIBUTE_UNUSED
,
8270 PyObject
*pyobj_conn
;
8271 PyObject
*ret
= NULL
;
8272 PyObject
*pycpumap
= NULL
;
8274 unsigned char *cpumap
= NULL
;
8275 unsigned int online
= 0;
8279 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetCPUMap",
8280 &pyobj_conn
, &flags
))
8282 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8284 LIBVIRT_BEGIN_ALLOW_THREADS
;
8285 i_retval
= virNodeGetCPUMap(conn
, &cpumap
, &online
, flags
);
8286 LIBVIRT_END_ALLOW_THREADS
;
8291 if ((ret
= PyTuple_New(3)) == NULL
)
8294 /* 0: number of CPUs */
8295 VIR_PY_TUPLE_SET_GOTO(ret
, 0, libvirt_intWrap(i_retval
), error
);
8298 if ((pycpumap
= PyList_New(i_retval
)) == NULL
)
8301 VIR_PY_TUPLE_SET_GOTO(ret
, 1, pycpumap
, error
);
8303 for (i
= 0; i
< i_retval
; i
++)
8304 VIR_PY_LIST_SET_GOTO(pycpumap
, i
,
8305 PyBool_FromLong(VIR_CPU_USED(cpumap
, i
)), error
);
8307 /* 2: number of online CPUs */
8308 VIR_PY_TUPLE_SET_GOTO(ret
, 2, libvirt_uintWrap(online
), error
);
8318 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
8321 #if LIBVIR_CHECK_VERSION(1, 1, 1)
8323 libvirt_virDomainCreateWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
8326 PyObject
*py_retval
= NULL
;
8328 virDomainPtr domain
;
8329 PyObject
*pyobj_domain
;
8330 PyObject
*pyobj_files
;
8332 unsigned int nfiles
;
8336 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainCreateWithFiles",
8337 &pyobj_domain
, &pyobj_files
, &flags
))
8339 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8341 nfiles
= PyList_Size(pyobj_files
);
8343 if (VIR_ALLOC_N(files
, nfiles
) < 0)
8344 return PyErr_NoMemory();
8346 for (i
= 0; i
< nfiles
; i
++) {
8350 pyfd
= PyList_GetItem(pyobj_files
, i
);
8352 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
8358 LIBVIRT_BEGIN_ALLOW_THREADS
;
8359 c_retval
= virDomainCreateWithFiles(domain
, nfiles
, files
, flags
);
8360 LIBVIRT_END_ALLOW_THREADS
;
8362 py_retval
= libvirt_intWrap((int) c_retval
);
8371 libvirt_virDomainCreateXMLWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
8374 PyObject
*py_retval
= NULL
;
8375 virDomainPtr c_retval
;
8377 PyObject
*pyobj_conn
;
8379 PyObject
*pyobj_files
;
8381 unsigned int nfiles
;
8385 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainCreateXMLWithFiles",
8386 &pyobj_conn
, &xmlDesc
, &pyobj_files
, &flags
))
8388 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8390 nfiles
= PyList_Size(pyobj_files
);
8392 if (VIR_ALLOC_N(files
, nfiles
) < 0)
8393 return PyErr_NoMemory();
8395 for (i
= 0; i
< nfiles
; i
++) {
8399 pyfd
= PyList_GetItem(pyobj_files
, i
);
8401 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
8407 LIBVIRT_BEGIN_ALLOW_THREADS
;
8408 c_retval
= virDomainCreateXMLWithFiles(conn
, xmlDesc
, nfiles
, files
, flags
);
8409 LIBVIRT_END_ALLOW_THREADS
;
8411 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
8417 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
8420 #if LIBVIR_CHECK_VERSION(1, 2, 5)
8422 libvirt_virDomainFSFreeze(PyObject
*self ATTRIBUTE_UNUSED
,
8425 PyObject
*py_retval
= NULL
;
8427 virDomainPtr domain
;
8428 PyObject
*pyobj_domain
;
8429 PyObject
*pyobj_list
;
8431 unsigned int nmountpoints
= 0;
8432 char **mountpoints
= NULL
;
8435 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSFreeze",
8436 &pyobj_domain
, &pyobj_list
, &flags
))
8438 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8440 if (PyList_Check(pyobj_list
)) {
8441 nmountpoints
= PyList_Size(pyobj_list
);
8443 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8444 return PyErr_NoMemory();
8446 for (i
= 0; i
< nmountpoints
; i
++) {
8447 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8453 LIBVIRT_BEGIN_ALLOW_THREADS
;
8454 c_retval
= virDomainFSFreeze(domain
, (const char **) mountpoints
,
8455 nmountpoints
, flags
);
8456 LIBVIRT_END_ALLOW_THREADS
;
8458 py_retval
= libvirt_intWrap(c_retval
);
8461 for (j
= 0 ; j
< i
; j
++)
8462 VIR_FREE(mountpoints
[j
]);
8463 VIR_FREE(mountpoints
);
8469 libvirt_virDomainFSThaw(PyObject
*self ATTRIBUTE_UNUSED
,
8472 PyObject
*py_retval
= NULL
;
8474 virDomainPtr domain
;
8475 PyObject
*pyobj_domain
;
8476 PyObject
*pyobj_list
;
8478 unsigned int nmountpoints
= 0;
8479 char **mountpoints
= NULL
;
8482 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSThaw",
8483 &pyobj_domain
, &pyobj_list
, &flags
))
8485 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8487 if (PyList_Check(pyobj_list
)) {
8488 nmountpoints
= PyList_Size(pyobj_list
);
8490 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8491 return PyErr_NoMemory();
8493 for (i
= 0; i
< nmountpoints
; i
++) {
8494 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8500 LIBVIRT_BEGIN_ALLOW_THREADS
;
8501 c_retval
= virDomainFSThaw(domain
, (const char **) mountpoints
,
8502 nmountpoints
, flags
);
8503 LIBVIRT_END_ALLOW_THREADS
;
8505 py_retval
= libvirt_intWrap(c_retval
);
8508 for (j
= 0 ; j
< i
; j
++)
8509 VIR_FREE(mountpoints
[j
]);
8510 VIR_FREE(mountpoints
);
8515 libvirt_virDomainGetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8518 PyObject
*py_retval
= NULL
;
8519 PyObject
*dict
= NULL
;
8520 PyObject
*pyobj_domain
;
8521 virDomainPtr domain
;
8523 unsigned int nseconds
;
8527 if (!PyArg_ParseTuple(args
, (char*)"OI:virDomainGetTime",
8528 &pyobj_domain
, &flags
))
8530 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8532 if (!(dict
= PyDict_New()))
8535 LIBVIRT_BEGIN_ALLOW_THREADS
;
8536 c_retval
= virDomainGetTime(domain
, &seconds
, &nseconds
, flags
);
8537 LIBVIRT_END_ALLOW_THREADS
;
8540 py_retval
= VIR_PY_NONE
;
8544 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("seconds"),
8545 libvirt_longlongWrap(seconds
), cleanup
);
8546 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("nseconds"),
8547 libvirt_longlongWrap(nseconds
), cleanup
);
8558 libvirt_virDomainSetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8561 PyObject
*pyobj_domain
;
8562 PyObject
*pyobj_seconds
;
8563 PyObject
*pyobj_nseconds
;
8565 virDomainPtr domain
;
8566 long long seconds
= 0;
8567 unsigned int nseconds
= 0;
8569 ssize_t py_dict_size
= 0;
8572 if (!PyArg_ParseTuple(args
, (char*)"OOI:virDomainSetTime",
8573 &pyobj_domain
, &py_dict
, &flags
))
8575 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8577 if (PyDict_Check(py_dict
)) {
8578 py_dict_size
= PyDict_Size(py_dict
);
8579 if ((pyobj_seconds
= PyDict_GetItemString(py_dict
, "seconds"))) {
8580 if (libvirt_longlongUnwrap(pyobj_seconds
, &seconds
) < 0)
8583 PyErr_Format(PyExc_LookupError
, "Dictionary must contains 'seconds'");
8587 if ((pyobj_nseconds
= PyDict_GetItemString(py_dict
, "nseconds"))) {
8588 if (libvirt_uintUnwrap(pyobj_nseconds
, &nseconds
) < 0)
8590 } else if (py_dict_size
> 1) {
8591 PyErr_Format(PyExc_LookupError
, "Dictionary contains unknown key");
8594 } else if (py_dict
!= Py_None
|| !flags
) {
8595 PyErr_Format(PyExc_TypeError
, "time must be a dictionary "
8596 "or None with flags set");
8600 LIBVIRT_BEGIN_ALLOW_THREADS
;
8601 c_retval
= virDomainSetTime(domain
, seconds
, nseconds
, flags
);
8602 LIBVIRT_END_ALLOW_THREADS
;
8604 return libvirt_intWrap(c_retval
);
8606 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
8609 #if LIBVIR_CHECK_VERSION(1, 2, 6)
8611 libvirt_virNodeGetFreePages(PyObject
*self ATTRIBUTE_UNUSED
,
8614 PyObject
*py_retval
= NULL
;
8615 PyObject
*pyobj_conn
;
8616 PyObject
*pyobj_pagesize
;
8617 PyObject
*pyobj_counts
= NULL
;
8619 unsigned int *pages
= NULL
;
8621 unsigned int cellCount
;
8623 unsigned long long *counts
= NULL
;
8625 ssize_t pyobj_pagesize_size
, i
, j
;
8627 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeGetFreePages",
8628 &pyobj_conn
, &pyobj_pagesize
, &startCell
,
8629 &cellCount
, &flags
))
8632 if (!PyList_Check(pyobj_pagesize
)) {
8633 PyErr_Format(PyExc_TypeError
, "pagesize must be list");
8637 if (cellCount
== 0) {
8638 PyErr_Format(PyExc_LookupError
, "cellCount must not be zero");
8642 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8644 pyobj_pagesize_size
= PyList_Size(pyobj_pagesize
);
8645 if (VIR_ALLOC_N(pages
, pyobj_pagesize_size
) < 0 ||
8646 VIR_ALLOC_N(counts
, pyobj_pagesize_size
* cellCount
) < 0) {
8651 if (!(pyobj_counts
= PyDict_New()))
8654 for (i
= 0; i
< pyobj_pagesize_size
; i
++) {
8655 PyObject
*tmp
= PyList_GetItem(pyobj_pagesize
, i
);
8657 if (libvirt_uintUnwrap(tmp
, &pages
[i
]) < 0)
8661 LIBVIRT_BEGIN_ALLOW_THREADS
;
8662 c_retval
= virNodeGetFreePages(conn
,
8663 pyobj_pagesize_size
, pages
,
8664 startCell
, cellCount
,
8666 LIBVIRT_END_ALLOW_THREADS
;
8669 py_retval
= VIR_PY_NONE
;
8673 for (i
= 0; i
< c_retval
;) {
8674 PyObject
*per_node
= NULL
;
8676 if (!(per_node
= PyDict_New()))
8679 VIR_PY_DICT_SET_GOTO(pyobj_counts
,
8680 libvirt_intWrap(startCell
+ i
/pyobj_pagesize_size
),
8683 for (j
= 0; j
< pyobj_pagesize_size
; j
++)
8684 VIR_PY_DICT_SET_GOTO(per_node
, libvirt_intWrap(pages
[j
]),
8685 libvirt_intWrap(counts
[i
+ j
]), cleanup
);
8687 i
+= pyobj_pagesize_size
;
8690 py_retval
= pyobj_counts
;
8691 pyobj_counts
= NULL
;
8693 Py_XDECREF(pyobj_counts
);
8701 libvirt_virNetworkGetDHCPLeases(PyObject
*self ATTRIBUTE_UNUSED
,
8704 PyObject
*py_retval
= NULL
;
8705 PyObject
*py_lease
= NULL
;
8706 virNetworkPtr network
;
8707 PyObject
*pyobj_network
;
8709 virNetworkDHCPLeasePtr
*leases
= NULL
;
8714 if (!PyArg_ParseTuple(args
, (char *) "OzI:virNetworkGetDHCPLeases",
8715 &pyobj_network
, &mac
, &flags
))
8718 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
8720 LIBVIRT_BEGIN_ALLOW_THREADS
;
8721 leases_count
= virNetworkGetDHCPLeases(network
, mac
, &leases
, flags
);
8722 LIBVIRT_END_ALLOW_THREADS
;
8724 if (leases_count
< 0) {
8725 py_retval
= VIR_PY_NONE
;
8729 if (!(py_retval
= PyList_New(leases_count
)))
8732 for (i
= 0; i
< leases_count
; i
++) {
8733 virNetworkDHCPLeasePtr lease
= leases
[i
];
8735 if ((py_lease
= PyDict_New()) == NULL
)
8738 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_lease
, error
);
8740 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iface"),
8741 libvirt_charPtrWrap(lease
->iface
), error
);
8742 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("expirytime"),
8743 libvirt_longlongWrap(lease
->expirytime
), error
);
8744 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("type"),
8745 libvirt_intWrap(lease
->type
), error
);
8746 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("mac"),
8747 libvirt_charPtrWrap(lease
->mac
), error
);
8748 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("ipaddr"),
8749 libvirt_charPtrWrap(lease
->ipaddr
), error
);
8750 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("prefix"),
8751 libvirt_uintWrap(lease
->prefix
), error
);
8752 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("hostname"),
8753 libvirt_charPtrWrap(lease
->hostname
), error
);
8754 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("clientid"),
8755 libvirt_charPtrWrap(lease
->clientid
), error
);
8756 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iaid"),
8757 libvirt_charPtrWrap(lease
->iaid
), error
);
8761 if (leases_count
> 0)
8762 for (i
= 0; i
< leases_count
; i
++)
8763 virNetworkDHCPLeaseFree(leases
[i
]);
8769 Py_CLEAR(py_retval
);
8773 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
8775 #if LIBVIR_CHECK_VERSION(1, 2, 8)
8778 convertDomainStatsRecord(virDomainStatsRecordPtr
*records
,
8781 PyObject
*py_retval
;
8782 PyObject
*py_record
;
8783 PyObject
*py_record_stats
= NULL
;
8784 virDomainPtr dom
= NULL
;
8787 if (!(py_retval
= PyList_New(nrecords
)))
8790 for (i
= 0; i
< nrecords
; i
++) {
8791 if (!(py_record
= PyTuple_New(2)))
8794 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_record
, error
);
8796 dom
= records
[i
]->dom
;
8798 VIR_PY_TUPLE_SET_GOTO(py_record
, 0,
8799 libvirt_virDomainPtrWrap(dom
),
8803 if (!(py_record_stats
= getPyVirTypedParameter(records
[i
]->params
,
8804 records
[i
]->nparams
)))
8806 VIR_PY_TUPLE_SET_GOTO(py_record
, 1, py_record_stats
, error
);
8815 Py_XDECREF(py_retval
);
8821 libvirt_virConnectGetAllDomainStats(PyObject
*self ATTRIBUTE_UNUSED
,
8824 PyObject
*pyobj_conn
;
8825 PyObject
*py_retval
;
8827 virDomainStatsRecordPtr
*records
;
8832 if (!PyArg_ParseTuple(args
, (char *)"OII:virConnectGetAllDomainStats",
8833 &pyobj_conn
, &stats
, &flags
))
8835 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8837 LIBVIRT_BEGIN_ALLOW_THREADS
;
8838 nrecords
= virConnectGetAllDomainStats(conn
, stats
, &records
, flags
);
8839 LIBVIRT_END_ALLOW_THREADS
;
8844 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8846 virDomainStatsRecordListFree(records
);
8853 libvirt_virDomainListGetStats(PyObject
*self ATTRIBUTE_UNUSED
,
8856 PyObject
*pyobj_conn
;
8857 PyObject
*py_retval
;
8858 PyObject
*py_domlist
;
8859 virDomainStatsRecordPtr
*records
= NULL
;
8860 virDomainPtr
*doms
= NULL
;
8867 if (!PyArg_ParseTuple(args
, (char *)"OOII:virDomainListGetStats",
8868 &pyobj_conn
, &py_domlist
, &stats
, &flags
))
8871 if (PyList_Check(py_domlist
)) {
8872 ndoms
= PyList_Size(py_domlist
);
8874 if (VIR_ALLOC_N(doms
, ndoms
+ 1) < 0)
8875 return PyErr_NoMemory();
8877 for (i
= 0; i
< ndoms
; i
++)
8878 doms
[i
] = PyvirDomain_Get(PyList_GetItem(py_domlist
, i
));
8881 LIBVIRT_BEGIN_ALLOW_THREADS
;
8882 nrecords
= virDomainListGetStats(doms
, stats
, &records
, flags
);
8883 LIBVIRT_END_ALLOW_THREADS
;
8886 py_retval
= VIR_PY_NONE
;
8890 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8893 virDomainStatsRecordListFree(records
);
8900 static virPyTypedParamsHint virPyDomainBlockCopyParams
[] = {
8901 { VIR_DOMAIN_BLOCK_COPY_BANDWIDTH
, VIR_TYPED_PARAM_ULLONG
},
8902 { VIR_DOMAIN_BLOCK_COPY_GRANULARITY
, VIR_TYPED_PARAM_UINT
},
8903 { VIR_DOMAIN_BLOCK_COPY_BUF_SIZE
, VIR_TYPED_PARAM_ULLONG
},
8908 libvirt_virDomainBlockCopy(PyObject
*self ATTRIBUTE_UNUSED
,
8911 PyObject
*pyobj_dom
= NULL
;
8912 PyObject
*pyobj_dict
= NULL
;
8916 char *destxml
= NULL
;
8917 virTypedParameterPtr params
= NULL
;
8919 unsigned int flags
= 0;
8922 if (!PyArg_ParseTuple(args
, (char *) "Ozz|OI:virDomainBlockCopy",
8923 &pyobj_dom
, &disk
, &destxml
, &pyobj_dict
, &flags
))
8926 if (PyDict_Check(pyobj_dict
)) {
8927 if (virPyDictToTypedParams(pyobj_dict
, ¶ms
, &nparams
,
8928 virPyDomainBlockCopyParams
,
8929 VIR_N_ELEMENTS(virPyDomainBlockCopyParams
)) < 0) {
8932 } else if (pyobj_dict
!= Py_None
) {
8933 PyErr_Format(PyExc_TypeError
, "block params must be a dictionary");
8937 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
8939 LIBVIRT_BEGIN_ALLOW_THREADS
;
8940 c_retval
= virDomainBlockCopy(dom
, disk
, destxml
, params
, nparams
, flags
);
8941 LIBVIRT_END_ALLOW_THREADS
;
8943 virTypedParamsFree(params
, nparams
);
8944 return libvirt_intWrap(c_retval
);
8947 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
8949 #if LIBVIR_CHECK_VERSION(1, 2, 9)
8951 libvirt_virNodeAllocPages(PyObject
*self ATTRIBUTE_UNUSED
,
8954 PyObject
*pyobj_conn
;
8955 PyObject
*pyobj_pages
;
8956 Py_ssize_t size
= 0;
8958 PyObject
*key
, *value
;
8960 unsigned int npages
= 0;
8961 unsigned int *pageSizes
= NULL
;
8962 unsigned long long *pageCounts
= NULL
;
8964 unsigned int cellCount
= 1;
8965 unsigned int flags
= VIR_NODE_ALLOC_PAGES_ADD
;
8968 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeAllocPages",
8969 &pyobj_conn
, &pyobj_pages
,
8970 &startCell
, &cellCount
, &flags
))
8972 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8974 if ((size
= PyDict_Size(pyobj_pages
)) < 0)
8978 PyErr_Format(PyExc_LookupError
,
8979 "Need non-empty dictionary to pages attribute");
8983 if (VIR_ALLOC_N(pageSizes
, size
) < 0 ||
8984 VIR_ALLOC_N(pageCounts
, size
) < 0) {
8989 while (PyDict_Next(pyobj_pages
, &pos
, &key
, &value
)) {
8990 if (libvirt_uintUnwrap(key
, &pageSizes
[npages
]) < 0 ||
8991 libvirt_ulonglongUnwrap(value
, &pageCounts
[npages
]) < 0)
8996 LIBVIRT_BEGIN_ALLOW_THREADS
;
8997 c_retval
= virNodeAllocPages(conn
, npages
, pageSizes
,
8998 pageCounts
, startCell
, cellCount
, flags
);
8999 LIBVIRT_END_ALLOW_THREADS
;
9001 VIR_FREE(pageSizes
);
9002 VIR_FREE(pageCounts
);
9004 return libvirt_intWrap(c_retval
);
9007 VIR_FREE(pageSizes
);
9008 VIR_FREE(pageCounts
);
9011 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
9013 #if LIBVIR_CHECK_VERSION(1, 2, 11)
9016 libvirt_virDomainGetFSInfo(PyObject
*self ATTRIBUTE_UNUSED
,
9019 virDomainPtr domain
;
9020 PyObject
*pyobj_domain
;
9022 virDomainFSInfoPtr
*fsinfo
= NULL
;
9025 PyObject
*py_retval
= NULL
;
9027 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetFSInfo",
9028 &pyobj_domain
, &flags
))
9030 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9032 LIBVIRT_BEGIN_ALLOW_THREADS
;
9033 c_retval
= virDomainGetFSInfo(domain
, &fsinfo
, flags
);
9034 LIBVIRT_END_ALLOW_THREADS
;
9037 py_retval
= VIR_PY_NONE
;
9041 /* convert to a Python list */
9042 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
9045 for (i
= 0; i
< c_retval
; i
++) {
9046 virDomainFSInfoPtr fs
= fsinfo
[i
];
9047 PyObject
*info
, *alias
;
9052 info
= PyTuple_New(4);
9056 VIR_PY_LIST_SET_GOTO(py_retval
, i
, info
, error
);
9058 VIR_PY_TUPLE_SET_GOTO(info
, 0,
9059 libvirt_constcharPtrWrap(fs
->mountpoint
), error
);
9060 VIR_PY_TUPLE_SET_GOTO(info
, 1,
9061 libvirt_constcharPtrWrap(fs
->name
), error
);
9062 VIR_PY_TUPLE_SET_GOTO(info
, 2,
9063 libvirt_constcharPtrWrap(fs
->fstype
), error
);
9065 alias
= PyList_New(0);
9068 VIR_PY_TUPLE_SET_GOTO(info
, 3, alias
, error
);
9070 for (j
= 0; j
< fs
->ndevAlias
; j
++)
9071 VIR_PY_LIST_APPEND_GOTO(alias
,
9072 libvirt_constcharPtrWrap(fs
->devAlias
[j
]),
9078 for (i
= 0; i
< c_retval
; i
++)
9079 virDomainFSInfoFree(fsinfo
[i
]);
9084 Py_CLEAR(py_retval
);
9088 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
9090 #if LIBVIR_CHECK_VERSION(1, 3, 3)
9092 libvirt_virDomainGetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
9095 PyObject
*pyobj_domain
;
9096 virDomainPtr domain
;
9097 virTypedParameterPtr params
= NULL
;
9099 PyObject
*dict
= NULL
;
9103 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetPerfEvents",
9104 &pyobj_domain
, &flags
))
9106 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9108 LIBVIRT_BEGIN_ALLOW_THREADS
;
9109 rc
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
9110 LIBVIRT_END_ALLOW_THREADS
;
9115 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
9119 virTypedParamsFree(params
, nparams
);
9124 libvirt_virDomainSetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
9127 virDomainPtr domain
;
9128 PyObject
*pyobj_domain
, *info
;
9129 PyObject
*ret
= NULL
;
9132 Py_ssize_t size
= 0;
9134 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
9136 if (!PyArg_ParseTuple(args
,
9137 (char *)"OOI:virDomainSetPerfEvents",
9138 &pyobj_domain
, &info
, &flags
))
9140 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9142 if ((size
= PyDict_Size(info
)) < 0)
9146 PyErr_Format(PyExc_LookupError
,
9147 "Need non-empty dictionary to set attributes");
9151 LIBVIRT_BEGIN_ALLOW_THREADS
;
9152 i_retval
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
9153 LIBVIRT_END_ALLOW_THREADS
;
9156 return VIR_PY_INT_FAIL
;
9159 PyErr_Format(PyExc_LookupError
,
9160 "Domain has no settable attributes");
9164 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
9168 LIBVIRT_BEGIN_ALLOW_THREADS
;
9169 i_retval
= virDomainSetPerfEvents(domain
, new_params
, size
, flags
);
9170 LIBVIRT_END_ALLOW_THREADS
;
9173 ret
= VIR_PY_INT_FAIL
;
9177 ret
= VIR_PY_INT_SUCCESS
;
9180 virTypedParamsFree(params
, nparams
);
9181 virTypedParamsFree(new_params
, size
);
9184 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
9186 #if LIBVIR_CHECK_VERSION(2, 0, 0)
9188 libvirt_virConnectStoragePoolEventFreeFunc(void *opaque
)
9190 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9191 LIBVIRT_ENSURE_THREAD_STATE
;
9192 Py_DECREF(pyobj_conn
);
9193 LIBVIRT_RELEASE_THREAD_STATE
;
9197 libvirt_virConnectStoragePoolEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9198 virStoragePoolPtr pool
,
9203 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9204 PyObject
*pyobj_pool
;
9205 PyObject
*pyobj_ret
= NULL
;
9206 PyObject
*pyobj_conn
;
9210 LIBVIRT_ENSURE_THREAD_STATE
;
9212 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9214 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9217 /* Create a python instance of this virStoragePoolPtr */
9218 virStoragePoolRef(pool
);
9219 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
9220 virStoragePoolFree(pool
);
9223 Py_INCREF(pyobj_cbData
);
9225 /* Call the Callback Dispatcher */
9226 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9227 (char*)"_dispatchStoragePoolEventLifecycleCallback",
9234 Py_DECREF(pyobj_cbData
);
9235 Py_DECREF(pyobj_pool
);
9239 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9242 Py_DECREF(pyobj_ret
);
9246 LIBVIRT_RELEASE_THREAD_STATE
;
9251 libvirt_virConnectStoragePoolEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9252 virStoragePoolPtr pool
,
9255 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9256 PyObject
*pyobj_pool
;
9257 PyObject
*pyobj_ret
= NULL
;
9258 PyObject
*pyobj_conn
;
9262 LIBVIRT_ENSURE_THREAD_STATE
;
9264 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9266 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9269 /* Create a python instance of this virStoragePoolPtr */
9270 virStoragePoolRef(pool
);
9271 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
9272 virStoragePoolFree(pool
);
9275 Py_INCREF(pyobj_cbData
);
9277 /* Call the Callback Dispatcher */
9278 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9279 (char*)"_dispatchStoragePoolEventGenericCallback",
9284 Py_DECREF(pyobj_cbData
);
9285 Py_DECREF(pyobj_pool
);
9289 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9292 Py_DECREF(pyobj_ret
);
9296 LIBVIRT_RELEASE_THREAD_STATE
;
9301 libvirt_virConnectStoragePoolEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9304 PyObject
*pyobj_conn
; /* virConnectPtr */
9305 PyObject
*pyobj_pool
;
9306 PyObject
*pyobj_cbData
; /* hash of callback data */
9310 virConnectStoragePoolEventGenericCallback cb
= NULL
;
9311 virStoragePoolPtr pool
;
9313 if (!PyArg_ParseTuple(args
,
9314 (char *) "OOiO:virConnectStoragePoolEventRegisterAny",
9315 &pyobj_conn
, &pyobj_pool
, &eventID
, &pyobj_cbData
))
9318 DEBUG("libvirt_virConnectStoragePoolEventRegister(%p %p %d %p) called\n",
9319 pyobj_conn
, pyobj_pool
, eventID
, pyobj_cbData
);
9320 conn
= PyvirConnect_Get(pyobj_conn
);
9321 if (pyobj_pool
== Py_None
)
9324 pool
= PyvirStoragePool_Get(pyobj_pool
);
9326 switch ((virStoragePoolEventID
) eventID
) {
9327 case VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE
:
9328 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventLifecycleCallback
);
9331 case VIR_STORAGE_POOL_EVENT_ID_REFRESH
:
9332 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventGenericCallback
);
9335 case VIR_STORAGE_POOL_EVENT_ID_LAST
:
9340 return VIR_PY_INT_FAIL
;
9343 Py_INCREF(pyobj_cbData
);
9345 LIBVIRT_BEGIN_ALLOW_THREADS
;
9346 ret
= virConnectStoragePoolEventRegisterAny(conn
,
9351 libvirt_virConnectStoragePoolEventFreeFunc
);
9352 LIBVIRT_END_ALLOW_THREADS
;
9355 Py_DECREF(pyobj_cbData
);
9358 return libvirt_intWrap(ret
);
9362 libvirt_virConnectStoragePoolEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9365 PyObject
*pyobj_conn
;
9370 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectStoragePoolEventDeregisterAny",
9371 &pyobj_conn
, &callbackID
))
9374 DEBUG("libvirt_virConnectStoragePoolEventDeregister(%p) called\n",
9377 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9379 LIBVIRT_BEGIN_ALLOW_THREADS
;
9380 ret
= virConnectStoragePoolEventDeregisterAny(conn
, callbackID
);
9381 LIBVIRT_END_ALLOW_THREADS
;
9383 return libvirt_intWrap(ret
);
9387 libvirt_virDomainGetGuestVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
9390 PyObject
*pyobj_domain
;
9391 virDomainPtr domain
;
9392 virTypedParameterPtr params
= NULL
;
9393 unsigned int nparams
= 0;
9396 PyObject
*ret
= NULL
;
9398 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetGuestVcpus",
9399 &pyobj_domain
, &flags
))
9401 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9403 LIBVIRT_BEGIN_ALLOW_THREADS
;
9404 i_retval
= virDomainGetGuestVcpus(domain
, ¶ms
, &nparams
, flags
);
9405 LIBVIRT_END_ALLOW_THREADS
;
9412 ret
= getPyVirTypedParameter(params
, nparams
);
9414 virTypedParamsFree(params
, nparams
);
9417 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0)*/
9419 #if LIBVIR_CHECK_VERSION(2, 2, 0)
9421 libvirt_virConnectNodeDeviceEventFreeFunc(void *opaque
)
9423 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9424 LIBVIRT_ENSURE_THREAD_STATE
;
9425 Py_DECREF(pyobj_conn
);
9426 LIBVIRT_RELEASE_THREAD_STATE
;
9430 libvirt_virConnectNodeDeviceEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9431 virNodeDevicePtr dev
,
9436 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9437 PyObject
*pyobj_dev
;
9438 PyObject
*pyobj_ret
= NULL
;
9439 PyObject
*pyobj_conn
;
9443 LIBVIRT_ENSURE_THREAD_STATE
;
9445 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9447 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9450 /* Create a python instance of this virNodeDevicePtr */
9451 virNodeDeviceRef(dev
);
9452 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9453 virNodeDeviceFree(dev
);
9456 Py_INCREF(pyobj_cbData
);
9458 /* Call the Callback Dispatcher */
9459 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9460 (char*)"_dispatchNodeDeviceEventLifecycleCallback",
9467 Py_DECREF(pyobj_cbData
);
9468 Py_DECREF(pyobj_dev
);
9472 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9475 Py_DECREF(pyobj_ret
);
9479 LIBVIRT_RELEASE_THREAD_STATE
;
9484 libvirt_virConnectNodeDeviceEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9485 virNodeDevicePtr dev
,
9488 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9489 PyObject
*pyobj_dev
;
9490 PyObject
*pyobj_ret
= NULL
;
9491 PyObject
*pyobj_conn
;
9495 LIBVIRT_ENSURE_THREAD_STATE
;
9497 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9499 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9502 /* Create a python instance of this virNodeDevicePtr */
9503 virNodeDeviceRef(dev
);
9504 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9505 virNodeDeviceFree(dev
);
9508 Py_INCREF(pyobj_cbData
);
9510 /* Call the Callback Dispatcher */
9511 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9512 (char*)"_dispatchNodeDeviceEventGenericCallback",
9517 Py_DECREF(pyobj_cbData
);
9518 Py_DECREF(pyobj_dev
);
9522 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9525 Py_DECREF(pyobj_ret
);
9529 LIBVIRT_RELEASE_THREAD_STATE
;
9534 libvirt_virConnectNodeDeviceEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9537 PyObject
*pyobj_conn
; /* virConnectPtr */
9538 PyObject
*pyobj_dev
;
9539 PyObject
*pyobj_cbData
; /* hash of callback data */
9543 virConnectNodeDeviceEventGenericCallback cb
= NULL
;
9544 virNodeDevicePtr dev
;
9546 if (!PyArg_ParseTuple(args
,
9547 (char *) "OOiO:virConnectNodeDeviceEventRegisterAny",
9548 &pyobj_conn
, &pyobj_dev
, &eventID
, &pyobj_cbData
))
9551 DEBUG("libvirt_virConnectNodeDeviceEventRegister(%p %p %d %p) called\n",
9552 pyobj_conn
, pyobj_dev
, eventID
, pyobj_cbData
);
9553 conn
= PyvirConnect_Get(pyobj_conn
);
9554 if (pyobj_dev
== Py_None
)
9557 dev
= PyvirNodeDevice_Get(pyobj_dev
);
9559 switch ((virNodeDeviceEventID
) eventID
) {
9560 case VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE
:
9561 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventLifecycleCallback
);
9564 case VIR_NODE_DEVICE_EVENT_ID_UPDATE
:
9565 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventGenericCallback
);
9568 case VIR_NODE_DEVICE_EVENT_ID_LAST
:
9573 return VIR_PY_INT_FAIL
;
9576 Py_INCREF(pyobj_cbData
);
9578 LIBVIRT_BEGIN_ALLOW_THREADS
;
9579 ret
= virConnectNodeDeviceEventRegisterAny(conn
,
9584 libvirt_virConnectNodeDeviceEventFreeFunc
);
9585 LIBVIRT_END_ALLOW_THREADS
;
9588 Py_DECREF(pyobj_cbData
);
9591 return libvirt_intWrap(ret
);
9595 libvirt_virConnectNodeDeviceEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9598 PyObject
*pyobj_conn
;
9603 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNodeDeviceEventDeregister",
9604 &pyobj_conn
, &callbackID
))
9607 DEBUG("libvirt_virConnectNodeDeviceEventDeregister(%p) called\n",
9610 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9612 LIBVIRT_BEGIN_ALLOW_THREADS
;
9613 ret
= virConnectNodeDeviceEventDeregisterAny(conn
, callbackID
);
9614 LIBVIRT_END_ALLOW_THREADS
;
9616 return libvirt_intWrap(ret
);
9619 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0)*/
9621 #if LIBVIR_CHECK_VERSION(3, 0, 0)
9623 libvirt_virConnectSecretEventFreeFunc(void *opaque
)
9625 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9626 LIBVIRT_ENSURE_THREAD_STATE
;
9627 Py_DECREF(pyobj_conn
);
9628 LIBVIRT_RELEASE_THREAD_STATE
;
9632 libvirt_virConnectSecretEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9633 virSecretPtr secret
,
9638 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9639 PyObject
*pyobj_secret
;
9640 PyObject
*pyobj_ret
= NULL
;
9641 PyObject
*pyobj_conn
;
9645 LIBVIRT_ENSURE_THREAD_STATE
;
9647 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9649 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9652 /* Create a python instance of this virSecretPtr */
9653 virSecretRef(secret
);
9654 if (!(pyobj_secret
= libvirt_virSecretPtrWrap(secret
))) {
9655 virSecretFree(secret
);
9658 Py_INCREF(pyobj_cbData
);
9660 /* Call the Callback Dispatcher */
9661 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9662 (char*)"_dispatchSecretEventLifecycleCallback",
9669 Py_DECREF(pyobj_cbData
);
9670 Py_DECREF(pyobj_secret
);
9674 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9677 Py_DECREF(pyobj_ret
);
9681 LIBVIRT_RELEASE_THREAD_STATE
;
9686 libvirt_virConnectSecretEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9687 virSecretPtr secret
,
9690 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9691 PyObject
*pyobj_secret
;
9692 PyObject
*pyobj_ret
= NULL
;
9693 PyObject
*pyobj_conn
;
9697 LIBVIRT_ENSURE_THREAD_STATE
;
9699 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9701 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9704 /* Create a python instance of this virSecretPtr */
9705 virSecretRef(secret
);
9706 if (!(pyobj_secret
= libvirt_virSecretPtrWrap(secret
))) {
9707 virSecretFree(secret
);
9710 Py_INCREF(pyobj_cbData
);
9712 /* Call the Callback Dispatcher */
9713 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9714 (char*)"_dispatchSecretEventGenericCallback",
9719 Py_DECREF(pyobj_cbData
);
9720 Py_DECREF(pyobj_secret
);
9724 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9727 Py_DECREF(pyobj_ret
);
9731 LIBVIRT_RELEASE_THREAD_STATE
;
9736 libvirt_virConnectSecretEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9739 PyObject
*pyobj_conn
; /* virConnectPtr */
9740 PyObject
*pyobj_secret
;
9741 PyObject
*pyobj_cbData
; /* hash of callback data */
9745 virConnectSecretEventGenericCallback cb
= NULL
;
9746 virSecretPtr secret
;
9748 if (!PyArg_ParseTuple(args
,
9749 (char *) "OOiO:virConnectSecretEventRegisterAny",
9750 &pyobj_conn
, &pyobj_secret
, &eventID
, &pyobj_cbData
))
9753 DEBUG("libvirt_virConnectSecretEventRegister(%p %p %d %p) called\n",
9754 pyobj_conn
, pyobj_secret
, eventID
, pyobj_cbData
);
9755 conn
= PyvirConnect_Get(pyobj_conn
);
9756 if (pyobj_secret
== Py_None
)
9759 secret
= PyvirSecret_Get(pyobj_secret
);
9761 switch ((virSecretEventID
) eventID
) {
9762 case VIR_SECRET_EVENT_ID_LIFECYCLE
:
9763 cb
= VIR_SECRET_EVENT_CALLBACK(libvirt_virConnectSecretEventLifecycleCallback
);
9766 case VIR_SECRET_EVENT_ID_VALUE_CHANGED
:
9767 cb
= VIR_SECRET_EVENT_CALLBACK(libvirt_virConnectSecretEventGenericCallback
);
9770 case VIR_SECRET_EVENT_ID_LAST
:
9775 return VIR_PY_INT_FAIL
;
9778 Py_INCREF(pyobj_cbData
);
9780 LIBVIRT_BEGIN_ALLOW_THREADS
;
9781 ret
= virConnectSecretEventRegisterAny(conn
, secret
, eventID
,
9783 libvirt_virConnectSecretEventFreeFunc
);
9784 LIBVIRT_END_ALLOW_THREADS
;
9787 Py_DECREF(pyobj_cbData
);
9790 return libvirt_intWrap(ret
);
9794 libvirt_virConnectSecretEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9797 PyObject
*pyobj_conn
;
9802 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectSecretEventDeregister",
9803 &pyobj_conn
, &callbackID
))
9806 DEBUG("libvirt_virConnectSecretEventDeregister(%p) called\n", pyobj_conn
);
9808 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9810 LIBVIRT_BEGIN_ALLOW_THREADS
;
9811 ret
= virConnectSecretEventDeregisterAny(conn
, callbackID
);
9812 LIBVIRT_END_ALLOW_THREADS
;
9814 return libvirt_intWrap(ret
);
9816 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0)*/
9819 #if LIBVIR_CHECK_VERSION(3, 4, 0)
9821 libvirt_virStreamRecvHole(PyObject
*self ATTRIBUTE_UNUSED
,
9824 PyObject
*pyobj_stream
;
9825 virStreamPtr stream
;
9826 long long length
= -1;
9830 if (!PyArg_ParseTuple(args
, (char *) "OI:virStreamRecvHole",
9831 &pyobj_stream
, &flags
))
9834 stream
= PyvirStream_Get(pyobj_stream
);
9836 LIBVIRT_BEGIN_ALLOW_THREADS
;
9837 ret
= virStreamRecvHole(stream
, &length
, flags
);
9838 LIBVIRT_END_ALLOW_THREADS
;
9840 DEBUG("StreamRecvHole ret=%d length=%lld\n", ret
, length
);
9845 return libvirt_longlongWrap(length
);
9850 libvirt_virStreamSendHole(PyObject
*self ATTRIBUTE_UNUSED
,
9853 PyObject
*pyobj_stream
;
9854 virStreamPtr stream
;
9859 if (!PyArg_ParseTuple(args
, (char *) "OLI:virStreamSendHole",
9860 &pyobj_stream
, &length
, &flags
))
9863 stream
= PyvirStream_Get(pyobj_stream
);
9865 LIBVIRT_BEGIN_ALLOW_THREADS
;
9866 ret
= virStreamSendHole(stream
, length
, flags
);
9867 LIBVIRT_END_ALLOW_THREADS
;
9869 DEBUG("StreamSendHole ret=%d\n", ret
);
9871 return libvirt_intWrap(ret
);
9876 libvirt_virStreamRecvFlags(PyObject
*self ATTRIBUTE_UNUSED
,
9879 PyObject
*pyobj_stream
;
9881 virStreamPtr stream
;
9887 if (!PyArg_ParseTuple(args
, (char *) "OkI:virStreamRecvFlags",
9888 &pyobj_stream
, &nbytes
, &flags
))
9891 stream
= PyvirStream_Get(pyobj_stream
);
9893 if (VIR_ALLOC_N(buf
, nbytes
+ 1) < 0)
9894 return PyErr_NoMemory();
9896 LIBVIRT_BEGIN_ALLOW_THREADS
;
9897 ret
= virStreamRecvFlags(stream
, buf
, nbytes
, flags
);
9898 LIBVIRT_END_ALLOW_THREADS
;
9900 buf
[ret
> -1 ? ret
: 0] = '\0';
9901 DEBUG("StreamRecvFlags ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
9903 if (ret
== -2 || ret
== -3)
9904 return libvirt_intWrap(ret
);
9907 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
9912 #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
9915 #if LIBVIR_CHECK_VERSION(4, 4, 0)
9917 libvirt_virConnectBaselineHypervisorCPU(PyObject
*self ATTRIBUTE_UNUSED
,
9921 PyObject
*pyobj_conn
;
9928 char **xmlCPUs
= NULL
;
9932 PyObject
*ret
= NULL
;
9934 if (!PyArg_ParseTuple(args
, (char *)"OzzzzOI:virConnectBaselineHypervisorCPU",
9935 &pyobj_conn
, &emulator
, &arch
, &machine
, &virttype
,
9939 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9941 if (PyList_Check(list
)) {
9942 ncpus
= PyList_Size(list
);
9943 if (VIR_ALLOC_N(xmlCPUs
, ncpus
) < 0)
9944 return PyErr_NoMemory();
9946 for (i
= 0; i
< ncpus
; i
++) {
9947 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
),
9953 LIBVIRT_BEGIN_ALLOW_THREADS
;
9954 cpu
= virConnectBaselineHypervisorCPU(conn
, emulator
, arch
, machine
, virttype
,
9955 (const char **)xmlCPUs
, ncpus
, flags
);
9956 LIBVIRT_END_ALLOW_THREADS
;
9958 ret
= libvirt_constcharPtrWrap(cpu
);
9961 for (i
= 0; i
< ncpus
; i
++)
9962 VIR_FREE(xmlCPUs
[i
]);
9968 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
9971 #if LIBVIR_CHECK_VERSION(4, 5, 0)
9973 libvirt_virDomainGetLaunchSecurityInfo(PyObject
*self ATTRIBUTE_UNUSED
,
9976 PyObject
*pyobj_dom
= NULL
;
9977 PyObject
*ret
= NULL
;
9979 virDomainPtr dom
= NULL
;
9980 virTypedParameterPtr params
= NULL
;
9982 unsigned int flags
= 0;
9985 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetLaunchSecurityInfo",
9986 &pyobj_dom
, &flags
))
9988 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
9990 LIBVIRT_BEGIN_ALLOW_THREADS
;
9991 i_retval
= virDomainGetLaunchSecurityInfo(dom
, ¶ms
, &nparams
, flags
);
9992 LIBVIRT_END_ALLOW_THREADS
;
9999 ret
= getPyVirTypedParameter(params
, nparams
);
10001 virTypedParamsFree(params
, nparams
);
10007 libvirt_virNodeGetSEVInfo(PyObject
*self ATTRIBUTE_UNUSED
,
10010 PyObject
*pyobj_conn
= NULL
;
10011 PyObject
*ret
= NULL
;
10013 virConnectPtr conn
= NULL
;
10014 virTypedParameterPtr params
= NULL
;
10016 unsigned int flags
= 0;
10019 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetSEVInfo",
10020 &pyobj_conn
, &flags
))
10022 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
10024 LIBVIRT_BEGIN_ALLOW_THREADS
;
10025 i_retval
= virNodeGetSEVInfo(conn
, ¶ms
, &nparams
, flags
);
10026 LIBVIRT_END_ALLOW_THREADS
;
10028 if (i_retval
< 0) {
10033 ret
= getPyVirTypedParameter(params
, nparams
);
10035 virTypedParamsFree(params
, nparams
);
10038 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
10040 #if LIBVIR_CHECK_VERSION(5, 5, 0)
10042 libvirt_virNetworkListAllPorts(PyObject
*self ATTRIBUTE_UNUSED
,
10045 PyObject
*pyobj_conn
;
10046 PyObject
*py_retval
= NULL
;
10047 virNetworkPtr conn
;
10048 virNetworkPortPtr
*doms
= NULL
;
10051 unsigned int flags
;
10053 if (!PyArg_ParseTuple(args
, (char *)"OI:virNetworkListAllPorts",
10054 &pyobj_conn
, &flags
))
10056 conn
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_conn
);
10058 LIBVIRT_BEGIN_ALLOW_THREADS
;
10059 c_retval
= virNetworkListAllPorts(conn
, &doms
, flags
);
10060 LIBVIRT_END_ALLOW_THREADS
;
10063 return VIR_PY_NONE
;
10065 if (!(py_retval
= PyList_New(c_retval
)))
10068 for (i
= 0; i
< c_retval
; i
++) {
10069 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_virNetworkPortPtrWrap(doms
[i
]), error
);
10070 /* python steals the pointer */
10075 for (i
= 0; i
< c_retval
; i
++)
10077 virNetworkPortFree(doms
[i
]);
10082 Py_CLEAR(py_retval
);
10087 libvirt_virNetworkPortSetParameters(PyObject
*self ATTRIBUTE_UNUSED
,
10090 virNetworkPortPtr port
;
10091 PyObject
*pyobj_port
, *info
;
10092 PyObject
*ret
= NULL
;
10095 Py_ssize_t size
= 0;
10096 unsigned int flags
;
10097 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
10099 if (!PyArg_ParseTuple(args
,
10100 (char *)"OOI:virNetworkPortSetParameters",
10101 &pyobj_port
, &info
, &flags
))
10103 port
= (virNetworkPortPtr
) PyvirNetworkPort_Get(pyobj_port
);
10105 if ((size
= PyDict_Size(info
)) < 0)
10109 PyErr_Format(PyExc_LookupError
,
10110 "Need non-empty dictionary to set attributes");
10114 LIBVIRT_BEGIN_ALLOW_THREADS
;
10115 i_retval
= virNetworkPortGetParameters(port
, ¶ms
, &nparams
, flags
);
10116 LIBVIRT_END_ALLOW_THREADS
;
10119 return VIR_PY_INT_FAIL
;
10121 if (nparams
== 0) {
10122 PyErr_Format(PyExc_LookupError
,
10123 "Port has no settable attributes");
10127 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
10131 LIBVIRT_BEGIN_ALLOW_THREADS
;
10132 i_retval
= virNetworkPortSetParameters(port
, new_params
, size
, flags
);
10133 LIBVIRT_END_ALLOW_THREADS
;
10135 if (i_retval
< 0) {
10136 ret
= VIR_PY_INT_FAIL
;
10140 ret
= VIR_PY_INT_SUCCESS
;
10143 virTypedParamsFree(params
, nparams
);
10144 virTypedParamsFree(new_params
, size
);
10149 libvirt_virNetworkPortGetParameters(PyObject
*self ATTRIBUTE_UNUSED
,
10152 PyObject
*pyobj_port
;
10153 virNetworkPortPtr port
;
10154 virTypedParameterPtr params
= NULL
;
10156 PyObject
*dict
= NULL
;
10157 unsigned int flags
;
10160 if (!PyArg_ParseTuple(args
, (char *) "OI:virNetworkPortGetParameters",
10161 &pyobj_port
, &flags
))
10163 port
= (virNetworkPortPtr
) PyvirNetworkPort_Get(pyobj_port
);
10165 LIBVIRT_BEGIN_ALLOW_THREADS
;
10166 rc
= virNetworkPortGetParameters(port
, ¶ms
, &nparams
, flags
);
10167 LIBVIRT_END_ALLOW_THREADS
;
10170 return VIR_PY_NONE
;
10172 dict
= getPyVirTypedParameter(params
, nparams
);
10174 virTypedParamsFree(params
, nparams
);
10177 #endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
10179 /************************************************************************
10181 * The registration stuff *
10183 ************************************************************************/
10184 static PyMethodDef libvirtMethods
[] = {
10185 #include "build/libvirt-export.c"
10186 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
10187 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
10188 #if LIBVIR_CHECK_VERSION(1, 1, 3)
10189 {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames
, METH_VARARGS
, NULL
},
10190 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
10191 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
10192 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
10193 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
10194 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
10195 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10196 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
10197 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10198 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
10199 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
10200 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
10201 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
10202 #if LIBVIR_CHECK_VERSION(1, 2, 1)
10203 {(char *) "virConnectNetworkEventRegisterAny", libvirt_virConnectNetworkEventRegisterAny
, METH_VARARGS
, NULL
},
10204 {(char *) "virConnectNetworkEventDeregisterAny", libvirt_virConnectNetworkEventDeregisterAny
, METH_VARARGS
, NULL
},
10205 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1) */
10206 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10207 {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback
, METH_VARARGS
, NULL
},
10208 {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback
, METH_VARARGS
, NULL
},
10209 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10210 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
10211 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
10212 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
10213 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
10214 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
10215 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
10216 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
10217 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
10218 {(char *) "virNodeGetSecurityModel", libvirt_virNodeGetSecurityModel
, METH_VARARGS
, NULL
},
10219 {(char *) "virDomainGetSecurityLabel", libvirt_virDomainGetSecurityLabel
, METH_VARARGS
, NULL
},
10220 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10221 {(char *) "virDomainGetSecurityLabelList", libvirt_virDomainGetSecurityLabelList
, METH_VARARGS
, NULL
},
10222 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10223 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
10224 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
10225 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
10226 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
10227 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
10228 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
10229 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
10230 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
10231 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
10232 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
10233 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10234 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
10235 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10236 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
10237 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
10238 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
10239 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
10240 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
10241 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
10242 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
10243 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
10244 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
10245 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
10246 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
10247 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
10248 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
10249 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
10250 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
10251 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
10252 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
10253 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
10254 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
10255 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
10256 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
10257 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
10258 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
10259 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
10260 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
10261 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
10262 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
10263 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
10264 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10265 {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo
, METH_VARARGS
, NULL
},
10266 {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator
, METH_VARARGS
, NULL
},
10267 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10268 #if LIBVIR_CHECK_VERSION(1, 2, 14)
10269 {(char *) "virDomainGetIOThreadInfo", libvirt_virDomainGetIOThreadInfo
, METH_VARARGS
, NULL
},
10270 {(char *) "virDomainPinIOThread", libvirt_virDomainPinIOThread
, METH_VARARGS
, NULL
},
10271 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
10272 #if LIBVIR_CHECK_VERSION(4, 10, 0)
10273 {(char *) "virDomainSetIOThreadParams", libvirt_virDomainSetIOThreadParams
, METH_VARARGS
, NULL
},
10274 #endif /* LIBVIR_CHECK_VERSION(4, 10, 0) */
10275 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
10276 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
10277 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10278 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
10279 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10280 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
10281 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
10282 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10283 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
10284 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10285 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
10286 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
10287 #if LIBVIR_CHECK_VERSION(3, 0, 0)
10288 {(char *) "virStorageVolGetInfoFlags", libvirt_virStorageVolGetInfoFlags
, METH_VARARGS
, NULL
},
10289 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0) */
10290 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
10291 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
10292 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
10293 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
10294 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
10295 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
10296 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
10297 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
10298 {(char *) "virEventInvokeFreeCallback", libvirt_virEventInvokeFreeCallback
, METH_VARARGS
, NULL
},
10299 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
10300 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10301 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
10302 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10303 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
10304 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
10305 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
10306 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
10307 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
10308 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10309 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
10310 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10311 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
10312 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
10313 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
10314 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
10315 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
10316 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
10317 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10318 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
10319 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10320 #if LIBVIR_CHECK_VERSION(4, 5, 0)
10321 {(char *) "virConnectListAllNWFilterBindings", libvirt_virConnectListAllNWFilterBindings
, METH_VARARGS
, NULL
},
10322 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
10323 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
10324 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
10325 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10326 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
10327 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10328 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
10329 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
10330 #if LIBVIR_CHECK_VERSION(1, 0, 3)
10331 {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats
, METH_VARARGS
, NULL
},
10332 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
10333 #if LIBVIR_CHECK_VERSION(5, 1, 0)
10334 {(char *) "virDomainListAllCheckpoints", libvirt_virDomainListAllCheckpoints
, METH_VARARGS
, NULL
},
10335 {(char *) "virDomainCheckpointListAllChildren", libvirt_virDomainCheckpointListAllChildren
, METH_VARARGS
, NULL
},
10336 #endif /* LIBVIR_CHECK_VERSION(5, 1, 0) */
10337 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
10338 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10339 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
10340 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10341 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
10342 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10343 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
10344 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10345 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
10346 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
10347 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
10348 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
10349 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
10350 #if LIBVIR_CHECK_VERSION(1, 0, 3)
10351 {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache
, METH_VARARGS
, NULL
},
10352 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
10353 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
10354 #if LIBVIR_CHECK_VERSION(3, 7, 0)
10355 {(char *) "virDomainMigrateGetMaxDowntime", libvirt_virDomainMigrateGetMaxDowntime
, METH_VARARGS
, NULL
},
10356 #endif /* LIBVIR_CHECK_VERSION(3, 7, 0) */
10357 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
10358 #if LIBVIR_CHECK_VERSION(1, 1, 0)
10359 {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3
, METH_VARARGS
, NULL
},
10360 {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3
, METH_VARARGS
, NULL
},
10361 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
10362 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
10363 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
10364 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
10365 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10366 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
10367 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
10368 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10369 #if LIBVIR_CHECK_VERSION(1, 0, 0)
10370 {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap
, METH_VARARGS
, NULL
},
10371 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
10372 #if LIBVIR_CHECK_VERSION(1, 1, 1)
10373 {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles
, METH_VARARGS
, NULL
},
10374 {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles
, METH_VARARGS
, NULL
},
10375 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
10376 #if LIBVIR_CHECK_VERSION(1, 2, 5)
10377 {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze
, METH_VARARGS
, NULL
},
10378 {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw
, METH_VARARGS
, NULL
},
10379 {(char *) "virDomainGetTime", libvirt_virDomainGetTime
, METH_VARARGS
, NULL
},
10380 {(char *) "virDomainSetTime", libvirt_virDomainSetTime
, METH_VARARGS
, NULL
},
10381 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
10382 #if LIBVIR_CHECK_VERSION(1, 2, 6)
10383 {(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages
, METH_VARARGS
, NULL
},
10384 {(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases
, METH_VARARGS
, NULL
},
10385 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
10386 #if LIBVIR_CHECK_VERSION(1, 2, 8)
10387 {(char *) "virConnectGetAllDomainStats", libvirt_virConnectGetAllDomainStats
, METH_VARARGS
, NULL
},
10388 {(char *) "virDomainListGetStats", libvirt_virDomainListGetStats
, METH_VARARGS
, NULL
},
10389 {(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy
, METH_VARARGS
, NULL
},
10390 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
10391 #if LIBVIR_CHECK_VERSION(1, 2, 9)
10392 {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages
, METH_VARARGS
, NULL
},
10393 #endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
10394 #if LIBVIR_CHECK_VERSION(1, 2, 11)
10395 {(char *) "virDomainGetFSInfo", libvirt_virDomainGetFSInfo
, METH_VARARGS
, NULL
},
10396 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
10397 #if LIBVIR_CHECK_VERSION(1, 2, 14)
10398 {(char *) "virDomainInterfaceAddresses", libvirt_virDomainInterfaceAddresses
, METH_VARARGS
, NULL
},
10399 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
10400 #if LIBVIR_CHECK_VERSION(1, 3, 3)
10401 {(char *) "virDomainGetPerfEvents", libvirt_virDomainGetPerfEvents
, METH_VARARGS
, NULL
},
10402 {(char *) "virDomainSetPerfEvents", libvirt_virDomainSetPerfEvents
, METH_VARARGS
, NULL
},
10403 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
10404 #if LIBVIR_CHECK_VERSION(2, 0, 0)
10405 {(char *) "virConnectStoragePoolEventRegisterAny", libvirt_virConnectStoragePoolEventRegisterAny
, METH_VARARGS
, NULL
},
10406 {(char *) "virConnectStoragePoolEventDeregisterAny", libvirt_virConnectStoragePoolEventDeregisterAny
, METH_VARARGS
, NULL
},
10407 {(char *) "virDomainGetGuestVcpus", libvirt_virDomainGetGuestVcpus
, METH_VARARGS
, NULL
},
10408 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0) */
10409 #if LIBVIR_CHECK_VERSION(2, 2, 0)
10410 {(char *) "virConnectNodeDeviceEventRegisterAny", libvirt_virConnectNodeDeviceEventRegisterAny
, METH_VARARGS
, NULL
},
10411 {(char *) "virConnectNodeDeviceEventDeregisterAny", libvirt_virConnectNodeDeviceEventDeregisterAny
, METH_VARARGS
, NULL
},
10412 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0) */
10413 #if LIBVIR_CHECK_VERSION(3, 0, 0)
10414 {(char *) "virConnectSecretEventRegisterAny", libvirt_virConnectSecretEventRegisterAny
, METH_VARARGS
, NULL
},
10415 {(char *) "virConnectSecretEventDeregisterAny", libvirt_virConnectSecretEventDeregisterAny
, METH_VARARGS
, NULL
},
10416 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0) */
10417 #if LIBVIR_CHECK_VERSION(3, 4, 0)
10418 {(char *) "virStreamRecvHole", libvirt_virStreamRecvHole
, METH_VARARGS
, NULL
},
10419 {(char *) "virStreamSendHole", libvirt_virStreamSendHole
, METH_VARARGS
, NULL
},
10420 {(char *) "virStreamRecvFlags", libvirt_virStreamRecvFlags
, METH_VARARGS
, NULL
},
10421 #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
10422 #if LIBVIR_CHECK_VERSION(4, 4, 0)
10423 {(char *) "virConnectBaselineHypervisorCPU", libvirt_virConnectBaselineHypervisorCPU
, METH_VARARGS
, NULL
},
10424 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
10425 #if LIBVIR_CHECK_VERSION(4, 5, 0)
10426 {(char *) "virDomainGetLaunchSecurityInfo", libvirt_virDomainGetLaunchSecurityInfo
, METH_VARARGS
, NULL
},
10427 {(char *) "virNodeGetSEVInfo", libvirt_virNodeGetSEVInfo
, METH_VARARGS
, NULL
},
10428 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
10429 #if LIBVIR_CHECK_VERSION(5, 5, 0)
10430 {(char *) "virNetworkListAllPorts", libvirt_virNetworkListAllPorts
, METH_VARARGS
, NULL
},
10431 {(char *) "virNetworkPortSetParameters", libvirt_virNetworkPortSetParameters
, METH_VARARGS
, NULL
},
10432 {(char *) "virNetworkPortGetParameters", libvirt_virNetworkPortGetParameters
, METH_VARARGS
, NULL
},
10433 #endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
10434 {NULL
, NULL
, 0, NULL
}
10437 #if PY_MAJOR_VERSION > 2
10438 static struct PyModuleDef moduledef
= {
10439 PyModuleDef_HEAD_INIT
,
10440 # ifndef __CYGWIN__
10455 # ifndef __CYGWIN__
10464 if (virInitialize() < 0)
10467 module
= PyModule_Create(&moduledef
);
10471 #else /* ! PY_MAJOR_VERSION > 2 */
10473 # ifndef __CYGWIN__
10480 if (virInitialize() < 0)
10483 /* initialize the python extension module */
10484 Py_InitModule((char *)
10485 # ifndef __CYGWIN__
10492 #endif /* ! PY_MAJOR_VERSION > 2 */