]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add restart framework
authorCedric Le Goater <clg@vnet.ibm.com>
Tue, 1 Jun 2010 09:44:44 +0000 (11:44 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 1 Jun 2010 09:44:44 +0000 (11:44 +0200)
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/restart.c

index 2fbdabf3086733ca640bca2007a31cd4efe3fbc2..c947b81337ee5a765105e088d66284a5aa4b92f9 100644 (file)
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
-#include <lxc/lxc.h>
+
+#include "../config.h"
+#include <stdio.h>
+#undef _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
 #include <lxc/log.h>
+#include <lxc/start.h> /* for struct lxc_handler */
+#include <lxc/utils.h>
+#include <lxc/error.h>
 
 lxc_log_define(lxc_restart, lxc);
 
-int lxc_restart(const char *name, int sfd, struct lxc_conf *conf, int flags)
+struct restart_args {
+       int sfd;
+       int flags;
+};
+
+static int restart(struct lxc_handler *handler, void* data)
 {
+       struct restart_args *arg __attribute__ ((unused)) = data;
+
        ERROR("'restart' function not implemented");
        return -1;
 }
+
+static int post_restart(struct lxc_handler *handler, void* data)
+{
+       struct restart_args *arg __attribute__ ((unused)) = data;
+
+       NOTICE("'%s' container restarting with pid '%d'", handler->name,
+              handler->pid);
+       return 0;
+}
+
+static struct lxc_operations restart_ops = {
+       .start = restart,
+       .post_start = post_restart
+};
+
+int lxc_restart(const char *name, int sfd, struct lxc_conf *conf, int flags)
+{
+       struct restart_args restart_arg = {
+               .sfd = sfd,
+               .flags = flags
+       };
+
+       if (lxc_check_inherited(sfd))
+               return -1;
+
+       return __lxc_start(name, conf, &restart_ops, &restart_arg);
+}