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) 2012-2019 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/python3.x/pyconfig*.h,
14 which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
18 #include <libvirt/libvirt-lxc.h>
19 #include <libvirt/virterror.h>
20 #include "typewrappers.h"
21 #include "libvirt-utils.h"
22 #include "libvirt-lxc.h"
25 # define DEBUG_ERROR 1
29 # define DEBUG(fmt, ...) \
30 printf(fmt, __VA_ARGS__)
32 # define DEBUG(fmt, ...) \
33 while (0) {printf(fmt, __VA_ARGS__);}
36 /************************************************************************
40 ************************************************************************/
43 libvirt_lxc_virDomainLxcOpenNamespace(PyObject
*self ATTRIBUTE_UNUSED
,
48 PyObject
*pyobj_domain
;
54 if (!PyArg_ParseTuple(args
, (char *)"OI:virDomainLxcOpenNamespace",
55 &pyobj_domain
, &flags
))
57 domain
= (virDomainPtr
) PyvirDomain_Get(pyobj_domain
);
61 LIBVIRT_BEGIN_ALLOW_THREADS
;
62 c_retval
= virDomainLxcOpenNamespace(domain
, &fdlist
, flags
);
63 LIBVIRT_END_ALLOW_THREADS
;
68 if ((py_retval
= PyList_New(0)) == NULL
)
71 for (i
= 0; i
< c_retval
; i
++)
72 VIR_PY_LIST_APPEND_GOTO(py_retval
, libvirt_intWrap(fdlist
[i
]), error
);
79 for (i
= 0; i
< c_retval
; i
++) {
80 VIR_FORCE_CLOSE(fdlist
[i
]);
85 /************************************************************************
87 * The registration stuff *
89 ************************************************************************/
90 static PyMethodDef libvirtLxcMethods
[] = {
91 #include "libvirt-lxc-export.c.inc"
92 {(char *) "virDomainLxcOpenNamespace", libvirt_lxc_virDomainLxcOpenNamespace
, METH_VARARGS
, NULL
},
96 static struct PyModuleDef moduledef
= {
97 PyModuleDef_HEAD_INIT
,
114 PyInit_libvirtmod_lxc
116 PyInit_cygvirtmod_lxc
122 if (virInitialize() < 0)
125 module
= PyModule_Create(&moduledef
);