mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-14 12:47:41 +00:00
python3: Fix crashes in snapshot()
This makes sure all PyObject structs are always initialized to NULL, this will fix issues such as (issue #239). Also add a snapshot/list/restore testcase to the python3 api test code. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
0f84d97e6d
commit
4e31246a25
@ -180,6 +180,14 @@ assert(container.init_pid == -1)
|
|||||||
assert(not container.running)
|
assert(not container.running)
|
||||||
assert(container.state == "STOPPED")
|
assert(container.state == "STOPPED")
|
||||||
|
|
||||||
|
## Snapshotting the container
|
||||||
|
print("Snapshotting the container")
|
||||||
|
assert(not container.snapshot_list())
|
||||||
|
assert(container.snapshot() == "snap0")
|
||||||
|
assert(len(container.snapshot_list()) == 1)
|
||||||
|
assert(container.snapshot_restore("snap0") is True)
|
||||||
|
assert(container.snapshot_destroy("snap0") is True)
|
||||||
|
|
||||||
## Cloning the container
|
## Cloning the container
|
||||||
print("Cloning the container as '%s'" % CLONE_NAME)
|
print("Cloning the container as '%s'" % CLONE_NAME)
|
||||||
clone = container.clone(CLONE_NAME)
|
clone = container.clone(CLONE_NAME)
|
||||||
|
@ -148,7 +148,7 @@ static lxc_attach_options_t *lxc_attach_parse_options(PyObject *kwds)
|
|||||||
PyObject *stdout_obj = NULL;
|
PyObject *stdout_obj = NULL;
|
||||||
PyObject *stderr_obj = NULL;
|
PyObject *stderr_obj = NULL;
|
||||||
PyObject *initial_cwd_obj = NULL;
|
PyObject *initial_cwd_obj = NULL;
|
||||||
PyObject *dummy;
|
PyObject *dummy = NULL;
|
||||||
bool parse_result;
|
bool parse_result;
|
||||||
|
|
||||||
lxc_attach_options_t default_options = LXC_ATTACH_OPTIONS_DEFAULT;
|
lxc_attach_options_t default_options = LXC_ATTACH_OPTIONS_DEFAULT;
|
||||||
@ -257,7 +257,7 @@ static PyObject *
|
|||||||
LXC_arch_to_personality(PyObject *self, PyObject *arg)
|
LXC_arch_to_personality(PyObject *self, PyObject *arg)
|
||||||
{
|
{
|
||||||
long rv = -1;
|
long rv = -1;
|
||||||
PyObject *pystr;
|
PyObject *pystr = NULL;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (!PyUnicode_Check(arg)) {
|
if (!PyUnicode_Check(arg)) {
|
||||||
@ -737,7 +737,8 @@ Container_create(Container *self, PyObject *args, PyObject *kwds)
|
|||||||
char* template_name = NULL;
|
char* template_name = NULL;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
char** create_args = {NULL};
|
char** create_args = {NULL};
|
||||||
PyObject *retval = NULL, *vargs = NULL;
|
PyObject *retval = NULL;
|
||||||
|
PyObject *vargs = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
static char *kwlist[] = {"template", "flags", "args", NULL};
|
static char *kwlist[] = {"template", "flags", "args", NULL};
|
||||||
|
|
||||||
@ -1229,7 +1230,7 @@ Container_snapshot(Container *self, PyObject *args, PyObject *kwds)
|
|||||||
int retval = 0;
|
int retval = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char newname[20];
|
char newname[20];
|
||||||
PyObject *py_comment_path;
|
PyObject *py_comment_path = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
|
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
|
||||||
PyUnicode_FSConverter, &py_comment_path))
|
PyUnicode_FSConverter, &py_comment_path))
|
||||||
|
Loading…
Reference in New Issue
Block a user