HI,
I am trying to run LXC on Ubuntu 14.04 and LXC version 1.0.8. When I run
attached program with Valgrind, then call to c->start doesn't return. And I
get following warning continuously,
Warning: invalid file descriptor 1024 in syscall close()
==7897== at 0x5195F60: __close_nocancel (syscall-template.S:81)
==7897== by 0x4E526BC: lxc_check_inherited (in
/usr/lib/x86_64-linux-gnu/liblxc.so.1.0.8)
==7897== by 0x4E55840: lxc_monitord_spawn (in
/usr/lib/x86_64-linux-gnu/liblxc.so.1.0.8)
==7897== by 0x4E82659: ??? (in /usr/lib/x86_64-linux-gnu/liblxc.so.1.0.8)
I tried following Valgrind command
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes
--num-callers=20 --track-fds=yes -v ./container.
Any solution to this?
Adithya
#include <stdio.h>
#include <lxc/lxccontainer.h>
int main() {
struct lxc_container *c;
int ret = 1;
fprintf(stderr, "Container start\n");
/* Setup container struct */
c = lxc_container_new("test", "/tmp/container");
if (!c) {
fprintf(stderr, "Failed to setup lxc_container struct\n");
goto out;
}
fprintf(stderr, "Container start 1\n");
if (c->is_defined(c)) {
fprintf(stderr, "Container already exists\n");
goto out;
}
fprintf(stderr, "Container start 2\n");
if (!c->load_config(c, "/tmp/lxc.conf"))
{
// Failed to setup lxc_container struct.
fprintf(stderr, "Container config failed\n");
lxc_container_put(c);
return false;
}
fprintf(stderr, "Container start 3\n");
/* Create the container */
if (!c->create(c, "busybox", NULL, NULL, LXC_CREATE_QUIET, NULL)) {
fprintf(stderr, "Failed to create container rootfs\n");
goto out;
}
fprintf(stderr, "Container start 4\n");
/* Start the container */
if (!c->start(c, 0, NULL)) {
fprintf(stderr, "Failed to start the container\n");
goto out;
}
/* Query some information */
printf("Container state: %s\n", c->state(c));
printf("Container PID: %d\n", c->init_pid(c));
/* Stop the container */
if (!c->shutdown(c, 30)) {
printf("Failed to cleanly shutdown the container, forcing.\n");
if (!c->stop(c)) {
fprintf(stderr, "Failed to kill the container.\n");
goto out;
}
}
fprintf(stderr, "Container start 5\n");
/* Destroy the container */
if (!c->destroy(c)) {
fprintf(stderr, "Failed to destroy the container.\n");
goto out;
}
ret = 0;
out:
lxc_container_put(c);
return ret;
}
_______________________________________________
lxc-users mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-users