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
);
2329 libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED
,
2332 PyObject
*py_retval
;
2333 char **names
= NULL
;
2337 PyObject
*pyobj_dom
;
2340 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListNames",
2341 &pyobj_dom
, &flags
))
2343 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2345 LIBVIRT_BEGIN_ALLOW_THREADS
;
2346 c_retval
= virDomainSnapshotNum(dom
, flags
);
2347 LIBVIRT_END_ALLOW_THREADS
;
2353 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2354 return PyErr_NoMemory();
2356 LIBVIRT_BEGIN_ALLOW_THREADS
;
2357 c_retval
= virDomainSnapshotListNames(dom
, names
, c_retval
, flags
);
2358 LIBVIRT_END_ALLOW_THREADS
;
2361 py_retval
= VIR_PY_NONE
;
2365 py_retval
= PyList_New(c_retval
);
2369 for (i
= 0; i
< c_retval
; i
++)
2370 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2374 for (i
= 0; i
< c_retval
; i
++)
2380 Py_CLEAR(py_retval
);
2384 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2386 libvirt_virDomainListAllSnapshots(PyObject
*self ATTRIBUTE_UNUSED
,
2389 PyObject
*py_retval
= NULL
;
2390 virDomainSnapshotPtr
*snaps
= NULL
;
2394 PyObject
*pyobj_dom
;
2397 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainListAllSnapshots",
2398 &pyobj_dom
, &flags
))
2400 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2402 LIBVIRT_BEGIN_ALLOW_THREADS
;
2403 c_retval
= virDomainListAllSnapshots(dom
, &snaps
, flags
);
2404 LIBVIRT_END_ALLOW_THREADS
;
2409 if (!(py_retval
= PyList_New(c_retval
)))
2412 for (i
= 0; i
< c_retval
; i
++) {
2413 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2414 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2419 for (i
= 0; i
< c_retval
; i
++)
2421 virDomainSnapshotFree(snaps
[i
]);
2426 Py_CLEAR(py_retval
);
2429 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2432 libvirt_virDomainSnapshotListChildrenNames(PyObject
*self ATTRIBUTE_UNUSED
,
2435 PyObject
*py_retval
;
2436 char **names
= NULL
;
2439 virDomainSnapshotPtr snap
;
2440 PyObject
*pyobj_snap
;
2443 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListChildrenNames",
2444 &pyobj_snap
, &flags
))
2446 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2448 LIBVIRT_BEGIN_ALLOW_THREADS
;
2449 c_retval
= virDomainSnapshotNumChildren(snap
, flags
);
2450 LIBVIRT_END_ALLOW_THREADS
;
2456 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2457 return PyErr_NoMemory();
2459 LIBVIRT_BEGIN_ALLOW_THREADS
;
2460 c_retval
= virDomainSnapshotListChildrenNames(snap
, names
, c_retval
,
2462 LIBVIRT_END_ALLOW_THREADS
;
2465 py_retval
= VIR_PY_NONE
;
2470 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
2473 for (i
= 0; i
< c_retval
; i
++)
2474 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_constcharPtrWrap(names
[i
]), error
);
2478 for (i
= 0; i
< c_retval
; i
++)
2484 Py_CLEAR(py_retval
);
2488 #if LIBVIR_CHECK_VERSION(0, 9, 13)
2490 libvirt_virDomainSnapshotListAllChildren(PyObject
*self ATTRIBUTE_UNUSED
,
2493 PyObject
*py_retval
= NULL
;
2494 virDomainSnapshotPtr
*snaps
= NULL
;
2497 virDomainSnapshotPtr parent
;
2498 PyObject
*pyobj_parent
;
2501 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainSnapshotListAllChildren",
2502 &pyobj_parent
, &flags
))
2504 parent
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_parent
);
2506 LIBVIRT_BEGIN_ALLOW_THREADS
;
2507 c_retval
= virDomainSnapshotListAllChildren(parent
, &snaps
, flags
);
2508 LIBVIRT_END_ALLOW_THREADS
;
2513 if (!(py_retval
= PyList_New(c_retval
)))
2516 for (i
= 0; i
< c_retval
; i
++) {
2517 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
2518 libvirt_virDomainSnapshotPtrWrap(snaps
[i
]), error
);
2523 for (i
= 0; i
< c_retval
; i
++)
2525 virDomainSnapshotFree(snaps
[i
]);
2530 Py_CLEAR(py_retval
);
2533 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
2536 libvirt_virDomainRevertToSnapshot(PyObject
*self ATTRIBUTE_UNUSED
,
2540 virDomainSnapshotPtr snap
;
2541 PyObject
*pyobj_snap
;
2542 PyObject
*pyobj_dom
;
2545 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainRevertToSnapshot",
2546 &pyobj_dom
, &pyobj_snap
, &flags
))
2548 snap
= (virDomainSnapshotPtr
) PyvirDomainSnapshot_Get(pyobj_snap
);
2550 LIBVIRT_BEGIN_ALLOW_THREADS
;
2551 c_retval
= virDomainRevertToSnapshot(snap
, flags
);
2552 LIBVIRT_END_ALLOW_THREADS
;
2555 return VIR_PY_INT_FAIL
;
2557 return libvirt_intWrap(c_retval
);
2561 libvirt_virDomainGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2564 PyObject
*py_retval
;
2566 virDomainPtr domain
;
2567 PyObject
*pyobj_domain
;
2570 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetInfo", &pyobj_domain
))
2572 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2574 LIBVIRT_BEGIN_ALLOW_THREADS
;
2575 c_retval
= virDomainGetInfo(domain
, &info
);
2576 LIBVIRT_END_ALLOW_THREADS
;
2581 if ((py_retval
= PyList_New(5)) == NULL
)
2584 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap((int) info
.state
), error
);
2585 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_ulongWrap(info
.maxMem
), error
);
2586 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_ulongWrap(info
.memory
), error
);
2587 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
2588 libvirt_intWrap((int) info
.nrVirtCpu
), error
);
2589 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
2590 libvirt_ulonglongWrap(info
.cpuTime
), error
);
2595 Py_XDECREF(py_retval
);
2600 libvirt_virDomainGetState(PyObject
*self ATTRIBUTE_UNUSED
,
2603 PyObject
*py_retval
;
2605 virDomainPtr domain
;
2606 PyObject
*pyobj_domain
;
2611 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetState",
2612 &pyobj_domain
, &flags
))
2615 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2617 LIBVIRT_BEGIN_ALLOW_THREADS
;
2618 c_retval
= virDomainGetState(domain
, &state
, &reason
, flags
);
2619 LIBVIRT_END_ALLOW_THREADS
;
2624 if ((py_retval
= PyList_New(2)) == NULL
)
2627 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(state
), error
);
2628 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(reason
), error
);
2633 Py_XDECREF(py_retval
);
2638 libvirt_virDomainGetControlInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2641 PyObject
*py_retval
;
2643 virDomainPtr domain
;
2644 PyObject
*pyobj_domain
;
2645 virDomainControlInfo info
;
2648 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetControlInfo",
2649 &pyobj_domain
, &flags
))
2651 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2653 LIBVIRT_BEGIN_ALLOW_THREADS
;
2654 c_retval
= virDomainGetControlInfo(domain
, &info
, flags
);
2655 LIBVIRT_END_ALLOW_THREADS
;
2660 if ((py_retval
= PyList_New(3)) == NULL
)
2663 VIR_PY_LIST_SET_GOTO(py_retval
, 0, libvirt_intWrap(info
.state
), error
);
2664 VIR_PY_LIST_SET_GOTO(py_retval
, 1, libvirt_intWrap(info
.details
), error
);
2665 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2666 libvirt_ulonglongWrap(info
.stateTime
), error
);
2671 Py_XDECREF(py_retval
);
2676 libvirt_virDomainGetBlockInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2679 PyObject
*py_retval
;
2681 virDomainPtr domain
;
2682 PyObject
*pyobj_domain
;
2683 virDomainBlockInfo info
;
2687 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockInfo",
2688 &pyobj_domain
, &path
, &flags
))
2690 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2692 LIBVIRT_BEGIN_ALLOW_THREADS
;
2693 c_retval
= virDomainGetBlockInfo(domain
, path
, &info
, flags
);
2694 LIBVIRT_END_ALLOW_THREADS
;
2699 if ((py_retval
= PyList_New(3)) == NULL
)
2702 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2703 libvirt_ulonglongWrap(info
.capacity
), error
);
2704 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2705 libvirt_ulonglongWrap(info
.allocation
), error
);
2706 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
2707 libvirt_ulonglongWrap(info
.physical
), error
);
2712 Py_XDECREF(py_retval
);
2717 libvirt_virNodeGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
2720 PyObject
*py_retval
;
2723 PyObject
*pyobj_conn
;
2726 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeGetInfo", &pyobj_conn
))
2728 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2730 LIBVIRT_BEGIN_ALLOW_THREADS
;
2731 c_retval
= virNodeGetInfo(conn
, &info
);
2732 LIBVIRT_END_ALLOW_THREADS
;
2737 if ((py_retval
= PyList_New(8)) == NULL
)
2740 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2741 libvirt_constcharPtrWrap(&info
.model
[0]), error
);
2742 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2743 libvirt_longWrap((long) info
.memory
>> 10), error
);
2744 VIR_PY_LIST_SET_GOTO(py_retval
, 2, libvirt_intWrap((int) info
.cpus
), error
);
2745 VIR_PY_LIST_SET_GOTO(py_retval
, 3, libvirt_intWrap((int) info
.mhz
), error
);
2746 VIR_PY_LIST_SET_GOTO(py_retval
, 4, libvirt_intWrap((int) info
.nodes
), error
);
2747 VIR_PY_LIST_SET_GOTO(py_retval
, 5, libvirt_intWrap((int) info
.sockets
), error
);
2748 VIR_PY_LIST_SET_GOTO(py_retval
, 6, libvirt_intWrap((int) info
.cores
), error
);
2749 VIR_PY_LIST_SET_GOTO(py_retval
, 7, libvirt_intWrap((int) info
.threads
), error
);
2754 Py_XDECREF(py_retval
);
2759 libvirt_virNodeGetSecurityModel(PyObject
*self ATTRIBUTE_UNUSED
,
2762 PyObject
*py_retval
;
2765 PyObject
*pyobj_conn
;
2766 virSecurityModel model
;
2768 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityModel",
2771 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2773 LIBVIRT_BEGIN_ALLOW_THREADS
;
2774 c_retval
= virNodeGetSecurityModel(conn
, &model
);
2775 LIBVIRT_END_ALLOW_THREADS
;
2780 if ((py_retval
= PyList_New(2)) == NULL
)
2783 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2784 libvirt_constcharPtrWrap(&model
.model
[0]), error
);
2785 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2786 libvirt_constcharPtrWrap(&model
.doi
[0]), error
);
2791 Py_XDECREF(py_retval
);
2796 libvirt_virDomainGetSecurityLabel(PyObject
*self ATTRIBUTE_UNUSED
,
2799 PyObject
*py_retval
;
2802 PyObject
*pyobj_dom
;
2803 virSecurityLabel label
;
2805 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabel",
2808 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2810 LIBVIRT_BEGIN_ALLOW_THREADS
;
2811 c_retval
= virDomainGetSecurityLabel(dom
, &label
);
2812 LIBVIRT_END_ALLOW_THREADS
;
2817 if ((py_retval
= PyList_New(2)) == NULL
)
2820 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
2821 libvirt_constcharPtrWrap(&label
.label
[0]), error
);
2822 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
2823 libvirt_boolWrap(label
.enforcing
), error
);
2828 Py_XDECREF(py_retval
);
2832 #if LIBVIR_CHECK_VERSION(0, 10, 0)
2834 libvirt_virDomainGetSecurityLabelList(PyObject
*self ATTRIBUTE_UNUSED
,
2837 PyObject
*py_retval
;
2840 PyObject
*pyobj_dom
;
2841 virSecurityLabel
*labels
= NULL
;
2844 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetSecurityLabelList",
2848 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2850 LIBVIRT_BEGIN_ALLOW_THREADS
;
2851 c_retval
= virDomainGetSecurityLabelList(dom
, &labels
);
2852 LIBVIRT_END_ALLOW_THREADS
;
2857 if (!(py_retval
= PyList_New(0)))
2860 for (i
= 0 ; i
< c_retval
; i
++) {
2863 if (!(entry
= PyList_New(2)))
2866 VIR_PY_LIST_APPEND_GOTO(py_retval
, entry
, error
);
2868 VIR_PY_LIST_SET_GOTO(entry
, 0,
2869 libvirt_constcharPtrWrap(&labels
[i
].label
[0]),
2871 VIR_PY_LIST_SET_GOTO(entry
, 1,
2872 libvirt_boolWrap(labels
[i
].enforcing
), error
);
2880 Py_CLEAR(py_retval
);
2883 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
2886 libvirt_virDomainGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
2889 unsigned char uuid
[VIR_UUID_BUFLEN
];
2890 virDomainPtr domain
;
2891 PyObject
*pyobj_domain
;
2894 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUID", &pyobj_domain
))
2896 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
2901 LIBVIRT_BEGIN_ALLOW_THREADS
;
2902 c_retval
= virDomainGetUUID(domain
, &uuid
[0]);
2903 LIBVIRT_END_ALLOW_THREADS
;
2908 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
2912 libvirt_virDomainGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
2915 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
2917 PyObject
*pyobj_dom
;
2920 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetUUIDString",
2923 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
2928 LIBVIRT_BEGIN_ALLOW_THREADS
;
2929 c_retval
= virDomainGetUUIDString(dom
, &uuidstr
[0]);
2930 LIBVIRT_END_ALLOW_THREADS
;
2935 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
2939 libvirt_virDomainLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
2942 virDomainPtr c_retval
;
2944 PyObject
*pyobj_conn
;
2945 unsigned char * uuid
;
2948 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virDomainLookupByUUID",
2949 &pyobj_conn
, &uuid
, &len
))
2951 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2953 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
2956 LIBVIRT_BEGIN_ALLOW_THREADS
;
2957 c_retval
= virDomainLookupByUUID(conn
, uuid
);
2958 LIBVIRT_END_ALLOW_THREADS
;
2960 return libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
2965 libvirt_virConnectListNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
2968 PyObject
*py_retval
;
2969 char **names
= NULL
;
2973 PyObject
*pyobj_conn
;
2976 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNetworks",
2979 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
2981 LIBVIRT_BEGIN_ALLOW_THREADS
;
2982 c_retval
= virConnectNumOfNetworks(conn
);
2983 LIBVIRT_END_ALLOW_THREADS
;
2989 if (VIR_ALLOC_N(names
, c_retval
) < 0)
2990 return PyErr_NoMemory();
2992 LIBVIRT_BEGIN_ALLOW_THREADS
;
2993 c_retval
= virConnectListNetworks(conn
, names
, c_retval
);
2994 LIBVIRT_END_ALLOW_THREADS
;
2997 py_retval
= VIR_PY_NONE
;
3002 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3006 for (i
= 0; i
< c_retval
; i
++)
3007 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3008 libvirt_constcharPtrWrap(names
[i
]), error
);
3012 for (i
= 0; i
< c_retval
; i
++)
3018 Py_CLEAR(py_retval
);
3024 libvirt_virConnectListDefinedNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3027 PyObject
*py_retval
;
3028 char **names
= NULL
;
3032 PyObject
*pyobj_conn
;
3035 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedNetworks",
3038 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3040 LIBVIRT_BEGIN_ALLOW_THREADS
;
3041 c_retval
= virConnectNumOfDefinedNetworks(conn
);
3042 LIBVIRT_END_ALLOW_THREADS
;
3048 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3049 return PyErr_NoMemory();
3051 LIBVIRT_BEGIN_ALLOW_THREADS
;
3052 c_retval
= virConnectListDefinedNetworks(conn
, names
, c_retval
);
3053 LIBVIRT_END_ALLOW_THREADS
;
3056 py_retval
= VIR_PY_NONE
;
3061 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3064 for (i
= 0; i
< c_retval
; i
++)
3065 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3066 libvirt_constcharPtrWrap(names
[i
]), error
);
3070 for (i
= 0; i
< c_retval
; i
++)
3076 Py_CLEAR(py_retval
);
3080 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3082 libvirt_virConnectListAllNetworks(PyObject
*self ATTRIBUTE_UNUSED
,
3085 PyObject
*pyobj_conn
;
3086 PyObject
*py_retval
= NULL
;
3088 virNetworkPtr
*nets
= NULL
;
3093 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNetworks",
3094 &pyobj_conn
, &flags
))
3096 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3098 LIBVIRT_BEGIN_ALLOW_THREADS
;
3099 c_retval
= virConnectListAllNetworks(conn
, &nets
, flags
);
3100 LIBVIRT_END_ALLOW_THREADS
;
3105 if (!(py_retval
= PyList_New(c_retval
)))
3108 for (i
= 0; i
< c_retval
; i
++) {
3109 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3110 libvirt_virNetworkPtrWrap(nets
[i
]), error
);
3115 for (i
= 0; i
< c_retval
; i
++)
3117 virNetworkFree(nets
[i
]);
3122 Py_CLEAR(py_retval
);
3125 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3129 libvirt_virNetworkGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3132 unsigned char uuid
[VIR_UUID_BUFLEN
];
3133 virNetworkPtr domain
;
3134 PyObject
*pyobj_domain
;
3137 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUID", &pyobj_domain
))
3139 domain
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_domain
);
3144 LIBVIRT_BEGIN_ALLOW_THREADS
;
3145 c_retval
= virNetworkGetUUID(domain
, &uuid
[0]);
3146 LIBVIRT_END_ALLOW_THREADS
;
3151 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3155 libvirt_virNetworkGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3158 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3160 PyObject
*pyobj_net
;
3163 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetUUIDString",
3166 net
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_net
);
3171 LIBVIRT_BEGIN_ALLOW_THREADS
;
3172 c_retval
= virNetworkGetUUIDString(net
, &uuidstr
[0]);
3173 LIBVIRT_END_ALLOW_THREADS
;
3178 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3182 libvirt_virNetworkLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3185 virNetworkPtr c_retval
;
3187 PyObject
*pyobj_conn
;
3188 unsigned char * uuid
;
3191 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNetworkLookupByUUID",
3192 &pyobj_conn
, &uuid
, &len
))
3194 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3196 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3199 LIBVIRT_BEGIN_ALLOW_THREADS
;
3200 c_retval
= virNetworkLookupByUUID(conn
, uuid
);
3201 LIBVIRT_END_ALLOW_THREADS
;
3203 return libvirt_virNetworkPtrWrap((virNetworkPtr
) c_retval
);
3208 libvirt_virDomainGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3211 int c_retval
, autostart
;
3212 virDomainPtr domain
;
3213 PyObject
*pyobj_domain
;
3215 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetAutostart",
3219 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
3221 LIBVIRT_BEGIN_ALLOW_THREADS
;
3222 c_retval
= virDomainGetAutostart(domain
, &autostart
);
3223 LIBVIRT_END_ALLOW_THREADS
;
3226 return VIR_PY_INT_FAIL
;
3228 return libvirt_intWrap(autostart
);
3233 libvirt_virNetworkGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3236 int c_retval
, autostart
;
3237 virNetworkPtr network
;
3238 PyObject
*pyobj_network
;
3240 if (!PyArg_ParseTuple(args
, (char *)"O:virNetworkGetAutostart",
3244 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
3246 LIBVIRT_BEGIN_ALLOW_THREADS
;
3247 c_retval
= virNetworkGetAutostart(network
, &autostart
);
3248 LIBVIRT_END_ALLOW_THREADS
;
3251 return VIR_PY_INT_FAIL
;
3253 return libvirt_intWrap(autostart
);
3257 libvirt_virNodeGetCellsFreeMemory(PyObject
*self ATTRIBUTE_UNUSED
,
3260 PyObject
*py_retval
;
3261 PyObject
*pyobj_conn
;
3262 int startCell
, maxCells
, c_retval
;
3265 unsigned long long *freeMems
;
3267 if (!PyArg_ParseTuple(args
, (char *)"Oii:virNodeGetCellsFreeMemory",
3268 &pyobj_conn
, &startCell
, &maxCells
))
3271 if ((startCell
< 0) || (maxCells
<= 0) || (startCell
+ maxCells
> 10000))
3274 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3275 if (VIR_ALLOC_N(freeMems
, maxCells
) < 0)
3276 return PyErr_NoMemory();
3278 LIBVIRT_BEGIN_ALLOW_THREADS
;
3279 c_retval
= virNodeGetCellsFreeMemory(conn
, freeMems
, startCell
, maxCells
);
3280 LIBVIRT_END_ALLOW_THREADS
;
3283 py_retval
= VIR_PY_NONE
;
3287 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3290 for (i
= 0; i
< c_retval
; i
++)
3291 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3292 libvirt_ulonglongWrap(freeMems
[i
]), error
);
3299 Py_CLEAR(py_retval
);
3304 libvirt_virNodeGetCPUStats(PyObject
*self ATTRIBUTE_UNUSED
,
3307 PyObject
*ret
= NULL
;
3308 PyObject
*key
= NULL
;
3309 PyObject
*val
= NULL
;
3310 PyObject
*pyobj_conn
;
3313 int cpuNum
, c_retval
;
3316 virNodeCPUStatsPtr stats
= NULL
;
3318 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetCPUStats",
3319 &pyobj_conn
, &cpuNum
, &flags
))
3321 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3323 LIBVIRT_BEGIN_ALLOW_THREADS
;
3324 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, NULL
, &nparams
, flags
);
3325 LIBVIRT_END_ALLOW_THREADS
;
3331 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3332 return PyErr_NoMemory();
3334 LIBVIRT_BEGIN_ALLOW_THREADS
;
3335 c_retval
= virNodeGetCPUStats(conn
, cpuNum
, stats
, &nparams
, flags
);
3336 LIBVIRT_END_ALLOW_THREADS
;
3344 if (!(ret
= PyDict_New()))
3347 for (i
= 0; i
< nparams
; i
++) {
3348 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3349 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3351 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3364 libvirt_virNodeGetMemoryStats(PyObject
*self ATTRIBUTE_UNUSED
,
3367 PyObject
*ret
= NULL
;
3368 PyObject
*key
= NULL
;
3369 PyObject
*val
= NULL
;
3370 PyObject
*pyobj_conn
;
3373 int cellNum
, c_retval
;
3376 virNodeMemoryStatsPtr stats
= NULL
;
3378 if (!PyArg_ParseTuple(args
, (char *)"OiI:virNodeGetMemoryStats",
3379 &pyobj_conn
, &cellNum
, &flags
))
3381 conn
= (virConnectPtr
)(PyvirConnect_Get(pyobj_conn
));
3383 LIBVIRT_BEGIN_ALLOW_THREADS
;
3384 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, NULL
, &nparams
, flags
);
3385 LIBVIRT_END_ALLOW_THREADS
;
3391 if (VIR_ALLOC_N(stats
, nparams
) < 0)
3392 return PyErr_NoMemory();
3394 LIBVIRT_BEGIN_ALLOW_THREADS
;
3395 c_retval
= virNodeGetMemoryStats(conn
, cellNum
, stats
, &nparams
, flags
);
3396 LIBVIRT_END_ALLOW_THREADS
;
3404 if (!(ret
= PyDict_New()))
3407 for (i
= 0; i
< nparams
; i
++) {
3408 key
= libvirt_constcharPtrWrap(stats
[i
].field
);
3409 val
= libvirt_ulonglongWrap(stats
[i
].value
);
3411 VIR_PY_DICT_SET_GOTO(ret
, key
, val
, error
);
3424 libvirt_virConnectListStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3427 PyObject
*py_retval
;
3428 char **names
= NULL
;
3432 PyObject
*pyobj_conn
;
3434 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListStoragePools",
3437 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3439 LIBVIRT_BEGIN_ALLOW_THREADS
;
3440 c_retval
= virConnectNumOfStoragePools(conn
);
3441 LIBVIRT_END_ALLOW_THREADS
;
3447 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3448 return PyErr_NoMemory();
3450 LIBVIRT_BEGIN_ALLOW_THREADS
;
3451 c_retval
= virConnectListStoragePools(conn
, names
, c_retval
);
3452 LIBVIRT_END_ALLOW_THREADS
;
3455 py_retval
= VIR_PY_NONE
;
3460 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3463 for (i
= 0; i
< c_retval
; i
++)
3464 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3465 libvirt_constcharPtrWrap(names
[i
]), error
);
3469 for (i
= 0; i
< c_retval
; i
++)
3475 Py_CLEAR(py_retval
);
3481 libvirt_virConnectListDefinedStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3484 PyObject
*py_retval
;
3485 char **names
= NULL
;
3489 PyObject
*pyobj_conn
;
3491 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedStoragePools",
3494 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3496 LIBVIRT_BEGIN_ALLOW_THREADS
;
3497 c_retval
= virConnectNumOfDefinedStoragePools(conn
);
3498 LIBVIRT_END_ALLOW_THREADS
;
3504 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3505 return PyErr_NoMemory();
3507 LIBVIRT_BEGIN_ALLOW_THREADS
;
3508 c_retval
= virConnectListDefinedStoragePools(conn
, names
, c_retval
);
3509 LIBVIRT_END_ALLOW_THREADS
;
3512 py_retval
= VIR_PY_NONE
;
3517 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3521 for (i
= 0; i
< c_retval
; i
++)
3522 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3523 libvirt_constcharPtrWrap(names
[i
]), error
);
3528 for (i
= 0; i
< c_retval
; i
++)
3534 Py_CLEAR(py_retval
);
3538 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3540 libvirt_virConnectListAllStoragePools(PyObject
*self ATTRIBUTE_UNUSED
,
3543 PyObject
*pyobj_conn
;
3544 PyObject
*py_retval
= NULL
;
3546 virStoragePoolPtr
*pools
= NULL
;
3551 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllStoragePools",
3552 &pyobj_conn
, &flags
))
3554 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3556 LIBVIRT_BEGIN_ALLOW_THREADS
;
3557 c_retval
= virConnectListAllStoragePools(conn
, &pools
, flags
);
3558 LIBVIRT_END_ALLOW_THREADS
;
3563 if (!(py_retval
= PyList_New(c_retval
)))
3566 for (i
= 0; i
< c_retval
; i
++) {
3567 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3568 libvirt_virStoragePoolPtrWrap(pools
[i
]), error
);
3569 /* python steals the pointer */
3574 for (i
= 0; i
< c_retval
; i
++)
3576 virStoragePoolFree(pools
[i
]);
3581 Py_CLEAR(py_retval
);
3584 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3587 libvirt_virStoragePoolListVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3590 PyObject
*py_retval
;
3591 char **names
= NULL
;
3594 virStoragePoolPtr pool
;
3595 PyObject
*pyobj_pool
;
3597 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolListVolumes",
3600 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3602 LIBVIRT_BEGIN_ALLOW_THREADS
;
3603 c_retval
= virStoragePoolNumOfVolumes(pool
);
3604 LIBVIRT_END_ALLOW_THREADS
;
3610 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3611 return PyErr_NoMemory();
3613 LIBVIRT_BEGIN_ALLOW_THREADS
;
3614 c_retval
= virStoragePoolListVolumes(pool
, names
, c_retval
);
3615 LIBVIRT_END_ALLOW_THREADS
;
3618 py_retval
= VIR_PY_NONE
;
3623 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3627 for (i
= 0; i
< c_retval
; i
++)
3628 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3629 libvirt_constcharPtrWrap(names
[i
]), error
);
3633 for (i
= 0; i
< c_retval
; i
++)
3639 Py_CLEAR(py_retval
);
3643 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3645 libvirt_virStoragePoolListAllVolumes(PyObject
*self ATTRIBUTE_UNUSED
,
3648 PyObject
*py_retval
= NULL
;
3649 virStoragePoolPtr pool
;
3650 virStorageVolPtr
*vols
= NULL
;
3654 PyObject
*pyobj_pool
;
3656 if (!PyArg_ParseTuple(args
, (char *)"OI:virStoragePoolListAllVolumes",
3657 &pyobj_pool
, &flags
))
3660 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3662 LIBVIRT_BEGIN_ALLOW_THREADS
;
3663 c_retval
= virStoragePoolListAllVolumes(pool
, &vols
, flags
);
3664 LIBVIRT_END_ALLOW_THREADS
;
3669 if (!(py_retval
= PyList_New(c_retval
)))
3672 for (i
= 0; i
< c_retval
; i
++) {
3673 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3674 libvirt_virStorageVolPtrWrap(vols
[i
]), error
);
3675 /* python steals the pointer */
3680 for (i
= 0; i
< c_retval
; i
++)
3682 virStorageVolFree(vols
[i
]);
3687 Py_CLEAR(py_retval
);
3690 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
3694 libvirt_virStoragePoolGetAutostart(PyObject
*self ATTRIBUTE_UNUSED
,
3697 int c_retval
, autostart
;
3698 virStoragePoolPtr pool
;
3699 PyObject
*pyobj_pool
;
3701 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetAutostart",
3705 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3707 LIBVIRT_BEGIN_ALLOW_THREADS
;
3708 c_retval
= virStoragePoolGetAutostart(pool
, &autostart
);
3709 LIBVIRT_END_ALLOW_THREADS
;
3712 return VIR_PY_INT_FAIL
;
3714 return libvirt_intWrap(autostart
);
3718 libvirt_virStoragePoolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3721 PyObject
*py_retval
;
3723 virStoragePoolPtr pool
;
3724 PyObject
*pyobj_pool
;
3725 virStoragePoolInfo info
;
3727 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetInfo", &pyobj_pool
))
3729 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3731 LIBVIRT_BEGIN_ALLOW_THREADS
;
3732 c_retval
= virStoragePoolGetInfo(pool
, &info
);
3733 LIBVIRT_END_ALLOW_THREADS
;
3738 if ((py_retval
= PyList_New(4)) == NULL
)
3741 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3742 libvirt_intWrap((int) info
.state
), error
);
3743 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3744 libvirt_ulonglongWrap(info
.capacity
), error
);
3745 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3746 libvirt_ulonglongWrap(info
.allocation
), error
);
3747 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
3748 libvirt_ulonglongWrap(info
.available
), error
);
3753 Py_XDECREF(py_retval
);
3759 libvirt_virStorageVolGetInfo(PyObject
*self ATTRIBUTE_UNUSED
,
3762 PyObject
*py_retval
;
3764 virStorageVolPtr pool
;
3765 PyObject
*pyobj_pool
;
3766 virStorageVolInfo info
;
3768 if (!PyArg_ParseTuple(args
, (char *)"O:virStorageVolGetInfo", &pyobj_pool
))
3770 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3772 LIBVIRT_BEGIN_ALLOW_THREADS
;
3773 c_retval
= virStorageVolGetInfo(pool
, &info
);
3774 LIBVIRT_END_ALLOW_THREADS
;
3779 if ((py_retval
= PyList_New(3)) == NULL
)
3782 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3783 libvirt_intWrap((int) info
.type
), error
);
3784 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3785 libvirt_ulonglongWrap(info
.capacity
), error
);
3786 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3787 libvirt_ulonglongWrap(info
.allocation
), error
);
3792 Py_DECREF(py_retval
);
3796 #if LIBVIR_CHECK_VERSION(3, 0, 0)
3798 libvirt_virStorageVolGetInfoFlags(PyObject
*self ATTRIBUTE_UNUSED
,
3801 PyObject
*py_retval
;
3803 virStorageVolPtr pool
;
3804 PyObject
*pyobj_pool
;
3805 virStorageVolInfo info
;
3808 if (!PyArg_ParseTuple(args
, (char *)"OI:virStorageVolGetInfoFlags", &pyobj_pool
, &flags
))
3810 pool
= (virStorageVolPtr
) PyvirStorageVol_Get(pyobj_pool
);
3812 LIBVIRT_BEGIN_ALLOW_THREADS
;
3813 c_retval
= virStorageVolGetInfoFlags(pool
, &info
, flags
);
3814 LIBVIRT_END_ALLOW_THREADS
;
3819 if ((py_retval
= PyList_New(3)) == NULL
)
3822 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
3823 libvirt_intWrap((int) info
.type
), error
);
3824 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
3825 libvirt_ulonglongWrap(info
.capacity
), error
);
3826 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
3827 libvirt_ulonglongWrap(info
.allocation
), error
);
3832 Py_DECREF(py_retval
);
3838 libvirt_virStoragePoolGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3841 unsigned char uuid
[VIR_UUID_BUFLEN
];
3842 virStoragePoolPtr pool
;
3843 PyObject
*pyobj_pool
;
3846 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUID", &pyobj_pool
))
3848 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3853 LIBVIRT_BEGIN_ALLOW_THREADS
;
3854 c_retval
= virStoragePoolGetUUID(pool
, &uuid
[0]);
3855 LIBVIRT_END_ALLOW_THREADS
;
3860 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
3864 libvirt_virStoragePoolGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
3867 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
3868 virStoragePoolPtr pool
;
3869 PyObject
*pyobj_pool
;
3872 if (!PyArg_ParseTuple(args
, (char *)"O:virStoragePoolGetUUIDString",
3875 pool
= (virStoragePoolPtr
) PyvirStoragePool_Get(pyobj_pool
);
3880 LIBVIRT_BEGIN_ALLOW_THREADS
;
3881 c_retval
= virStoragePoolGetUUIDString(pool
, &uuidstr
[0]);
3882 LIBVIRT_END_ALLOW_THREADS
;
3887 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
3891 libvirt_virStoragePoolLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
3894 virStoragePoolPtr c_retval
;
3896 PyObject
*pyobj_conn
;
3897 unsigned char * uuid
;
3900 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virStoragePoolLookupByUUID",
3901 &pyobj_conn
, &uuid
, &len
))
3903 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3905 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
3908 LIBVIRT_BEGIN_ALLOW_THREADS
;
3909 c_retval
= virStoragePoolLookupByUUID(conn
, uuid
);
3910 LIBVIRT_END_ALLOW_THREADS
;
3912 return libvirt_virStoragePoolPtrWrap((virStoragePoolPtr
) c_retval
);
3916 libvirt_virNodeListDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3919 PyObject
*py_retval
;
3920 char **names
= NULL
;
3924 PyObject
*pyobj_conn
;
3928 if (!PyArg_ParseTuple(args
, (char *)"OzI:virNodeListDevices",
3929 &pyobj_conn
, &cap
, &flags
))
3931 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3933 LIBVIRT_BEGIN_ALLOW_THREADS
;
3934 c_retval
= virNodeNumOfDevices(conn
, cap
, flags
);
3935 LIBVIRT_END_ALLOW_THREADS
;
3941 if (VIR_ALLOC_N(names
, c_retval
) < 0)
3942 return PyErr_NoMemory();
3944 LIBVIRT_BEGIN_ALLOW_THREADS
;
3945 c_retval
= virNodeListDevices(conn
, cap
, names
, c_retval
, flags
);
3946 LIBVIRT_END_ALLOW_THREADS
;
3949 py_retval
= VIR_PY_NONE
;
3954 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
3958 for (i
= 0; i
< c_retval
; i
++)
3959 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
3960 libvirt_constcharPtrWrap(names
[i
]), error
);
3964 for (i
= 0; i
< c_retval
; i
++)
3970 Py_CLEAR(py_retval
);
3974 #if LIBVIR_CHECK_VERSION(0, 10, 2)
3976 libvirt_virConnectListAllNodeDevices(PyObject
*self ATTRIBUTE_UNUSED
,
3979 PyObject
*pyobj_conn
;
3980 PyObject
*py_retval
= NULL
;
3982 virNodeDevicePtr
*devices
= NULL
;
3987 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNodeDevices",
3988 &pyobj_conn
, &flags
))
3990 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
3992 LIBVIRT_BEGIN_ALLOW_THREADS
;
3993 c_retval
= virConnectListAllNodeDevices(conn
, &devices
, flags
);
3994 LIBVIRT_END_ALLOW_THREADS
;
3999 if (!(py_retval
= PyList_New(c_retval
)))
4002 for (i
= 0; i
< c_retval
; i
++) {
4003 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4004 libvirt_virNodeDevicePtrWrap(devices
[i
]), error
);
4005 /* python steals the pointer */
4010 for (i
= 0; i
< c_retval
; i
++)
4012 virNodeDeviceFree(devices
[i
]);
4017 Py_CLEAR(py_retval
);
4020 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4023 libvirt_virNodeDeviceListCaps(PyObject
*self ATTRIBUTE_UNUSED
,
4026 PyObject
*py_retval
;
4027 char **names
= NULL
;
4030 virNodeDevicePtr dev
;
4031 PyObject
*pyobj_dev
;
4033 if (!PyArg_ParseTuple(args
, (char *)"O:virNodeDeviceListCaps", &pyobj_dev
))
4035 dev
= (virNodeDevicePtr
) PyvirNodeDevice_Get(pyobj_dev
);
4037 LIBVIRT_BEGIN_ALLOW_THREADS
;
4038 c_retval
= virNodeDeviceNumOfCaps(dev
);
4039 LIBVIRT_END_ALLOW_THREADS
;
4045 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4046 return PyErr_NoMemory();
4048 LIBVIRT_BEGIN_ALLOW_THREADS
;
4049 c_retval
= virNodeDeviceListCaps(dev
, names
, c_retval
);
4050 LIBVIRT_END_ALLOW_THREADS
;
4053 py_retval
= VIR_PY_NONE
;
4058 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4062 for (i
= 0; i
< c_retval
; i
++)
4063 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4064 libvirt_constcharPtrWrap(names
[i
]), error
);
4068 for (i
= 0; i
< c_retval
; i
++)
4074 Py_CLEAR(py_retval
);
4079 libvirt_virSecretGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4082 unsigned char uuid
[VIR_UUID_BUFLEN
];
4083 virSecretPtr secret
;
4084 PyObject
*pyobj_secret
;
4087 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUID", &pyobj_secret
))
4089 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4094 LIBVIRT_BEGIN_ALLOW_THREADS
;
4095 c_retval
= virSecretGetUUID(secret
, &uuid
[0]);
4096 LIBVIRT_END_ALLOW_THREADS
;
4101 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4105 libvirt_virSecretGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4108 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4110 PyObject
*pyobj_dom
;
4113 if (!PyArg_ParseTuple(args
, (char *)"O:virSecretGetUUIDString",
4116 dom
= (virSecretPtr
) PyvirSecret_Get(pyobj_dom
);
4121 LIBVIRT_BEGIN_ALLOW_THREADS
;
4122 c_retval
= virSecretGetUUIDString(dom
, &uuidstr
[0]);
4123 LIBVIRT_END_ALLOW_THREADS
;
4128 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4132 libvirt_virSecretLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4135 virSecretPtr c_retval
;
4137 PyObject
*pyobj_conn
;
4138 unsigned char * uuid
;
4141 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virSecretLookupByUUID",
4142 &pyobj_conn
, &uuid
, &len
))
4144 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4146 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4149 LIBVIRT_BEGIN_ALLOW_THREADS
;
4150 c_retval
= virSecretLookupByUUID(conn
, uuid
);
4151 LIBVIRT_END_ALLOW_THREADS
;
4153 return libvirt_virSecretPtrWrap((virSecretPtr
) c_retval
);
4158 libvirt_virConnectListSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4161 PyObject
*py_retval
;
4162 char **uuids
= NULL
;
4166 PyObject
*pyobj_conn
;
4168 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListSecrets", &pyobj_conn
))
4170 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4172 LIBVIRT_BEGIN_ALLOW_THREADS
;
4173 c_retval
= virConnectNumOfSecrets(conn
);
4174 LIBVIRT_END_ALLOW_THREADS
;
4180 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4181 return PyErr_NoMemory();
4183 LIBVIRT_BEGIN_ALLOW_THREADS
;
4184 c_retval
= virConnectListSecrets(conn
, uuids
, c_retval
);
4185 LIBVIRT_END_ALLOW_THREADS
;
4188 py_retval
= VIR_PY_NONE
;
4193 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4197 for (i
= 0; i
< c_retval
; i
++)
4198 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4199 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4204 for (i
= 0; i
< c_retval
; i
++)
4210 Py_CLEAR(py_retval
);
4214 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4216 libvirt_virConnectListAllSecrets(PyObject
*self ATTRIBUTE_UNUSED
,
4219 PyObject
*pyobj_conn
;
4220 PyObject
*py_retval
= NULL
;
4222 virSecretPtr
*secrets
= NULL
;
4227 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllSecrets",
4228 &pyobj_conn
, &flags
))
4230 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4232 LIBVIRT_BEGIN_ALLOW_THREADS
;
4233 c_retval
= virConnectListAllSecrets(conn
, &secrets
, flags
);
4234 LIBVIRT_END_ALLOW_THREADS
;
4239 if (!(py_retval
= PyList_New(c_retval
)))
4242 for (i
= 0; i
< c_retval
; i
++) {
4243 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4244 libvirt_virSecretPtrWrap(secrets
[i
]), error
);
4245 /* python steals the pointer */
4250 for (i
= 0; i
< c_retval
; i
++)
4252 virSecretFree(secrets
[i
]);
4257 Py_CLEAR(py_retval
);
4260 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4263 libvirt_virSecretGetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4266 PyObject
*py_retval
;
4267 unsigned char *c_retval
;
4269 virSecretPtr secret
;
4270 PyObject
*pyobj_secret
;
4273 if (!PyArg_ParseTuple(args
, (char *)"OI:virSecretGetValue", &pyobj_secret
,
4276 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4278 LIBVIRT_BEGIN_ALLOW_THREADS
;
4279 c_retval
= virSecretGetValue(secret
, &size
, flags
);
4280 LIBVIRT_END_ALLOW_THREADS
;
4282 if (c_retval
== NULL
)
4285 py_retval
= libvirt_charPtrSizeWrap((char*)c_retval
, size
);
4292 libvirt_virSecretSetValue(PyObject
*self ATTRIBUTE_UNUSED
,
4296 virSecretPtr secret
;
4297 PyObject
*pyobj_secret
;
4302 if (!PyArg_ParseTuple(args
, (char *)"Oz#I:virSecretSetValue", &pyobj_secret
,
4303 &value
, &size
, &flags
))
4305 secret
= (virSecretPtr
) PyvirSecret_Get(pyobj_secret
);
4307 LIBVIRT_BEGIN_ALLOW_THREADS
;
4308 c_retval
= virSecretSetValue(secret
, (const unsigned char *)value
, size
,
4310 LIBVIRT_END_ALLOW_THREADS
;
4312 return libvirt_intWrap(c_retval
);
4316 libvirt_virNWFilterGetUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4319 unsigned char uuid
[VIR_UUID_BUFLEN
];
4320 virNWFilterPtr nwfilter
;
4321 PyObject
*pyobj_nwfilter
;
4324 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUID",
4327 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4329 if (nwfilter
== NULL
)
4332 LIBVIRT_BEGIN_ALLOW_THREADS
;
4333 c_retval
= virNWFilterGetUUID(nwfilter
, &uuid
[0]);
4334 LIBVIRT_END_ALLOW_THREADS
;
4339 return libvirt_charPtrSizeWrap((char *) &uuid
[0], VIR_UUID_BUFLEN
);
4343 libvirt_virNWFilterGetUUIDString(PyObject
*self ATTRIBUTE_UNUSED
,
4346 char uuidstr
[VIR_UUID_STRING_BUFLEN
];
4347 virNWFilterPtr nwfilter
;
4348 PyObject
*pyobj_nwfilter
;
4351 if (!PyArg_ParseTuple(args
, (char *)"O:virNWFilterGetUUIDString",
4354 nwfilter
= (virNWFilterPtr
) PyvirNWFilter_Get(pyobj_nwfilter
);
4356 if (nwfilter
== NULL
)
4359 LIBVIRT_BEGIN_ALLOW_THREADS
;
4360 c_retval
= virNWFilterGetUUIDString(nwfilter
, &uuidstr
[0]);
4361 LIBVIRT_END_ALLOW_THREADS
;
4366 return libvirt_constcharPtrWrap((char *) &uuidstr
[0]);
4370 libvirt_virNWFilterLookupByUUID(PyObject
*self ATTRIBUTE_UNUSED
,
4373 virNWFilterPtr c_retval
;
4375 PyObject
*pyobj_conn
;
4376 unsigned char * uuid
;
4379 if (!PyArg_ParseTuple(args
, (char *)"Oz#:virNWFilterLookupByUUID",
4380 &pyobj_conn
, &uuid
, &len
))
4382 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4384 if ((uuid
== NULL
) || (len
!= VIR_UUID_BUFLEN
))
4387 LIBVIRT_BEGIN_ALLOW_THREADS
;
4388 c_retval
= virNWFilterLookupByUUID(conn
, uuid
);
4389 LIBVIRT_END_ALLOW_THREADS
;
4391 return libvirt_virNWFilterPtrWrap((virNWFilterPtr
) c_retval
);
4396 libvirt_virConnectListNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4399 PyObject
*py_retval
;
4400 char **uuids
= NULL
;
4404 PyObject
*pyobj_conn
;
4406 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListNWFilters",
4409 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4411 LIBVIRT_BEGIN_ALLOW_THREADS
;
4412 c_retval
= virConnectNumOfNWFilters(conn
);
4413 LIBVIRT_END_ALLOW_THREADS
;
4419 if (VIR_ALLOC_N(uuids
, c_retval
) < 0)
4420 return PyErr_NoMemory();
4422 LIBVIRT_BEGIN_ALLOW_THREADS
;
4423 c_retval
= virConnectListNWFilters(conn
, uuids
, c_retval
);
4424 LIBVIRT_END_ALLOW_THREADS
;
4427 py_retval
= VIR_PY_NONE
;
4432 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4436 for (i
= 0; i
< c_retval
; i
++)
4437 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4438 libvirt_constcharPtrWrap(uuids
[i
]), error
);
4442 for (i
= 0; i
< c_retval
; i
++)
4448 Py_CLEAR(py_retval
);
4452 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4454 libvirt_virConnectListAllNWFilters(PyObject
*self ATTRIBUTE_UNUSED
,
4457 PyObject
*pyobj_conn
;
4458 PyObject
*py_retval
= NULL
;
4460 virNWFilterPtr
*filters
= NULL
;
4465 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNWFilters",
4466 &pyobj_conn
, &flags
))
4468 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4470 LIBVIRT_BEGIN_ALLOW_THREADS
;
4471 c_retval
= virConnectListAllNWFilters(conn
, &filters
, flags
);
4472 LIBVIRT_END_ALLOW_THREADS
;
4477 if (!(py_retval
= PyList_New(c_retval
)))
4480 for (i
= 0; i
< c_retval
; i
++) {
4481 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4482 libvirt_virNWFilterPtrWrap(filters
[i
]), error
);
4483 /* python steals the pointer */
4488 for (i
= 0; i
< c_retval
; i
++)
4490 virNWFilterFree(filters
[i
]);
4495 Py_CLEAR(py_retval
);
4498 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4500 #if LIBVIR_CHECK_VERSION(4, 5, 0)
4502 libvirt_virConnectListAllNWFilterBindings(PyObject
*self ATTRIBUTE_UNUSED
,
4505 PyObject
*pyobj_conn
;
4506 PyObject
*py_retval
= NULL
;
4508 virNWFilterBindingPtr
*bindings
= NULL
;
4513 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllNWFilterBindings",
4514 &pyobj_conn
, &flags
))
4516 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4518 LIBVIRT_BEGIN_ALLOW_THREADS
;
4519 c_retval
= virConnectListAllNWFilterBindings(conn
, &bindings
, flags
);
4520 LIBVIRT_END_ALLOW_THREADS
;
4525 if (!(py_retval
= PyList_New(c_retval
)))
4528 for (i
= 0; i
< c_retval
; i
++) {
4529 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4530 libvirt_virNWFilterBindingPtrWrap(bindings
[i
]), error
);
4531 /* python steals the pointer */
4536 for (i
= 0; i
< c_retval
; i
++)
4538 virNWFilterBindingFree(bindings
[i
]);
4543 Py_CLEAR(py_retval
);
4546 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
4549 libvirt_virConnectListInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4552 PyObject
*py_retval
;
4553 char **names
= NULL
;
4557 PyObject
*pyobj_conn
;
4560 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListInterfaces",
4563 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4565 LIBVIRT_BEGIN_ALLOW_THREADS
;
4566 c_retval
= virConnectNumOfInterfaces(conn
);
4567 LIBVIRT_END_ALLOW_THREADS
;
4573 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4574 return PyErr_NoMemory();
4576 LIBVIRT_BEGIN_ALLOW_THREADS
;
4577 c_retval
= virConnectListInterfaces(conn
, names
, c_retval
);
4578 LIBVIRT_END_ALLOW_THREADS
;
4581 py_retval
= VIR_PY_NONE
;
4586 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4590 for (i
= 0; i
< c_retval
; i
++)
4591 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4592 libvirt_constcharPtrWrap(names
[i
]), error
);
4596 for (i
= 0; i
< c_retval
; i
++)
4602 Py_CLEAR(py_retval
);
4608 libvirt_virConnectListDefinedInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4611 PyObject
*py_retval
;
4612 char **names
= NULL
;
4616 PyObject
*pyobj_conn
;
4619 if (!PyArg_ParseTuple(args
, (char *)"O:virConnectListDefinedInterfaces",
4622 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4624 LIBVIRT_BEGIN_ALLOW_THREADS
;
4625 c_retval
= virConnectNumOfDefinedInterfaces(conn
);
4626 LIBVIRT_END_ALLOW_THREADS
;
4632 if (VIR_ALLOC_N(names
, c_retval
) < 0)
4633 return PyErr_NoMemory();
4635 LIBVIRT_BEGIN_ALLOW_THREADS
;
4636 c_retval
= virConnectListDefinedInterfaces(conn
, names
, c_retval
);
4637 LIBVIRT_END_ALLOW_THREADS
;
4640 py_retval
= VIR_PY_NONE
;
4645 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
4649 for (i
= 0; i
< c_retval
; i
++)
4650 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4651 libvirt_constcharPtrWrap(names
[i
]), error
);
4656 for (i
= 0; i
< c_retval
; i
++)
4662 Py_CLEAR(py_retval
);
4667 #if LIBVIR_CHECK_VERSION(0, 10, 2)
4669 libvirt_virConnectListAllInterfaces(PyObject
*self ATTRIBUTE_UNUSED
,
4672 PyObject
*pyobj_conn
;
4673 PyObject
*py_retval
= NULL
;
4675 virInterfacePtr
*ifaces
= NULL
;
4680 if (!PyArg_ParseTuple(args
, (char *)"OI:virConnectListAllInterfaces",
4681 &pyobj_conn
, &flags
))
4683 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4685 LIBVIRT_BEGIN_ALLOW_THREADS
;
4686 c_retval
= virConnectListAllInterfaces(conn
, &ifaces
, flags
);
4687 LIBVIRT_END_ALLOW_THREADS
;
4692 if (!(py_retval
= PyList_New(c_retval
)))
4695 for (i
= 0; i
< c_retval
; i
++) {
4696 VIR_PY_LIST_SET_GOTO(py_retval
, i
,
4697 libvirt_virInterfacePtrWrap(ifaces
[i
]), error
);
4698 /* python steals the pointer */
4703 for (i
= 0; i
< c_retval
; i
++)
4705 virInterfaceFree(ifaces
[i
]);
4710 Py_CLEAR(py_retval
);
4713 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
4716 libvirt_virConnectBaselineCPU(PyObject
*self ATTRIBUTE_UNUSED
,
4719 PyObject
*pyobj_conn
;
4723 char **xmlcpus
= NULL
;
4726 PyObject
*pybase_cpu
;
4729 if (!PyArg_ParseTuple(args
, (char *)"OOI:virConnectBaselineCPU",
4730 &pyobj_conn
, &list
, &flags
))
4732 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
4734 if (PyList_Check(list
)) {
4735 ncpus
= PyList_Size(list
);
4736 if (VIR_ALLOC_N(xmlcpus
, ncpus
) < 0)
4737 return PyErr_NoMemory();
4739 for (i
= 0; i
< ncpus
; i
++) {
4740 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
),
4741 &(xmlcpus
[i
])) < 0) {
4742 for (j
= 0 ; j
< i
; j
++)
4743 VIR_FREE(xmlcpus
[j
]);
4750 LIBVIRT_BEGIN_ALLOW_THREADS
;
4751 base_cpu
= virConnectBaselineCPU(conn
, (const char **)xmlcpus
, ncpus
, flags
);
4752 LIBVIRT_END_ALLOW_THREADS
;
4754 for (i
= 0 ; i
< ncpus
; i
++)
4755 VIR_FREE(xmlcpus
[i
]);
4758 if (base_cpu
== NULL
)
4761 pybase_cpu
= libvirt_constcharPtrWrap(base_cpu
);
4769 libvirt_virDomainGetJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4772 PyObject
*py_retval
;
4774 virDomainPtr domain
;
4775 PyObject
*pyobj_domain
;
4776 virDomainJobInfo info
;
4778 if (!PyArg_ParseTuple(args
, (char *)"O:virDomainGetJobInfo", &pyobj_domain
))
4780 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4782 LIBVIRT_BEGIN_ALLOW_THREADS
;
4783 c_retval
= virDomainGetJobInfo(domain
, &info
);
4784 LIBVIRT_END_ALLOW_THREADS
;
4789 if ((py_retval
= PyList_New(12)) == NULL
)
4792 VIR_PY_LIST_SET_GOTO(py_retval
, 0,
4793 libvirt_intWrap((int) info
.type
), error
);
4794 VIR_PY_LIST_SET_GOTO(py_retval
, 1,
4795 libvirt_ulonglongWrap(info
.timeElapsed
), error
);
4796 VIR_PY_LIST_SET_GOTO(py_retval
, 2,
4797 libvirt_ulonglongWrap(info
.timeRemaining
), error
);
4798 VIR_PY_LIST_SET_GOTO(py_retval
, 3,
4799 libvirt_ulonglongWrap(info
.dataTotal
), error
);
4800 VIR_PY_LIST_SET_GOTO(py_retval
, 4,
4801 libvirt_ulonglongWrap(info
.dataProcessed
), error
);
4802 VIR_PY_LIST_SET_GOTO(py_retval
, 5,
4803 libvirt_ulonglongWrap(info
.dataRemaining
), error
);
4804 VIR_PY_LIST_SET_GOTO(py_retval
, 6,
4805 libvirt_ulonglongWrap(info
.memTotal
), error
);
4806 VIR_PY_LIST_SET_GOTO(py_retval
, 7,
4807 libvirt_ulonglongWrap(info
.memProcessed
), error
);
4808 VIR_PY_LIST_SET_GOTO(py_retval
, 8,
4809 libvirt_ulonglongWrap(info
.memRemaining
), error
);
4810 VIR_PY_LIST_SET_GOTO(py_retval
, 9,
4811 libvirt_ulonglongWrap(info
.fileTotal
), error
);
4812 VIR_PY_LIST_SET_GOTO(py_retval
, 10,
4813 libvirt_ulonglongWrap(info
.fileProcessed
), error
);
4814 VIR_PY_LIST_SET_GOTO(py_retval
, 11,
4815 libvirt_ulonglongWrap(info
.fileRemaining
), error
);
4820 Py_DECREF(py_retval
);
4824 #if LIBVIR_CHECK_VERSION(1, 0, 3)
4826 libvirt_virDomainGetJobStats(PyObject
*self ATTRIBUTE_UNUSED
,
4829 PyObject
*pyobj_domain
;
4830 virDomainPtr domain
;
4832 virTypedParameterPtr params
= NULL
;
4835 PyObject
*dict
= NULL
;
4838 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetJobStats",
4839 &pyobj_domain
, &flags
))
4841 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4843 LIBVIRT_BEGIN_ALLOW_THREADS
;
4844 rc
= virDomainGetJobStats(domain
, &type
, ¶ms
, &nparams
, flags
);
4845 LIBVIRT_END_ALLOW_THREADS
;
4850 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
4853 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4854 libvirt_intWrap(type
), error
);
4857 virTypedParamsFree(params
, nparams
);
4864 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
4867 libvirt_virDomainGetBlockJobInfo(PyObject
*self ATTRIBUTE_UNUSED
,
4870 virDomainPtr domain
;
4871 PyObject
*pyobj_domain
;
4874 virDomainBlockJobInfo info
;
4878 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockJobInfo",
4879 &pyobj_domain
, &path
, &flags
))
4881 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4883 LIBVIRT_BEGIN_ALLOW_THREADS
;
4884 c_ret
= virDomainGetBlockJobInfo(domain
, path
, &info
, flags
);
4885 LIBVIRT_END_ALLOW_THREADS
;
4890 if ((dict
= PyDict_New()) == NULL
)
4896 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("type"),
4897 libvirt_intWrap(info
.type
), error
);
4898 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("bandwidth"),
4899 libvirt_ulongWrap(info
.bandwidth
), error
);
4900 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("cur"),
4901 libvirt_ulonglongWrap(info
.cur
), error
);
4902 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("end"),
4903 libvirt_ulonglongWrap(info
.end
), error
);
4913 libvirt_virDomainSetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4916 virDomainPtr domain
;
4917 PyObject
*pyobj_domain
, *info
;
4918 PyObject
*ret
= NULL
;
4921 Py_ssize_t size
= 0;
4924 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
4926 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainSetBlockIoTune",
4927 &pyobj_domain
, &disk
, &info
, &flags
))
4929 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
4931 if ((size
= PyDict_Size(info
)) < 0)
4935 PyErr_Format(PyExc_LookupError
,
4936 "Need non-empty dictionary to set attributes");
4940 LIBVIRT_BEGIN_ALLOW_THREADS
;
4941 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
4942 LIBVIRT_END_ALLOW_THREADS
;
4945 return VIR_PY_INT_FAIL
;
4948 PyErr_Format(PyExc_LookupError
,
4949 "Domain has no settable attributes");
4953 if (VIR_ALLOC_N(params
, nparams
) < 0)
4954 return PyErr_NoMemory();
4956 LIBVIRT_BEGIN_ALLOW_THREADS
;
4957 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
4958 LIBVIRT_END_ALLOW_THREADS
;
4961 ret
= VIR_PY_INT_FAIL
;
4965 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
4969 LIBVIRT_BEGIN_ALLOW_THREADS
;
4970 i_retval
= virDomainSetBlockIoTune(domain
, disk
, new_params
, size
, flags
);
4971 LIBVIRT_END_ALLOW_THREADS
;
4974 ret
= VIR_PY_INT_FAIL
;
4978 ret
= VIR_PY_INT_SUCCESS
;
4981 virTypedParamsFree(params
, nparams
);
4982 virTypedParamsFree(new_params
, size
);
4987 libvirt_virDomainGetBlockIoTune(PyObject
*self ATTRIBUTE_UNUSED
,
4990 virDomainPtr domain
;
4991 PyObject
*pyobj_domain
;
4992 PyObject
*ret
= NULL
;
4997 virTypedParameterPtr params
;
4999 if (!PyArg_ParseTuple(args
, (char *)"OzI:virDomainGetBlockIoTune",
5000 &pyobj_domain
, &disk
, &flags
))
5002 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5004 LIBVIRT_BEGIN_ALLOW_THREADS
;
5005 i_retval
= virDomainGetBlockIoTune(domain
, disk
, NULL
, &nparams
, flags
);
5006 LIBVIRT_END_ALLOW_THREADS
;
5012 return PyDict_New();
5014 if (VIR_ALLOC_N(params
, nparams
) < 0)
5015 return PyErr_NoMemory();
5017 LIBVIRT_BEGIN_ALLOW_THREADS
;
5018 i_retval
= virDomainGetBlockIoTune(domain
, disk
, params
, &nparams
, flags
);
5019 LIBVIRT_END_ALLOW_THREADS
;
5026 ret
= getPyVirTypedParameter(params
, nparams
);
5029 virTypedParamsFree(params
, nparams
);
5034 libvirt_virDomainGetDiskErrors(PyObject
*self ATTRIBUTE_UNUSED
,
5037 PyObject
*py_retval
= VIR_PY_NONE
;
5038 virDomainPtr domain
;
5039 PyObject
*pyobj_domain
;
5041 virDomainDiskErrorPtr disks
= NULL
;
5042 unsigned int ndisks
;
5046 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetDiskErrors",
5047 &pyobj_domain
, &flags
))
5050 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5052 LIBVIRT_BEGIN_ALLOW_THREADS
;
5053 count
= virDomainGetDiskErrors(domain
, NULL
, 0, 0);
5054 LIBVIRT_END_ALLOW_THREADS
;
5061 if (VIR_ALLOC_N(disks
, ndisks
) < 0)
5062 return PyErr_NoMemory();
5064 LIBVIRT_BEGIN_ALLOW_THREADS
;
5065 count
= virDomainGetDiskErrors(domain
, disks
, ndisks
, 0);
5066 LIBVIRT_END_ALLOW_THREADS
;
5069 py_retval
= VIR_PY_NONE
;
5074 if (!(py_retval
= PyDict_New()))
5077 for (i
= 0; i
< count
; i
++) {
5078 VIR_PY_DICT_SET_GOTO(py_retval
,
5079 libvirt_constcharPtrWrap(disks
[i
].disk
),
5080 libvirt_intWrap(disks
[i
].error
),
5086 for (i
= 0; i
< count
; i
++)
5087 VIR_FREE(disks
[i
].disk
);
5092 Py_CLEAR(py_retval
);
5097 #if LIBVIR_CHECK_VERSION(1, 2, 14)
5099 libvirt_virDomainInterfaceAddresses(PyObject
*self ATTRIBUTE_UNUSED
,
5102 PyObject
*py_retval
= VIR_PY_NONE
;
5103 PyObject
*pyobj_domain
;
5104 virDomainPtr domain
;
5105 virDomainInterfacePtr
*ifaces
= NULL
;
5106 unsigned int source
;
5108 int ifaces_count
= 0;
5111 if (!PyArg_ParseTuple(args
, (char *) "OII:virDomainInterfaceAddresses",
5112 &pyobj_domain
, &source
, &flags
))
5115 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
5117 LIBVIRT_BEGIN_ALLOW_THREADS
;
5118 ifaces_count
= virDomainInterfaceAddresses(domain
, &ifaces
, source
, flags
);
5119 LIBVIRT_END_ALLOW_THREADS
;
5121 if (ifaces_count
< 0)
5124 if (!(py_retval
= PyDict_New()))
5127 for (i
= 0; i
< ifaces_count
; i
++) {
5128 virDomainInterfacePtr iface
= ifaces
[i
];
5129 PyObject
*py_addrs
= NULL
;
5130 PyObject
*py_iface
= NULL
;
5132 if (!(py_iface
= PyDict_New()))
5135 VIR_PY_DICT_SET_GOTO(py_retval
, libvirt_charPtrWrap(iface
->name
),
5138 if (iface
->naddrs
) {
5139 if (!(py_addrs
= PyList_New(iface
->naddrs
))) {
5143 py_addrs
= VIR_PY_NONE
;
5146 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("addrs"),
5149 VIR_PY_DICT_SET_GOTO(py_iface
, libvirt_constcharPtrWrap("hwaddr"),
5150 libvirt_constcharPtrWrap(iface
->hwaddr
), error
);
5152 for (j
= 0; j
< iface
->naddrs
; j
++) {
5153 virDomainIPAddressPtr addr
= &(iface
->addrs
[j
]);
5154 PyObject
*py_addr
= PyDict_New();
5159 VIR_PY_LIST_SET_GOTO(py_addrs
, j
, py_addr
, error
);
5161 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("addr"),
5162 libvirt_constcharPtrWrap(addr
->addr
), error
);
5163 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("prefix"),
5164 libvirt_uintWrap(addr
->prefix
), error
);
5165 VIR_PY_DICT_SET_GOTO(py_addr
, libvirt_constcharPtrWrap("type"),
5166 libvirt_intWrap(addr
->type
), error
);
5171 if (ifaces
&& ifaces_count
> 0) {
5172 for (i
= 0; i
< ifaces_count
; i
++) {
5173 virDomainInterfaceFree(ifaces
[i
]);
5181 Py_CLEAR(py_retval
);
5184 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
5187 /*******************************************
5188 * Helper functions to avoid importing modules
5189 * for every callback
5190 *******************************************/
5191 static PyObject
*libvirt_module
= NULL
;
5192 static PyObject
*libvirt_dict
= NULL
;
5195 getLibvirtModuleObject(void)
5198 return libvirt_module
;
5200 // PyImport_ImportModule returns a new reference
5201 /* Bogus (char *) cast for RHEL-5 python API brokenness */
5202 libvirt_module
= PyImport_ImportModule((char *)"libvirt");
5203 if (!libvirt_module
) {
5204 DEBUG("%s Error importing libvirt module\n", __FUNCTION__
);
5209 return libvirt_module
;
5213 getLibvirtDictObject(void)
5216 return libvirt_dict
;
5218 // PyModule_GetDict returns a borrowed reference
5219 libvirt_dict
= PyModule_GetDict(getLibvirtModuleObject());
5220 if (!libvirt_dict
) {
5221 DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__
);
5226 Py_INCREF(libvirt_dict
);
5227 return libvirt_dict
;
5232 libvirt_lookupPythonFunc(const char *funcname
)
5234 PyObject
*python_cb
;
5236 /* Lookup the python callback */
5237 python_cb
= PyDict_GetItemString(getLibvirtDictObject(), funcname
);
5240 DEBUG("%s: Error finding %s\n", __FUNCTION__
, funcname
);
5246 if (!PyCallable_Check(python_cb
)) {
5247 DEBUG("%s: %s is not callable\n", __FUNCTION__
, funcname
);
5254 /*******************************************
5256 *******************************************/
5259 libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5265 PyObject
*pyobj_ret
= NULL
;
5267 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5268 PyObject
*pyobj_dom
;
5272 LIBVIRT_ENSURE_THREAD_STATE
;
5274 /* Create a python instance of this virDomainPtr */
5276 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5281 /* Call the Callback Dispatcher */
5282 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5283 (char*)"_dispatchDomainEventCallbacks",
5288 Py_DECREF(pyobj_dom
);
5292 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5295 Py_DECREF(pyobj_ret
);
5299 LIBVIRT_RELEASE_THREAD_STATE
;
5304 libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject
*self
,
5307 PyObject
*pyobj_conn
; /* virConnectPtr */
5308 PyObject
*pyobj_conn_inst
; /* virConnect Python object */
5313 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventRegister",
5314 &pyobj_conn
, &pyobj_conn_inst
))
5317 DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
5318 pyobj_conn
, pyobj_conn_inst
);
5319 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5321 Py_INCREF(pyobj_conn_inst
);
5323 LIBVIRT_BEGIN_ALLOW_THREADS
;
5324 ret
= virConnectDomainEventRegister(conn
,
5325 libvirt_virConnectDomainEventCallback
,
5326 pyobj_conn_inst
, NULL
);
5327 LIBVIRT_END_ALLOW_THREADS
;
5329 return libvirt_intWrap(ret
);
5333 libvirt_virConnectDomainEventDeregister(PyObject
*self ATTRIBUTE_UNUSED
,
5336 PyObject
*pyobj_conn
;
5337 PyObject
*pyobj_conn_inst
;
5342 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectDomainEventDeregister",
5343 &pyobj_conn
, &pyobj_conn_inst
))
5346 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
5348 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
5350 LIBVIRT_BEGIN_ALLOW_THREADS
;
5351 ret
= virConnectDomainEventDeregister(conn
, libvirt_virConnectDomainEventCallback
);
5352 LIBVIRT_END_ALLOW_THREADS
;
5354 Py_DECREF(pyobj_conn_inst
);
5355 return libvirt_intWrap(ret
);
5358 /*******************************************
5360 *******************************************/
5361 static PyObject
*addHandleObj
;
5362 static PyObject
*updateHandleObj
;
5363 static PyObject
*removeHandleObj
;
5364 static PyObject
*addTimeoutObj
;
5365 static PyObject
*updateTimeoutObj
;
5366 static PyObject
*removeTimeoutObj
;
5369 libvirt_virEventAddHandleFunc(int fd
,
5371 virEventHandleCallback cb
,
5376 PyObject
*python_cb
= NULL
;
5377 PyObject
*cb_args
= NULL
;
5378 PyObject
*pyobj_args
= NULL
;
5381 LIBVIRT_ENSURE_THREAD_STATE
;
5383 if ((pyobj_args
= PyTuple_New(4)) == NULL
)
5386 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(fd
), cleanup
);
5387 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5389 /* Lookup the python callback */
5390 python_cb
= libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
5394 Py_INCREF(python_cb
);
5396 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, python_cb
, cleanup
);
5398 if ((cb_args
= PyTuple_New(3)) == NULL
)
5401 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 3, cb_args
, cleanup
);
5403 /* If changing contents of the opaque object, please also change
5404 * virEventInvokeFreeCallback() in libvirt-override.py
5406 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventHandleCallbackWrap(cb
), cleanup
);
5407 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5408 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5410 result
= PyEval_CallObject(addHandleObj
, pyobj_args
);
5415 libvirt_intUnwrap(result
, &retval
);
5421 Py_XDECREF(pyobj_args
);
5423 LIBVIRT_RELEASE_THREAD_STATE
;
5429 libvirt_virEventUpdateHandleFunc(int watch
,
5432 PyObject
*result
= NULL
;
5433 PyObject
*pyobj_args
;
5435 LIBVIRT_ENSURE_THREAD_STATE
;
5437 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5440 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5441 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(event
), cleanup
);
5443 result
= PyEval_CallObject(updateHandleObj
, pyobj_args
);
5451 Py_XDECREF(pyobj_args
);
5453 LIBVIRT_RELEASE_THREAD_STATE
;
5458 libvirt_virEventRemoveHandleFunc(int watch
)
5460 PyObject
*result
= NULL
;
5461 PyObject
*pyobj_args
;
5464 LIBVIRT_ENSURE_THREAD_STATE
;
5466 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5469 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(watch
), cleanup
);
5471 result
= PyEval_CallObject(removeHandleObj
, pyobj_args
);
5481 Py_XDECREF(pyobj_args
);
5483 LIBVIRT_RELEASE_THREAD_STATE
;
5490 libvirt_virEventAddTimeoutFunc(int timeout
,
5491 virEventTimeoutCallback cb
,
5495 PyObject
*result
= NULL
;
5496 PyObject
*python_cb
= NULL
;
5497 PyObject
*cb_args
= NULL
;
5498 PyObject
*pyobj_args
= NULL
;
5501 LIBVIRT_ENSURE_THREAD_STATE
;
5503 if ((pyobj_args
= PyTuple_New(3)) == NULL
)
5506 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timeout
), cleanup
);
5508 /* Lookup the python callback */
5509 python_cb
= libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
5513 Py_INCREF(python_cb
);
5514 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, python_cb
, cleanup
);
5516 if ((cb_args
= PyTuple_New(3)) == NULL
)
5519 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 2, cb_args
, cleanup
);
5521 /* If changing contents of the opaque object, please also change
5522 * virEventInvokeFreeCallback() in libvirt-override.py
5524 VIR_PY_TUPLE_SET_GOTO(cb_args
, 0, libvirt_virEventTimeoutCallbackWrap(cb
), cleanup
);
5525 VIR_PY_TUPLE_SET_GOTO(cb_args
, 1, libvirt_virVoidPtrWrap(opaque
), cleanup
);
5526 VIR_PY_TUPLE_SET_GOTO(cb_args
, 2, libvirt_virFreeCallbackWrap(ff
), cleanup
);
5528 result
= PyEval_CallObject(addTimeoutObj
, pyobj_args
);
5533 libvirt_intUnwrap(result
, &retval
);
5538 Py_XDECREF(pyobj_args
);
5540 LIBVIRT_RELEASE_THREAD_STATE
;
5545 libvirt_virEventUpdateTimeoutFunc(int timer
,
5548 PyObject
*result
= NULL
;
5549 PyObject
*pyobj_args
;
5551 LIBVIRT_ENSURE_THREAD_STATE
;
5553 if ((pyobj_args
= PyTuple_New(2)) == NULL
)
5556 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5557 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 1, libvirt_intWrap(timeout
), cleanup
);
5559 result
= PyEval_CallObject(updateTimeoutObj
, pyobj_args
);
5567 Py_XDECREF(pyobj_args
);
5569 LIBVIRT_RELEASE_THREAD_STATE
;
5573 libvirt_virEventRemoveTimeoutFunc(int timer
)
5575 PyObject
*result
= NULL
;
5576 PyObject
*pyobj_args
;
5579 LIBVIRT_ENSURE_THREAD_STATE
;
5581 if ((pyobj_args
= PyTuple_New(1)) == NULL
)
5584 VIR_PY_TUPLE_SET_GOTO(pyobj_args
, 0, libvirt_intWrap(timer
), cleanup
);
5586 result
= PyEval_CallObject(removeTimeoutObj
, pyobj_args
);
5596 Py_XDECREF(pyobj_args
);
5598 LIBVIRT_RELEASE_THREAD_STATE
;
5604 libvirt_virEventRegisterImpl(PyObject
*self ATTRIBUTE_UNUSED
,
5607 if (addHandleObj
|| updateHandleObj
|| removeHandleObj
||
5608 addTimeoutObj
|| updateTimeoutObj
|| removeTimeoutObj
) {
5609 PyErr_SetString(PyExc_RuntimeError
,
5610 "Event loop is already registered");
5614 /* Parse and check arguments */
5615 if (!PyArg_ParseTuple(args
, (char *) "OOOOOO:virEventRegisterImpl",
5616 &addHandleObj
, &updateHandleObj
,
5617 &removeHandleObj
, &addTimeoutObj
,
5618 &updateTimeoutObj
, &removeTimeoutObj
) ||
5619 !PyCallable_Check(addHandleObj
) ||
5620 !PyCallable_Check(updateHandleObj
) ||
5621 !PyCallable_Check(removeHandleObj
) ||
5622 !PyCallable_Check(addTimeoutObj
) ||
5623 !PyCallable_Check(updateTimeoutObj
) ||
5624 !PyCallable_Check(removeTimeoutObj
))
5627 /* Inc refs since we're holding on to these objects until
5628 * the next call (if any) to this function.
5630 Py_INCREF(addHandleObj
);
5631 Py_INCREF(updateHandleObj
);
5632 Py_INCREF(removeHandleObj
);
5633 Py_INCREF(addTimeoutObj
);
5634 Py_INCREF(updateTimeoutObj
);
5635 Py_INCREF(removeTimeoutObj
);
5637 /* Now register our C EventImpl, which will dispatch
5638 * to the Python callbacks passed in as args.
5640 LIBVIRT_BEGIN_ALLOW_THREADS
;
5641 virEventRegisterImpl(libvirt_virEventAddHandleFunc
,
5642 libvirt_virEventUpdateHandleFunc
,
5643 libvirt_virEventRemoveHandleFunc
,
5644 libvirt_virEventAddTimeoutFunc
,
5645 libvirt_virEventUpdateTimeoutFunc
,
5646 libvirt_virEventRemoveTimeoutFunc
);
5647 LIBVIRT_END_ALLOW_THREADS
;
5649 return VIR_PY_INT_SUCCESS
;
5653 libvirt_virEventInvokeHandleCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5656 int watch
, fd
, event
;
5658 PyObject
*py_opaque
;
5659 virEventHandleCallback cb
;
5662 if (!PyArg_ParseTuple(args
, (char *) "iiiOO:virEventInvokeHandleCallback",
5663 &watch
, &fd
, &event
, &py_f
, &py_opaque
))
5666 cb
= (virEventHandleCallback
) PyvirEventHandleCallback_Get(py_f
);
5667 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5670 LIBVIRT_BEGIN_ALLOW_THREADS
;
5671 cb(watch
, fd
, event
, opaque
);
5672 LIBVIRT_END_ALLOW_THREADS
;
5675 return VIR_PY_INT_SUCCESS
;
5679 libvirt_virEventInvokeTimeoutCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5684 PyObject
*py_opaque
;
5685 virEventTimeoutCallback cb
;
5688 if (!PyArg_ParseTuple(args
, (char *) "iOO:virEventInvokeTimeoutCallback",
5689 &timer
, &py_f
, &py_opaque
))
5692 cb
= (virEventTimeoutCallback
) PyvirEventTimeoutCallback_Get(py_f
);
5693 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5695 LIBVIRT_BEGIN_ALLOW_THREADS
;
5697 LIBVIRT_END_ALLOW_THREADS
;
5700 return VIR_PY_INT_SUCCESS
;
5704 libvirt_virEventInvokeFreeCallback(PyObject
*self ATTRIBUTE_UNUSED
,
5708 PyObject
*py_opaque
;
5712 if (!PyArg_ParseTuple(args
, (char *) "OO:virEventInvokeFreeCallback",
5716 cb
= (virFreeCallback
) PyvirEventHandleCallback_Get(py_f
);
5717 opaque
= (void *) PyvirVoidPtr_Get(py_opaque
);
5720 LIBVIRT_BEGIN_ALLOW_THREADS
;
5722 LIBVIRT_END_ALLOW_THREADS
;
5725 return VIR_PY_INT_SUCCESS
;
5729 libvirt_virEventHandleCallback(int watch
,
5734 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5735 PyObject
*pyobj_ret
;
5736 PyObject
*python_cb
;
5738 LIBVIRT_ENSURE_THREAD_STATE
;
5740 /* Lookup the python callback */
5741 python_cb
= libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
5746 Py_INCREF(pyobj_cbData
);
5748 /* Call the pure python dispatcher */
5749 pyobj_ret
= PyObject_CallFunction(python_cb
,
5751 watch
, fd
, events
, pyobj_cbData
);
5753 Py_DECREF(pyobj_cbData
);
5756 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5759 Py_DECREF(pyobj_ret
);
5763 LIBVIRT_RELEASE_THREAD_STATE
;
5767 libvirt_virEventAddHandle(PyObject
*self ATTRIBUTE_UNUSED
,
5770 PyObject
*pyobj_cbData
;
5771 virEventHandleCallback cb
= libvirt_virEventHandleCallback
;
5776 if (!PyArg_ParseTuple(args
, (char *) "iiO:virEventAddHandle",
5777 &fd
, &events
, &pyobj_cbData
))
5780 Py_INCREF(pyobj_cbData
);
5782 LIBVIRT_BEGIN_ALLOW_THREADS
;
5783 ret
= virEventAddHandle(fd
, events
, cb
, pyobj_cbData
, NULL
);
5784 LIBVIRT_END_ALLOW_THREADS
;
5787 Py_DECREF(pyobj_cbData
);
5790 return libvirt_intWrap(ret
);
5794 libvirt_virEventTimeoutCallback(int timer
,
5797 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5798 PyObject
*pyobj_ret
;
5799 PyObject
*python_cb
;
5801 LIBVIRT_ENSURE_THREAD_STATE
;
5803 /* Lookup the python callback */
5804 python_cb
= libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
5809 Py_INCREF(pyobj_cbData
);
5811 /* Call the pure python dispatcher */
5812 pyobj_ret
= PyObject_CallFunction(python_cb
,
5814 timer
, pyobj_cbData
);
5816 Py_DECREF(pyobj_cbData
);
5819 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5822 Py_DECREF(pyobj_ret
);
5826 LIBVIRT_RELEASE_THREAD_STATE
;
5830 libvirt_virEventAddTimeout(PyObject
*self ATTRIBUTE_UNUSED
,
5833 PyObject
*pyobj_cbData
;
5834 virEventTimeoutCallback cb
= libvirt_virEventTimeoutCallback
;
5838 if (!PyArg_ParseTuple(args
, (char *) "iO:virEventAddTimeout",
5839 &timeout
, &pyobj_cbData
))
5842 Py_INCREF(pyobj_cbData
);
5844 LIBVIRT_BEGIN_ALLOW_THREADS
;
5845 ret
= virEventAddTimeout(timeout
, cb
, pyobj_cbData
, NULL
);
5846 LIBVIRT_END_ALLOW_THREADS
;
5849 Py_DECREF(pyobj_cbData
);
5852 return libvirt_intWrap(ret
);
5856 libvirt_virConnectDomainEventFreeFunc(void *opaque
)
5858 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
5859 LIBVIRT_ENSURE_THREAD_STATE
;
5860 Py_DECREF(pyobj_conn
);
5861 LIBVIRT_RELEASE_THREAD_STATE
;
5865 libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5871 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5872 PyObject
*pyobj_dom
;
5873 PyObject
*pyobj_ret
= NULL
;
5874 PyObject
*pyobj_conn
;
5878 LIBVIRT_ENSURE_THREAD_STATE
;
5880 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5882 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5885 /* Create a python instance of this virDomainPtr */
5887 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5891 Py_INCREF(pyobj_cbData
);
5893 /* Call the Callback Dispatcher */
5894 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5895 (char*)"_dispatchDomainEventLifecycleCallback",
5901 Py_DECREF(pyobj_cbData
);
5902 Py_DECREF(pyobj_dom
);
5906 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5909 Py_DECREF(pyobj_ret
);
5913 LIBVIRT_RELEASE_THREAD_STATE
;
5918 libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5922 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5923 PyObject
*pyobj_dom
;
5924 PyObject
*pyobj_ret
= NULL
;
5925 PyObject
*pyobj_conn
;
5929 LIBVIRT_ENSURE_THREAD_STATE
;
5931 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5933 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5936 /* Create a python instance of this virDomainPtr */
5938 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5942 Py_INCREF(pyobj_cbData
);
5944 /* Call the Callback Dispatcher */
5945 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5946 (char*)"_dispatchDomainEventGenericCallback",
5948 pyobj_dom
, pyobj_cbData
);
5950 Py_DECREF(pyobj_cbData
);
5951 Py_DECREF(pyobj_dom
);
5955 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
5958 Py_DECREF(pyobj_ret
);
5962 LIBVIRT_RELEASE_THREAD_STATE
;
5967 libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
5969 long long utcoffset
,
5972 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
5973 PyObject
*pyobj_dom
;
5974 PyObject
*pyobj_ret
= NULL
;
5975 PyObject
*pyobj_conn
;
5979 LIBVIRT_ENSURE_THREAD_STATE
;
5981 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
5983 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
5986 /* Create a python instance of this virDomainPtr */
5988 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
5992 Py_INCREF(pyobj_cbData
);
5994 /* Call the Callback Dispatcher */
5995 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
5996 (char*)"_dispatchDomainEventRTCChangeCallback",
5999 (PY_LONG_LONG
)utcoffset
,
6002 Py_DECREF(pyobj_cbData
);
6003 Py_DECREF(pyobj_dom
);
6007 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6010 Py_DECREF(pyobj_ret
);
6014 LIBVIRT_RELEASE_THREAD_STATE
;
6019 libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6024 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6025 PyObject
*pyobj_dom
;
6026 PyObject
*pyobj_ret
= NULL
;
6027 PyObject
*pyobj_conn
;
6031 LIBVIRT_ENSURE_THREAD_STATE
;
6033 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6035 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6038 /* Create a python instance of this virDomainPtr */
6040 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6044 Py_INCREF(pyobj_cbData
);
6046 /* Call the Callback Dispatcher */
6047 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6048 (char*)"_dispatchDomainEventWatchdogCallback",
6054 Py_DECREF(pyobj_cbData
);
6055 Py_DECREF(pyobj_dom
);
6059 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6062 Py_DECREF(pyobj_ret
);
6066 LIBVIRT_RELEASE_THREAD_STATE
;
6071 libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6073 const char *srcPath
,
6074 const char *devAlias
,
6078 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6079 PyObject
*pyobj_dom
;
6080 PyObject
*pyobj_ret
= NULL
;
6081 PyObject
*pyobj_conn
;
6085 LIBVIRT_ENSURE_THREAD_STATE
;
6087 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6089 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6092 /* Create a python instance of this virDomainPtr */
6094 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6098 Py_INCREF(pyobj_cbData
);
6100 /* Call the Callback Dispatcher */
6101 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6102 (char*)"_dispatchDomainEventIOErrorCallback",
6105 srcPath
, devAlias
, action
,
6108 Py_DECREF(pyobj_cbData
);
6109 Py_DECREF(pyobj_dom
);
6113 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6116 Py_DECREF(pyobj_ret
);
6120 LIBVIRT_RELEASE_THREAD_STATE
;
6125 libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6127 const char *srcPath
,
6128 const char *devAlias
,
6133 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6134 PyObject
*pyobj_dom
;
6135 PyObject
*pyobj_ret
= NULL
;
6136 PyObject
*pyobj_conn
;
6140 LIBVIRT_ENSURE_THREAD_STATE
;
6142 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6144 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6147 /* Create a python instance of this virDomainPtr */
6149 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6153 Py_INCREF(pyobj_cbData
);
6155 /* Call the Callback Dispatcher */
6156 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6157 (char*)"_dispatchDomainEventIOErrorReasonCallback",
6160 srcPath
, devAlias
, action
, reason
,
6163 Py_DECREF(pyobj_cbData
);
6164 Py_DECREF(pyobj_dom
);
6168 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6171 Py_DECREF(pyobj_ret
);
6175 LIBVIRT_RELEASE_THREAD_STATE
;
6180 libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6183 virDomainEventGraphicsAddressPtr local
,
6184 virDomainEventGraphicsAddressPtr remote
,
6185 const char *authScheme
,
6186 virDomainEventGraphicsSubjectPtr subject
,
6189 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6190 PyObject
*pyobj_dom
= NULL
;
6191 PyObject
*pyobj_ret
= NULL
;
6192 PyObject
*pyobj_conn
;
6194 PyObject
*pyobj_local
= NULL
;
6195 PyObject
*pyobj_remote
= NULL
;
6196 PyObject
*pyobj_subject
= NULL
;
6200 LIBVIRT_ENSURE_THREAD_STATE
;
6202 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6204 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6207 /* Create a python instance of this virDomainPtr */
6209 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6213 Py_INCREF(pyobj_cbData
);
6215 if ((pyobj_local
= PyDict_New()) == NULL
)
6218 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6219 libvirt_constcharPtrWrap("family"),
6220 libvirt_intWrap(local
->family
),
6222 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6223 libvirt_constcharPtrWrap("node"),
6224 libvirt_constcharPtrWrap(local
->node
),
6226 VIR_PY_DICT_SET_GOTO(pyobj_local
,
6227 libvirt_constcharPtrWrap("service"),
6228 libvirt_constcharPtrWrap(local
->service
),
6231 if ((pyobj_remote
= PyDict_New()) == NULL
)
6234 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6235 libvirt_constcharPtrWrap("family"),
6236 libvirt_intWrap(remote
->family
),
6238 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6239 libvirt_constcharPtrWrap("node"),
6240 libvirt_constcharPtrWrap(remote
->node
),
6242 VIR_PY_DICT_SET_GOTO(pyobj_remote
,
6243 libvirt_constcharPtrWrap("service"),
6244 libvirt_constcharPtrWrap(remote
->service
),
6247 if ((pyobj_subject
= PyList_New(subject
->nidentity
)) == NULL
)
6250 for (i
= 0; i
< subject
->nidentity
; i
++) {
6251 PyObject
*pair
= PyTuple_New(2);
6255 VIR_PY_LIST_SET_GOTO(pyobj_subject
, i
, pair
, cleanup
);
6257 VIR_PY_TUPLE_SET_GOTO(pair
, 0,
6258 libvirt_constcharPtrWrap(subject
->identities
[i
].type
),
6260 VIR_PY_TUPLE_SET_GOTO(pair
, 1,
6261 libvirt_constcharPtrWrap(subject
->identities
[i
].name
),
6265 /* Call the Callback Dispatcher */
6266 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6267 (char*)"_dispatchDomainEventGraphicsCallback",
6270 phase
, pyobj_local
, pyobj_remote
,
6271 authScheme
, pyobj_subject
,
6275 Py_DECREF(pyobj_cbData
);
6276 Py_XDECREF(pyobj_dom
);
6279 Py_XDECREF(pyobj_local
);
6280 Py_XDECREF(pyobj_remote
);
6281 Py_XDECREF(pyobj_subject
);
6282 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6285 Py_DECREF(pyobj_ret
);
6289 LIBVIRT_RELEASE_THREAD_STATE
;
6294 libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6301 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6302 PyObject
*pyobj_dom
;
6303 PyObject
*pyobj_ret
= NULL
;
6304 PyObject
*pyobj_conn
;
6308 LIBVIRT_ENSURE_THREAD_STATE
;
6310 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6312 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6315 /* Create a python instance of this virDomainPtr */
6317 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6321 Py_INCREF(pyobj_cbData
);
6323 /* Call the Callback Dispatcher */
6324 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6325 (char*)"_dispatchDomainEventBlockJobCallback",
6327 pyobj_dom
, disk
, type
, status
, pyobj_cbData
);
6329 Py_DECREF(pyobj_cbData
);
6330 Py_DECREF(pyobj_dom
);
6334 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6337 Py_DECREF(pyobj_ret
);
6341 LIBVIRT_RELEASE_THREAD_STATE
;
6346 libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6348 const char *oldSrcPath
,
6349 const char *newSrcPath
,
6350 const char *devAlias
,
6354 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6355 PyObject
*pyobj_dom
;
6356 PyObject
*pyobj_ret
= NULL
;
6357 PyObject
*pyobj_conn
;
6361 LIBVIRT_ENSURE_THREAD_STATE
;
6363 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6365 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6368 /* Create a python instance of this virDomainPtr */
6370 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6374 Py_INCREF(pyobj_cbData
);
6376 /* Call the Callback Dispatcher */
6377 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6378 (char*)"_dispatchDomainEventDiskChangeCallback",
6381 oldSrcPath
, newSrcPath
,
6382 devAlias
, reason
, pyobj_cbData
);
6384 Py_DECREF(pyobj_cbData
);
6385 Py_DECREF(pyobj_dom
);
6389 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6392 Py_DECREF(pyobj_ret
);
6396 LIBVIRT_RELEASE_THREAD_STATE
;
6401 libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6403 const char *devAlias
,
6407 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6408 PyObject
*pyobj_dom
;
6409 PyObject
*pyobj_ret
= NULL
;
6410 PyObject
*pyobj_conn
;
6414 LIBVIRT_ENSURE_THREAD_STATE
;
6416 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6418 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6421 /* Create a python instance of this virDomainPtr */
6423 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6427 Py_INCREF(pyobj_cbData
);
6429 /* Call the Callback Dispatcher */
6430 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6431 (char*)"_dispatchDomainEventTrayChangeCallback",
6434 devAlias
, reason
, pyobj_cbData
);
6436 Py_DECREF(pyobj_cbData
);
6437 Py_DECREF(pyobj_dom
);
6441 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6444 Py_DECREF(pyobj_ret
);
6448 LIBVIRT_RELEASE_THREAD_STATE
;
6453 libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6458 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6459 PyObject
*pyobj_dom
;
6460 PyObject
*pyobj_ret
= NULL
;
6461 PyObject
*pyobj_conn
;
6465 LIBVIRT_ENSURE_THREAD_STATE
;
6467 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6469 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6472 /* Create a python instance of this virDomainPtr */
6474 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6478 Py_INCREF(pyobj_cbData
);
6480 /* Call the Callback Dispatcher */
6481 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6482 (char*)"_dispatchDomainEventPMWakeupCallback",
6488 Py_DECREF(pyobj_cbData
);
6489 Py_DECREF(pyobj_dom
);
6493 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6496 Py_DECREF(pyobj_ret
);
6500 LIBVIRT_RELEASE_THREAD_STATE
;
6505 libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6510 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6511 PyObject
*pyobj_dom
;
6512 PyObject
*pyobj_ret
= NULL
;
6513 PyObject
*pyobj_conn
;
6517 LIBVIRT_ENSURE_THREAD_STATE
;
6519 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6521 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6524 /* Create a python instance of this virDomainPtr */
6526 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6530 Py_INCREF(pyobj_cbData
);
6532 /* Call the Callback Dispatcher */
6533 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6534 (char*)"_dispatchDomainEventPMSuspendCallback",
6540 Py_DECREF(pyobj_cbData
);
6541 Py_DECREF(pyobj_dom
);
6545 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6548 Py_DECREF(pyobj_ret
);
6552 LIBVIRT_RELEASE_THREAD_STATE
;
6557 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
6559 libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6561 unsigned long long actual
,
6564 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6565 PyObject
*pyobj_dom
;
6566 PyObject
*pyobj_ret
= NULL
;
6567 PyObject
*pyobj_conn
;
6571 LIBVIRT_ENSURE_THREAD_STATE
;
6573 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6575 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6578 /* Create a python instance of this virDomainPtr */
6580 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6584 Py_INCREF(pyobj_cbData
);
6586 /* Call the Callback Dispatcher */
6587 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6588 (char*)"_dispatchDomainEventBalloonChangeCallback",
6591 (PY_LONG_LONG
)actual
,
6594 Py_DECREF(pyobj_cbData
);
6595 Py_DECREF(pyobj_dom
);
6599 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6602 Py_DECREF(pyobj_ret
);
6606 LIBVIRT_RELEASE_THREAD_STATE
;
6609 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
6611 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
6613 libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6618 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6619 PyObject
*pyobj_dom
;
6620 PyObject
*pyobj_ret
= NULL
;
6621 PyObject
*pyobj_conn
;
6625 LIBVIRT_ENSURE_THREAD_STATE
;
6627 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6629 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6632 /* Create a python instance of this virDomainPtr */
6634 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6638 Py_INCREF(pyobj_cbData
);
6640 /* Call the Callback Dispatcher */
6641 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6642 (char*)"_dispatchDomainEventPMSuspendDiskCallback",
6648 Py_DECREF(pyobj_cbData
);
6649 Py_DECREF(pyobj_dom
);
6653 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6656 Py_DECREF(pyobj_ret
);
6660 LIBVIRT_RELEASE_THREAD_STATE
;
6663 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
6665 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
6667 libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6669 const char *devAlias
,
6672 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6673 PyObject
*pyobj_dom
;
6674 PyObject
*pyobj_ret
= NULL
;
6675 PyObject
*pyobj_conn
;
6679 LIBVIRT_ENSURE_THREAD_STATE
;
6681 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6683 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6686 /* Create a python instance of this virDomainPtr */
6688 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6692 Py_INCREF(pyobj_cbData
);
6694 /* Call the Callback Dispatcher */
6695 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6696 (char*)"_dispatchDomainEventDeviceRemovedCallback",
6698 pyobj_dom
, devAlias
, pyobj_cbData
);
6700 Py_DECREF(pyobj_cbData
);
6701 Py_DECREF(pyobj_dom
);
6705 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6708 Py_DECREF(pyobj_ret
);
6712 LIBVIRT_RELEASE_THREAD_STATE
;
6715 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
6717 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
6719 libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6721 virTypedParameterPtr params
,
6725 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6726 PyObject
*pyobj_dom
;
6727 PyObject
*pyobj_ret
= NULL
;
6728 PyObject
*pyobj_conn
;
6730 PyObject
*pyobj_dict
= NULL
;
6733 LIBVIRT_ENSURE_THREAD_STATE
;
6735 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
6739 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6741 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6744 /* Create a python instance of this virDomainPtr */
6746 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6750 Py_INCREF(pyobj_cbData
);
6752 /* Call the Callback Dispatcher */
6753 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6754 (char*)"_dispatchDomainEventTunableCallback",
6756 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
6758 Py_DECREF(pyobj_cbData
);
6759 Py_DECREF(pyobj_dom
);
6763 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6766 Py_DECREF(pyobj_ret
);
6769 Py_XDECREF(pyobj_dict
);
6771 LIBVIRT_RELEASE_THREAD_STATE
;
6775 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
6777 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
6779 libvirt_virConnectDomainEventAgentLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6785 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6786 PyObject
*pyobj_dom
;
6787 PyObject
*pyobj_ret
= NULL
;
6788 PyObject
*pyobj_conn
;
6792 LIBVIRT_ENSURE_THREAD_STATE
;
6794 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6796 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6799 /* Create a python instance of this virDomainPtr */
6801 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6805 Py_INCREF(pyobj_cbData
);
6807 /* Call the Callback Dispatcher */
6808 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6809 (char*)"_dispatchDomainEventAgentLifecycleCallback",
6811 pyobj_dom
, state
, reason
, pyobj_cbData
);
6813 Py_DECREF(pyobj_cbData
);
6814 Py_DECREF(pyobj_dom
);
6818 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6821 Py_DECREF(pyobj_ret
);
6825 LIBVIRT_RELEASE_THREAD_STATE
;
6829 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
6831 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
6833 libvirt_virConnectDomainEventDeviceAddedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6835 const char *devAlias
,
6838 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6839 PyObject
*pyobj_dom
;
6840 PyObject
*pyobj_ret
= NULL
;
6841 PyObject
*pyobj_conn
;
6845 LIBVIRT_ENSURE_THREAD_STATE
;
6847 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6849 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6852 /* Create a python instance of this virDomainPtr */
6854 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6858 Py_INCREF(pyobj_cbData
);
6860 /* Call the Callback Dispatcher */
6861 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6862 (char*)"_dispatchDomainEventDeviceAddedCallback",
6864 pyobj_dom
, devAlias
, pyobj_cbData
);
6866 Py_DECREF(pyobj_cbData
);
6867 Py_DECREF(pyobj_dom
);
6871 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6874 Py_DECREF(pyobj_ret
);
6878 LIBVIRT_RELEASE_THREAD_STATE
;
6882 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
6884 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
6886 libvirt_virConnectDomainEventMigrationIterationCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6891 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6892 PyObject
*pyobj_dom
;
6893 PyObject
*pyobj_ret
= NULL
;
6894 PyObject
*pyobj_conn
;
6898 LIBVIRT_ENSURE_THREAD_STATE
;
6900 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6902 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6905 /* Create a python instance of this virDomainPtr */
6907 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6911 Py_INCREF(pyobj_cbData
);
6913 /* Call the Callback Dispatcher */
6914 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6915 (char*)"_dispatchDomainEventMigrationIterationCallback",
6917 pyobj_dom
, iteration
, pyobj_cbData
);
6919 Py_DECREF(pyobj_cbData
);
6920 Py_DECREF(pyobj_dom
);
6924 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6927 Py_DECREF(pyobj_ret
);
6931 LIBVIRT_RELEASE_THREAD_STATE
;
6934 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
6936 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
6938 libvirt_virConnectDomainEventJobCompletedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
6940 virTypedParameterPtr params
,
6944 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
6945 PyObject
*pyobj_dom
;
6946 PyObject
*pyobj_ret
= NULL
;
6947 PyObject
*pyobj_conn
;
6949 PyObject
*pyobj_dict
= NULL
;
6952 LIBVIRT_ENSURE_THREAD_STATE
;
6954 pyobj_dict
= getPyVirTypedParameter(params
, nparams
);
6958 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
6960 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
6963 /* Create a python instance of this virDomainPtr */
6965 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
6969 Py_INCREF(pyobj_cbData
);
6971 /* Call the Callback Dispatcher */
6972 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
6973 (char*)"_dispatchDomainEventJobCompletedCallback",
6975 pyobj_dom
, pyobj_dict
, pyobj_cbData
);
6977 Py_DECREF(pyobj_cbData
);
6978 Py_DECREF(pyobj_dom
);
6982 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
6984 Py_XDECREF(pyobj_dict
);
6986 Py_DECREF(pyobj_ret
);
6990 LIBVIRT_RELEASE_THREAD_STATE
;
6993 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
6996 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
6998 libvirt_virConnectDomainEventDeviceRemovalFailedCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7000 const char *devAlias
,
7003 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7004 PyObject
*pyobj_dom
;
7005 PyObject
*pyobj_ret
= NULL
;
7006 PyObject
*pyobj_conn
;
7010 LIBVIRT_ENSURE_THREAD_STATE
;
7012 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7014 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7017 /* Create a python instance of this virDomainPtr */
7019 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7023 Py_INCREF(pyobj_cbData
);
7025 /* Call the Callback Dispatcher */
7026 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7027 (char*)"_dispatchDomainEventDeviceRemovalFailedCallback",
7029 pyobj_dom
, devAlias
, pyobj_cbData
);
7031 Py_DECREF(pyobj_cbData
);
7032 Py_DECREF(pyobj_dom
);
7036 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7039 Py_DECREF(pyobj_ret
);
7043 LIBVIRT_RELEASE_THREAD_STATE
;
7047 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
7049 #ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
7051 libvirt_virConnectDomainEventMetadataChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7057 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7058 PyObject
*pyobj_dom
;
7059 PyObject
*pyobj_ret
= NULL
;
7060 PyObject
*pyobj_conn
;
7064 LIBVIRT_ENSURE_THREAD_STATE
;
7066 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7068 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7071 /* Create a python instance of this virDomainPtr */
7073 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7077 Py_INCREF(pyobj_cbData
);
7079 /* Call the Callback Dispatcher */
7080 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7081 (char*)"_dispatchDomainEventMetadataChangeCallback",
7083 pyobj_dom
, type
, nsuri
, pyobj_cbData
);
7085 Py_DECREF(pyobj_cbData
);
7086 Py_DECREF(pyobj_dom
);
7090 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7093 Py_DECREF(pyobj_ret
);
7097 LIBVIRT_RELEASE_THREAD_STATE
;
7100 #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */
7102 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
7104 libvirt_virConnectDomainEventBlockThresholdCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7108 unsigned long long threshold
,
7109 unsigned long long excess
,
7112 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7113 PyObject
*pyobj_dom
;
7114 PyObject
*pyobj_ret
= NULL
;
7115 PyObject
*pyobj_conn
;
7119 LIBVIRT_ENSURE_THREAD_STATE
;
7121 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7123 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7126 /* Create a python instance of this virDomainPtr */
7128 if (!(pyobj_dom
= libvirt_virDomainPtrWrap(dom
))) {
7132 Py_INCREF(pyobj_cbData
);
7134 /* Call the Callback Dispatcher */
7135 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7136 (char*)"_dispatchDomainEventBlockThresholdCallback",
7138 pyobj_dom
, dev
, path
, threshold
, excess
,
7141 Py_DECREF(pyobj_cbData
);
7142 Py_DECREF(pyobj_dom
);
7146 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7149 Py_DECREF(pyobj_ret
);
7153 LIBVIRT_RELEASE_THREAD_STATE
;
7156 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */
7160 libvirt_virConnectDomainEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7163 PyObject
*py_retval
; /* return value */
7164 PyObject
*pyobj_conn
; /* virConnectPtr */
7165 PyObject
*pyobj_dom
;
7166 PyObject
*pyobj_cbData
; /* hash of callback data */
7170 virConnectDomainEventGenericCallback cb
= NULL
;
7173 if (!PyArg_ParseTuple(args
,
7174 (char *) "OOiO:virConnectDomainEventRegisterAny",
7175 &pyobj_conn
, &pyobj_dom
, &eventID
, &pyobj_cbData
))
7178 DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
7179 pyobj_conn
, pyobj_dom
, eventID
, pyobj_cbData
);
7180 conn
= PyvirConnect_Get(pyobj_conn
);
7181 if (pyobj_dom
== Py_None
)
7184 dom
= PyvirDomain_Get(pyobj_dom
);
7186 switch ((virDomainEventID
) eventID
) {
7187 case VIR_DOMAIN_EVENT_ID_LIFECYCLE
:
7188 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback
);
7190 case VIR_DOMAIN_EVENT_ID_REBOOT
:
7191 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
7193 case VIR_DOMAIN_EVENT_ID_RTC_CHANGE
:
7194 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback
);
7196 case VIR_DOMAIN_EVENT_ID_WATCHDOG
:
7197 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback
);
7199 case VIR_DOMAIN_EVENT_ID_IO_ERROR
:
7200 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback
);
7202 case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
:
7203 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback
);
7205 case VIR_DOMAIN_EVENT_ID_GRAPHICS
:
7206 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback
);
7208 case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR
:
7209 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback
);
7211 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB
:
7212 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
7213 case VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
:
7214 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 */
7215 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback
);
7217 case VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
7218 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback
);
7220 case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
7221 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback
);
7223 case VIR_DOMAIN_EVENT_ID_PMWAKEUP
:
7224 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback
);
7226 case VIR_DOMAIN_EVENT_ID_PMSUSPEND
:
7227 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback
);
7229 #ifdef VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
7230 case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
:
7231 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback
);
7233 #endif /* VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE */
7234 #ifdef VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
7235 case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
:
7236 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback
);
7238 #endif /* VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK */
7239 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
7240 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
:
7241 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback
);
7243 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED */
7244 #ifdef VIR_DOMAIN_EVENT_ID_TUNABLE
7245 case VIR_DOMAIN_EVENT_ID_TUNABLE
:
7246 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTunableCallback
);
7248 #endif /* VIR_DOMAIN_EVENT_ID_TUNABLE */
7249 #ifdef VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
7250 case VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
:
7251 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventAgentLifecycleCallback
);
7253 #endif /* VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE */
7254 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
7255 case VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
:
7256 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceAddedCallback
);
7258 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_ADDED */
7259 #ifdef VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
7260 case VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION
:
7261 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMigrationIterationCallback
);
7263 #endif /* VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION */
7264 #ifdef VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
7265 case VIR_DOMAIN_EVENT_ID_JOB_COMPLETED
:
7266 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventJobCompletedCallback
);
7268 #endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
7269 #ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
7270 case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
:
7271 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovalFailedCallback
);
7273 #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
7274 #ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
7275 case VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
:
7276 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMetadataChangeCallback
);
7278 #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */
7279 #ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
7280 case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
:
7281 cb
= VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockThresholdCallback
);
7283 #endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */
7284 case VIR_DOMAIN_EVENT_ID_LAST
:
7289 return VIR_PY_INT_FAIL
;
7292 Py_INCREF(pyobj_cbData
);
7294 LIBVIRT_BEGIN_ALLOW_THREADS
;
7295 ret
= virConnectDomainEventRegisterAny(conn
, dom
, eventID
,
7297 libvirt_virConnectDomainEventFreeFunc
);
7298 LIBVIRT_END_ALLOW_THREADS
;
7301 Py_DECREF(pyobj_cbData
);
7304 py_retval
= libvirt_intWrap(ret
);
7309 libvirt_virConnectDomainEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7312 PyObject
*pyobj_conn
;
7317 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectDomainEventDeregister",
7318 &pyobj_conn
, &callbackID
))
7321 DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn
);
7323 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7325 LIBVIRT_BEGIN_ALLOW_THREADS
;
7326 ret
= virConnectDomainEventDeregisterAny(conn
, callbackID
);
7327 LIBVIRT_END_ALLOW_THREADS
;
7329 return libvirt_intWrap(ret
);
7332 #if LIBVIR_CHECK_VERSION(1, 2, 1)
7334 libvirt_virConnectNetworkEventFreeFunc(void *opaque
)
7336 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
7337 LIBVIRT_ENSURE_THREAD_STATE
;
7338 Py_DECREF(pyobj_conn
);
7339 LIBVIRT_RELEASE_THREAD_STATE
;
7343 libvirt_virConnectNetworkEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
7349 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7350 PyObject
*pyobj_net
;
7351 PyObject
*pyobj_ret
= NULL
;
7352 PyObject
*pyobj_conn
;
7356 LIBVIRT_ENSURE_THREAD_STATE
;
7358 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
7360 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7363 /* Create a python instance of this virNetworkPtr */
7365 if (!(pyobj_net
= libvirt_virNetworkPtrWrap(net
))) {
7366 virNetworkFree(net
);
7369 Py_INCREF(pyobj_cbData
);
7371 /* Call the Callback Dispatcher */
7372 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7373 (char*)"_dispatchNetworkEventLifecycleCallback",
7380 Py_DECREF(pyobj_cbData
);
7381 Py_DECREF(pyobj_net
);
7385 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7388 Py_DECREF(pyobj_ret
);
7392 LIBVIRT_RELEASE_THREAD_STATE
;
7397 libvirt_virConnectNetworkEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7400 PyObject
*pyobj_conn
; /* virConnectPtr */
7401 PyObject
*pyobj_net
;
7402 PyObject
*pyobj_cbData
; /* hash of callback data */
7406 virConnectNetworkEventGenericCallback cb
= NULL
;
7409 if (!PyArg_ParseTuple(args
,
7410 (char *) "OOiO:virConnectNetworkEventRegisterAny",
7411 &pyobj_conn
, &pyobj_net
, &eventID
, &pyobj_cbData
))
7414 DEBUG("libvirt_virConnectNetworkEventRegister(%p %p %d %p) called\n",
7415 pyobj_conn
, pyobj_net
, eventID
, pyobj_cbData
);
7416 conn
= PyvirConnect_Get(pyobj_conn
);
7417 if (pyobj_net
== Py_None
)
7420 net
= PyvirNetwork_Get(pyobj_net
);
7422 switch ((virNetworkEventID
) eventID
) {
7423 case VIR_NETWORK_EVENT_ID_LIFECYCLE
:
7424 cb
= VIR_NETWORK_EVENT_CALLBACK(libvirt_virConnectNetworkEventLifecycleCallback
);
7427 case VIR_NETWORK_EVENT_ID_LAST
:
7432 return VIR_PY_INT_FAIL
;
7435 Py_INCREF(pyobj_cbData
);
7437 LIBVIRT_BEGIN_ALLOW_THREADS
;
7438 ret
= virConnectNetworkEventRegisterAny(conn
, net
, eventID
,
7440 libvirt_virConnectNetworkEventFreeFunc
);
7441 LIBVIRT_END_ALLOW_THREADS
;
7444 Py_DECREF(pyobj_cbData
);
7447 return libvirt_intWrap(ret
);
7451 libvirt_virConnectNetworkEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
7454 PyObject
*pyobj_conn
;
7459 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNetworkEventDeregister",
7460 &pyobj_conn
, &callbackID
))
7463 DEBUG("libvirt_virConnectNetworkEventDeregister(%p) called\n", pyobj_conn
);
7465 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
7467 LIBVIRT_BEGIN_ALLOW_THREADS
;
7468 ret
= virConnectNetworkEventDeregisterAny(conn
, callbackID
);
7469 LIBVIRT_END_ALLOW_THREADS
;
7471 return libvirt_intWrap(ret
);
7473 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1)*/
7475 #if LIBVIR_CHECK_VERSION(0, 10, 0)
7477 libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED
,
7481 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7482 PyObject
*pyobj_ret
;
7483 PyObject
*pyobj_conn
;
7486 LIBVIRT_ENSURE_THREAD_STATE
;
7488 Py_INCREF(pyobj_cbData
);
7490 dictKey
= libvirt_constcharPtrWrap("conn");
7491 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7494 /* Call the Callback Dispatcher */
7495 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
7496 (char*)"_dispatchCloseCallback",
7501 Py_DECREF(pyobj_cbData
);
7504 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7507 Py_DECREF(pyobj_ret
);
7510 LIBVIRT_RELEASE_THREAD_STATE
;
7514 libvirt_virConnectRegisterCloseCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7517 PyObject
*pyobj_conn
; /* virConnectPtr */
7518 PyObject
*pyobj_cbData
; /* hash of callback data */
7522 if (!PyArg_ParseTuple(args
, (char *) "OO:virConnectRegisterCloseCallback",
7523 &pyobj_conn
, &pyobj_cbData
))
7526 DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
7527 pyobj_conn
, pyobj_cbData
);
7528 conn
= PyvirConnect_Get(pyobj_conn
);
7530 Py_INCREF(pyobj_cbData
);
7532 LIBVIRT_BEGIN_ALLOW_THREADS
;
7533 ret
= virConnectRegisterCloseCallback(conn
,
7534 libvirt_virConnectCloseCallbackDispatch
,
7536 libvirt_virConnectDomainEventFreeFunc
);
7537 LIBVIRT_END_ALLOW_THREADS
;
7540 Py_DECREF(pyobj_cbData
);
7543 return libvirt_intWrap(ret
);
7547 libvirt_virConnectUnregisterCloseCallback(PyObject
* self ATTRIBUTE_UNUSED
,
7550 PyObject
*pyobj_conn
;
7554 if (!PyArg_ParseTuple(args
, (char *) "O:virConnectUnregisterCloseCallback",
7558 DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
7561 conn
= PyvirConnect_Get(pyobj_conn
);
7563 LIBVIRT_BEGIN_ALLOW_THREADS
;
7564 ret
= virConnectUnregisterCloseCallback(conn
,
7565 libvirt_virConnectCloseCallbackDispatch
);
7566 LIBVIRT_END_ALLOW_THREADS
;
7568 return libvirt_intWrap(ret
);
7570 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
7573 libvirt_virStreamEventFreeFunc(void *opaque
)
7575 PyObject
*pyobj_stream
= (PyObject
*)opaque
;
7576 LIBVIRT_ENSURE_THREAD_STATE
;
7577 Py_DECREF(pyobj_stream
);
7578 LIBVIRT_RELEASE_THREAD_STATE
;
7582 libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED
,
7586 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
7587 PyObject
*pyobj_stream
;
7588 PyObject
*pyobj_ret
;
7591 LIBVIRT_ENSURE_THREAD_STATE
;
7593 Py_INCREF(pyobj_cbData
);
7594 dictKey
= libvirt_constcharPtrWrap("stream");
7595 pyobj_stream
= PyDict_GetItem(pyobj_cbData
, dictKey
);
7598 /* Call the pure python dispatcher */
7599 pyobj_ret
= PyObject_CallMethod(pyobj_stream
,
7600 (char *)"_dispatchStreamEventCallback",
7602 events
, pyobj_cbData
);
7604 Py_DECREF(pyobj_cbData
);
7607 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
7610 Py_DECREF(pyobj_ret
);
7613 LIBVIRT_RELEASE_THREAD_STATE
;
7617 libvirt_virStreamEventAddCallback(PyObject
*self ATTRIBUTE_UNUSED
,
7620 PyObject
*pyobj_stream
;
7621 PyObject
*pyobj_cbData
;
7622 virStreamPtr stream
;
7623 virStreamEventCallback cb
= libvirt_virStreamEventCallback
;
7627 if (!PyArg_ParseTuple(args
, (char *) "OiO:virStreamEventAddCallback",
7628 &pyobj_stream
, &events
, &pyobj_cbData
))
7631 DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
7632 pyobj_stream
, events
, pyobj_cbData
);
7633 stream
= PyvirStream_Get(pyobj_stream
);
7635 Py_INCREF(pyobj_cbData
);
7637 LIBVIRT_BEGIN_ALLOW_THREADS
;
7638 ret
= virStreamEventAddCallback(stream
, events
, cb
, pyobj_cbData
,
7639 libvirt_virStreamEventFreeFunc
);
7640 LIBVIRT_END_ALLOW_THREADS
;
7643 Py_DECREF(pyobj_cbData
);
7646 return libvirt_intWrap(ret
);
7650 libvirt_virStreamRecv(PyObject
*self ATTRIBUTE_UNUSED
,
7653 PyObject
*pyobj_stream
;
7655 virStreamPtr stream
;
7660 if (!PyArg_ParseTuple(args
, (char *) "Oi:virStreamRecv",
7661 &pyobj_stream
, &nbytes
)) {
7664 stream
= PyvirStream_Get(pyobj_stream
);
7666 if (VIR_ALLOC_N(buf
, nbytes
+1 > 0 ? nbytes
+1 : 1) < 0)
7667 return PyErr_NoMemory();
7669 LIBVIRT_BEGIN_ALLOW_THREADS
;
7670 ret
= virStreamRecv(stream
, buf
, nbytes
);
7671 LIBVIRT_END_ALLOW_THREADS
;
7673 buf
[ret
> -1 ? ret
: 0] = '\0';
7674 DEBUG("StreamRecv ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
7677 return libvirt_intWrap(ret
);
7680 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
7686 libvirt_virStreamSend(PyObject
*self ATTRIBUTE_UNUSED
,
7689 PyObject
*pyobj_stream
;
7690 PyObject
*pyobj_data
;
7691 virStreamPtr stream
;
7696 if (!PyArg_ParseTuple(args
, (char *) "OO:virStreamSend",
7697 &pyobj_stream
, &pyobj_data
))
7700 stream
= PyvirStream_Get(pyobj_stream
);
7701 libvirt_charPtrSizeUnwrap(pyobj_data
, &data
, &datalen
);
7703 LIBVIRT_BEGIN_ALLOW_THREADS
;
7704 ret
= virStreamSend(stream
, data
, datalen
);
7705 LIBVIRT_END_ALLOW_THREADS
;
7707 DEBUG("StreamSend ret=%d\n", ret
);
7709 return libvirt_intWrap(ret
);
7713 libvirt_virDomainSendKey(PyObject
*self ATTRIBUTE_UNUSED
,
7716 virDomainPtr domain
;
7717 PyObject
*pyobj_domain
;
7718 PyObject
*pyobj_list
;
7724 unsigned int keycodes
[VIR_DOMAIN_SEND_KEY_MAX_KEYS
];
7725 unsigned int nkeycodes
;
7727 if (!PyArg_ParseTuple(args
, (char *)"OiiOII:virDomainSendKey",
7728 &pyobj_domain
, &codeset
, &holdtime
, &pyobj_list
,
7729 &nkeycodes
, &flags
))
7732 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7734 if (!PyList_Check(pyobj_list
)) {
7735 return VIR_PY_INT_FAIL
;
7738 if (nkeycodes
!= PyList_Size(pyobj_list
) ||
7739 nkeycodes
> VIR_DOMAIN_SEND_KEY_MAX_KEYS
) {
7740 return VIR_PY_INT_FAIL
;
7743 for (i
= 0; i
< nkeycodes
; i
++) {
7744 if (libvirt_uintUnwrap(PyList_GetItem(pyobj_list
, i
), &keycodes
[i
]) < 0)
7748 LIBVIRT_BEGIN_ALLOW_THREADS
;
7749 ret
= virDomainSendKey(domain
, codeset
, holdtime
, keycodes
, nkeycodes
, flags
);
7750 LIBVIRT_END_ALLOW_THREADS
;
7752 DEBUG("virDomainSendKey ret=%d\n", ret
);
7754 return libvirt_intWrap(ret
);
7757 #if LIBVIR_CHECK_VERSION(1, 0, 3)
7759 libvirt_virDomainMigrateGetCompressionCache(PyObject
*self ATTRIBUTE_UNUSED
,
7762 PyObject
*pyobj_domain
;
7763 virDomainPtr domain
;
7765 unsigned long long cacheSize
;
7768 if (!PyArg_ParseTuple(args
,
7769 (char *) "OI:virDomainMigrateGetCompressionCache",
7770 &pyobj_domain
, &flags
))
7773 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7775 LIBVIRT_BEGIN_ALLOW_THREADS
;
7776 rc
= virDomainMigrateGetCompressionCache(domain
, &cacheSize
, flags
);
7777 LIBVIRT_END_ALLOW_THREADS
;
7782 return libvirt_ulonglongWrap(cacheSize
);
7784 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
7787 libvirt_virDomainMigrateGetMaxSpeed(PyObject
*self ATTRIBUTE_UNUSED
,
7791 unsigned long bandwidth
;
7792 virDomainPtr domain
;
7793 PyObject
*pyobj_domain
;
7794 unsigned int flags
= 0;
7796 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainMigrateGetMaxSpeed",
7797 &pyobj_domain
, &flags
))
7800 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7802 LIBVIRT_BEGIN_ALLOW_THREADS
;
7803 c_retval
= virDomainMigrateGetMaxSpeed(domain
, &bandwidth
, flags
);
7804 LIBVIRT_END_ALLOW_THREADS
;
7807 return VIR_PY_INT_FAIL
;
7809 return libvirt_ulongWrap(bandwidth
);
7812 #if LIBVIR_CHECK_VERSION(3, 7, 0)
7814 libvirt_virDomainMigrateGetMaxDowntime(PyObject
*self ATTRIBUTE_UNUSED
,
7817 PyObject
*pyobj_domain
;
7818 virDomainPtr domain
;
7820 unsigned long long downtime
;
7823 if (!PyArg_ParseTuple(args
,
7824 (char *) "OI:virDomainMigrateGetMaxDowntime",
7825 &pyobj_domain
, &flags
))
7828 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7830 LIBVIRT_BEGIN_ALLOW_THREADS
;
7831 rc
= virDomainMigrateGetMaxDowntime(domain
, &downtime
, flags
);
7832 LIBVIRT_END_ALLOW_THREADS
;
7837 return libvirt_ulonglongWrap(downtime
);
7839 #endif /* LIBVIR_CHECK_VERSION(3, 7, 0) */
7841 #if LIBVIR_CHECK_VERSION(1, 1, 0)
7842 static virPyTypedParamsHint virPyDomainMigrate3Params
[] = {
7843 # ifdef VIR_MIGRATE_PARAM_URI
7844 { VIR_MIGRATE_PARAM_URI
, VIR_TYPED_PARAM_STRING
},
7846 # ifdef VIR_MIGRATE_PARAM_DEST_NAME
7847 { VIR_MIGRATE_PARAM_DEST_NAME
, VIR_TYPED_PARAM_STRING
},
7849 # ifdef VIR_MIGRATE_PARAM_DEST_XML
7850 { VIR_MIGRATE_PARAM_DEST_XML
, VIR_TYPED_PARAM_STRING
},
7852 # ifdef VIR_MIGRATE_PARAM_PERSIST_XML
7853 { VIR_MIGRATE_PARAM_PERSIST_XML
, VIR_TYPED_PARAM_STRING
},
7855 # ifdef VIR_MIGRATE_PARAM_BANDWIDTH
7856 { VIR_MIGRATE_PARAM_BANDWIDTH
, VIR_TYPED_PARAM_ULLONG
},
7858 # ifdef VIR_MIGRATE_PARAM_GRAPHICS_URI
7859 { VIR_MIGRATE_PARAM_GRAPHICS_URI
, VIR_TYPED_PARAM_STRING
},
7861 # ifdef VIR_MIGRATE_PARAM_LISTEN_ADDRESS
7862 { VIR_MIGRATE_PARAM_LISTEN_ADDRESS
, VIR_TYPED_PARAM_STRING
},
7864 # ifdef VIR_MIGRATE_PARAM_MIGRATE_DISKS
7865 { VIR_MIGRATE_PARAM_MIGRATE_DISKS
, VIR_TYPED_PARAM_STRING
},
7867 # ifdef VIR_MIGRATE_PARAM_DISKS_PORT
7868 { VIR_MIGRATE_PARAM_DISKS_PORT
, VIR_TYPED_PARAM_INT
},
7870 # ifdef VIR_MIGRATE_PARAM_COMPRESSION
7871 { VIR_MIGRATE_PARAM_COMPRESSION
, VIR_TYPED_PARAM_STRING
},
7873 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL
7874 { VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL
, VIR_TYPED_PARAM_INT
},
7876 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS
7877 { VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS
, VIR_TYPED_PARAM_INT
},
7879 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS
7880 { VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS
, VIR_TYPED_PARAM_INT
},
7882 # ifdef VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE
7883 { VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE
, VIR_TYPED_PARAM_ULLONG
},
7885 # ifdef VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL
7886 { VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL
, VIR_TYPED_PARAM_INT
},
7888 # ifdef VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT
7889 { VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT
, VIR_TYPED_PARAM_INT
},
7895 libvirt_virDomainMigrate3(PyObject
*self ATTRIBUTE_UNUSED
,
7898 PyObject
*pyobj_domain
;
7899 virDomainPtr domain
;
7900 PyObject
*pyobj_dconn
;
7901 virConnectPtr dconn
;
7904 virTypedParameterPtr params
;
7906 virDomainPtr ddom
= NULL
;
7908 if (!PyArg_ParseTuple(args
, (char *) "OOOI:virDomainMigrate3",
7909 &pyobj_domain
, &pyobj_dconn
, &dict
, &flags
))
7912 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7913 dconn
= (virConnectPtr
) PyvirConnect_Get(pyobj_dconn
);
7915 if (!PyDict_Check(dict
)) {
7916 PyErr_Format(PyExc_TypeError
, "migration params must be a dictionary");
7920 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
,
7921 virPyDomainMigrate3Params
,
7922 VIR_N_ELEMENTS(virPyDomainMigrate3Params
)) < 0) {
7926 LIBVIRT_BEGIN_ALLOW_THREADS
;
7927 ddom
= virDomainMigrate3(domain
, dconn
, params
, nparams
, flags
);
7928 LIBVIRT_END_ALLOW_THREADS
;
7930 virTypedParamsFree(params
, nparams
);
7931 return libvirt_virDomainPtrWrap(ddom
);
7935 libvirt_virDomainMigrateToURI3(PyObject
*self ATTRIBUTE_UNUSED
,
7938 PyObject
*pyobj_domain
;
7939 virDomainPtr domain
;
7943 virTypedParameterPtr params
;
7947 if (!PyArg_ParseTuple(args
, (char *) "OzOI:virDomainMigrate3",
7948 &pyobj_domain
, &dconnuri
, &dict
, &flags
))
7951 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7953 if (!PyDict_Check(dict
)) {
7954 PyErr_Format(PyExc_TypeError
, "migration params must be a dictionary");
7958 if (virPyDictToTypedParams(dict
, ¶ms
, &nparams
,
7959 virPyDomainMigrate3Params
,
7960 VIR_N_ELEMENTS(virPyDomainMigrate3Params
)) < 0) {
7964 LIBVIRT_BEGIN_ALLOW_THREADS
;
7965 ret
= virDomainMigrateToURI3(domain
, dconnuri
, params
, nparams
, flags
);
7966 LIBVIRT_END_ALLOW_THREADS
;
7968 virTypedParamsFree(params
, nparams
);
7969 return libvirt_intWrap(ret
);
7971 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
7974 libvirt_virDomainBlockPeek(PyObject
*self ATTRIBUTE_UNUSED
,
7977 PyObject
*py_retval
= NULL
;
7979 virDomainPtr domain
;
7980 PyObject
*pyobj_domain
;
7982 unsigned long long offset
;
7987 if (!PyArg_ParseTuple(args
, (char *)"OzKkI:virDomainBlockPeek",
7988 &pyobj_domain
, &disk
, &offset
, &size
, &flags
))
7991 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
7993 if (VIR_ALLOC_N(buf
, size
) < 0)
7994 return PyErr_NoMemory();
7996 LIBVIRT_BEGIN_ALLOW_THREADS
;
7997 c_retval
= virDomainBlockPeek(domain
, disk
, offset
, size
, buf
, flags
);
7998 LIBVIRT_END_ALLOW_THREADS
;
8001 py_retval
= VIR_PY_NONE
;
8005 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
8013 libvirt_virDomainMemoryPeek(PyObject
*self ATTRIBUTE_UNUSED
,
8016 PyObject
*py_retval
= NULL
;
8018 virDomainPtr domain
;
8019 PyObject
*pyobj_domain
;
8020 unsigned long long start
;
8025 if (!PyArg_ParseTuple(args
, (char *)"OKkI:virDomainMemoryPeek",
8026 &pyobj_domain
, &start
, &size
, &flags
))
8029 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8031 if (VIR_ALLOC_N(buf
, size
) < 0)
8032 return PyErr_NoMemory();
8034 LIBVIRT_BEGIN_ALLOW_THREADS
;
8035 c_retval
= virDomainMemoryPeek(domain
, start
, size
, buf
, flags
);
8036 LIBVIRT_END_ALLOW_THREADS
;
8039 py_retval
= VIR_PY_NONE
;
8043 py_retval
= libvirt_charPtrSizeWrap(buf
, size
);
8050 #if LIBVIR_CHECK_VERSION(0, 10, 2)
8052 libvirt_virNodeSetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
8056 PyObject
*pyobj_conn
, *info
;
8057 PyObject
*ret
= NULL
;
8060 Py_ssize_t size
= 0;
8062 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
8064 if (!PyArg_ParseTuple(args
,
8065 (char *)"OOI:virNodeSetMemoryParameters",
8066 &pyobj_conn
, &info
, &flags
))
8068 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8070 if ((size
= PyDict_Size(info
)) < 0)
8074 PyErr_Format(PyExc_LookupError
,
8075 "Need non-empty dictionary to set attributes");
8079 LIBVIRT_BEGIN_ALLOW_THREADS
;
8080 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
8081 LIBVIRT_END_ALLOW_THREADS
;
8084 return VIR_PY_INT_FAIL
;
8087 PyErr_Format(PyExc_LookupError
,
8088 "no settable attributes");
8092 if (VIR_ALLOC_N(params
, nparams
) < 0)
8093 return PyErr_NoMemory();
8095 LIBVIRT_BEGIN_ALLOW_THREADS
;
8096 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
8097 LIBVIRT_END_ALLOW_THREADS
;
8100 ret
= VIR_PY_INT_FAIL
;
8104 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
8108 LIBVIRT_BEGIN_ALLOW_THREADS
;
8109 i_retval
= virNodeSetMemoryParameters(conn
, new_params
, size
, flags
);
8110 LIBVIRT_END_ALLOW_THREADS
;
8113 ret
= VIR_PY_INT_FAIL
;
8117 ret
= VIR_PY_INT_SUCCESS
;
8120 virTypedParamsFree(params
, nparams
);
8121 virTypedParamsFree(new_params
, size
);
8126 libvirt_virNodeGetMemoryParameters(PyObject
*self ATTRIBUTE_UNUSED
,
8130 PyObject
*pyobj_conn
;
8131 PyObject
*ret
= NULL
;
8135 virTypedParameterPtr params
;
8137 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetMemoryParameters",
8138 &pyobj_conn
, &flags
))
8140 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8142 LIBVIRT_BEGIN_ALLOW_THREADS
;
8143 i_retval
= virNodeGetMemoryParameters(conn
, NULL
, &nparams
, flags
);
8144 LIBVIRT_END_ALLOW_THREADS
;
8150 return PyDict_New();
8152 if (VIR_ALLOC_N(params
, nparams
) < 0)
8153 return PyErr_NoMemory();
8155 LIBVIRT_BEGIN_ALLOW_THREADS
;
8156 i_retval
= virNodeGetMemoryParameters(conn
, params
, &nparams
, flags
);
8157 LIBVIRT_END_ALLOW_THREADS
;
8164 ret
= getPyVirTypedParameter(params
, nparams
);
8167 virTypedParamsFree(params
, nparams
);
8170 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
8172 #if LIBVIR_CHECK_VERSION(1, 0, 0)
8174 libvirt_virNodeGetCPUMap(PyObject
*self ATTRIBUTE_UNUSED
,
8178 PyObject
*pyobj_conn
;
8179 PyObject
*ret
= NULL
;
8180 PyObject
*pycpumap
= NULL
;
8182 unsigned char *cpumap
= NULL
;
8183 unsigned int online
= 0;
8187 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetCPUMap",
8188 &pyobj_conn
, &flags
))
8190 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8192 LIBVIRT_BEGIN_ALLOW_THREADS
;
8193 i_retval
= virNodeGetCPUMap(conn
, &cpumap
, &online
, flags
);
8194 LIBVIRT_END_ALLOW_THREADS
;
8199 if ((ret
= PyTuple_New(3)) == NULL
)
8202 /* 0: number of CPUs */
8203 VIR_PY_TUPLE_SET_GOTO(ret
, 0, libvirt_intWrap(i_retval
), error
);
8206 if ((pycpumap
= PyList_New(i_retval
)) == NULL
)
8209 VIR_PY_TUPLE_SET_GOTO(ret
, 1, pycpumap
, error
);
8211 for (i
= 0; i
< i_retval
; i
++)
8212 VIR_PY_LIST_SET_GOTO(pycpumap
, i
,
8213 PyBool_FromLong(VIR_CPU_USED(cpumap
, i
)), error
);
8215 /* 2: number of online CPUs */
8216 VIR_PY_TUPLE_SET_GOTO(ret
, 2, libvirt_uintWrap(online
), error
);
8226 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
8229 #if LIBVIR_CHECK_VERSION(1, 1, 1)
8231 libvirt_virDomainCreateWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
8234 PyObject
*py_retval
= NULL
;
8236 virDomainPtr domain
;
8237 PyObject
*pyobj_domain
;
8238 PyObject
*pyobj_files
;
8240 unsigned int nfiles
;
8244 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainCreateWithFiles",
8245 &pyobj_domain
, &pyobj_files
, &flags
))
8247 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8249 nfiles
= PyList_Size(pyobj_files
);
8251 if (VIR_ALLOC_N(files
, nfiles
) < 0)
8252 return PyErr_NoMemory();
8254 for (i
= 0; i
< nfiles
; i
++) {
8258 pyfd
= PyList_GetItem(pyobj_files
, i
);
8260 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
8266 LIBVIRT_BEGIN_ALLOW_THREADS
;
8267 c_retval
= virDomainCreateWithFiles(domain
, nfiles
, files
, flags
);
8268 LIBVIRT_END_ALLOW_THREADS
;
8270 py_retval
= libvirt_intWrap((int) c_retval
);
8279 libvirt_virDomainCreateXMLWithFiles(PyObject
*self ATTRIBUTE_UNUSED
,
8282 PyObject
*py_retval
= NULL
;
8283 virDomainPtr c_retval
;
8285 PyObject
*pyobj_conn
;
8287 PyObject
*pyobj_files
;
8289 unsigned int nfiles
;
8293 if (!PyArg_ParseTuple(args
, (char *)"OzOI:virDomainCreateXMLWithFiles",
8294 &pyobj_conn
, &xmlDesc
, &pyobj_files
, &flags
))
8296 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8298 nfiles
= PyList_Size(pyobj_files
);
8300 if (VIR_ALLOC_N(files
, nfiles
) < 0)
8301 return PyErr_NoMemory();
8303 for (i
= 0; i
< nfiles
; i
++) {
8307 pyfd
= PyList_GetItem(pyobj_files
, i
);
8309 if (libvirt_intUnwrap(pyfd
, &fd
) < 0)
8315 LIBVIRT_BEGIN_ALLOW_THREADS
;
8316 c_retval
= virDomainCreateXMLWithFiles(conn
, xmlDesc
, nfiles
, files
, flags
);
8317 LIBVIRT_END_ALLOW_THREADS
;
8319 py_retval
= libvirt_virDomainPtrWrap((virDomainPtr
) c_retval
);
8325 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
8328 #if LIBVIR_CHECK_VERSION(1, 2, 5)
8330 libvirt_virDomainFSFreeze(PyObject
*self ATTRIBUTE_UNUSED
,
8333 PyObject
*py_retval
= NULL
;
8335 virDomainPtr domain
;
8336 PyObject
*pyobj_domain
;
8337 PyObject
*pyobj_list
;
8339 unsigned int nmountpoints
= 0;
8340 char **mountpoints
= NULL
;
8343 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSFreeze",
8344 &pyobj_domain
, &pyobj_list
, &flags
))
8346 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8348 if (PyList_Check(pyobj_list
)) {
8349 nmountpoints
= PyList_Size(pyobj_list
);
8351 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8352 return PyErr_NoMemory();
8354 for (i
= 0; i
< nmountpoints
; i
++) {
8355 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8361 LIBVIRT_BEGIN_ALLOW_THREADS
;
8362 c_retval
= virDomainFSFreeze(domain
, (const char **) mountpoints
,
8363 nmountpoints
, flags
);
8364 LIBVIRT_END_ALLOW_THREADS
;
8366 py_retval
= libvirt_intWrap(c_retval
);
8369 for (j
= 0 ; j
< i
; j
++)
8370 VIR_FREE(mountpoints
[j
]);
8371 VIR_FREE(mountpoints
);
8377 libvirt_virDomainFSThaw(PyObject
*self ATTRIBUTE_UNUSED
,
8380 PyObject
*py_retval
= NULL
;
8382 virDomainPtr domain
;
8383 PyObject
*pyobj_domain
;
8384 PyObject
*pyobj_list
;
8386 unsigned int nmountpoints
= 0;
8387 char **mountpoints
= NULL
;
8390 if (!PyArg_ParseTuple(args
, (char *)"OOI:virDomainFSThaw",
8391 &pyobj_domain
, &pyobj_list
, &flags
))
8393 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8395 if (PyList_Check(pyobj_list
)) {
8396 nmountpoints
= PyList_Size(pyobj_list
);
8398 if (VIR_ALLOC_N(mountpoints
, nmountpoints
) < 0)
8399 return PyErr_NoMemory();
8401 for (i
= 0; i
< nmountpoints
; i
++) {
8402 if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list
, i
),
8408 LIBVIRT_BEGIN_ALLOW_THREADS
;
8409 c_retval
= virDomainFSThaw(domain
, (const char **) mountpoints
,
8410 nmountpoints
, flags
);
8411 LIBVIRT_END_ALLOW_THREADS
;
8413 py_retval
= libvirt_intWrap(c_retval
);
8416 for (j
= 0 ; j
< i
; j
++)
8417 VIR_FREE(mountpoints
[j
]);
8418 VIR_FREE(mountpoints
);
8423 libvirt_virDomainGetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8426 PyObject
*py_retval
= NULL
;
8427 PyObject
*dict
= NULL
;
8428 PyObject
*pyobj_domain
;
8429 virDomainPtr domain
;
8431 unsigned int nseconds
;
8435 if (!PyArg_ParseTuple(args
, (char*)"OI:virDomainGetTime",
8436 &pyobj_domain
, &flags
))
8438 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8440 if (!(dict
= PyDict_New()))
8443 LIBVIRT_BEGIN_ALLOW_THREADS
;
8444 c_retval
= virDomainGetTime(domain
, &seconds
, &nseconds
, flags
);
8445 LIBVIRT_END_ALLOW_THREADS
;
8448 py_retval
= VIR_PY_NONE
;
8452 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("seconds"),
8453 libvirt_longlongWrap(seconds
), cleanup
);
8454 VIR_PY_DICT_SET_GOTO(dict
, libvirt_constcharPtrWrap("nseconds"),
8455 libvirt_longlongWrap(nseconds
), cleanup
);
8466 libvirt_virDomainSetTime(PyObject
*self ATTRIBUTE_UNUSED
,
8469 PyObject
*pyobj_domain
;
8470 PyObject
*pyobj_seconds
;
8471 PyObject
*pyobj_nseconds
;
8473 virDomainPtr domain
;
8474 long long seconds
= 0;
8475 unsigned int nseconds
= 0;
8477 ssize_t py_dict_size
= 0;
8480 if (!PyArg_ParseTuple(args
, (char*)"OOI:virDomainSetTime",
8481 &pyobj_domain
, &py_dict
, &flags
))
8483 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8485 if (PyDict_Check(py_dict
)) {
8486 py_dict_size
= PyDict_Size(py_dict
);
8487 if ((pyobj_seconds
= PyDict_GetItemString(py_dict
, "seconds"))) {
8488 if (libvirt_longlongUnwrap(pyobj_seconds
, &seconds
) < 0)
8491 PyErr_Format(PyExc_LookupError
, "Dictionary must contains 'seconds'");
8495 if ((pyobj_nseconds
= PyDict_GetItemString(py_dict
, "nseconds"))) {
8496 if (libvirt_uintUnwrap(pyobj_nseconds
, &nseconds
) < 0)
8498 } else if (py_dict_size
> 1) {
8499 PyErr_Format(PyExc_LookupError
, "Dictionary contains unknown key");
8502 } else if (py_dict
!= Py_None
|| !flags
) {
8503 PyErr_Format(PyExc_TypeError
, "time must be a dictionary "
8504 "or None with flags set");
8508 LIBVIRT_BEGIN_ALLOW_THREADS
;
8509 c_retval
= virDomainSetTime(domain
, seconds
, nseconds
, flags
);
8510 LIBVIRT_END_ALLOW_THREADS
;
8512 return libvirt_intWrap(c_retval
);
8514 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
8517 #if LIBVIR_CHECK_VERSION(1, 2, 6)
8519 libvirt_virNodeGetFreePages(PyObject
*self ATTRIBUTE_UNUSED
,
8522 PyObject
*py_retval
= NULL
;
8523 PyObject
*pyobj_conn
;
8524 PyObject
*pyobj_pagesize
;
8525 PyObject
*pyobj_counts
= NULL
;
8527 unsigned int *pages
= NULL
;
8529 unsigned int cellCount
;
8531 unsigned long long *counts
= NULL
;
8533 ssize_t pyobj_pagesize_size
, i
, j
;
8535 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeGetFreePages",
8536 &pyobj_conn
, &pyobj_pagesize
, &startCell
,
8537 &cellCount
, &flags
))
8540 if (!PyList_Check(pyobj_pagesize
)) {
8541 PyErr_Format(PyExc_TypeError
, "pagesize must be list");
8545 if (cellCount
== 0) {
8546 PyErr_Format(PyExc_LookupError
, "cellCount must not be zero");
8550 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8552 pyobj_pagesize_size
= PyList_Size(pyobj_pagesize
);
8553 if (VIR_ALLOC_N(pages
, pyobj_pagesize_size
) < 0 ||
8554 VIR_ALLOC_N(counts
, pyobj_pagesize_size
* cellCount
) < 0) {
8559 if (!(pyobj_counts
= PyDict_New()))
8562 for (i
= 0; i
< pyobj_pagesize_size
; i
++) {
8563 PyObject
*tmp
= PyList_GetItem(pyobj_pagesize
, i
);
8565 if (libvirt_uintUnwrap(tmp
, &pages
[i
]) < 0)
8569 LIBVIRT_BEGIN_ALLOW_THREADS
;
8570 c_retval
= virNodeGetFreePages(conn
,
8571 pyobj_pagesize_size
, pages
,
8572 startCell
, cellCount
,
8574 LIBVIRT_END_ALLOW_THREADS
;
8577 py_retval
= VIR_PY_NONE
;
8581 for (i
= 0; i
< c_retval
;) {
8582 PyObject
*per_node
= NULL
;
8584 if (!(per_node
= PyDict_New()))
8587 VIR_PY_DICT_SET_GOTO(pyobj_counts
,
8588 libvirt_intWrap(startCell
+ i
/pyobj_pagesize_size
),
8591 for (j
= 0; j
< pyobj_pagesize_size
; j
++)
8592 VIR_PY_DICT_SET_GOTO(per_node
, libvirt_intWrap(pages
[j
]),
8593 libvirt_intWrap(counts
[i
+ j
]), cleanup
);
8595 i
+= pyobj_pagesize_size
;
8598 py_retval
= pyobj_counts
;
8599 pyobj_counts
= NULL
;
8601 Py_XDECREF(pyobj_counts
);
8609 libvirt_virNetworkGetDHCPLeases(PyObject
*self ATTRIBUTE_UNUSED
,
8612 PyObject
*py_retval
= NULL
;
8613 PyObject
*py_lease
= NULL
;
8614 virNetworkPtr network
;
8615 PyObject
*pyobj_network
;
8617 virNetworkDHCPLeasePtr
*leases
= NULL
;
8622 if (!PyArg_ParseTuple(args
, (char *) "OzI:virNetworkGetDHCPLeases",
8623 &pyobj_network
, &mac
, &flags
))
8626 network
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_network
);
8628 LIBVIRT_BEGIN_ALLOW_THREADS
;
8629 leases_count
= virNetworkGetDHCPLeases(network
, mac
, &leases
, flags
);
8630 LIBVIRT_END_ALLOW_THREADS
;
8632 if (leases_count
< 0) {
8633 py_retval
= VIR_PY_NONE
;
8637 if (!(py_retval
= PyList_New(leases_count
)))
8640 for (i
= 0; i
< leases_count
; i
++) {
8641 virNetworkDHCPLeasePtr lease
= leases
[i
];
8643 if ((py_lease
= PyDict_New()) == NULL
)
8646 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_lease
, error
);
8648 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iface"),
8649 libvirt_charPtrWrap(lease
->iface
), error
);
8650 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("expirytime"),
8651 libvirt_longlongWrap(lease
->expirytime
), error
);
8652 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("type"),
8653 libvirt_intWrap(lease
->type
), error
);
8654 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("mac"),
8655 libvirt_charPtrWrap(lease
->mac
), error
);
8656 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("ipaddr"),
8657 libvirt_charPtrWrap(lease
->ipaddr
), error
);
8658 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("prefix"),
8659 libvirt_uintWrap(lease
->prefix
), error
);
8660 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("hostname"),
8661 libvirt_charPtrWrap(lease
->hostname
), error
);
8662 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("clientid"),
8663 libvirt_charPtrWrap(lease
->clientid
), error
);
8664 VIR_PY_DICT_SET_GOTO(py_lease
, libvirt_constcharPtrWrap("iaid"),
8665 libvirt_charPtrWrap(lease
->iaid
), error
);
8669 if (leases_count
> 0)
8670 for (i
= 0; i
< leases_count
; i
++)
8671 virNetworkDHCPLeaseFree(leases
[i
]);
8677 Py_CLEAR(py_retval
);
8681 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
8683 #if LIBVIR_CHECK_VERSION(1, 2, 8)
8686 convertDomainStatsRecord(virDomainStatsRecordPtr
*records
,
8689 PyObject
*py_retval
;
8690 PyObject
*py_record
;
8691 PyObject
*py_record_stats
= NULL
;
8692 virDomainPtr dom
= NULL
;
8695 if (!(py_retval
= PyList_New(nrecords
)))
8698 for (i
= 0; i
< nrecords
; i
++) {
8699 if (!(py_record
= PyTuple_New(2)))
8702 VIR_PY_LIST_SET_GOTO(py_retval
, i
, py_record
, error
);
8704 dom
= records
[i
]->dom
;
8706 VIR_PY_TUPLE_SET_GOTO(py_record
, 0,
8707 libvirt_virDomainPtrWrap(dom
),
8711 if (!(py_record_stats
= getPyVirTypedParameter(records
[i
]->params
,
8712 records
[i
]->nparams
)))
8714 VIR_PY_TUPLE_SET_GOTO(py_record
, 1, py_record_stats
, error
);
8723 Py_XDECREF(py_retval
);
8729 libvirt_virConnectGetAllDomainStats(PyObject
*self ATTRIBUTE_UNUSED
,
8732 PyObject
*pyobj_conn
;
8733 PyObject
*py_retval
;
8735 virDomainStatsRecordPtr
*records
;
8740 if (!PyArg_ParseTuple(args
, (char *)"OII:virConnectGetAllDomainStats",
8741 &pyobj_conn
, &stats
, &flags
))
8743 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8745 LIBVIRT_BEGIN_ALLOW_THREADS
;
8746 nrecords
= virConnectGetAllDomainStats(conn
, stats
, &records
, flags
);
8747 LIBVIRT_END_ALLOW_THREADS
;
8752 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8754 virDomainStatsRecordListFree(records
);
8761 libvirt_virDomainListGetStats(PyObject
*self ATTRIBUTE_UNUSED
,
8764 PyObject
*pyobj_conn
;
8765 PyObject
*py_retval
;
8766 PyObject
*py_domlist
;
8767 virDomainStatsRecordPtr
*records
= NULL
;
8768 virDomainPtr
*doms
= NULL
;
8775 if (!PyArg_ParseTuple(args
, (char *)"OOII:virDomainListGetStats",
8776 &pyobj_conn
, &py_domlist
, &stats
, &flags
))
8779 if (PyList_Check(py_domlist
)) {
8780 ndoms
= PyList_Size(py_domlist
);
8782 if (VIR_ALLOC_N(doms
, ndoms
+ 1) < 0)
8783 return PyErr_NoMemory();
8785 for (i
= 0; i
< ndoms
; i
++)
8786 doms
[i
] = PyvirDomain_Get(PyList_GetItem(py_domlist
, i
));
8789 LIBVIRT_BEGIN_ALLOW_THREADS
;
8790 nrecords
= virDomainListGetStats(doms
, stats
, &records
, flags
);
8791 LIBVIRT_END_ALLOW_THREADS
;
8794 py_retval
= VIR_PY_NONE
;
8798 py_retval
= convertDomainStatsRecord(records
, nrecords
);
8801 virDomainStatsRecordListFree(records
);
8808 static virPyTypedParamsHint virPyDomainBlockCopyParams
[] = {
8809 { VIR_DOMAIN_BLOCK_COPY_BANDWIDTH
, VIR_TYPED_PARAM_ULLONG
},
8810 { VIR_DOMAIN_BLOCK_COPY_GRANULARITY
, VIR_TYPED_PARAM_UINT
},
8811 { VIR_DOMAIN_BLOCK_COPY_BUF_SIZE
, VIR_TYPED_PARAM_ULLONG
},
8816 libvirt_virDomainBlockCopy(PyObject
*self ATTRIBUTE_UNUSED
,
8819 PyObject
*pyobj_dom
= NULL
;
8820 PyObject
*pyobj_dict
= NULL
;
8824 char *destxml
= NULL
;
8825 virTypedParameterPtr params
= NULL
;
8827 unsigned int flags
= 0;
8830 if (!PyArg_ParseTuple(args
, (char *) "Ozz|OI:virDomainBlockCopy",
8831 &pyobj_dom
, &disk
, &destxml
, &pyobj_dict
, &flags
))
8834 if (PyDict_Check(pyobj_dict
)) {
8835 if (virPyDictToTypedParams(pyobj_dict
, ¶ms
, &nparams
,
8836 virPyDomainBlockCopyParams
,
8837 VIR_N_ELEMENTS(virPyDomainBlockCopyParams
)) < 0) {
8840 } else if (pyobj_dict
!= Py_None
) {
8841 PyErr_Format(PyExc_TypeError
, "block params must be a dictionary");
8845 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
8847 LIBVIRT_BEGIN_ALLOW_THREADS
;
8848 c_retval
= virDomainBlockCopy(dom
, disk
, destxml
, params
, nparams
, flags
);
8849 LIBVIRT_END_ALLOW_THREADS
;
8851 virTypedParamsFree(params
, nparams
);
8852 return libvirt_intWrap(c_retval
);
8855 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
8857 #if LIBVIR_CHECK_VERSION(1, 2, 9)
8859 libvirt_virNodeAllocPages(PyObject
*self ATTRIBUTE_UNUSED
,
8862 PyObject
*pyobj_conn
;
8863 PyObject
*pyobj_pages
;
8864 Py_ssize_t size
= 0;
8866 PyObject
*key
, *value
;
8868 unsigned int npages
= 0;
8869 unsigned int *pageSizes
= NULL
;
8870 unsigned long long *pageCounts
= NULL
;
8872 unsigned int cellCount
= 1;
8873 unsigned int flags
= VIR_NODE_ALLOC_PAGES_ADD
;
8876 if (!PyArg_ParseTuple(args
, (char *)"OOiII:virNodeAllocPages",
8877 &pyobj_conn
, &pyobj_pages
,
8878 &startCell
, &cellCount
, &flags
))
8880 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
8882 if ((size
= PyDict_Size(pyobj_pages
)) < 0)
8886 PyErr_Format(PyExc_LookupError
,
8887 "Need non-empty dictionary to pages attribute");
8891 if (VIR_ALLOC_N(pageSizes
, size
) < 0 ||
8892 VIR_ALLOC_N(pageCounts
, size
) < 0) {
8897 while (PyDict_Next(pyobj_pages
, &pos
, &key
, &value
)) {
8898 if (libvirt_uintUnwrap(key
, &pageSizes
[npages
]) < 0 ||
8899 libvirt_ulonglongUnwrap(value
, &pageCounts
[npages
]) < 0)
8904 LIBVIRT_BEGIN_ALLOW_THREADS
;
8905 c_retval
= virNodeAllocPages(conn
, npages
, pageSizes
,
8906 pageCounts
, startCell
, cellCount
, flags
);
8907 LIBVIRT_END_ALLOW_THREADS
;
8909 VIR_FREE(pageSizes
);
8910 VIR_FREE(pageCounts
);
8912 return libvirt_intWrap(c_retval
);
8915 VIR_FREE(pageSizes
);
8916 VIR_FREE(pageCounts
);
8919 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
8921 #if LIBVIR_CHECK_VERSION(1, 2, 11)
8924 libvirt_virDomainGetFSInfo(PyObject
*self ATTRIBUTE_UNUSED
,
8927 virDomainPtr domain
;
8928 PyObject
*pyobj_domain
;
8930 virDomainFSInfoPtr
*fsinfo
= NULL
;
8933 PyObject
*py_retval
= NULL
;
8935 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetFSInfo",
8936 &pyobj_domain
, &flags
))
8938 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
8940 LIBVIRT_BEGIN_ALLOW_THREADS
;
8941 c_retval
= virDomainGetFSInfo(domain
, &fsinfo
, flags
);
8942 LIBVIRT_END_ALLOW_THREADS
;
8945 py_retval
= VIR_PY_NONE
;
8949 /* convert to a Python list */
8950 if ((py_retval
= PyList_New(c_retval
)) == NULL
)
8953 for (i
= 0; i
< c_retval
; i
++) {
8954 virDomainFSInfoPtr fs
= fsinfo
[i
];
8955 PyObject
*info
, *alias
;
8960 info
= PyTuple_New(4);
8964 VIR_PY_LIST_SET_GOTO(py_retval
, i
, info
, error
);
8966 VIR_PY_TUPLE_SET_GOTO(info
, 0,
8967 libvirt_constcharPtrWrap(fs
->mountpoint
), error
);
8968 VIR_PY_TUPLE_SET_GOTO(info
, 1,
8969 libvirt_constcharPtrWrap(fs
->name
), error
);
8970 VIR_PY_TUPLE_SET_GOTO(info
, 2,
8971 libvirt_constcharPtrWrap(fs
->fstype
), error
);
8973 alias
= PyList_New(0);
8976 VIR_PY_TUPLE_SET_GOTO(info
, 3, alias
, error
);
8978 for (j
= 0; j
< fs
->ndevAlias
; j
++)
8979 VIR_PY_LIST_APPEND_GOTO(alias
,
8980 libvirt_constcharPtrWrap(fs
->devAlias
[j
]),
8986 for (i
= 0; i
< c_retval
; i
++)
8987 virDomainFSInfoFree(fsinfo
[i
]);
8992 Py_CLEAR(py_retval
);
8996 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
8998 #if LIBVIR_CHECK_VERSION(1, 3, 3)
9000 libvirt_virDomainGetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
9003 PyObject
*pyobj_domain
;
9004 virDomainPtr domain
;
9005 virTypedParameterPtr params
= NULL
;
9007 PyObject
*dict
= NULL
;
9011 if (!PyArg_ParseTuple(args
, (char *) "OI:virDomainGetPerfEvents",
9012 &pyobj_domain
, &flags
))
9014 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9016 LIBVIRT_BEGIN_ALLOW_THREADS
;
9017 rc
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
9018 LIBVIRT_END_ALLOW_THREADS
;
9023 if (!(dict
= getPyVirTypedParameter(params
, nparams
)))
9027 virTypedParamsFree(params
, nparams
);
9032 libvirt_virDomainSetPerfEvents(PyObject
*self ATTRIBUTE_UNUSED
,
9035 virDomainPtr domain
;
9036 PyObject
*pyobj_domain
, *info
;
9037 PyObject
*ret
= NULL
;
9040 Py_ssize_t size
= 0;
9042 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
9044 if (!PyArg_ParseTuple(args
,
9045 (char *)"OOI:virDomainSetPerfEvents",
9046 &pyobj_domain
, &info
, &flags
))
9048 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9050 if ((size
= PyDict_Size(info
)) < 0)
9054 PyErr_Format(PyExc_LookupError
,
9055 "Need non-empty dictionary to set attributes");
9059 LIBVIRT_BEGIN_ALLOW_THREADS
;
9060 i_retval
= virDomainGetPerfEvents(domain
, ¶ms
, &nparams
, flags
);
9061 LIBVIRT_END_ALLOW_THREADS
;
9064 return VIR_PY_INT_FAIL
;
9067 PyErr_Format(PyExc_LookupError
,
9068 "Domain has no settable attributes");
9072 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
9076 LIBVIRT_BEGIN_ALLOW_THREADS
;
9077 i_retval
= virDomainSetPerfEvents(domain
, new_params
, size
, flags
);
9078 LIBVIRT_END_ALLOW_THREADS
;
9081 ret
= VIR_PY_INT_FAIL
;
9085 ret
= VIR_PY_INT_SUCCESS
;
9088 virTypedParamsFree(params
, nparams
);
9089 virTypedParamsFree(new_params
, size
);
9092 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
9094 #if LIBVIR_CHECK_VERSION(2, 0, 0)
9096 libvirt_virConnectStoragePoolEventFreeFunc(void *opaque
)
9098 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9099 LIBVIRT_ENSURE_THREAD_STATE
;
9100 Py_DECREF(pyobj_conn
);
9101 LIBVIRT_RELEASE_THREAD_STATE
;
9105 libvirt_virConnectStoragePoolEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9106 virStoragePoolPtr pool
,
9111 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9112 PyObject
*pyobj_pool
;
9113 PyObject
*pyobj_ret
= NULL
;
9114 PyObject
*pyobj_conn
;
9118 LIBVIRT_ENSURE_THREAD_STATE
;
9120 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9122 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9125 /* Create a python instance of this virStoragePoolPtr */
9126 virStoragePoolRef(pool
);
9127 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
9128 virStoragePoolFree(pool
);
9131 Py_INCREF(pyobj_cbData
);
9133 /* Call the Callback Dispatcher */
9134 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9135 (char*)"_dispatchStoragePoolEventLifecycleCallback",
9142 Py_DECREF(pyobj_cbData
);
9143 Py_DECREF(pyobj_pool
);
9147 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9150 Py_DECREF(pyobj_ret
);
9154 LIBVIRT_RELEASE_THREAD_STATE
;
9159 libvirt_virConnectStoragePoolEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9160 virStoragePoolPtr pool
,
9163 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9164 PyObject
*pyobj_pool
;
9165 PyObject
*pyobj_ret
= NULL
;
9166 PyObject
*pyobj_conn
;
9170 LIBVIRT_ENSURE_THREAD_STATE
;
9172 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9174 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9177 /* Create a python instance of this virStoragePoolPtr */
9178 virStoragePoolRef(pool
);
9179 if (!(pyobj_pool
= libvirt_virStoragePoolPtrWrap(pool
))) {
9180 virStoragePoolFree(pool
);
9183 Py_INCREF(pyobj_cbData
);
9185 /* Call the Callback Dispatcher */
9186 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9187 (char*)"_dispatchStoragePoolEventGenericCallback",
9192 Py_DECREF(pyobj_cbData
);
9193 Py_DECREF(pyobj_pool
);
9197 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9200 Py_DECREF(pyobj_ret
);
9204 LIBVIRT_RELEASE_THREAD_STATE
;
9209 libvirt_virConnectStoragePoolEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9212 PyObject
*pyobj_conn
; /* virConnectPtr */
9213 PyObject
*pyobj_pool
;
9214 PyObject
*pyobj_cbData
; /* hash of callback data */
9218 virConnectStoragePoolEventGenericCallback cb
= NULL
;
9219 virStoragePoolPtr pool
;
9221 if (!PyArg_ParseTuple(args
,
9222 (char *) "OOiO:virConnectStoragePoolEventRegisterAny",
9223 &pyobj_conn
, &pyobj_pool
, &eventID
, &pyobj_cbData
))
9226 DEBUG("libvirt_virConnectStoragePoolEventRegister(%p %p %d %p) called\n",
9227 pyobj_conn
, pyobj_pool
, eventID
, pyobj_cbData
);
9228 conn
= PyvirConnect_Get(pyobj_conn
);
9229 if (pyobj_pool
== Py_None
)
9232 pool
= PyvirStoragePool_Get(pyobj_pool
);
9234 switch ((virStoragePoolEventID
) eventID
) {
9235 case VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE
:
9236 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventLifecycleCallback
);
9239 case VIR_STORAGE_POOL_EVENT_ID_REFRESH
:
9240 cb
= VIR_STORAGE_POOL_EVENT_CALLBACK(libvirt_virConnectStoragePoolEventGenericCallback
);
9243 case VIR_STORAGE_POOL_EVENT_ID_LAST
:
9248 return VIR_PY_INT_FAIL
;
9251 Py_INCREF(pyobj_cbData
);
9253 LIBVIRT_BEGIN_ALLOW_THREADS
;
9254 ret
= virConnectStoragePoolEventRegisterAny(conn
,
9259 libvirt_virConnectStoragePoolEventFreeFunc
);
9260 LIBVIRT_END_ALLOW_THREADS
;
9263 Py_DECREF(pyobj_cbData
);
9266 return libvirt_intWrap(ret
);
9270 libvirt_virConnectStoragePoolEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9273 PyObject
*pyobj_conn
;
9278 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectStoragePoolEventDeregisterAny",
9279 &pyobj_conn
, &callbackID
))
9282 DEBUG("libvirt_virConnectStoragePoolEventDeregister(%p) called\n",
9285 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9287 LIBVIRT_BEGIN_ALLOW_THREADS
;
9288 ret
= virConnectStoragePoolEventDeregisterAny(conn
, callbackID
);
9289 LIBVIRT_END_ALLOW_THREADS
;
9291 return libvirt_intWrap(ret
);
9295 libvirt_virDomainGetGuestVcpus(PyObject
*self ATTRIBUTE_UNUSED
,
9298 PyObject
*pyobj_domain
;
9299 virDomainPtr domain
;
9300 virTypedParameterPtr params
= NULL
;
9301 unsigned int nparams
= 0;
9304 PyObject
*ret
= NULL
;
9306 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetGuestVcpus",
9307 &pyobj_domain
, &flags
))
9309 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
9311 LIBVIRT_BEGIN_ALLOW_THREADS
;
9312 i_retval
= virDomainGetGuestVcpus(domain
, ¶ms
, &nparams
, flags
);
9313 LIBVIRT_END_ALLOW_THREADS
;
9320 ret
= getPyVirTypedParameter(params
, nparams
);
9322 virTypedParamsFree(params
, nparams
);
9325 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0)*/
9327 #if LIBVIR_CHECK_VERSION(2, 2, 0)
9329 libvirt_virConnectNodeDeviceEventFreeFunc(void *opaque
)
9331 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9332 LIBVIRT_ENSURE_THREAD_STATE
;
9333 Py_DECREF(pyobj_conn
);
9334 LIBVIRT_RELEASE_THREAD_STATE
;
9338 libvirt_virConnectNodeDeviceEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9339 virNodeDevicePtr dev
,
9344 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9345 PyObject
*pyobj_dev
;
9346 PyObject
*pyobj_ret
= NULL
;
9347 PyObject
*pyobj_conn
;
9351 LIBVIRT_ENSURE_THREAD_STATE
;
9353 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9355 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9358 /* Create a python instance of this virNodeDevicePtr */
9359 virNodeDeviceRef(dev
);
9360 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9361 virNodeDeviceFree(dev
);
9364 Py_INCREF(pyobj_cbData
);
9366 /* Call the Callback Dispatcher */
9367 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9368 (char*)"_dispatchNodeDeviceEventLifecycleCallback",
9375 Py_DECREF(pyobj_cbData
);
9376 Py_DECREF(pyobj_dev
);
9380 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9383 Py_DECREF(pyobj_ret
);
9387 LIBVIRT_RELEASE_THREAD_STATE
;
9392 libvirt_virConnectNodeDeviceEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9393 virNodeDevicePtr dev
,
9396 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9397 PyObject
*pyobj_dev
;
9398 PyObject
*pyobj_ret
= NULL
;
9399 PyObject
*pyobj_conn
;
9403 LIBVIRT_ENSURE_THREAD_STATE
;
9405 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9407 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9410 /* Create a python instance of this virNodeDevicePtr */
9411 virNodeDeviceRef(dev
);
9412 if (!(pyobj_dev
= libvirt_virNodeDevicePtrWrap(dev
))) {
9413 virNodeDeviceFree(dev
);
9416 Py_INCREF(pyobj_cbData
);
9418 /* Call the Callback Dispatcher */
9419 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9420 (char*)"_dispatchNodeDeviceEventGenericCallback",
9425 Py_DECREF(pyobj_cbData
);
9426 Py_DECREF(pyobj_dev
);
9430 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9433 Py_DECREF(pyobj_ret
);
9437 LIBVIRT_RELEASE_THREAD_STATE
;
9442 libvirt_virConnectNodeDeviceEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9445 PyObject
*pyobj_conn
; /* virConnectPtr */
9446 PyObject
*pyobj_dev
;
9447 PyObject
*pyobj_cbData
; /* hash of callback data */
9451 virConnectNodeDeviceEventGenericCallback cb
= NULL
;
9452 virNodeDevicePtr dev
;
9454 if (!PyArg_ParseTuple(args
,
9455 (char *) "OOiO:virConnectNodeDeviceEventRegisterAny",
9456 &pyobj_conn
, &pyobj_dev
, &eventID
, &pyobj_cbData
))
9459 DEBUG("libvirt_virConnectNodeDeviceEventRegister(%p %p %d %p) called\n",
9460 pyobj_conn
, pyobj_dev
, eventID
, pyobj_cbData
);
9461 conn
= PyvirConnect_Get(pyobj_conn
);
9462 if (pyobj_dev
== Py_None
)
9465 dev
= PyvirNodeDevice_Get(pyobj_dev
);
9467 switch ((virNodeDeviceEventID
) eventID
) {
9468 case VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE
:
9469 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventLifecycleCallback
);
9472 case VIR_NODE_DEVICE_EVENT_ID_UPDATE
:
9473 cb
= VIR_NODE_DEVICE_EVENT_CALLBACK(libvirt_virConnectNodeDeviceEventGenericCallback
);
9476 case VIR_NODE_DEVICE_EVENT_ID_LAST
:
9481 return VIR_PY_INT_FAIL
;
9484 Py_INCREF(pyobj_cbData
);
9486 LIBVIRT_BEGIN_ALLOW_THREADS
;
9487 ret
= virConnectNodeDeviceEventRegisterAny(conn
,
9492 libvirt_virConnectNodeDeviceEventFreeFunc
);
9493 LIBVIRT_END_ALLOW_THREADS
;
9496 Py_DECREF(pyobj_cbData
);
9499 return libvirt_intWrap(ret
);
9503 libvirt_virConnectNodeDeviceEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9506 PyObject
*pyobj_conn
;
9511 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectNodeDeviceEventDeregister",
9512 &pyobj_conn
, &callbackID
))
9515 DEBUG("libvirt_virConnectNodeDeviceEventDeregister(%p) called\n",
9518 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9520 LIBVIRT_BEGIN_ALLOW_THREADS
;
9521 ret
= virConnectNodeDeviceEventDeregisterAny(conn
, callbackID
);
9522 LIBVIRT_END_ALLOW_THREADS
;
9524 return libvirt_intWrap(ret
);
9527 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0)*/
9529 #if LIBVIR_CHECK_VERSION(3, 0, 0)
9531 libvirt_virConnectSecretEventFreeFunc(void *opaque
)
9533 PyObject
*pyobj_conn
= (PyObject
*)opaque
;
9534 LIBVIRT_ENSURE_THREAD_STATE
;
9535 Py_DECREF(pyobj_conn
);
9536 LIBVIRT_RELEASE_THREAD_STATE
;
9540 libvirt_virConnectSecretEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9541 virSecretPtr secret
,
9546 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9547 PyObject
*pyobj_secret
;
9548 PyObject
*pyobj_ret
= NULL
;
9549 PyObject
*pyobj_conn
;
9553 LIBVIRT_ENSURE_THREAD_STATE
;
9555 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9557 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9560 /* Create a python instance of this virSecretPtr */
9561 virSecretRef(secret
);
9562 if (!(pyobj_secret
= libvirt_virSecretPtrWrap(secret
))) {
9563 virSecretFree(secret
);
9566 Py_INCREF(pyobj_cbData
);
9568 /* Call the Callback Dispatcher */
9569 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9570 (char*)"_dispatchSecretEventLifecycleCallback",
9577 Py_DECREF(pyobj_cbData
);
9578 Py_DECREF(pyobj_secret
);
9582 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9585 Py_DECREF(pyobj_ret
);
9589 LIBVIRT_RELEASE_THREAD_STATE
;
9594 libvirt_virConnectSecretEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
,
9595 virSecretPtr secret
,
9598 PyObject
*pyobj_cbData
= (PyObject
*)opaque
;
9599 PyObject
*pyobj_secret
;
9600 PyObject
*pyobj_ret
= NULL
;
9601 PyObject
*pyobj_conn
;
9605 LIBVIRT_ENSURE_THREAD_STATE
;
9607 if (!(dictKey
= libvirt_constcharPtrWrap("conn")))
9609 pyobj_conn
= PyDict_GetItem(pyobj_cbData
, dictKey
);
9612 /* Create a python instance of this virSecretPtr */
9613 virSecretRef(secret
);
9614 if (!(pyobj_secret
= libvirt_virSecretPtrWrap(secret
))) {
9615 virSecretFree(secret
);
9618 Py_INCREF(pyobj_cbData
);
9620 /* Call the Callback Dispatcher */
9621 pyobj_ret
= PyObject_CallMethod(pyobj_conn
,
9622 (char*)"_dispatchSecretEventGenericCallback",
9627 Py_DECREF(pyobj_cbData
);
9628 Py_DECREF(pyobj_secret
);
9632 DEBUG("%s - ret:%p\n", __FUNCTION__
, pyobj_ret
);
9635 Py_DECREF(pyobj_ret
);
9639 LIBVIRT_RELEASE_THREAD_STATE
;
9644 libvirt_virConnectSecretEventRegisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9647 PyObject
*pyobj_conn
; /* virConnectPtr */
9648 PyObject
*pyobj_secret
;
9649 PyObject
*pyobj_cbData
; /* hash of callback data */
9653 virConnectSecretEventGenericCallback cb
= NULL
;
9654 virSecretPtr secret
;
9656 if (!PyArg_ParseTuple(args
,
9657 (char *) "OOiO:virConnectSecretEventRegisterAny",
9658 &pyobj_conn
, &pyobj_secret
, &eventID
, &pyobj_cbData
))
9661 DEBUG("libvirt_virConnectSecretEventRegister(%p %p %d %p) called\n",
9662 pyobj_conn
, pyobj_secret
, eventID
, pyobj_cbData
);
9663 conn
= PyvirConnect_Get(pyobj_conn
);
9664 if (pyobj_secret
== Py_None
)
9667 secret
= PyvirSecret_Get(pyobj_secret
);
9669 switch ((virSecretEventID
) eventID
) {
9670 case VIR_SECRET_EVENT_ID_LIFECYCLE
:
9671 cb
= VIR_SECRET_EVENT_CALLBACK(libvirt_virConnectSecretEventLifecycleCallback
);
9674 case VIR_SECRET_EVENT_ID_VALUE_CHANGED
:
9675 cb
= VIR_SECRET_EVENT_CALLBACK(libvirt_virConnectSecretEventGenericCallback
);
9678 case VIR_SECRET_EVENT_ID_LAST
:
9683 return VIR_PY_INT_FAIL
;
9686 Py_INCREF(pyobj_cbData
);
9688 LIBVIRT_BEGIN_ALLOW_THREADS
;
9689 ret
= virConnectSecretEventRegisterAny(conn
, secret
, eventID
,
9691 libvirt_virConnectSecretEventFreeFunc
);
9692 LIBVIRT_END_ALLOW_THREADS
;
9695 Py_DECREF(pyobj_cbData
);
9698 return libvirt_intWrap(ret
);
9702 libvirt_virConnectSecretEventDeregisterAny(PyObject
*self ATTRIBUTE_UNUSED
,
9705 PyObject
*pyobj_conn
;
9710 if (!PyArg_ParseTuple(args
, (char *) "Oi:virConnectSecretEventDeregister",
9711 &pyobj_conn
, &callbackID
))
9714 DEBUG("libvirt_virConnectSecretEventDeregister(%p) called\n", pyobj_conn
);
9716 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9718 LIBVIRT_BEGIN_ALLOW_THREADS
;
9719 ret
= virConnectSecretEventDeregisterAny(conn
, callbackID
);
9720 LIBVIRT_END_ALLOW_THREADS
;
9722 return libvirt_intWrap(ret
);
9724 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0)*/
9727 #if LIBVIR_CHECK_VERSION(3, 4, 0)
9729 libvirt_virStreamRecvHole(PyObject
*self ATTRIBUTE_UNUSED
,
9732 PyObject
*pyobj_stream
;
9733 virStreamPtr stream
;
9734 long long length
= -1;
9738 if (!PyArg_ParseTuple(args
, (char *) "OI:virStreamRecvHole",
9739 &pyobj_stream
, &flags
))
9742 stream
= PyvirStream_Get(pyobj_stream
);
9744 LIBVIRT_BEGIN_ALLOW_THREADS
;
9745 ret
= virStreamRecvHole(stream
, &length
, flags
);
9746 LIBVIRT_END_ALLOW_THREADS
;
9748 DEBUG("StreamRecvHole ret=%d length=%lld\n", ret
, length
);
9753 return libvirt_longlongWrap(length
);
9758 libvirt_virStreamSendHole(PyObject
*self ATTRIBUTE_UNUSED
,
9761 PyObject
*pyobj_stream
;
9762 virStreamPtr stream
;
9767 if (!PyArg_ParseTuple(args
, (char *) "OLI:virStreamSendHole",
9768 &pyobj_stream
, &length
, &flags
))
9771 stream
= PyvirStream_Get(pyobj_stream
);
9773 LIBVIRT_BEGIN_ALLOW_THREADS
;
9774 ret
= virStreamSendHole(stream
, length
, flags
);
9775 LIBVIRT_END_ALLOW_THREADS
;
9777 DEBUG("StreamSendHole ret=%d\n", ret
);
9779 return libvirt_intWrap(ret
);
9784 libvirt_virStreamRecvFlags(PyObject
*self ATTRIBUTE_UNUSED
,
9787 PyObject
*pyobj_stream
;
9789 virStreamPtr stream
;
9795 if (!PyArg_ParseTuple(args
, (char *) "OkI:virStreamRecvFlags",
9796 &pyobj_stream
, &nbytes
, &flags
))
9799 stream
= PyvirStream_Get(pyobj_stream
);
9801 if (VIR_ALLOC_N(buf
, nbytes
+ 1) < 0)
9802 return PyErr_NoMemory();
9804 LIBVIRT_BEGIN_ALLOW_THREADS
;
9805 ret
= virStreamRecvFlags(stream
, buf
, nbytes
, flags
);
9806 LIBVIRT_END_ALLOW_THREADS
;
9808 buf
[ret
> -1 ? ret
: 0] = '\0';
9809 DEBUG("StreamRecvFlags ret=%d strlen=%d\n", ret
, (int) strlen(buf
));
9811 if (ret
== -2 || ret
== -3)
9812 return libvirt_intWrap(ret
);
9815 rv
= libvirt_charPtrSizeWrap((char *) buf
, (Py_ssize_t
) ret
);
9820 #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
9823 #if LIBVIR_CHECK_VERSION(4, 4, 0)
9825 libvirt_virConnectBaselineHypervisorCPU(PyObject
*self ATTRIBUTE_UNUSED
,
9829 PyObject
*pyobj_conn
;
9836 char **xmlCPUs
= NULL
;
9840 PyObject
*ret
= NULL
;
9842 if (!PyArg_ParseTuple(args
, (char *)"OzzzzOI:virConnectBaselineHypervisorCPU",
9843 &pyobj_conn
, &emulator
, &arch
, &machine
, &virttype
,
9847 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9849 if (PyList_Check(list
)) {
9850 ncpus
= PyList_Size(list
);
9851 if (VIR_ALLOC_N(xmlCPUs
, ncpus
) < 0)
9852 return PyErr_NoMemory();
9854 for (i
= 0; i
< ncpus
; i
++) {
9855 if (libvirt_charPtrUnwrap(PyList_GetItem(list
, i
),
9861 LIBVIRT_BEGIN_ALLOW_THREADS
;
9862 cpu
= virConnectBaselineHypervisorCPU(conn
, emulator
, arch
, machine
, virttype
,
9863 (const char **)xmlCPUs
, ncpus
, flags
);
9864 LIBVIRT_END_ALLOW_THREADS
;
9866 ret
= libvirt_constcharPtrWrap(cpu
);
9869 for (i
= 0; i
< ncpus
; i
++)
9870 VIR_FREE(xmlCPUs
[i
]);
9876 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
9879 #if LIBVIR_CHECK_VERSION(4, 5, 0)
9881 libvirt_virDomainGetLaunchSecurityInfo(PyObject
*self ATTRIBUTE_UNUSED
,
9884 PyObject
*pyobj_dom
= NULL
;
9885 PyObject
*ret
= NULL
;
9887 virDomainPtr dom
= NULL
;
9888 virTypedParameterPtr params
= NULL
;
9890 unsigned int flags
= 0;
9893 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainGetLaunchSecurityInfo",
9894 &pyobj_dom
, &flags
))
9896 dom
= (virDomainPtr
) PyvirDomain_Get(pyobj_dom
);
9898 LIBVIRT_BEGIN_ALLOW_THREADS
;
9899 i_retval
= virDomainGetLaunchSecurityInfo(dom
, ¶ms
, &nparams
, flags
);
9900 LIBVIRT_END_ALLOW_THREADS
;
9907 ret
= getPyVirTypedParameter(params
, nparams
);
9909 virTypedParamsFree(params
, nparams
);
9915 libvirt_virNodeGetSEVInfo(PyObject
*self ATTRIBUTE_UNUSED
,
9918 PyObject
*pyobj_conn
= NULL
;
9919 PyObject
*ret
= NULL
;
9921 virConnectPtr conn
= NULL
;
9922 virTypedParameterPtr params
= NULL
;
9924 unsigned int flags
= 0;
9927 if (!PyArg_ParseTuple(args
, (char *)"OI:virNodeGetSEVInfo",
9928 &pyobj_conn
, &flags
))
9930 conn
= (virConnectPtr
) PyvirConnect_Get(pyobj_conn
);
9932 LIBVIRT_BEGIN_ALLOW_THREADS
;
9933 i_retval
= virNodeGetSEVInfo(conn
, ¶ms
, &nparams
, flags
);
9934 LIBVIRT_END_ALLOW_THREADS
;
9941 ret
= getPyVirTypedParameter(params
, nparams
);
9943 virTypedParamsFree(params
, nparams
);
9946 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
9948 #if LIBVIR_CHECK_VERSION(5, 5, 0)
9950 libvirt_virNetworkListAllPorts(PyObject
*self ATTRIBUTE_UNUSED
,
9953 PyObject
*pyobj_conn
;
9954 PyObject
*py_retval
= NULL
;
9956 virNetworkPortPtr
*doms
= NULL
;
9961 if (!PyArg_ParseTuple(args
, (char *)"OI:virNetworkListAllPorts",
9962 &pyobj_conn
, &flags
))
9964 conn
= (virNetworkPtr
) PyvirNetwork_Get(pyobj_conn
);
9966 LIBVIRT_BEGIN_ALLOW_THREADS
;
9967 c_retval
= virNetworkListAllPorts(conn
, &doms
, flags
);
9968 LIBVIRT_END_ALLOW_THREADS
;
9973 if (!(py_retval
= PyList_New(c_retval
)))
9976 for (i
= 0; i
< c_retval
; i
++) {
9977 VIR_PY_LIST_SET_GOTO(py_retval
, i
, libvirt_virNetworkPortPtrWrap(doms
[i
]), error
);
9978 /* python steals the pointer */
9983 for (i
= 0; i
< c_retval
; i
++)
9985 virNetworkPortFree(doms
[i
]);
9990 Py_CLEAR(py_retval
);
9995 libvirt_virNetworkPortSetParameters(PyObject
*self ATTRIBUTE_UNUSED
,
9998 virNetworkPortPtr port
;
9999 PyObject
*pyobj_port
, *info
;
10000 PyObject
*ret
= NULL
;
10003 Py_ssize_t size
= 0;
10004 unsigned int flags
;
10005 virTypedParameterPtr params
= NULL
, new_params
= NULL
;
10007 if (!PyArg_ParseTuple(args
,
10008 (char *)"OOI:virNetworkPortSetParameters",
10009 &pyobj_port
, &info
, &flags
))
10011 port
= (virNetworkPortPtr
) PyvirNetworkPort_Get(pyobj_port
);
10013 if ((size
= PyDict_Size(info
)) < 0)
10017 PyErr_Format(PyExc_LookupError
,
10018 "Need non-empty dictionary to set attributes");
10022 LIBVIRT_BEGIN_ALLOW_THREADS
;
10023 i_retval
= virNetworkPortGetParameters(port
, ¶ms
, &nparams
, flags
);
10024 LIBVIRT_END_ALLOW_THREADS
;
10027 return VIR_PY_INT_FAIL
;
10029 if (nparams
== 0) {
10030 PyErr_Format(PyExc_LookupError
,
10031 "Port has no settable attributes");
10035 new_params
= setPyVirTypedParameter(info
, params
, nparams
);
10039 LIBVIRT_BEGIN_ALLOW_THREADS
;
10040 i_retval
= virNetworkPortSetParameters(port
, new_params
, size
, flags
);
10041 LIBVIRT_END_ALLOW_THREADS
;
10043 if (i_retval
< 0) {
10044 ret
= VIR_PY_INT_FAIL
;
10048 ret
= VIR_PY_INT_SUCCESS
;
10051 virTypedParamsFree(params
, nparams
);
10052 virTypedParamsFree(new_params
, size
);
10057 libvirt_virNetworkPortGetParameters(PyObject
*self ATTRIBUTE_UNUSED
,
10060 PyObject
*pyobj_port
;
10061 virNetworkPortPtr port
;
10062 virTypedParameterPtr params
= NULL
;
10064 PyObject
*dict
= NULL
;
10065 unsigned int flags
;
10068 if (!PyArg_ParseTuple(args
, (char *) "OI:virNetworkPortGetParameters",
10069 &pyobj_port
, &flags
))
10071 port
= (virNetworkPortPtr
) PyvirNetworkPort_Get(pyobj_port
);
10073 LIBVIRT_BEGIN_ALLOW_THREADS
;
10074 rc
= virNetworkPortGetParameters(port
, ¶ms
, &nparams
, flags
);
10075 LIBVIRT_END_ALLOW_THREADS
;
10078 return VIR_PY_NONE
;
10080 dict
= getPyVirTypedParameter(params
, nparams
);
10082 virTypedParamsFree(params
, nparams
);
10085 #endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
10087 /************************************************************************
10089 * The registration stuff *
10091 ************************************************************************/
10092 static PyMethodDef libvirtMethods
[] = {
10093 #include "build/libvirt-export.c"
10094 {(char *) "virGetVersion", libvirt_virGetVersion
, METH_VARARGS
, NULL
},
10095 {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion
, METH_VARARGS
, NULL
},
10096 #if LIBVIR_CHECK_VERSION(1, 1, 3)
10097 {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames
, METH_VARARGS
, NULL
},
10098 #endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */
10099 {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion
, METH_VARARGS
, NULL
},
10100 {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth
, METH_VARARGS
, NULL
},
10101 {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID
, METH_VARARGS
, NULL
},
10102 {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains
, METH_VARARGS
, NULL
},
10103 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10104 {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains
, METH_VARARGS
, NULL
},
10105 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10106 {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister
, METH_VARARGS
, NULL
},
10107 {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister
, METH_VARARGS
, NULL
},
10108 {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny
, METH_VARARGS
, NULL
},
10109 {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny
, METH_VARARGS
, NULL
},
10110 #if LIBVIR_CHECK_VERSION(1, 2, 1)
10111 {(char *) "virConnectNetworkEventRegisterAny", libvirt_virConnectNetworkEventRegisterAny
, METH_VARARGS
, NULL
},
10112 {(char *) "virConnectNetworkEventDeregisterAny", libvirt_virConnectNetworkEventDeregisterAny
, METH_VARARGS
, NULL
},
10113 #endif /* LIBVIR_CHECK_VERSION(1, 2, 1) */
10114 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10115 {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback
, METH_VARARGS
, NULL
},
10116 {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback
, METH_VARARGS
, NULL
},
10117 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10118 {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback
, METH_VARARGS
, NULL
},
10119 {(char *) "virStreamRecv", libvirt_virStreamRecv
, METH_VARARGS
, NULL
},
10120 {(char *) "virStreamSend", libvirt_virStreamSend
, METH_VARARGS
, NULL
},
10121 {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo
, METH_VARARGS
, NULL
},
10122 {(char *) "virDomainGetState", libvirt_virDomainGetState
, METH_VARARGS
, NULL
},
10123 {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo
, METH_VARARGS
, NULL
},
10124 {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo
, METH_VARARGS
, NULL
},
10125 {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo
, METH_VARARGS
, NULL
},
10126 {(char *) "virNodeGetSecurityModel", libvirt_virNodeGetSecurityModel
, METH_VARARGS
, NULL
},
10127 {(char *) "virDomainGetSecurityLabel", libvirt_virDomainGetSecurityLabel
, METH_VARARGS
, NULL
},
10128 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10129 {(char *) "virDomainGetSecurityLabelList", libvirt_virDomainGetSecurityLabelList
, METH_VARARGS
, NULL
},
10130 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10131 {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats
, METH_VARARGS
, NULL
},
10132 {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats
, METH_VARARGS
, NULL
},
10133 {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID
, METH_VARARGS
, NULL
},
10134 {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString
, METH_VARARGS
, NULL
},
10135 {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID
, METH_VARARGS
, NULL
},
10136 {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler
, METH_VARARGS
, NULL
},
10137 {(char *) "virGetLastError", libvirt_virGetLastError
, METH_VARARGS
, NULL
},
10138 {(char *) "virConnGetLastError", libvirt_virConnGetLastError
, METH_VARARGS
, NULL
},
10139 {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks
, METH_VARARGS
, NULL
},
10140 {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks
, METH_VARARGS
, NULL
},
10141 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10142 {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks
, METH_VARARGS
, NULL
},
10143 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10144 {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID
, METH_VARARGS
, NULL
},
10145 {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString
, METH_VARARGS
, NULL
},
10146 {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID
, METH_VARARGS
, NULL
},
10147 {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart
, METH_VARARGS
, NULL
},
10148 {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart
, METH_VARARGS
, NULL
},
10149 {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats
, METH_VARARGS
, NULL
},
10150 {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags
, METH_VARARGS
, NULL
},
10151 {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats
, METH_VARARGS
, NULL
},
10152 {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats
, METH_VARARGS
, NULL
},
10153 {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats
, METH_VARARGS
, NULL
},
10154 {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory
, METH_VARARGS
, NULL
},
10155 {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType
, METH_VARARGS
, NULL
},
10156 {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters
, METH_VARARGS
, NULL
},
10157 {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
10158 {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters
, METH_VARARGS
, NULL
},
10159 {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags
, METH_VARARGS
, NULL
},
10160 {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters
, METH_VARARGS
, NULL
},
10161 {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters
, METH_VARARGS
, NULL
},
10162 {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters
, METH_VARARGS
, NULL
},
10163 {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters
, METH_VARARGS
, NULL
},
10164 {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters
, METH_VARARGS
, NULL
},
10165 {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters
, METH_VARARGS
, NULL
},
10166 {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters
, METH_VARARGS
, NULL
},
10167 {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters
, METH_VARARGS
, NULL
},
10168 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus
, METH_VARARGS
, NULL
},
10169 {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu
, METH_VARARGS
, NULL
},
10170 {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags
, METH_VARARGS
, NULL
},
10171 {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo
, METH_VARARGS
, NULL
},
10172 #if LIBVIR_CHECK_VERSION(0, 10, 0)
10173 {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo
, METH_VARARGS
, NULL
},
10174 {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator
, METH_VARARGS
, NULL
},
10175 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
10176 #if LIBVIR_CHECK_VERSION(1, 2, 14)
10177 {(char *) "virDomainGetIOThreadInfo", libvirt_virDomainGetIOThreadInfo
, METH_VARARGS
, NULL
},
10178 {(char *) "virDomainPinIOThread", libvirt_virDomainPinIOThread
, METH_VARARGS
, NULL
},
10179 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
10180 #if LIBVIR_CHECK_VERSION(4, 10, 0)
10181 {(char *) "virDomainSetIOThreadParams", libvirt_virDomainSetIOThreadParams
, METH_VARARGS
, NULL
},
10182 #endif /* LIBVIR_CHECK_VERSION(4, 10, 0) */
10183 {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools
, METH_VARARGS
, NULL
},
10184 {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools
, METH_VARARGS
, NULL
},
10185 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10186 {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools
, METH_VARARGS
, NULL
},
10187 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10188 {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart
, METH_VARARGS
, NULL
},
10189 {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes
, METH_VARARGS
, NULL
},
10190 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10191 {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes
, METH_VARARGS
, NULL
},
10192 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10193 {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo
, METH_VARARGS
, NULL
},
10194 {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo
, METH_VARARGS
, NULL
},
10195 #if LIBVIR_CHECK_VERSION(3, 0, 0)
10196 {(char *) "virStorageVolGetInfoFlags", libvirt_virStorageVolGetInfoFlags
, METH_VARARGS
, NULL
},
10197 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0) */
10198 {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID
, METH_VARARGS
, NULL
},
10199 {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString
, METH_VARARGS
, NULL
},
10200 {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID
, METH_VARARGS
, NULL
},
10201 {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl
, METH_VARARGS
, NULL
},
10202 {(char *) "virEventAddHandle", libvirt_virEventAddHandle
, METH_VARARGS
, NULL
},
10203 {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout
, METH_VARARGS
, NULL
},
10204 {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback
, METH_VARARGS
, NULL
},
10205 {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback
, METH_VARARGS
, NULL
},
10206 {(char *) "virEventInvokeFreeCallback", libvirt_virEventInvokeFreeCallback
, METH_VARARGS
, NULL
},
10207 {(char *) "virNodeListDevices", libvirt_virNodeListDevices
, METH_VARARGS
, NULL
},
10208 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10209 {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices
, METH_VARARGS
, NULL
},
10210 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10211 {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps
, METH_VARARGS
, NULL
},
10212 {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID
, METH_VARARGS
, NULL
},
10213 {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString
, METH_VARARGS
, NULL
},
10214 {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID
, METH_VARARGS
, NULL
},
10215 {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets
, METH_VARARGS
, NULL
},
10216 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10217 {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets
, METH_VARARGS
, NULL
},
10218 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10219 {(char *) "virSecretGetValue", libvirt_virSecretGetValue
, METH_VARARGS
, NULL
},
10220 {(char *) "virSecretSetValue", libvirt_virSecretSetValue
, METH_VARARGS
, NULL
},
10221 {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID
, METH_VARARGS
, NULL
},
10222 {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString
, METH_VARARGS
, NULL
},
10223 {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID
, METH_VARARGS
, NULL
},
10224 {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters
, METH_VARARGS
, NULL
},
10225 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10226 {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters
, METH_VARARGS
, NULL
},
10227 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10228 #if LIBVIR_CHECK_VERSION(4, 5, 0)
10229 {(char *) "virConnectListAllNWFilterBindings", libvirt_virConnectListAllNWFilterBindings
, METH_VARARGS
, NULL
},
10230 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
10231 {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces
, METH_VARARGS
, NULL
},
10232 {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces
, METH_VARARGS
, NULL
},
10233 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10234 {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces
, METH_VARARGS
, NULL
},
10235 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10236 {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU
, METH_VARARGS
, NULL
},
10237 {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo
, METH_VARARGS
, NULL
},
10238 #if LIBVIR_CHECK_VERSION(1, 0, 3)
10239 {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats
, METH_VARARGS
, NULL
},
10240 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
10241 {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames
, METH_VARARGS
, NULL
},
10242 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10243 {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots
, METH_VARARGS
, NULL
},
10244 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10245 {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames
, METH_VARARGS
, NULL
},
10246 #if LIBVIR_CHECK_VERSION(0, 9, 13)
10247 {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren
, METH_VARARGS
, NULL
},
10248 #endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
10249 {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot
, METH_VARARGS
, NULL
},
10250 {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo
, METH_VARARGS
, NULL
},
10251 {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune
, METH_VARARGS
, NULL
},
10252 {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune
, METH_VARARGS
, NULL
},
10253 {(char *) "virDomainSendKey", libvirt_virDomainSendKey
, METH_VARARGS
, NULL
},
10254 #if LIBVIR_CHECK_VERSION(1, 0, 3)
10255 {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache
, METH_VARARGS
, NULL
},
10256 #endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */
10257 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
10258 #if LIBVIR_CHECK_VERSION(3, 7, 0)
10259 {(char *) "virDomainMigrateGetMaxDowntime", libvirt_virDomainMigrateGetMaxDowntime
, METH_VARARGS
, NULL
},
10260 #endif /* LIBVIR_CHECK_VERSION(3, 7, 0) */
10261 {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed
, METH_VARARGS
, NULL
},
10262 #if LIBVIR_CHECK_VERSION(1, 1, 0)
10263 {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3
, METH_VARARGS
, NULL
},
10264 {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3
, METH_VARARGS
, NULL
},
10265 #endif /* LIBVIR_CHECK_VERSION(1, 1, 0) */
10266 {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek
, METH_VARARGS
, NULL
},
10267 {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek
, METH_VARARGS
, NULL
},
10268 {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors
, METH_VARARGS
, NULL
},
10269 #if LIBVIR_CHECK_VERSION(0, 10, 2)
10270 {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters
, METH_VARARGS
, NULL
},
10271 {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters
, METH_VARARGS
, NULL
},
10272 #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
10273 #if LIBVIR_CHECK_VERSION(1, 0, 0)
10274 {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap
, METH_VARARGS
, NULL
},
10275 #endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */
10276 #if LIBVIR_CHECK_VERSION(1, 1, 1)
10277 {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles
, METH_VARARGS
, NULL
},
10278 {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles
, METH_VARARGS
, NULL
},
10279 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
10280 #if LIBVIR_CHECK_VERSION(1, 2, 5)
10281 {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze
, METH_VARARGS
, NULL
},
10282 {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw
, METH_VARARGS
, NULL
},
10283 {(char *) "virDomainGetTime", libvirt_virDomainGetTime
, METH_VARARGS
, NULL
},
10284 {(char *) "virDomainSetTime", libvirt_virDomainSetTime
, METH_VARARGS
, NULL
},
10285 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
10286 #if LIBVIR_CHECK_VERSION(1, 2, 6)
10287 {(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages
, METH_VARARGS
, NULL
},
10288 {(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases
, METH_VARARGS
, NULL
},
10289 #endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
10290 #if LIBVIR_CHECK_VERSION(1, 2, 8)
10291 {(char *) "virConnectGetAllDomainStats", libvirt_virConnectGetAllDomainStats
, METH_VARARGS
, NULL
},
10292 {(char *) "virDomainListGetStats", libvirt_virDomainListGetStats
, METH_VARARGS
, NULL
},
10293 {(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy
, METH_VARARGS
, NULL
},
10294 #endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
10295 #if LIBVIR_CHECK_VERSION(1, 2, 9)
10296 {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages
, METH_VARARGS
, NULL
},
10297 #endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
10298 #if LIBVIR_CHECK_VERSION(1, 2, 11)
10299 {(char *) "virDomainGetFSInfo", libvirt_virDomainGetFSInfo
, METH_VARARGS
, NULL
},
10300 #endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
10301 #if LIBVIR_CHECK_VERSION(1, 2, 14)
10302 {(char *) "virDomainInterfaceAddresses", libvirt_virDomainInterfaceAddresses
, METH_VARARGS
, NULL
},
10303 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
10304 #if LIBVIR_CHECK_VERSION(1, 3, 3)
10305 {(char *) "virDomainGetPerfEvents", libvirt_virDomainGetPerfEvents
, METH_VARARGS
, NULL
},
10306 {(char *) "virDomainSetPerfEvents", libvirt_virDomainSetPerfEvents
, METH_VARARGS
, NULL
},
10307 #endif /* LIBVIR_CHECK_VERSION(1, 3, 3) */
10308 #if LIBVIR_CHECK_VERSION(2, 0, 0)
10309 {(char *) "virConnectStoragePoolEventRegisterAny", libvirt_virConnectStoragePoolEventRegisterAny
, METH_VARARGS
, NULL
},
10310 {(char *) "virConnectStoragePoolEventDeregisterAny", libvirt_virConnectStoragePoolEventDeregisterAny
, METH_VARARGS
, NULL
},
10311 {(char *) "virDomainGetGuestVcpus", libvirt_virDomainGetGuestVcpus
, METH_VARARGS
, NULL
},
10312 #endif /* LIBVIR_CHECK_VERSION(2, 0, 0) */
10313 #if LIBVIR_CHECK_VERSION(2, 2, 0)
10314 {(char *) "virConnectNodeDeviceEventRegisterAny", libvirt_virConnectNodeDeviceEventRegisterAny
, METH_VARARGS
, NULL
},
10315 {(char *) "virConnectNodeDeviceEventDeregisterAny", libvirt_virConnectNodeDeviceEventDeregisterAny
, METH_VARARGS
, NULL
},
10316 #endif /* LIBVIR_CHECK_VERSION(2, 2, 0) */
10317 #if LIBVIR_CHECK_VERSION(3, 0, 0)
10318 {(char *) "virConnectSecretEventRegisterAny", libvirt_virConnectSecretEventRegisterAny
, METH_VARARGS
, NULL
},
10319 {(char *) "virConnectSecretEventDeregisterAny", libvirt_virConnectSecretEventDeregisterAny
, METH_VARARGS
, NULL
},
10320 #endif /* LIBVIR_CHECK_VERSION(3, 0, 0) */
10321 #if LIBVIR_CHECK_VERSION(3, 4, 0)
10322 {(char *) "virStreamRecvHole", libvirt_virStreamRecvHole
, METH_VARARGS
, NULL
},
10323 {(char *) "virStreamSendHole", libvirt_virStreamSendHole
, METH_VARARGS
, NULL
},
10324 {(char *) "virStreamRecvFlags", libvirt_virStreamRecvFlags
, METH_VARARGS
, NULL
},
10325 #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
10326 #if LIBVIR_CHECK_VERSION(4, 4, 0)
10327 {(char *) "virConnectBaselineHypervisorCPU", libvirt_virConnectBaselineHypervisorCPU
, METH_VARARGS
, NULL
},
10328 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
10329 #if LIBVIR_CHECK_VERSION(4, 5, 0)
10330 {(char *) "virDomainGetLaunchSecurityInfo", libvirt_virDomainGetLaunchSecurityInfo
, METH_VARARGS
, NULL
},
10331 {(char *) "virNodeGetSEVInfo", libvirt_virNodeGetSEVInfo
, METH_VARARGS
, NULL
},
10332 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
10333 #if LIBVIR_CHECK_VERSION(5, 5, 0)
10334 {(char *) "virNetworkListAllPorts", libvirt_virNetworkListAllPorts
, METH_VARARGS
, NULL
},
10335 {(char *) "virNetworkPortSetParameters", libvirt_virNetworkPortSetParameters
, METH_VARARGS
, NULL
},
10336 {(char *) "virNetworkPortGetParameters", libvirt_virNetworkPortGetParameters
, METH_VARARGS
, NULL
},
10337 #endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
10338 {NULL
, NULL
, 0, NULL
}
10341 #if PY_MAJOR_VERSION > 2
10342 static struct PyModuleDef moduledef
= {
10343 PyModuleDef_HEAD_INIT
,
10344 # ifndef __CYGWIN__
10359 # ifndef __CYGWIN__
10368 if (virInitialize() < 0)
10371 module
= PyModule_Create(&moduledef
);
10375 #else /* ! PY_MAJOR_VERSION > 2 */
10377 # ifndef __CYGWIN__
10384 if (virInitialize() < 0)
10387 /* initialize the python extension module */
10388 Py_InitModule((char *)
10389 # ifndef __CYGWIN__
10396 #endif /* ! PY_MAJOR_VERSION > 2 */