2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include <sys/param.h>
38 #include <sys/mount.h>
40 #include <sys/types.h>
41 #include <sys/socket.h>
42 #include <sys/prctl.h>
43 #include <sys/types.h>
47 #include <sys/syscall.h>
49 #if HAVE_SYS_CAPABILITY_H
50 #include <sys/capability.h>
53 #ifdef HAVE_SYS_SIGNALFD_H
54 # include <sys/signalfd.h>
56 /* assume kernel headers are too old */
58 struct signalfd_siginfo
79 # ifndef __NR_signalfd4
80 /* assume kernel headers are too old */
82 # define __NR_signalfd4 327
84 # define __NR_signalfd4 289
86 # define __NR_signalfd4 313
88 # define __NR_signalfd4 322
92 # ifndef __NR_signalfd
93 /* assume kernel headers are too old */
95 # define __NR_signalfd 321
97 # define __NR_signalfd 282
99 # define __NR_signalfd 305
101 # define __NR_signalfd 316
105 int signalfd(int fd
, const sigset_t
*mask
, int flags
)
109 retval
= syscall (__NR_signalfd4
, fd
, mask
, _NSIG
/ 8, flags
);
110 if (errno
== ENOSYS
&& flags
== 0)
111 retval
= syscall (__NR_signalfd
, fd
, mask
, _NSIG
/ 8);
116 #if !HAVE_DECL_PR_CAPBSET_DROP
117 #define PR_CAPBSET_DROP 24
126 #include "mainloop.h"
130 #include "commands.h"
133 #include "namespace.h"
134 #include "apparmor.h"
135 #include "lxcseccomp.h"
138 lxc_log_define(lxc_start
, lxc
);
140 static int match_fd(int fd
)
142 return (fd
== 0 || fd
== 1 || fd
== 2);
145 int lxc_check_inherited(struct lxc_conf
*conf
, int fd_to_ignore
)
147 struct dirent dirent
, *direntp
;
152 dir
= opendir("/proc/self/fd");
154 WARN("failed to open directory: %m");
160 while (!readdir_r(dir
, &dirent
, &direntp
)) {
164 if (!strcmp(direntp
->d_name
, "."))
167 if (!strcmp(direntp
->d_name
, ".."))
170 fd
= atoi(direntp
->d_name
);
172 if (fd
== fddir
|| fd
== lxc_log_fd
|| fd
== fd_to_ignore
)
178 if (conf
->close_all_fds
) {
181 INFO("closed inherited fd %d", fd
);
184 WARN("inherited fd %d", fd
);
187 closedir(dir
); /* cannot fail */
191 static int setup_signal_fd(sigset_t
*oldmask
)
196 /* Block everything except serious error signals */
197 if (sigfillset(&mask
) ||
198 sigdelset(&mask
, SIGILL
) ||
199 sigdelset(&mask
, SIGSEGV
) ||
200 sigdelset(&mask
, SIGBUS
) ||
201 sigprocmask(SIG_BLOCK
, &mask
, oldmask
)) {
202 SYSERROR("failed to set signal mask");
206 fd
= signalfd(-1, &mask
, 0);
208 SYSERROR("failed to create the signal fd");
212 if (fcntl(fd
, F_SETFD
, FD_CLOEXEC
)) {
213 SYSERROR("failed to set sigfd to close-on-exec");
218 DEBUG("sigchild handler set");
223 static int signal_handler(int fd
, void *data
,
224 struct lxc_epoll_descr
*descr
)
226 struct signalfd_siginfo siginfo
;
230 ret
= read(fd
, &siginfo
, sizeof(siginfo
));
232 ERROR("failed to read signal info");
236 if (ret
!= sizeof(siginfo
)) {
237 ERROR("unexpected siginfo size");
241 if (siginfo
.ssi_signo
!= SIGCHLD
) {
242 kill(*pid
, siginfo
.ssi_signo
);
243 INFO("forwarded signal %d to pid %d", siginfo
.ssi_signo
, *pid
);
247 if (siginfo
.ssi_code
== CLD_STOPPED
||
248 siginfo
.ssi_code
== CLD_CONTINUED
) {
249 INFO("container init process was stopped/continued");
253 /* more robustness, protect ourself from a SIGCHLD sent
254 * by a process different from the container init
256 if (siginfo
.ssi_pid
!= *pid
) {
257 WARN("invalid pid for SIGCHLD");
261 DEBUG("container init process exited");
265 int lxc_pid_callback(int fd
, struct lxc_request
*request
,
266 struct lxc_handler
*handler
)
268 struct lxc_answer answer
;
271 memset(&answer
, 0, sizeof(answer
));
272 answer
.pid
= handler
->pid
;
275 ret
= send(fd
, &answer
, sizeof(answer
), 0);
277 WARN("failed to send answer to the peer");
281 if (ret
!= sizeof(answer
)) {
282 ERROR("partial answer sent");
289 int lxc_cgroup_callback(int fd
, struct lxc_request
*request
,
290 struct lxc_handler
*handler
)
292 struct lxc_answer answer
;
295 memset(&answer
, 0, sizeof(answer
));
296 answer
.pathlen
= strlen(handler
->cgroup
) + 1;
297 answer
.path
= handler
->cgroup
;
300 ret
= send(fd
, &answer
, sizeof(answer
), 0);
302 WARN("failed to send answer to the peer");
306 if (ret
!= sizeof(answer
)) {
307 ERROR("partial answer sent");
311 ret
= send(fd
, answer
.path
, answer
.pathlen
, 0);
313 WARN("failed to send answer to the peer");
317 if (ret
!= answer
.pathlen
) {
318 ERROR("partial answer sent");
325 int lxc_clone_flags_callback(int fd
, struct lxc_request
*request
,
326 struct lxc_handler
*handler
)
328 struct lxc_answer answer
;
331 memset(&answer
, 0, sizeof(answer
));
333 answer
.ret
= handler
->clone_flags
;
335 ret
= send(fd
, &answer
, sizeof(answer
), 0);
337 WARN("failed to send answer to the peer");
341 if (ret
!= sizeof(answer
)) {
342 ERROR("partial answer sent");
349 int lxc_set_state(const char *name
, struct lxc_handler
*handler
, lxc_state_t state
)
351 handler
->state
= state
;
352 lxc_monitor_send_state(name
, state
, handler
->lxcpath
);
356 int lxc_poll(const char *name
, struct lxc_handler
*handler
)
358 int sigfd
= handler
->sigfd
;
359 int pid
= handler
->pid
;
360 struct lxc_epoll_descr descr
;
362 if (lxc_mainloop_open(&descr
)) {
363 ERROR("failed to create mainloop");
367 if (lxc_mainloop_add_handler(&descr
, sigfd
, signal_handler
, &pid
)) {
368 ERROR("failed to add handler for the signal");
369 goto out_mainloop_open
;
372 if (lxc_console_mainloop_add(&descr
, handler
)) {
373 ERROR("failed to add console handler to mainloop");
374 goto out_mainloop_open
;
377 if (lxc_command_mainloop_add(name
, &descr
, handler
)) {
378 ERROR("failed to add command handler to mainloop");
379 goto out_mainloop_open
;
382 if (handler
->conf
->need_utmp_watch
) {
383 #if HAVE_SYS_CAPABILITY_H
384 if (lxc_utmp_mainloop_add(&descr
, handler
)) {
385 ERROR("failed to add utmp handler to mainloop");
386 goto out_mainloop_open
;
389 DEBUG("not starting utmp handler as cap_sys_boot cannot be dropped without capabilities support\n");
393 return lxc_mainloop(&descr
);
396 lxc_mainloop_close(&descr
);
402 extern int lxc_caps_check(void);
404 struct lxc_handler
*lxc_init(const char *name
, struct lxc_conf
*conf
, const char *lxcpath
)
406 struct lxc_handler
*handler
;
408 if (!lxc_caps_check()) {
409 ERROR("Not running with sufficient privilege");
413 handler
= malloc(sizeof(*handler
));
417 memset(handler
, 0, sizeof(*handler
));
419 handler
->conf
= conf
;
420 handler
->lxcpath
= lxcpath
;
422 apparmor_handler_init(handler
);
423 handler
->name
= strdup(name
);
424 if (!handler
->name
) {
425 ERROR("failed to allocate memory");
429 if (lxc_command_init(name
, handler
, lxcpath
))
432 if (lxc_read_seccomp_config(conf
) != 0) {
433 ERROR("failed loading seccomp policy");
434 goto out_close_maincmd_fd
;
437 /* Begin the set the state to STARTING*/
438 if (lxc_set_state(name
, handler
, STARTING
)) {
439 ERROR("failed to set state '%s'", lxc_state2str(STARTING
));
443 /* Start of environment variable setup for hooks */
444 if (setenv("LXC_NAME", name
, 1)) {
445 SYSERROR("failed to set environment variable for container name");
447 if (setenv("LXC_CONFIG_FILE", conf
->rcfile
, 1)) {
448 SYSERROR("failed to set environment variable for config path");
450 if (setenv("LXC_ROOTFS_MOUNT", conf
->rootfs
.mount
, 1)) {
451 SYSERROR("failed to set environment variable for rootfs mount");
453 if (setenv("LXC_ROOTFS_PATH", conf
->rootfs
.path
, 1)) {
454 SYSERROR("failed to set environment variable for rootfs mount");
456 if (conf
->console
.path
&& setenv("LXC_CONSOLE", conf
->console
.path
, 1)) {
457 SYSERROR("failed to set environment variable for console path");
459 if (conf
->console
.log_path
&& setenv("LXC_CONSOLE_LOGPATH", conf
->console
.log_path
, 1)) {
460 SYSERROR("failed to set environment variable for console log");
462 /* End of environment variable setup for hooks */
464 if (run_lxc_hooks(name
, "pre-start", conf
)) {
465 ERROR("failed to run pre-start hooks for container '%s'.", name
);
469 if (lxc_create_tty(name
, conf
)) {
470 ERROR("failed to create the ttys");
474 if (lxc_create_console(conf
)) {
475 ERROR("failed to create console");
479 /* the signal fd has to be created before forking otherwise
480 * if the child process exits before we setup the signal fd,
481 * the event will be lost and the command will be stuck */
482 handler
->sigfd
= setup_signal_fd(&handler
->oldmask
);
483 if (handler
->sigfd
< 0) {
484 ERROR("failed to set sigchild fd handler");
485 goto out_delete_console
;
488 INFO("'%s' is initialized", name
);
492 lxc_delete_console(&conf
->console
);
494 lxc_delete_tty(&conf
->tty_info
);
496 lxc_set_state(name
, handler
, ABORTING
);
497 out_close_maincmd_fd
:
498 close(conf
->maincmd_fd
);
499 conf
->maincmd_fd
= -1;
502 handler
->name
= NULL
;
508 static void lxc_fini(const char *name
, struct lxc_handler
*handler
)
510 /* The STOPPING state is there for future cleanup code
511 * which can take awhile
513 lxc_set_state(name
, handler
, STOPPING
);
514 lxc_set_state(name
, handler
, STOPPED
);
516 if (run_lxc_hooks(name
, "post-stop", handler
->conf
))
517 ERROR("failed to run post-stop hooks for container '%s'.", name
);
519 /* reset mask set by setup_signal_fd */
520 if (sigprocmask(SIG_SETMASK
, &handler
->oldmask
, NULL
))
521 WARN("failed to restore sigprocmask");
523 lxc_delete_console(&handler
->conf
->console
);
524 lxc_delete_tty(&handler
->conf
->tty_info
);
525 close(handler
->conf
->maincmd_fd
);
526 handler
->conf
->maincmd_fd
= -1;
528 if (handler
->cgroup
) {
529 lxc_cgroup_destroy(handler
->cgroup
);
530 free(handler
->cgroup
);
531 handler
->cgroup
= NULL
;
536 void lxc_abort(const char *name
, struct lxc_handler
*handler
)
538 lxc_set_state(name
, handler
, ABORTING
);
539 if (handler
->pid
> 0)
540 kill(handler
->pid
, SIGKILL
);
543 #include <sys/reboot.h>
544 #include <linux/reboot.h>
547 * reboot(LINUX_REBOOT_CMD_CAD_ON) will return -EINVAL
548 * in a child pid namespace if container reboot support exists.
549 * Otherwise, it will either succeed or return -EPERM.
551 static int container_reboot_supported(void *arg
)
557 if (ret
== -1 && errno
== EINVAL
)
562 static int must_drop_cap_sys_boot(void)
564 FILE *f
= fopen("/proc/sys/kernel/ctrl-alt-del", "r");
566 long stack_size
= 4096;
567 void *stack
= alloca(stack_size
);
572 DEBUG("failed to open /proc/sys/kernel/ctrl-alt-del");
576 ret
= fscanf(f
, "%d", &v
);
579 DEBUG("Failed to read /proc/sys/kernel/ctrl-alt-del");
582 cmd
= v
? LINUX_REBOOT_CMD_CAD_ON
: LINUX_REBOOT_CMD_CAD_OFF
;
585 pid
= __clone2(container_reboot_supported
, stack
, stack_size
, CLONE_NEWPID
| SIGCHLD
, &cmd
);
588 pid
= clone(container_reboot_supported
, stack
, CLONE_NEWPID
| SIGCHLD
, &cmd
);
591 SYSERROR("failed to clone\n");
594 if (wait(&status
) < 0) {
595 SYSERROR("unexpected wait error: %m\n");
599 if (WEXITSTATUS(status
) != 1)
605 static int do_start(void *data
)
607 struct lxc_handler
*handler
= data
;
609 if (sigprocmask(SIG_SETMASK
, &handler
->oldmask
, NULL
)) {
610 SYSERROR("failed to set sigprocmask");
614 /* This prctl must be before the synchro, so if the parent
615 * dies before we set the parent death signal, we will detect
616 * its death with the synchro right after, otherwise we have
617 * a window where the parent can exit before we set the pdeath
618 * signal leading to a unsupervized container.
620 if (prctl(PR_SET_PDEATHSIG
, SIGKILL
, 0, 0, 0)) {
621 SYSERROR("failed to set pdeath signal");
625 lxc_sync_fini_parent(handler
);
627 /* don't leak the pinfd to the container */
628 if (handler
->pinfd
>= 0)
629 close(handler
->pinfd
);
631 /* Tell the parent task it can begin to configure the
632 * container and wait for it to finish
634 if (lxc_sync_barrier_parent(handler
, LXC_SYNC_CONFIGURE
))
638 * if we are in a new user namespace, become root there to have
639 * privilege over our namespace
641 if (!lxc_list_empty(&handler
->conf
->id_map
)) {
642 NOTICE("switching to gid/uid 0 in new user namespace");
645 goto out_warn_father
;
649 goto out_warn_father
;
653 #if HAVE_SYS_CAPABILITY_H
654 if (handler
->conf
->need_utmp_watch
) {
655 if (prctl(PR_CAPBSET_DROP
, CAP_SYS_BOOT
, 0, 0, 0)) {
656 SYSERROR("failed to remove CAP_SYS_BOOT capability");
657 goto out_warn_father
;
659 DEBUG("Dropped cap_sys_boot\n");
663 /* Setup the container, ip, names, utsname, ... */
664 if (lxc_setup(handler
->name
, handler
->conf
)) {
665 ERROR("failed to setup the container");
666 goto out_warn_father
;
669 /* ask father to setup cgroups and wait for him to finish */
670 if (lxc_sync_barrier_parent(handler
, LXC_SYNC_CGROUP
))
673 if (apparmor_load(handler
) < 0)
674 goto out_warn_father
;
676 if (lxc_seccomp_load(handler
->conf
) != 0)
677 goto out_warn_father
;
679 if (run_lxc_hooks(handler
->name
, "start", handler
->conf
)) {
680 ERROR("failed to run start hooks for container '%s'.", handler
->name
);
681 goto out_warn_father
;
684 /* The clearenv() and putenv() calls have been moved here
685 * to allow us to use enviroment variables passed to the various
686 * hooks, such as the start hook above. Not all of the
687 * variables like CONFIG_PATH or ROOTFS are valid in this
688 * context but others are. */
690 SYSERROR("failed to clear environment");
691 /* don't error out though */
694 if (putenv("container=lxc")) {
695 SYSERROR("failed to set environment variable");
696 goto out_warn_father
;
699 close(handler
->sigfd
);
701 /* after this call, we are in error because this
702 * ops should not return as it execs */
703 handler
->ops
->start(handler
, handler
->data
);
706 /* we want the parent to know something went wrong, so any
707 * value other than what it expects is ok. */
708 lxc_sync_wake_parent(handler
, LXC_SYNC_POST_CONFIGURE
);
712 int save_phys_nics(struct lxc_conf
*conf
)
714 struct lxc_list
*iterator
;
716 lxc_list_for_each(iterator
, &conf
->network
) {
717 struct lxc_netdev
*netdev
= iterator
->elem
;
719 if (netdev
->type
!= LXC_NET_PHYS
)
721 conf
->saved_nics
= realloc(conf
->saved_nics
,
722 (conf
->num_savednics
+1)*sizeof(struct saved_nic
));
723 if (!conf
->saved_nics
) {
724 SYSERROR("failed to allocate memory");
727 conf
->saved_nics
[conf
->num_savednics
].ifindex
= netdev
->ifindex
;
728 conf
->saved_nics
[conf
->num_savednics
].orig_name
= strdup(netdev
->link
);
729 if (!conf
->saved_nics
[conf
->num_savednics
].orig_name
) {
730 SYSERROR("failed to allocate memory");
733 INFO("stored saved_nic #%d idx %d name %s\n", conf
->num_savednics
,
734 conf
->saved_nics
[conf
->num_savednics
].ifindex
,
735 conf
->saved_nics
[conf
->num_savednics
].orig_name
);
736 conf
->num_savednics
++;
743 int lxc_spawn(struct lxc_handler
*handler
)
745 int failed_before_rename
= 0;
746 const char *name
= handler
->name
;
748 if (lxc_sync_init(handler
))
751 handler
->clone_flags
= CLONE_NEWUTS
|CLONE_NEWPID
|CLONE_NEWIPC
|CLONE_NEWNS
;
752 if (!lxc_list_empty(&handler
->conf
->id_map
)) {
753 INFO("Cloning a new user namespace");
754 handler
->clone_flags
|= CLONE_NEWUSER
;
756 if (!lxc_list_empty(&handler
->conf
->network
)) {
758 handler
->clone_flags
|= CLONE_NEWNET
;
760 /* Find gateway addresses from the link device, which is
761 * no longer accessible inside the container. Do this
762 * before creating network interfaces, since goto
763 * out_delete_net does not work before lxc_clone. */
764 if (lxc_find_gateway_addresses(handler
)) {
765 ERROR("failed to find gateway addresses");
766 lxc_sync_fini(handler
);
770 /* that should be done before the clone because we will
771 * fill the netdev index and use them in the child
773 if (lxc_create_network(handler
)) {
774 ERROR("failed to create the network");
775 lxc_sync_fini(handler
);
780 if (save_phys_nics(handler
->conf
)) {
781 ERROR("failed to save physical nic info");
786 * if the rootfs is not a blockdev, prevent the container from
787 * marking it readonly.
790 handler
->pinfd
= pin_rootfs(handler
->conf
->rootfs
.path
);
791 if (handler
->pinfd
== -1) {
792 ERROR("failed to pin the container's rootfs");
796 /* Create a process in a new set of namespaces */
797 handler
->pid
= lxc_clone(do_start
, handler
, handler
->clone_flags
);
798 if (handler
->pid
< 0) {
799 SYSERROR("failed to fork into a new namespace");
803 lxc_sync_fini_child(handler
);
805 if (lxc_sync_wait_child(handler
, LXC_SYNC_CONFIGURE
))
806 failed_before_rename
= 1;
808 /* TODO - pass lxc.cgroup.dir (or user's pam cgroup) in for first argument */
809 if ((handler
->cgroup
= lxc_cgroup_path_create(NULL
, name
)) == NULL
)
812 if (lxc_cgroup_enter(handler
->cgroup
, handler
->pid
) < 0)
815 if (failed_before_rename
)
818 /* Create the network configuration */
819 if (handler
->clone_flags
& CLONE_NEWNET
) {
820 if (lxc_assign_network(&handler
->conf
->network
, handler
->pid
)) {
821 ERROR("failed to create the configured network");
826 /* map the container uids - the container became an invalid
827 * userid the moment it was cloned with CLONE_NEWUSER - this
828 * call doesn't change anything immediately, but allows the
829 * container to setuid(0) (0 being mapped to something else on
830 * the host) later to become a valid uid again */
831 if (lxc_map_ids(&handler
->conf
->id_map
, handler
->pid
)) {
832 ERROR("failed to set up id mapping");
836 /* Tell the child to continue its initialization. we'll get
837 * LXC_SYNC_CGROUP when it is ready for us to setup cgroups
839 if (lxc_sync_barrier_child(handler
, LXC_SYNC_POST_CONFIGURE
))
842 if (setup_cgroup(handler
->cgroup
, &handler
->conf
->cgroup
)) {
843 ERROR("failed to setup the cgroups for '%s'", name
);
848 /* Tell the child to complete its initialization and wait for
849 * it to exec or return an error. (the child will never
850 * return LXC_SYNC_POST_CGROUP+1. It will either close the
851 * sync pipe, causing lxc_sync_barrier_child to return
852 * success, or return a different value, causing us to error
855 if (lxc_sync_barrier_child(handler
, LXC_SYNC_POST_CGROUP
))
858 if (detect_shared_rootfs())
859 umount2(handler
->conf
->rootfs
.mount
, MNT_DETACH
);
861 /* If child is in a fresh user namespace, chown his ptys for
863 if (uid_shift_ttys(handler
->pid
, handler
->conf
))
864 DEBUG("Failed to chown ptys.\n");
866 if (handler
->ops
->post_start(handler
, handler
->data
))
869 if (lxc_set_state(name
, handler
, RUNNING
)) {
870 ERROR("failed to set state to %s",
871 lxc_state2str(RUNNING
));
875 lxc_sync_fini(handler
);
877 if (handler
->pinfd
>= 0)
878 close(handler
->pinfd
);
883 if (handler
->clone_flags
& CLONE_NEWNET
)
884 lxc_delete_network(handler
);
886 lxc_abort(name
, handler
);
887 lxc_sync_fini(handler
);
891 int __lxc_start(const char *name
, struct lxc_conf
*conf
,
892 struct lxc_operations
* ops
, void *data
, const char *lxcpath
)
894 struct lxc_handler
*handler
;
898 handler
= lxc_init(name
, conf
, lxcpath
);
900 ERROR("failed to initialize the container");
904 handler
->data
= data
;
906 if (must_drop_cap_sys_boot()) {
907 #if HAVE_SYS_CAPABILITY_H
908 DEBUG("Dropping cap_sys_boot\n");
910 DEBUG("Can't drop cap_sys_boot as capabilities aren't supported\n");
913 DEBUG("Not dropping cap_sys_boot or watching utmp\n");
914 handler
->conf
->need_utmp_watch
= 0;
917 err
= lxc_spawn(handler
);
919 ERROR("failed to spawn '%s'", name
);
923 err
= lxc_poll(name
, handler
);
925 ERROR("mainloop exited with an error");
929 while (waitpid(handler
->pid
, &status
, 0) < 0 && errno
== EINTR
)
933 * If the child process exited but was not signaled,
934 * it didn't call reboot. This should mean it was an
935 * lxc-execute which simply exited. In any case, treat
938 if (WIFSIGNALED(status
)) {
939 switch(WTERMSIG(status
)) {
940 case SIGINT
: /* halt */
941 DEBUG("Container halting");
943 case SIGHUP
: /* reboot */
944 DEBUG("Container rebooting");
945 handler
->conf
->reboot
= 1;
948 DEBUG("unknown exit status for init: %d\n", WTERMSIG(status
));
953 lxc_rename_phys_nics_on_shutdown(handler
->conf
);
955 err
= lxc_error_set_and_log(handler
->pid
, status
);
957 lxc_delete_network(handler
);
960 lxc_fini(name
, handler
);
964 lxc_abort(name
, handler
);
972 static int start(struct lxc_handler
*handler
, void* data
)
974 struct start_args
*arg
= data
;
976 NOTICE("exec'ing '%s'", arg
->argv
[0]);
978 execvp(arg
->argv
[0], arg
->argv
);
979 SYSERROR("failed to exec %s", arg
->argv
[0]);
983 static int post_start(struct lxc_handler
*handler
, void* data
)
985 struct start_args
*arg
= data
;
987 NOTICE("'%s' started with pid '%d'", arg
->argv
[0], handler
->pid
);
991 static struct lxc_operations start_ops
= {
993 .post_start
= post_start
996 int lxc_start(const char *name
, char *const argv
[], struct lxc_conf
*conf
,
999 struct start_args start_arg
= {
1003 if (lxc_check_inherited(conf
, -1))
1006 conf
->need_utmp_watch
= 1;
1007 return __lxc_start(name
, conf
, &start_ops
, &start_arg
, lxcpath
);