diff --git a/src/exec.c b/src/exec.c index 8dba5d1..a3883ee 100644 --- a/src/exec.c +++ b/src/exec.c @@ -731,7 +731,7 @@ static int hyper_release_exec(struct hyper_exec *exec, if (pod->type == DESTROYPOD) { /* shutdown vm manually, hyper doesn't care the pod finished codes */ - hyper_shutdown(0); + hyper_pod_destroyed(0); } else { /* send out pod finish message, hyper will decide if restart pod or not */ hyper_send_pod_finished(pod); diff --git a/src/hyper.h b/src/hyper.h index f9cc494..f4cca95 100644 --- a/src/hyper.h +++ b/src/hyper.h @@ -91,6 +91,7 @@ static inline int hyper_create(char *hyper_path) int hyper_open_serial(char *tty); void hyper_cleanup_pod(struct hyper_pod *pod); int hyper_enter_sandbox(struct hyper_pod *pod, int pidpipe); +void hyper_pod_destroyed(int failed); extern struct hyper_pod global_pod; extern struct hyper_ctl ctl; diff --git a/src/init.c b/src/init.c index ef8d9a7..21daa3d 100644 --- a/src/init.c +++ b/src/init.c @@ -519,11 +519,17 @@ static void hyper_print_uptime(void) close(fd); } +void hyper_pod_destroyed(int failed) +{ + hyper_send_msg_block(ctl.chan.fd, failed?ERROR:ACK, 0, NULL); + hyper_shutdown(); +} + static int hyper_destroy_pod(struct hyper_pod *pod, int error) { if (pod->init_pid == 0) { /* Pod stopped, just shutdown */ - hyper_shutdown(error); + hyper_pod_destroyed(error); } else { /* Kill pod */ hyper_term_all(pod); diff --git a/src/util.c b/src/util.c index df04e3d..9e6a45a 100644 --- a/src/util.c +++ b/src/util.c @@ -673,9 +673,8 @@ static void hyper_unmount_all(void) sync(); } -void hyper_shutdown(int error) +void hyper_shutdown() { - hyper_send_msg_block(ctl.chan.fd, error?ERROR:ACK, 0, NULL); hyper_unmount_all(); reboot(LINUX_REBOOT_CMD_POWER_OFF); } diff --git a/src/util.h b/src/util.h index 045a8a0..25310d9 100644 --- a/src/util.h +++ b/src/util.h @@ -35,7 +35,7 @@ int hyper_setfd_cloexec(int fd); int hyper_setfd_block(int fd); int hyper_setfd_nonblock(int fd); int hyper_socketpair(int domain, int type, int protocol, int sv[2]); -void hyper_shutdown(int ack); +void hyper_shutdown(); int hyper_insmod(char *module); struct passwd *hyper_getpwnam(const char *name); struct group *hyper_getgrnam(const char *name);