xref: /freebsd/tests/sys/vmm/utils.subr (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1a8540490SCyril Zhang#-
2*4d846d26SWarner 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 Zhangvmm_mkjail()
32a8540490SCyril Zhang{
33a8540490SCyril Zhang	jailname=$1
34a8540490SCyril Zhang	jail -c name=${jailname} persist allow.vmm
35a8540490SCyril Zhang	echo $jailname >> created_jails.lst
36a8540490SCyril Zhang}
37a8540490SCyril Zhangvmm_cleanup()
38a8540490SCyril Zhang{
39a8540490SCyril Zhang	if [ -f created_jails.lst ]
40a8540490SCyril Zhang	then
41a8540490SCyril Zhang		for jailname in `cat created_jails.lst`
42a8540490SCyril Zhang		do
43a8540490SCyril Zhang			jail -r ${jailname}
44a8540490SCyril Zhang		done
45a8540490SCyril Zhang		rm created_jails.lst
46a8540490SCyril Zhang	fi
47a8540490SCyril Zhang}
48