Commit 1bc5cc8c by Daniel Lezcano

export-fine-grain-api-for-start

Export the fine grain api of lxc to be usable for external component which wants to have more control on the container. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 59eb99ba
...@@ -4,6 +4,7 @@ INCLUDES= -I$(top_srcdir)/src -DLXCPATH="\"@LXCPATH@\"" \ ...@@ -4,6 +4,7 @@ INCLUDES= -I$(top_srcdir)/src -DLXCPATH="\"@LXCPATH@\"" \
AM_LDFLAGS= -lutil AM_LDFLAGS= -lutil
lib_LTLIBRARIES = liblxc.la lib_LTLIBRARIES = liblxc.la
pkginclude_HEADERS = \ pkginclude_HEADERS = \
start.h \
error.h \ error.h \
monitor.h \ monitor.h \
utils.h \ utils.h \
......
...@@ -43,6 +43,7 @@ extern "C" { ...@@ -43,6 +43,7 @@ extern "C" {
#include <lxc/error.h> #include <lxc/error.h>
#include <lxc/cgroup.h> #include <lxc/cgroup.h>
#include <lxc/monitor.h> #include <lxc/monitor.h>
#include <lxc/start.h>
/* /*
* Create the container object. Creates the /lxc/<name> directory * Create the container object. Creates the /lxc/<name> directory
......
...@@ -98,15 +98,6 @@ lxc_log_define(lxc_start, lxc); ...@@ -98,15 +98,6 @@ lxc_log_define(lxc_start, lxc);
LXC_TTY_HANDLER(SIGINT); LXC_TTY_HANDLER(SIGINT);
LXC_TTY_HANDLER(SIGQUIT); LXC_TTY_HANDLER(SIGQUIT);
struct lxc_handler {
int sigfd;
int lock;
pid_t pid;
char tty[MAXPATHLEN];
sigset_t oldmask;
struct lxc_tty_info tty_info;
};
static int setup_sigchld_fd(sigset_t *oldmask) static int setup_sigchld_fd(sigset_t *oldmask)
{ {
sigset_t mask; sigset_t mask;
...@@ -238,7 +229,7 @@ out_close: ...@@ -238,7 +229,7 @@ out_close:
goto out; goto out;
} }
static int lxc_poll(const char *name, struct lxc_handler *handler) int lxc_poll(const char *name, struct lxc_handler *handler)
{ {
int sigfd = handler->sigfd; int sigfd = handler->sigfd;
int pid = handler->pid; int pid = handler->pid;
...@@ -331,7 +322,7 @@ static void remove_init_pid(const char *name, pid_t pid) ...@@ -331,7 +322,7 @@ static void remove_init_pid(const char *name, pid_t pid)
unlink(init); unlink(init);
} }
static int lxc_init(const char *name, struct lxc_handler *handler) int lxc_init(const char *name, struct lxc_handler *handler)
{ {
int err = -1; int err = -1;
...@@ -382,7 +373,7 @@ out_put_lock: ...@@ -382,7 +373,7 @@ out_put_lock:
goto out; goto out;
} }
static void lxc_fini(const char *name, struct lxc_handler *handler) void lxc_fini(const char *name, struct lxc_handler *handler)
{ {
/* The STOPPING state is there for future cleanup code /* The STOPPING state is there for future cleanup code
* which can take awhile * which can take awhile
...@@ -403,13 +394,13 @@ static void lxc_fini(const char *name, struct lxc_handler *handler) ...@@ -403,13 +394,13 @@ static void lxc_fini(const char *name, struct lxc_handler *handler)
LXC_TTY_DEL_HANDLER(SIGINT); LXC_TTY_DEL_HANDLER(SIGINT);
} }
static void lxc_abort(const char *name, struct lxc_handler *handler) void lxc_abort(const char *name, struct lxc_handler *handler)
{ {
lxc_setstate(name, ABORTING); lxc_setstate(name, ABORTING);
kill(handler->pid, SIGKILL); kill(handler->pid, SIGKILL);
} }
static int lxc_spawn(const char *name, struct lxc_handler *handler, char *argv[]) int lxc_spawn(const char *name, struct lxc_handler *handler, char *argv[])
{ {
int sv[2]; int sv[2];
int clone_flags; int clone_flags;
...@@ -560,8 +551,8 @@ int lxc_start(const char *name, char *argv[]) ...@@ -560,8 +551,8 @@ int lxc_start(const char *name, char *argv[])
goto out_abort; goto out_abort;
} }
waitpid(handler.pid, &status, 0); while (waitpid(handler.pid, &status, 0) < 0 && errno == EINTR)
continue;
err = 0; err = 0;
out: out:
lxc_fini(name, &handler); lxc_fini(name, &handler);
......
/*
* lxc: linux Container library
*
* (C) Copyright IBM Corp. 2007, 2008
*
* Authors:
* Daniel Lezcano <dlezcano at fr.ibm.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
struct lxc_handler {
int sigfd;
int lock;
pid_t pid;
char tty[MAXPATHLEN];
sigset_t oldmask;
struct lxc_tty_info tty_info;
};
extern int lxc_init(const char *name, struct lxc_handler *handler);
extern int lxc_spawn(const char *name, struct lxc_handler *handler,
char *argv[]);
extern int lxc_poll(const char *name, struct lxc_handler *handler);
extern void lxc_abort(const char *name, struct lxc_handler *handler);
extern void lxc_fini(const char *name, struct lxc_handler *handler);
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