#include <net/if.h>
#include <libgen.h>
+#include "network.h"
+#include "error.h"
+
#include <lxc/lxc.h>
-#include <network.h>
+
#define MAXHWLEN 18
#define MAXINDEXLEN 20
if (conf->utsname && configure_utsname(name, conf->utsname)) {
lxc_log_error("failed to configure the utsname");
- return -1;
+ return -LXC_ERROR_CONF_UTSNAME;
}
if (configure_cgroup(name, &conf->cgroup)) {
lxc_log_error("failed to configure the control group");
- return -1;
+ return -LXC_ERROR_CONF_CGROUP;
}
if (configure_network(name, &conf->networks)) {
lxc_log_error("failed to configure the network");
- return -1;
+ return -LXC_ERROR_CONF_NETWORK;
}
if (conf->rootfs && configure_rootfs(name, conf->rootfs)) {
lxc_log_error("failed to configure the rootfs");
- return -1;
+ return -LXC_ERROR_CONF_ROOTFS;
}
if (conf->fstab && configure_mount(name, conf->fstab)) {
lxc_log_error("failed to configure the mount points");
- return -1;
+ return -LXC_ERROR_CONF_MOUNT;
}
return 0;
{
if (conf_has_utsname(name) && setup_utsname(name)) {
lxc_log_error("failed to setup the utsname for '%s'", name);
- return -1;
+ return -LXC_ERROR_SETUP_UTSNAME;
}
if (conf_has_network(name) && setup_network(name)) {
lxc_log_error("failed to setup the network for '%s'", name);
- return -1;
+ return -LXC_ERROR_SETUP_NETWORK;
}
if (conf_has_cgroup(name) && setup_cgroup(name)) {
lxc_log_error("failed to setup the cgroups for '%s'", name);
- return -1;
+ return -LXC_ERROR_SETUP_CGROUP;
}
if (conf_has_fstab(name) && setup_mount(name)) {
lxc_log_error("failed to setup the mount points for '%s'", name);
- return -1;
+ return -LXC_ERROR_SETUP_MOUNT;
}
if (conf_has_rootfs(name) && setup_rootfs(name)) {
lxc_log_error("failed to set rootfs for '%s'", name);
- return -1;
+ return -LXC_ERROR_SETUP_ROOTFS;
}
return 0;
int clone_flags;
lock = lxc_get_lock(name);
- if (lock < 0)
- return lock == -EWOULDBLOCK ?
- -LXC_ERROR_BUSY :
- -LXC_ERROR_LOCK;
+ if (lock < 0) {
+ if (lock == -EWOULDBLOCK)
+ return -LXC_ERROR_BUSY;
+ if (lock == -ENOENT)
+ return -LXC_ERROR_NOT_FOUND;
+ return -LXC_ERROR_LOCK;
+ }
/* Begin the set the state to STARTING*/
if (lxc_setstate(name, STARTING)) {
goto out;
}
-
/* Synchro socketpair */
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) {
lxc_log_syserror("failed to create communication socketpair");
}
/* Setup the container, ip, names, utsname, ... */
- if (lxc_setup(name)) {
+ err = lxc_setup(name);
+ if (err) {
lxc_log_error("failed to setup the container");
- if (write(sv[0], &sync, sizeof(sync)) < 0)
+ if (write(sv[0], &err, sizeof(err)) < 0)
lxc_log_syserror("failed to write the socket");
goto out_child;
}
lxc_log_syserror("failed to exec %s", argv[0]);
/* If the exec fails, tell that to our father */
- if (write(sv[0], &sync, sizeof(sync)) < 0)
+ if (write(sv[0], &err, sizeof(err)) < 0)
lxc_log_syserror("failed to write the socket");
out_child:
- exit(1);
+ exit(err);
}
close(sv[0]);
}
if (err > 0) {
- lxc_log_error("something went wrong with %d", pid);
+ err = sync;
+ printf("error value is %d\n", err);
/* TODO : check status etc ... */
waitpid(pid, NULL, 0);
goto err_child_failed;