2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 08:09:38 +00:00

Merge git://github.com/lxc/lxc

This commit is contained in:
Daniel Lezcano
2012-12-14 09:42:21 +01:00
5 changed files with 23 additions and 9 deletions

View File

@@ -287,11 +287,9 @@ out_close:
goto out;
}
extern int lxc_command_mainloop_add(const char *name,
struct lxc_epoll_descr *descr,
struct lxc_handler *handler)
extern int lxc_command_init(const char *name, struct lxc_handler *handler)
{
int ret, fd;
int fd;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
char *offset = &path[1];
int rc, len;
@@ -320,6 +318,16 @@ extern int lxc_command_mainloop_add(const char *name,
return -1;
}
handler->conf->maincmd_fd = fd;
return 0;
}
extern int lxc_command_mainloop_add(const char *name,
struct lxc_epoll_descr *descr,
struct lxc_handler *handler)
{
int ret, fd = handler->conf->maincmd_fd;
ret = lxc_mainloop_add_handler(descr, fd, incoming_command_handler,
handler);
if (ret) {
@@ -327,6 +335,5 @@ extern int lxc_command_mainloop_add(const char *name,
close(fd);
}
handler->conf->maincmd_fd = fd;
return ret;
}

View File

@@ -60,6 +60,7 @@ extern int lxc_command_connected(const char *name, struct lxc_command *command,
struct lxc_epoll_descr;
struct lxc_handler;
extern int lxc_command_init(const char *name, struct lxc_handler *handler);
extern int lxc_command_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
struct lxc_handler *handler);

View File

@@ -1895,6 +1895,7 @@ struct lxc_conf *lxc_conf_init(void)
new->console.master = -1;
new->console.slave = -1;
new->console.name[0] = '\0';
new->maincmd_fd = -1;
new->rootfs.mount = default_rootfs_mount;
new->loglevel = LXC_LOG_PRIORITY_NOTSET;
lxc_list_init(&new->cgroup);

View File

@@ -381,9 +381,6 @@ reboot:
if (conf->reboot) {
INFO("container requested reboot");
conf->reboot = 0;
if (conf->maincmd_fd)
close(conf->maincmd_fd);
conf->maincmd_fd = 0;
goto reboot;
}

View File

@@ -377,9 +377,12 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
goto out_free;
}
if (lxc_command_init(name, handler))
goto out_free_name;
if (lxc_read_seccomp_config(conf) != 0) {
ERROR("failed loading seccomp policy");
goto out_free_name;
goto out_close_maincmd_fd;
}
/* Begin the set the state to STARTING*/
@@ -421,6 +424,9 @@ out_delete_tty:
lxc_delete_tty(&conf->tty_info);
out_aborting:
lxc_set_state(name, handler, ABORTING);
out_close_maincmd_fd:
close(conf->maincmd_fd);
conf->maincmd_fd = -1;
out_free_name:
free(handler->name);
handler->name = NULL;
@@ -446,6 +452,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
lxc_delete_console(&handler->conf->console);
lxc_delete_tty(&handler->conf->tty_info);
close(handler->conf->maincmd_fd);
handler->conf->maincmd_fd = -1;
free(handler->name);
free(handler);
}