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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 #if !HAVE_DECL_PR_CAPBSET_DROP
54 #define PR_CAPBSET_DROP 24
70 #include "namespace.h"
71 #include "lxcseccomp.h"
76 lxc_log_define(lxc_start
, lxc
);
78 static int match_fd(int fd
)
80 return (fd
== 0 || fd
== 1 || fd
== 2);
83 int lxc_check_inherited(struct lxc_conf
*conf
, int fd_to_ignore
)
85 struct dirent dirent
, *direntp
;
91 dir
= opendir("/proc/self/fd");
94 WARN("failed to open directory: %m");
100 while (!readdir_r(dir
, &dirent
, &direntp
)) {
104 if (!strcmp(direntp
->d_name
, "."))
107 if (!strcmp(direntp
->d_name
, ".."))
110 fd
= atoi(direntp
->d_name
);
112 if (fd
== fddir
|| fd
== lxc_log_fd
|| fd
== fd_to_ignore
)
118 if (conf
->close_all_fds
) {
123 INFO("closed inherited fd %d", fd
);
126 WARN("inherited fd %d", fd
);
130 closedir(dir
); /* cannot fail */
135 static int setup_signal_fd(sigset_t
*oldmask
)
140 /* Block everything except serious error signals */
141 if (sigfillset(&mask
) ||
142 sigdelset(&mask
, SIGILL
) ||
143 sigdelset(&mask
, SIGSEGV
) ||
144 sigdelset(&mask
, SIGBUS
) ||
145 sigdelset(&mask
, SIGWINCH
) ||
146 sigprocmask(SIG_BLOCK
, &mask
, oldmask
)) {
147 SYSERROR("failed to set signal mask");
151 fd
= signalfd(-1, &mask
, 0);
153 SYSERROR("failed to create the signal fd");
157 if (fcntl(fd
, F_SETFD
, FD_CLOEXEC
)) {
158 SYSERROR("failed to set sigfd to close-on-exec");
163 DEBUG("sigchild handler set");
168 static int signal_handler(int fd
, void *data
,
169 struct lxc_epoll_descr
*descr
)
171 struct signalfd_siginfo siginfo
;
175 bool init_died
= false;
177 ret
= read(fd
, &siginfo
, sizeof(siginfo
));
179 ERROR("failed to read signal info");
183 if (ret
!= sizeof(siginfo
)) {
184 ERROR("unexpected siginfo size");
188 // check whether init is running
190 ret
= waitid(P_PID
, *pid
, &info
, WEXITED
| WNOWAIT
| WNOHANG
);
191 if (ret
== 0 && info
.si_pid
== *pid
) {
195 if (siginfo
.ssi_signo
!= SIGCHLD
) {
196 kill(*pid
, siginfo
.ssi_signo
);
197 INFO("forwarded signal %d to pid %d", siginfo
.ssi_signo
, *pid
);
198 return init_died
? 1 : 0;
201 if (siginfo
.ssi_code
== CLD_STOPPED
||
202 siginfo
.ssi_code
== CLD_CONTINUED
) {
203 INFO("container init process was stopped/continued");
204 return init_died
? 1 : 0;
207 /* more robustness, protect ourself from a SIGCHLD sent
208 * by a process different from the container init
210 if (siginfo
.ssi_pid
!= *pid
) {
211 WARN("invalid pid for SIGCHLD");
212 return init_died
? 1 : 0;
215 DEBUG("container init process exited");
219 int lxc_set_state(const char *name
, struct lxc_handler
*handler
, lxc_state_t state
)
221 handler
->state
= state
;
222 lxc_monitor_send_state(name
, state
, handler
->lxcpath
);
226 int lxc_poll(const char *name
, struct lxc_handler
*handler
)
228 int sigfd
= handler
->sigfd
;
229 int pid
= handler
->pid
;
230 struct lxc_epoll_descr descr
;
232 if (lxc_mainloop_open(&descr
)) {
233 ERROR("failed to create mainloop");
237 if (lxc_mainloop_add_handler(&descr
, sigfd
, signal_handler
, &pid
)) {
238 ERROR("failed to add handler for the signal");
239 goto out_mainloop_open
;
242 if (lxc_console_mainloop_add(&descr
, handler
)) {
243 ERROR("failed to add console handler to mainloop");
244 goto out_mainloop_open
;
247 if (lxc_cmd_mainloop_add(name
, &descr
, handler
)) {
248 ERROR("failed to add command handler to mainloop");
249 goto out_mainloop_open
;
252 if (handler
->conf
->need_utmp_watch
) {
253 #if HAVE_SYS_CAPABILITY_H
254 if (lxc_utmp_mainloop_add(&descr
, handler
)) {
255 ERROR("failed to add utmp handler to mainloop");
256 goto out_mainloop_open
;
259 DEBUG("not starting utmp handler as cap_sys_boot cannot be dropped without capabilities support\n");
263 return lxc_mainloop(&descr
, -1);
266 lxc_mainloop_close(&descr
);
274 struct lxc_handler
*lxc_init(const char *name
, struct lxc_conf
*conf
, const char *lxcpath
)
276 struct lxc_handler
*handler
;
278 handler
= malloc(sizeof(*handler
));
282 memset(handler
, 0, sizeof(*handler
));
284 handler
->conf
= conf
;
285 handler
->lxcpath
= lxcpath
;
290 handler
->name
= strdup(name
);
291 if (!handler
->name
) {
292 ERROR("failed to allocate memory");
296 if (lxc_cmd_init(name
, handler
, lxcpath
))
299 if (lxc_read_seccomp_config(conf
) != 0) {
300 ERROR("failed loading seccomp policy");
301 goto out_close_maincmd_fd
;
304 /* Begin by setting the state to STARTING */
305 if (lxc_set_state(name
, handler
, STARTING
)) {
306 ERROR("failed to set state '%s'", lxc_state2str(STARTING
));
307 goto out_close_maincmd_fd
;
310 /* Start of environment variable setup for hooks */
311 if (setenv("LXC_NAME", name
, 1)) {
312 SYSERROR("failed to set environment variable for container name");
314 if (setenv("LXC_CONFIG_FILE", conf
->rcfile
, 1)) {
315 SYSERROR("failed to set environment variable for config path");
317 if (setenv("LXC_ROOTFS_MOUNT", conf
->rootfs
.mount
, 1)) {
318 SYSERROR("failed to set environment variable for rootfs mount");
320 if (setenv("LXC_ROOTFS_PATH", conf
->rootfs
.path
, 1)) {
321 SYSERROR("failed to set environment variable for rootfs mount");
323 if (conf
->console
.path
&& setenv("LXC_CONSOLE", conf
->console
.path
, 1)) {
324 SYSERROR("failed to set environment variable for console path");
326 if (conf
->console
.log_path
&& setenv("LXC_CONSOLE_LOGPATH", conf
->console
.log_path
, 1)) {
327 SYSERROR("failed to set environment variable for console log");
329 /* End of environment variable setup for hooks */
331 if (run_lxc_hooks(name
, "pre-start", conf
, handler
->lxcpath
, NULL
)) {
332 ERROR("failed to run pre-start hooks for container '%s'.", name
);
336 if (lxc_create_tty(name
, conf
)) {
337 ERROR("failed to create the ttys");
341 /* the signal fd has to be created before forking otherwise
342 * if the child process exits before we setup the signal fd,
343 * the event will be lost and the command will be stuck */
344 handler
->sigfd
= setup_signal_fd(&handler
->oldmask
);
345 if (handler
->sigfd
< 0) {
346 ERROR("failed to set sigchild fd handler");
350 /* do this after setting up signals since it might unblock SIGWINCH */
351 if (lxc_console_create(conf
)) {
352 ERROR("failed to create console");
353 goto out_restore_sigmask
;
356 INFO("'%s' is initialized", name
);
360 sigprocmask(SIG_SETMASK
, &handler
->oldmask
, NULL
);
362 lxc_delete_tty(&conf
->tty_info
);
364 lxc_set_state(name
, handler
, ABORTING
);
365 out_close_maincmd_fd
:
367 close(conf
->maincmd_fd
);
369 conf
->maincmd_fd
= -1;
372 handler
->name
= NULL
;
378 static void lxc_fini(const char *name
, struct lxc_handler
*handler
)
380 /* The STOPPING state is there for future cleanup code
381 * which can take awhile
383 lxc_set_state(name
, handler
, STOPPING
);
384 lxc_set_state(name
, handler
, STOPPED
);
386 if (run_lxc_hooks(name
, "post-stop", handler
->conf
, handler
->lxcpath
, NULL
))
387 ERROR("failed to run post-stop hooks for container '%s'.", name
);
389 /* reset mask set by setup_signal_fd */
390 if (sigprocmask(SIG_SETMASK
, &handler
->oldmask
, NULL
))
391 WARN("failed to restore sigprocmask");
393 lxc_console_delete(&handler
->conf
->console
);
394 lxc_delete_tty(&handler
->conf
->tty_info
);
396 close(handler
->conf
->maincmd_fd
);
398 handler
->conf
->maincmd_fd
= -1;
400 if (handler
->cgroup
) {
401 lxc_cgroup_process_info_free_and_remove(handler
->cgroup
);
402 handler
->cgroup
= NULL
;
407 void lxc_abort(const char *name
, struct lxc_handler
*handler
)
411 lxc_set_state(name
, handler
, ABORTING
);
412 if (handler
->pid
> 0)
413 kill(handler
->pid
, SIGKILL
);
414 while ((ret
= waitpid(-1, &status
, 0)) > 0) ;
417 #include <sys/reboot.h>
418 #include <linux/reboot.h>
421 * reboot(LINUX_REBOOT_CMD_CAD_ON) will return -EINVAL
422 * in a child pid namespace if container reboot support exists.
423 * Otherwise, it will either succeed or return -EPERM.
425 static int container_reboot_supported(void *arg
)
431 if (ret
== -1 && errno
== EINVAL
)
436 static int must_drop_cap_sys_boot(struct lxc_conf
*conf
)
439 int ret
, cmd
, v
, flags
;
440 long stack_size
= 4096;
441 void *stack
= alloca(stack_size
);
446 f
= fopen("/proc/sys/kernel/ctrl-alt-del", "r");
449 DEBUG("failed to open /proc/sys/kernel/ctrl-alt-del");
453 ret
= fscanf(f
, "%d", &v
);
458 DEBUG("Failed to read /proc/sys/kernel/ctrl-alt-del");
461 cmd
= v
? LINUX_REBOOT_CMD_CAD_ON
: LINUX_REBOOT_CMD_CAD_OFF
;
463 flags
= CLONE_NEWPID
| SIGCHLD
;
464 if (!lxc_list_empty(&conf
->id_map
))
465 flags
|= CLONE_NEWUSER
;
468 pid
= __clone2(container_reboot_supported
, stack
, stack_size
, flags
, &cmd
);
471 pid
= clone(container_reboot_supported
, stack
, flags
, &cmd
);
474 SYSERROR("failed to clone\n");
477 if (wait(&status
) < 0) {
478 SYSERROR("unexpected wait error: %m\n");
482 if (WEXITSTATUS(status
) != 1)
488 static int do_start(void *data
)
490 struct lxc_handler
*handler
= data
;
492 if (sigprocmask(SIG_SETMASK
, &handler
->oldmask
, NULL
)) {
493 SYSERROR("failed to set sigprocmask");
497 /* This prctl must be before the synchro, so if the parent
498 * dies before we set the parent death signal, we will detect
499 * its death with the synchro right after, otherwise we have
500 * a window where the parent can exit before we set the pdeath
501 * signal leading to a unsupervized container.
503 if (prctl(PR_SET_PDEATHSIG
, SIGKILL
, 0, 0, 0)) {
504 SYSERROR("failed to set pdeath signal");
508 lxc_sync_fini_parent(handler
);
510 /* don't leak the pinfd to the container */
511 if (handler
->pinfd
>= 0) {
513 close(handler
->pinfd
);
517 /* Tell the parent task it can begin to configure the
518 * container and wait for it to finish
520 if (lxc_sync_barrier_parent(handler
, LXC_SYNC_CONFIGURE
))
524 * if we are in a new user namespace, become root there to have
525 * privilege over our namespace
527 if (!lxc_list_empty(&handler
->conf
->id_map
)) {
528 NOTICE("switching to gid/uid 0 in new user namespace");
531 goto out_warn_father
;
535 goto out_warn_father
;
539 #if HAVE_SYS_CAPABILITY_H
540 if (handler
->conf
->need_utmp_watch
) {
541 if (prctl(PR_CAPBSET_DROP
, CAP_SYS_BOOT
, 0, 0, 0)) {
542 SYSERROR("failed to remove CAP_SYS_BOOT capability");
543 goto out_warn_father
;
545 DEBUG("Dropped cap_sys_boot\n");
549 /* Setup the container, ip, names, utsname, ... */
550 if (lxc_setup(handler
->name
, handler
->conf
, handler
->lxcpath
, handler
->cgroup
)) {
551 ERROR("failed to setup the container");
552 goto out_warn_father
;
555 /* ask father to setup cgroups and wait for him to finish */
556 if (lxc_sync_barrier_parent(handler
, LXC_SYNC_CGROUP
))
559 /* XXX: hmm apparmor switches right away since it uses
560 * aa_change_profile() and not aa_change_onexec(). SELinux on the other
561 * hand is going to transition on exec(). Is it bad to run the stuff
562 * between here and exec() in the more privileged context?
564 if (lsm_process_label_set(handler
->conf
->lsm_aa_profile
?
565 handler
->conf
->lsm_aa_profile
:
566 handler
->conf
->lsm_se_context
, 1) < 0)
567 goto out_warn_father
;
568 lsm_proc_unmount(handler
->conf
);
570 if (lxc_seccomp_load(handler
->conf
) != 0)
571 goto out_warn_father
;
573 if (run_lxc_hooks(handler
->name
, "start", handler
->conf
, handler
->lxcpath
, NULL
)) {
574 ERROR("failed to run start hooks for container '%s'.", handler
->name
);
575 goto out_warn_father
;
578 /* The clearenv() and putenv() calls have been moved here
579 * to allow us to use enviroment variables passed to the various
580 * hooks, such as the start hook above. Not all of the
581 * variables like CONFIG_PATH or ROOTFS are valid in this
582 * context but others are. */
584 SYSERROR("failed to clear environment");
585 /* don't error out though */
588 if (putenv("container=lxc")) {
589 SYSERROR("failed to set environment variable");
590 goto out_warn_father
;
594 close(handler
->sigfd
);
597 /* after this call, we are in error because this
598 * ops should not return as it execs */
599 handler
->ops
->start(handler
, handler
->data
);
602 /* we want the parent to know something went wrong, so any
603 * value other than what it expects is ok. */
604 lxc_sync_wake_parent(handler
, LXC_SYNC_POST_CONFIGURE
);
608 int save_phys_nics(struct lxc_conf
*conf
)
610 struct lxc_list
*iterator
;
612 lxc_list_for_each(iterator
, &conf
->network
) {
613 struct lxc_netdev
*netdev
= iterator
->elem
;
615 if (netdev
->type
!= LXC_NET_PHYS
)
617 conf
->saved_nics
= realloc(conf
->saved_nics
,
618 (conf
->num_savednics
+1)*sizeof(struct saved_nic
));
619 if (!conf
->saved_nics
) {
620 SYSERROR("failed to allocate memory");
623 conf
->saved_nics
[conf
->num_savednics
].ifindex
= netdev
->ifindex
;
624 conf
->saved_nics
[conf
->num_savednics
].orig_name
= strdup(netdev
->link
);
625 if (!conf
->saved_nics
[conf
->num_savednics
].orig_name
) {
626 SYSERROR("failed to allocate memory");
629 INFO("stored saved_nic #%d idx %d name %s\n", conf
->num_savednics
,
630 conf
->saved_nics
[conf
->num_savednics
].ifindex
,
631 conf
->saved_nics
[conf
->num_savednics
].orig_name
);
632 conf
->num_savednics
++;
638 int lxc_spawn(struct lxc_handler
*handler
)
640 int failed_before_rename
= 0;
641 const char *name
= handler
->name
;
642 struct cgroup_meta_data
*cgroup_meta
= NULL
;
643 const char *cgroup_pattern
= NULL
;
645 if (lxc_sync_init(handler
))
648 handler
->clone_flags
= CLONE_NEWUTS
|CLONE_NEWPID
|CLONE_NEWIPC
|CLONE_NEWNS
;
649 if (!lxc_list_empty(&handler
->conf
->id_map
)) {
650 INFO("Cloning a new user namespace");
651 handler
->clone_flags
|= CLONE_NEWUSER
;
653 if (!lxc_list_empty(&handler
->conf
->network
)) {
655 handler
->clone_flags
|= CLONE_NEWNET
;
657 /* Find gateway addresses from the link device, which is
658 * no longer accessible inside the container. Do this
659 * before creating network interfaces, since goto
660 * out_delete_net does not work before lxc_clone. */
661 if (lxc_find_gateway_addresses(handler
)) {
662 ERROR("failed to find gateway addresses");
663 lxc_sync_fini(handler
);
667 /* that should be done before the clone because we will
668 * fill the netdev index and use them in the child
670 if (lxc_create_network(handler
)) {
671 ERROR("failed to create the network");
672 lxc_sync_fini(handler
);
677 if (save_phys_nics(handler
->conf
)) {
678 ERROR("failed to save physical nic info");
682 cgroup_meta
= lxc_cgroup_load_meta();
684 ERROR("failed to detect cgroup metadata");
688 /* if we are running as root, use system cgroup pattern, otherwise
689 * just create a cgroup under the current one. But also fall back to
690 * that if for some reason reading the configuration fails and no
691 * default value is available
694 cgroup_pattern
= lxc_global_config_value("cgroup.pattern");
696 cgroup_pattern
= "%n";
698 /* Create cgroup before doing clone(), so the child will know from
699 * handler which cgroup it is going to be put in later.
701 if ((handler
->cgroup
= lxc_cgroup_create(name
, cgroup_pattern
, cgroup_meta
, NULL
)) == NULL
) {
702 ERROR("failed to create cgroups for '%s'", name
);
707 * if the rootfs is not a blockdev, prevent the container from
708 * marking it readonly.
711 handler
->pinfd
= pin_rootfs(handler
->conf
->rootfs
.path
);
712 if (handler
->pinfd
== -1)
713 INFO("failed to pin the container's rootfs");
715 /* Create a process in a new set of namespaces */
716 handler
->pid
= lxc_clone(do_start
, handler
, handler
->clone_flags
);
717 if (handler
->pid
< 0) {
718 SYSERROR("failed to fork into a new namespace");
722 lxc_sync_fini_child(handler
);
724 if (lxc_sync_wait_child(handler
, LXC_SYNC_CONFIGURE
))
725 failed_before_rename
= 1;
727 /* In case there is still legacy ns cgroup support in the kernel.
728 * Should be removed at some later point in time.
730 if (lxc_cgroup_create_legacy(handler
->cgroup
, name
, handler
->pid
) < 0) {
731 ERROR("failed to create legacy ns cgroups for '%s'", name
);
735 if (lxc_setup_cgroup_without_devices(handler
, &handler
->conf
->cgroup
)) {
736 ERROR("failed to setup the cgroups for '%s'", name
);
740 if (lxc_cgroup_enter(handler
->cgroup
, handler
->pid
, false) < 0)
743 if (failed_before_rename
)
746 /* Create the network configuration */
747 if (handler
->clone_flags
& CLONE_NEWNET
) {
748 if (lxc_assign_network(&handler
->conf
->network
, handler
->pid
)) {
749 ERROR("failed to create the configured network");
754 /* map the container uids - the container became an invalid
755 * userid the moment it was cloned with CLONE_NEWUSER - this
756 * call doesn't change anything immediately, but allows the
757 * container to setuid(0) (0 being mapped to something else on
758 * the host) later to become a valid uid again */
759 if (lxc_map_ids(&handler
->conf
->id_map
, handler
->pid
)) {
760 ERROR("failed to set up id mapping");
764 /* Tell the child to continue its initialization. we'll get
765 * LXC_SYNC_CGROUP when it is ready for us to setup cgroups
767 if (lxc_sync_barrier_child(handler
, LXC_SYNC_POST_CONFIGURE
))
770 if (lxc_setup_cgroup_devices(handler
, &handler
->conf
->cgroup
)) {
771 ERROR("failed to setup the devices cgroup for '%s'", name
);
775 /* Tell the child to complete its initialization and wait for
776 * it to exec or return an error. (the child will never
777 * return LXC_SYNC_POST_CGROUP+1. It will either close the
778 * sync pipe, causing lxc_sync_barrier_child to return
779 * success, or return a different value, causing us to error
782 if (lxc_sync_barrier_child(handler
, LXC_SYNC_POST_CGROUP
))
785 if (detect_shared_rootfs())
786 umount2(handler
->conf
->rootfs
.mount
, MNT_DETACH
);
788 /* If child is in a fresh user namespace, chown his ptys for
790 if (uid_shift_ttys(handler
->pid
, handler
->conf
))
791 DEBUG("Failed to chown ptys.\n");
793 if (handler
->ops
->post_start(handler
, handler
->data
))
796 if (lxc_set_state(name
, handler
, RUNNING
)) {
797 ERROR("failed to set state to %s",
798 lxc_state2str(RUNNING
));
802 lxc_cgroup_put_meta(cgroup_meta
);
803 lxc_sync_fini(handler
);
808 if (handler
->clone_flags
& CLONE_NEWNET
)
809 lxc_delete_network(handler
);
811 lxc_cgroup_put_meta(cgroup_meta
);
812 lxc_abort(name
, handler
);
813 lxc_sync_fini(handler
);
814 if (handler
->pinfd
>= 0) {
816 close(handler
->pinfd
);
824 int __lxc_start(const char *name
, struct lxc_conf
*conf
,
825 struct lxc_operations
* ops
, void *data
, const char *lxcpath
)
827 struct lxc_handler
*handler
;
831 handler
= lxc_init(name
, conf
, lxcpath
);
833 ERROR("failed to initialize the container");
837 handler
->data
= data
;
839 if (must_drop_cap_sys_boot(handler
->conf
)) {
840 #if HAVE_SYS_CAPABILITY_H
841 DEBUG("Dropping cap_sys_boot\n");
843 DEBUG("Can't drop cap_sys_boot as capabilities aren't supported\n");
846 DEBUG("Not dropping cap_sys_boot or watching utmp\n");
847 handler
->conf
->need_utmp_watch
= 0;
850 err
= lxc_spawn(handler
);
852 ERROR("failed to spawn '%s'", name
);
856 err
= lxc_poll(name
, handler
);
858 ERROR("mainloop exited with an error");
862 while (waitpid(handler
->pid
, &status
, 0) < 0 && errno
== EINTR
)
866 * If the child process exited but was not signaled,
867 * it didn't call reboot. This should mean it was an
868 * lxc-execute which simply exited. In any case, treat
871 if (WIFSIGNALED(status
)) {
872 switch(WTERMSIG(status
)) {
873 case SIGINT
: /* halt */
874 DEBUG("Container halting");
876 case SIGHUP
: /* reboot */
877 DEBUG("Container rebooting");
878 handler
->conf
->reboot
= 1;
881 DEBUG("unknown exit status for init: %d\n", WTERMSIG(status
));
886 lxc_rename_phys_nics_on_shutdown(handler
->conf
);
888 if (handler
->pinfd
>= 0) {
890 close(handler
->pinfd
);
895 err
= lxc_error_set_and_log(handler
->pid
, status
);
897 lxc_delete_network(handler
);
900 lxc_fini(name
, handler
);
904 lxc_abort(name
, handler
);
912 static int start(struct lxc_handler
*handler
, void* data
)
914 struct start_args
*arg
= data
;
916 NOTICE("exec'ing '%s'", arg
->argv
[0]);
918 execvp(arg
->argv
[0], arg
->argv
);
919 SYSERROR("failed to exec %s", arg
->argv
[0]);
923 static int post_start(struct lxc_handler
*handler
, void* data
)
925 struct start_args
*arg
= data
;
927 NOTICE("'%s' started with pid '%d'", arg
->argv
[0], handler
->pid
);
931 static struct lxc_operations start_ops
= {
933 .post_start
= post_start
936 int lxc_start(const char *name
, char *const argv
[], struct lxc_conf
*conf
,
939 struct start_args start_arg
= {
943 if (lxc_check_inherited(conf
, -1))
946 conf
->need_utmp_watch
= 1;
947 return __lxc_start(name
, conf
, &start_ops
, &start_arg
, lxcpath
);