]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
export-fine-grain-api-for-start
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 29 Apr 2009 15:49:04 +0000 (17:49 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 29 Apr 2009 15:49:04 +0000 (17:49 +0200)
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: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/Makefile.am
src/lxc/lxc.h
src/lxc/start.c
src/lxc/start.h [new file with mode: 0644]

index fe974d216663b26ab36686638954553c0fa370e0..09a981c727d1ce44213921f423811b4d264701eb 100644 (file)
@@ -4,6 +4,7 @@ INCLUDES= -I$(top_srcdir)/src -DLXCPATH="\"@LXCPATH@\"" \
 AM_LDFLAGS= -lutil
 lib_LTLIBRARIES = liblxc.la
 pkginclude_HEADERS = \
+               start.h \
                error.h \
                monitor.h \
                utils.h \
index e374678045c28d59c4f43aac5142c9592b82618d..2f45523ff58c26e93f535d9543d73fc9371227b1 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 #include <lxc/error.h>
 #include <lxc/cgroup.h>
 #include <lxc/monitor.h>
+#include <lxc/start.h>
 
 /*
  * Create the container object. Creates the /lxc/<name> directory
index 2b75c384b82ba0db5c35c02eee38675ef98a67c4..7c6e4faee36946450cb41f41393b216af63c4d83 100644 (file)
@@ -98,15 +98,6 @@ lxc_log_define(lxc_start, lxc);
 LXC_TTY_HANDLER(SIGINT);
 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)
 {
        sigset_t mask;
@@ -238,7 +229,7 @@ out_close:
        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 pid = handler->pid;
@@ -331,7 +322,7 @@ static void remove_init_pid(const char *name, pid_t pid)
        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;
 
@@ -382,7 +373,7 @@ out_put_lock:
        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
         * which can take awhile
@@ -403,13 +394,13 @@ static void lxc_fini(const char *name, struct lxc_handler *handler)
        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);
        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 clone_flags;
@@ -560,8 +551,8 @@ int lxc_start(const char *name, char *argv[])
                goto out_abort;
        }
 
-       waitpid(handler.pid, &status, 0);
-
+       while (waitpid(handler.pid, &status, 0) < 0 && errno == EINTR)
+               continue;
        err = 0;
 out:
        lxc_fini(name, &handler);
diff --git a/src/lxc/start.h b/src/lxc/start.h
new file mode 100644 (file)
index 0000000..9eccc33
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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);
+
+
+