On Thu, Nov 07, 2013 at 10:20:33PM -0600, Serge Hallyn wrote: > lxc-start is not safe (and doesn't actually make sense) if the > task is nto single-threaded. > > Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com>
Acked-by: Stéphane Graber <stgra...@ubuntu.com> > --- > src/lxc/lxccontainer.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c > index 05e5405..827cae0 100644 > --- a/src/lxc/lxccontainer.c > +++ b/src/lxc/lxccontainer.c > @@ -506,6 +506,38 @@ static bool wait_on_daemonized_start(struct > lxc_container *c) > return lxcapi_wait(c, "RUNNING", timeout); > } > > +static bool am_single_threaded(void) > +{ > + struct dirent dirent, *direntp; > + DIR *dir; > + int count=0; > + > + process_lock(); > + dir = opendir("/proc/self/task"); > + process_unlock(); > + if (!dir) { > + INFO("failed to open /proc/self/task"); > + return false; > + } > + > + while (!readdir_r(dir, &dirent, &direntp)) { > + if (!direntp) > + break; > + > + if (!strcmp(direntp->d_name, ".")) > + continue; > + > + if (!strcmp(direntp->d_name, "..")) > + continue; > + if (++count > 1) > + break; > + } > + process_lock(); > + closedir(dir); > + process_unlock(); > + return count == 1; > +} > + > /* > * I can't decide if it'd be more convenient for callers if we accept '...', > * or a null-terminated array (i.e. execl vs execv) > @@ -598,6 +630,11 @@ static bool lxcapi_start(struct lxc_container *c, int > useinit, char * const argv > open("/dev/null", O_RDWR); > open("/dev/null", O_RDWR); > setsid(); > + } else { > + if (!am_single_threaded()) { > + ERROR("Cannot start non-daemonized container when > threaded"); > + return false; > + } > } > > reboot: > -- > 1.8.3.2 > > > ------------------------------------------------------------------------------ > November Webinars for C, C++, Fortran Developers > Accelerate application performance with scalable programming models. Explore > techniques for threading, error checking, porting, and tuning. Get the most > from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk > _______________________________________________ > Lxc-devel mailing list > Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel