Commit b0aedacb by Serge Hallyn Committed by Stéphane Graber

cgmanager updates

1. remove the cgm_dbus_disconnected handler. We're using a proxy anyway, and not keeping it around. 2. comment most of the cgm functions to describe when they are called, to ease locking review 3. the cgmanager mutex is now held for the duration of a connection, from cgm_dbus_connect to cgm_dbus_disconnect. 3b. so remove the mutex lock/unlock from functions which are called during container startup with the cgmanager connection already up 4. remove the cgroup_restart(). It's no longer needed since we don't daemonize while we have the cgmanager socket open. 5. report errors and return early if cgm_dbus_connect() fails 6. don't keep the cgm connection open after cgm_ops_init. I'm a bit torn on this one as it means that things like lxc-start will always connect twice. But if we do this there is no good answer, given threaded API users, on when to drop that initial connection. 7. cgm_unfreeze and nrtasks: grab the dbus connection, as we'll never have it at that point. (technically i doubt anyone will use cgmanager and utmp helper on the same host :) 8. lxc_spawn: make sure we only disconnect cgroups if they were already connected. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent f52d6fb5
......@@ -168,14 +168,6 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na
return -1;
}
void restart_cgroups(void)
{
if (ops && ops->disconnect)
ops->disconnect();
ops = NULL;
cgroup_ops_init();
}
void cgroup_disconnect(void)
{
if (ops && ops->disconnect)
......
......@@ -65,7 +65,6 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler);
extern int cgroup_nrtasks(struct lxc_handler *handler);
extern const char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem);
extern bool cgroup_unfreeze(struct lxc_handler *handler);
extern void restart_cgroups(void);
extern void cgroup_disconnect(void);
#endif
......@@ -637,7 +637,6 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);
setsid();
restart_cgroups();
} else {
if (!am_single_threaded()) {
ERROR("Cannot start non-daemonized container when threaded");
......
......@@ -773,6 +773,7 @@ static int lxc_spawn(struct lxc_handler *handler)
{
int failed_before_rename = 0;
const char *name = handler->name;
bool cgroups_connected = false;
int saved_ns_fd[LXC_NS_MAX];
int preserve_mask = 0, i;
int netpipepair[2], nveths;
......@@ -842,6 +843,8 @@ static int lxc_spawn(struct lxc_handler *handler)
goto out_delete_net;
}
cgroups_connected = true;
if (!cgroup_create(handler)) {
ERROR("failed creating cgroups");
goto out_delete_net;
......@@ -953,6 +956,7 @@ static int lxc_spawn(struct lxc_handler *handler)
}
cgroup_disconnect();
cgroups_connected = false;
/* Tell the child to complete its initialization and wait for
* it to exec or return an error. (the child will never
......@@ -981,6 +985,8 @@ static int lxc_spawn(struct lxc_handler *handler)
return 0;
out_delete_net:
if (cgroups_connected)
cgroup_disconnect();
if (handler->clone_flags & CLONE_NEWNET)
lxc_delete_network(handler);
out_abort:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment