void free_str(list_head_t *head) { struct vzctl_str_param *tmp, *it; if (list_empty(head)) return; list_for_each_safe(it, tmp, head, list) { free_str_param(it); free(it); }
/** Stop CT. * * @param h CT handler. * @param veid CT ID. * @param param CT parameters. * @param stop_mode stop mode, one of (M_REBOOT M_HALT M_KILL). * @param skip flag to skip run action script (SKIP_ACTION_SCRIPT) * @param action modules list, used to call cleanup() callback. * @return 0 on success. */ int vps_stop(vps_handler *h, envid_t veid, vps_param *param, int stop_mode, skipFlags skip, struct mod_action *action) { int ret; char buf[64]; vps_res *res = ¶m->res; if (check_var(res->fs.root, "VE_ROOT is not set")) return VZ_VE_ROOT_NOTSET; if (!vps_is_run(h, veid)) { logger(-1, 0, "Unable to stop: container is not running"); return 0; } if (!(skip & SKIP_ACTION_SCRIPT)) { snprintf(buf, sizeof(buf), VPS_CONF_DIR "%d.%s", veid, STOP_PREFIX); if (stat_file(buf)) { if (vps_exec_script(h, veid, res->fs.root, NULL, NULL, buf, NULL, 0)) { return VZ_ACTIONSCRIPT_ERROR; } } } /* get CT IP addresses for cleanup */ get_vps_ip(h, veid, ¶m->del_res.net.ip); if ((ret = env_stop(h, veid, res->fs.root, stop_mode))) goto end; mod_cleanup(h, veid, action, param); /* Cleanup CT IPs */ run_net_script(veid, DEL, ¶m->del_res.net.ip, STATE_STOPPING, param->res.net.skip_arpdetect); ret = vps_umount(h, veid, res->fs.root, skip); end: free_str_param(¶m->del_res.net.ip); return ret; }