1a8540490SCyril Zhang#- 24d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 3a8540490SCyril Zhang# 4a8540490SCyril Zhang# Copyright (c) 2021 The FreeBSD Foundation 5a8540490SCyril Zhang# 6a8540490SCyril Zhang# This software was developed by Cyril Zhang under sponsorship from 7a8540490SCyril Zhang# the FreeBSD Foundation. 8a8540490SCyril Zhang# 9a8540490SCyril Zhang# Redistribution and use in source and binary forms, with or without 10a8540490SCyril Zhang# modification, are permitted provided that the following conditions are 11a8540490SCyril Zhang# met: 12a8540490SCyril Zhang# 1. Redistributions of source code must retain the above copyright 13a8540490SCyril Zhang# notice, this list of conditions and the following disclaimer. 14a8540490SCyril Zhang# 2. Redistributions in binary form must reproduce the above copyright 15a8540490SCyril Zhang# notice, this list of conditions and the following disclaimer in 16a8540490SCyril Zhang# the documentation and/or other materials provided with the distribution. 17a8540490SCyril Zhang# 18a8540490SCyril Zhang# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19a8540490SCyril Zhang# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20a8540490SCyril Zhang# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21a8540490SCyril Zhang# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22a8540490SCyril Zhang# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23a8540490SCyril Zhang# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24a8540490SCyril Zhang# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25a8540490SCyril Zhang# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26a8540490SCyril Zhang# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27a8540490SCyril Zhang# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28a8540490SCyril Zhang# SUCH DAMAGE. 29a8540490SCyril Zhang# 30a8540490SCyril Zhang 31a8540490SCyril Zhang. $(atf_get_srcdir)/utils.subr 32a8540490SCyril Zhang 33a8540490SCyril Zhangatf_test_case vmm_cred_jail_host cleanup 34a8540490SCyril Zhangvmm_cred_jail_host_head() 35a8540490SCyril Zhang{ 36a8540490SCyril Zhang atf_set "descr" "Tests deleting the host's VM from within a jail" 37a8540490SCyril Zhang atf_set "require.user" "root" 38a8540490SCyril Zhang} 39a8540490SCyril Zhangvmm_cred_jail_host_body() 40a8540490SCyril Zhang{ 41*c2de0116SMark Johnston if ! -c /dev/vmmctl; then 42a8540490SCyril Zhang atf_skip "vmm is not loaded" 43a8540490SCyril Zhang fi 44a8540490SCyril Zhang bhyvectl --vm=testvm --create 45a8540490SCyril Zhang vmm_mkjail myjail 46a8540490SCyril Zhang atf_check -s exit:1 -e ignore jexec myjail bhyvectl --vm=testvm --destroy 47a8540490SCyril Zhang} 48a8540490SCyril Zhangvmm_cred_jail_host_cleanup() 49a8540490SCyril Zhang{ 50a8540490SCyril Zhang bhyvectl --vm=testvm --destroy 51a8540490SCyril Zhang vmm_cleanup 52a8540490SCyril Zhang} 53a8540490SCyril Zhang 54a8540490SCyril Zhangatf_test_case vmm_cred_jail_other cleanup 55a8540490SCyril Zhangvmm_cred_jail_other_head() 56a8540490SCyril Zhang{ 57a8540490SCyril Zhang atf_set "descr" "Tests deleting a jail's VM from within another jail" 58a8540490SCyril Zhang atf_set "require.user" "root" 59a8540490SCyril Zhang} 60a8540490SCyril Zhangvmm_cred_jail_other_body() 61a8540490SCyril Zhang{ 62*c2de0116SMark Johnston if ! -c /dev/vmmctl; then 63a8540490SCyril Zhang atf_skip "vmm is not loaded" 64a8540490SCyril Zhang fi 65a8540490SCyril Zhang vmm_mkjail myjail1 66a8540490SCyril Zhang vmm_mkjail myjail2 67a8540490SCyril Zhang atf_check -s exit:0 jexec myjail1 bhyvectl --vm=testvm --create 68a8540490SCyril Zhang atf_check -s exit:1 -e ignore jexec myjail2 bhyvectl --vm=testvm --destroy 69a8540490SCyril Zhang} 70a8540490SCyril Zhangvmm_cred_jail_other_cleanup() 71a8540490SCyril Zhang{ 72a8540490SCyril Zhang bhyvectl --vm=testvm --destroy 73a8540490SCyril Zhang vmm_cleanup 74a8540490SCyril Zhang} 75a8540490SCyril Zhang 76a8540490SCyril Zhangatf_init_test_cases() 77a8540490SCyril Zhang{ 78a8540490SCyril Zhang atf_add_test_case vmm_cred_jail_host 79a8540490SCyril Zhang atf_add_test_case vmm_cred_jail_other 80a8540490SCyril Zhang} 81