add restart framework

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Cedric Le Goater 2010-06-01 11:44:44 +02:00 committed by Daniel Lezcano
parent fac80c8f42
commit 196f1d54ce

View File

@ -20,13 +20,58 @@
* 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);
}