lxc.c revision 1b03969c7ce75d7d88fe88d25fa74febb89bea98
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * python-lxc: Python bindings for LXC
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (C) Copyright Canonical Ltd. 2012-2013
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Stéphane Graber <stgraber@ubuntu.com>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This library is free software; you can redistribute it and/or
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * modify it under the terms of the GNU Lesser General Public
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * License as published by the Free Software Foundation; either
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * version 2.1 of the License, or (at your option) any later version.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This library is distributed in the hope that it will be useful,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Lesser General Public License for more details.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You should have received a copy of the GNU Lesser General Public
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * License along with this library; if not, write to the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Helper functions */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncconvert_tuple_to_char_pointer_array(PyObject *argv) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* not a list or tuple */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync PyErr_SetString(PyExc_TypeError, "Expected list or tuple.");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char **result = (char**) calloc(argc + 1, sizeof(char*));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (i = 0; i < argc; i++) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync PyObject *pyobj = PySequence_Fast_GET_ITEM(argv, i);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync PyErr_SetString(PyExc_ValueError, "Expected a string");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Maybe it wasn't UTF-8 encoded. An exception is already set. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Maybe pystr wasn't a valid object. An exception is already set.
goto error;
return result;
return NULL;
struct lxc_attach_python_payload {
if (!result) {
PyErr_Print();
int temp_env_policy;
bool parse_result;
if (!options) {
return NULL;
&stderr_obj);
if (!parse_result) {
return NULL;
if (extra_env_vars_obj)
if (extra_keep_env_obj)
if (stdin_obj) {
return NULL;
if (stdout_obj) {
return NULL;
if (stderr_obj) {
return NULL;
return options;
if (!options)
static PyObject *
char *str;
return NULL;
if (!pystr)
return NULL;
if (!str)
goto out;
out:
static PyObject *
int i, rv;
return NULL;
return NULL;
return NULL;
static PyObject *
int rv;
static PyObject *
&key))
return NULL;
if (!value) {
return NULL;
static PyObject *
static PyObject *
int list_count = 0;
return NULL;
list_active = 0;
list_defined = 0;
if (list_count < 0) {
return NULL;
for (i = 0; i < list_count; i++) {
return list;
} Container;
&name,
static PyObject *
static PyObject *
return PyUnicode_FromString(
static PyObject *
static PyObject *
static PyObject *
static PyObject *
static PyObject *
static PyObject *
static PyObject *
return NULL;
dst_path)) {
static PyObject *
long ret;
return NULL;
return NULL;
if (!options)
return NULL;
if (ret < 0)
goto out;
if (wait) {
out:
static PyObject *
static PyObject *
static PyObject *
static PyObject *
&key))
return NULL;
static PyObject *
int flags = 0;
unsigned long newsize = 0;
&newname,
&py_hookargs))
return NULL;
if (py_hookargs) {
if (!hookargs) {
return NULL;
return NULL;
if (hookargs) {
static PyObject *
&escape))
return NULL;
static PyObject *
return NULL;
&masterfd) < 0) {
return NULL;
static PyObject *
int flags = 0;
return NULL;
if (vargs) {
if (!create_args) {
return NULL;
return NULL;
if (vargs) {
return retval;
static PyObject *
static PyObject *
static PyObject *
int len = 0;
&key))
return NULL;
if (len < 0) {
return NULL;
return PyErr_NoMemory();
return NULL;
return ret;
static PyObject *
int len = 0;
&key))
return NULL;
if (len < 0) {
return NULL;
if (len == 0) {
return PyErr_NoMemory();
return NULL;
return ret;
static PyObject *
return PyUnicode_FromString(
static PyObject *
int len = 0;
&key))
return NULL;
if (len < 0) {
return NULL;
return PyErr_NoMemory();
return NULL;
return ret;
static PyObject *
if (!interfaces)
return PyTuple_New(0);
while (interfaces[i])
if (!ret)
return NULL;
while (interfaces[i]) {
if (!unicode) {
while (interfaces[i]) {
return ret;
static PyObject *
int scope = 0;
return NULL;
if (!ips)
return PyTuple_New(0);
while (ips[i])
if (!ret)
return NULL;
while (ips[i]) {
if (!unicode) {
while (ips[i]) {
return ret;
static PyObject *
&key))
return NULL;
if (!value)
return ret;
static PyObject *
return NULL;
static PyObject *
static PyObject *
&new_name))
return NULL;
static PyObject *
return NULL;
dst_path)) {
static PyObject *
return NULL;
static PyObject *
return NULL;
static PyObject *
return NULL;
static PyObject *
&path))
return NULL;
static PyObject *
&timeout))
return NULL;
static PyObject *
int retval = 0;
int ret = 0;
return NULL;
if (retval < 0) {
return NULL;
static PyObject *
&name))
return NULL;
static PyObject *
int snap_count = 0;
if (snap_count < 0) {
return NULL;
for (i = 0; i < snap_count; i++) {
return list;
static PyObject *
return NULL;
static PyObject *
int init_useinit = 0, i = 0;
&vargs))
return NULL;
if (!init_args) {
return NULL;
if (vargs) {
return retval;
static PyObject *
static PyObject *
static PyObject *
return NULL;
/* Function/Properties list */
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
PyInit__lxc(void)
PyObject* m;
PyObject* d;
return NULL;
if (m == NULL)
return NULL;
d = PyModule_GetDict(m);
#define PYLXC_EXPORT_CONST(c) \