FreeBSD Bugzilla – Attachment 137872 Details for
Bug 183604
New port: sysutils/bhyve-rc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.shar
file.shar (text/plain), 6.86 KB, created by
Michael Gmelin
on 2013-11-03 03:10:00 UTC
(
hide
)
Description:
file.shar
Filename:
MIME Type:
Creator:
Michael Gmelin
Created:
2013-11-03 03:10:00 UTC
Size:
6.86 KB
patch
obsolete
># This is a shell archive. Save it in a file, remove anything before ># this line, and then unpack it by entering "sh file". Note, it may ># create directories; files and directories will be owned by you and ># have default permissions. ># ># This archive contains: ># ># bhyve-rc ># bhyve-rc/files ># bhyve-rc/files/bhyve.in ># bhyve-rc/pkg-message ># bhyve-rc/Makefile ># bhyve-rc/pkg-descr ># >echo c - bhyve-rc >mkdir -p bhyve-rc > /dev/null 2>&1 >echo c - bhyve-rc/files >mkdir -p bhyve-rc/files > /dev/null 2>&1 >echo x - bhyve-rc/files/bhyve.in >sed 's/^X//' >bhyve-rc/files/bhyve.in << '15204ded0697d56ea8130cce111027fe' >X#!/bin/sh >X# >X# $FreeBSD: mgmelin >X# >X >X# PROVIDE: bhyve >X# REQUIRE: LOGIN >X# KEYWORD: nojail >X# >X >X# >X# Add the following lines to /etc/rc.conf to enable bhyve: >X# bhyve_enable (bool): Set to "NO" by default. >X# Set it to "YES" to enable bhyve >X# bhyve_profiles (str): Set to "" by default. >X# Define your profiles here. >X# bhyve_tapdev (str): Set to "tap0" by default. >X# Set to the tap(4) device to use. >X# bhyve_diskdev (str): Must be set, no default. >X# Set to the disk device to use. >X# bhyve_ncpu (int): Set to 1 by default. >X# Set to the number of CPUs for the VM. >X# bhyve_memsize (int): Set to 512 by default. >X# Set to the number of MB of memory for the VM. >X >X. /etc/rc.subr >X >Xname="bhyve" >Xrcvar=bhyve_enable >X >Xstart_precmd="bhyve_prestart" >Xstatus_cmd="bhyve_status" >Xpoll_cmd="bhyve_poll" >Xstop_cmd="bhyve_stop" >X_session=$name >Xcommand="/usr/local/bin/tmux" >Xprocname="-sh" >X >X[ -z "$bhyve_enable" ] && bhyve_enable="NO" >X[ -z "$bhyve_tapdev" ] && bhyve_tapdev="tap0" >X[ -z "$bhyve_diskdev" ] && bhyve_diskdev="none" >X[ -z "$bhyve_ncpu" ] && bhyve_ncpu="1" >X[ -z "$bhyve_memsize" ] && bhyve_memsize="512" >X >Xload_rc_config $name >X >Xif [ -n "$2" ]; then >X profile="$2" >X _session="${_session}_${profile}" >X if [ "x${bhyve_profiles}" != "x" ]; then >X eval bhyve_enable="\${${_session}_enable:-${bhyve_enable}}" >X eval bhyve_tapdev="\${${_session}_tapdev:-${bhyve_tapdev}}" >X eval bhyve_diskdev="\${${_session}_diskdev:-${bhyve_diskdev}}" >X eval bhyve_ncpu="\${${_session}_ncpu:-${bhyve_ncpu}}" >X eval bhyve_memsize="\${${_session}_memsize:-${bhyve_memsize}}" >X else >X echo "$0: extra argument ignored" >X fi >Xelse >X if [ "x${bhyve_profiles}" != "x" -a "x$1" != "x" ]; then >X for profile in ${bhyve_profiles}; do >X eval _enable="\${bhyve_${profile}_enable}" >X case "x${_enable:-${bhyve_enable}}" in >X x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee]) >X continue >X ;; >X x[Yy][Ee][Ss]) >X ;; >X *) >X if test -z "$_enable"; then >X _var=bhyve_enable >X else >X _var=bhyve_"${profile}"_enable >X fi >X echo "Bad value" \ >X "'${_enable:-${bhyve_enable}}'" \ >X "for ${_var}. " \ >X "Profile ${profile} skipped." >X continue >X ;; >X esac >X echo "===> bhyve profile: ${profile}" >X /usr/local/etc/rc.d/bhyve $1 ${profile} >X retcode="$?" >X if [ "0${retcode}" -ne 0 ]; then >X failed="${profile} (${retcode}) ${failed:-}" >X else >X success="${profile} ${success:-}" >X fi >X done >X exit 0 >X fi >X profile=$name >Xfi >X >Xpidfile="/var/run/${_session}.pid" >X >X >Xbhyve_prestart() >X{ >X case ${bhyve_diskdev} in >X [Nn][Oo][Nn][Ee] | '') >X echo "No ${_session}_diskdev set. Quitting." 1>&2 >X return 1; >X ;; >X esac >X if [ ! -c "${bhyve_diskdev}" -a ! -f "${bhyve_diskdev}" ]; then >X echo "${bhyve_diskdev} doesn't exist or is not suitable as a diskdev" 1>&2 >X return 1; >X fi >X} >X >Xbhyve_status() >X{ >X if ${command} has-session -t ${_session} 2>/dev/null; then >X echo "${_session} is running." >X else >X echo "${_session} is not running." >X return 1 >X fi >X} >X >Xbhyve_poll() >X{ >X echo -n "Waiting for session: ${_session}" >X while ${command} has-session -t ${_session} 2>dev/null; do >X sleep 1 >X done >X echo >X} >X >Xbhyve_stop() >X{ >X if ${command} has-session -t ${_session} 2>/dev/null; then >X echo "Stopping ${_session}." >X ${command} kill-session -t ${_session} >X while ${command} has-session -t ${_session} 2>dev/null; do >X sleep 1 >X done >X fi >X rm -f ${pidfile} >X} >X >Xcommand_args="new-session -ds ${_session} \"sh -c 'echo \\\$PPID >${pidfile}; while true; do /usr/sbin/bhyvectl --vm=${_session} --destroy; /usr/sbin/bhyveload -m ${bhyve_memsize} -d ${bhyve_diskdev} ${_session} && /usr/sbin/bhyve -c ${bhyve_ncpu} -m ${bhyve_memsize} -AI -H -P -g 0 -s 0:0,hostbridge -s 1:0,virtio-net,${bhyve_tapdev} -s 2:0,virtio-blk,${bhyve_diskdev} -S 31,uart,stdio ${_session} || break; done'\"" >X >Xrun_rc_command "$1" >15204ded0697d56ea8130cce111027fe >echo x - bhyve-rc/pkg-message >sed 's/^X//' >bhyve-rc/pkg-message << '08f317d2efdcbca70cd87748f6d0df00' >XConfiguration is done completely though rc.conf. >XThe rc script won't touch any devices for you (neither disk, nor tap) >Xso you need to make sure all of those have been initialized properly. >X >XGeneral setup: >Xkldload vmm >Xnet.link.tap.up_on_open=1 >X >XMake it persistent: >Xecho "net.link.tap.up_on_open=1" >> /etc/sysctl.conf >Xcat >> /boot/loader.conf << EOF >Xvmm_load="YES" >XEOF >X >XMinimal example: >Xcat >> /etc/rc.conf << EOF >Xcloned_interfaces="tap0 bridge0" >Xbhyve_enable="YES" >Xbhyve_diskdev="/dev/zvol/tank/bhyve/virt" >XEOF >X >Xifconfig tap0 create >Xifconfig bridge0 create >X >Xservice bhyve start >Xtmux list-sessions >Xtmux attach -t bhyve >Xservice bhyve status >Xservice bhyve stop >X >XMulti profile configuration example: >Xcat >> /etc/rc.conf << EOF >Xcloned_interfaces="tap0 tap1 bridge0" >Xbhyve_enable="YES" >Xbhyve_profiles="virt1 virt2" >Xbhyve_virt1_diskdev="/dev/zvol/tank/bhyve/virt1" >X >Xbhyve_virt2_tapdev="tap1" >Xbhyve_virt2_diskdev="/dev/zvol/tank/bhyve/virt2" >Xbhyve_virt2_memsize="8192" >Xbhyve_virt2_ncpu="4" >XEOF >X >Xifconfig tap0 create >Xifconfig tap1 create >Xifconfig bridge0 create >X >Xservice bhyve start # start all >Xservice bhyve start virt2 # start individual >Xtmux attach -t bhyve_virt1 >Xtmux attach -t bhyve_virt1 >Xservice bhyve stop virt2 # stop individual >Xservice bhyve stop # stop all >X >X(by default ctrl-b d detaches from tmux). >08f317d2efdcbca70cd87748f6d0df00 >echo x - bhyve-rc/Makefile >sed 's/^X//' >bhyve-rc/Makefile << 'fd453146a6e0f48a938d410ed13f9cb7' >X# Created by: Michael Gmelin <freebsd@grem.de> >X# $FreeBSD$ >X >XPORTNAME= bhyve-rc >XPORTVERSION= 1 >XCATEGORIES= sysutils >XMASTER_SITES= # none >XDISTFILES= # none >X >XMAINTAINER= freebsd@grem.de >XCOMMENT= FreeBSD RC script for starting bhyve guests in tmux >X >XRUN_DEPENDS= tmux:${PORTSDIR}/sysutils/tmux >X >XNO_WRKSUBDIR= yes >XNO_BUILD= yes >X >XUSE_RC_SUBR= bhyve >X >X.include <bsd.port.pre.mk> >X >X.if ${OSVERSION} < 1000000 >XIGNORE= bhyve first appeared in FreeBSD 10.0 >X.endif >X >Xdo-fetch do-install: >X @${DO_NADA} >X >X.include <bsd.port.post.mk> >fd453146a6e0f48a938d410ed13f9cb7 >echo x - bhyve-rc/pkg-descr >sed 's/^X//' >bhyve-rc/pkg-descr << '123826cc3a27c1c38f22c520ea39dac1' >XFreeBSD RC script to start bhyve guests in tmux >123826cc3a27c1c38f22c520ea39dac1 >exit
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 183604
: 137872