Skip to content

Commit

Permalink
Implement ability to use the pre compiled base from other sources via…
Browse files Browse the repository at this point in the history
… specify path to archve ( https://github.com/olevole/cbsd/issues/57 ); bhyve fixes: soft shutdown
  • Loading branch information
olevole committed Apr 23, 2016
1 parent 2c32c3f commit 3ca1c87
Show file tree
Hide file tree
Showing 28 changed files with 531 additions and 34 deletions.
11 changes: 11 additions & 0 deletions bhyve.subr
Expand Up @@ -212,6 +212,17 @@ compile_lpc_args()
lpc_args="-s ${bhyve_pci_index}:0,lpc"
}

# export arguments for bhyve pci_passthru_args
compile_pci_passthru_args()
{
if ! next_pci_id; then
return 1
fi

pci_passthru_args="-s ${bhyve_pci_index},passthru,2/0/0 -S"
}


# export arguments for bhyve efi_args
compile_efi_args()
{
Expand Down
2 changes: 1 addition & 1 deletion bin/cbsdsh/about.c
Expand Up @@ -2,7 +2,7 @@
// For identification of correct CBSD shell only
#include "output.h"

#define VERSION "10.3.0"
#define VERSION "10.3.2"

int
aboutcmd(int argc, char **argv)
Expand Down
4 changes: 3 additions & 1 deletion cbsd.conf
@@ -1,5 +1,5 @@
product="CBSD"
myversion="10.3.0"
myversion="10.3.2"

if [ -z "${workdir}" ]; then
echo "no workdir"
Expand Down Expand Up @@ -75,6 +75,8 @@ sshdir="${workdir}/.ssh"
templateldir="${workdir}/template"
fwcount_st="99"
fwcount_end="2000"
fwexpose_st="2001"
fwexpose_end="2999"
rsync_flags="arlHpEAXogt8 --delete"
greeting="node"
jailmapdb="${dbdir}/jmap.txt"
Expand Down
2 changes: 1 addition & 1 deletion cbsd.lua
@@ -1,5 +1,5 @@
product="CBSD"
myversion="10.3.0"
myversion="10.3.2"

if not workdir then
print ( "no workdir" )
Expand Down
2 changes: 2 additions & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-amd64-11
Expand Up @@ -22,3 +22,5 @@ options TERMINAL_NORM_ATTR=(FG_GREEN|BG_BLACK)
#nooptions SC_PIXEL_MODE

options VIMAGE

options CAM_NETFLIX_IOSCHED
1 change: 1 addition & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-amd64-11.0
Expand Up @@ -23,3 +23,4 @@ device vt_vga
nooptions VESA

options VIMAGE
options CAM_NETFLIX_IOSCHED
1 change: 1 addition & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-amd64-11.1
Expand Up @@ -23,3 +23,4 @@ device vt_vga
nooptions VESA

options VIMAGE
options CAM_NETFLIX_IOSCHED
1 change: 1 addition & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-i386-11
Expand Up @@ -23,3 +23,4 @@ device vt_vga
nooptions VESA

options VIMAGE
options CAM_NETFLIX_IOSCHED
1 change: 1 addition & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-i386-11.0
Expand Up @@ -23,3 +23,4 @@ device vt_vga
nooptions VESA

options VIMAGE
options CAM_NETFLIX_IOSCHED
26 changes: 26 additions & 0 deletions etc/defaults/FreeBSD-kernel-GENERIC-i386-11.1
@@ -0,0 +1,26 @@
include GENERIC

ident GENERIC_CBSD

nooptions KDB # Enable kernel debugger support.
nooptions KDB_TRACE # Print a stack trace for a panic.
nooptions DDB # Support DDB.
nooptions GDB # Support remote GDB.
nooptions DEADLKRES # Enable the deadlock resolver
nooptions INVARIANTS # Enable calls of extra sanity checking
nooptions INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
nooptions WITNESS # Enable checks to detect deadlocks and cycles
nooptions WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
nooptions MALLOC_DEBUG_MAXZONES

options TERMINAL_NORM_ATTR=(FG_GREEN|BG_BLACK)
options VT_FB_DEFAULT_WIDTH=1024
options VT_FB_DEFAULT_HEIGHT=768
nodevice sc
nodevice vga
device vt
device vt_vga
nooptions VESA

options VIMAGE
options CAM_NETFLIX_IOSCHED
29 changes: 29 additions & 0 deletions etc/defaults/vm-linux-ubuntuserver-x86-16.04.conf
@@ -0,0 +1,29 @@
# don't remove this line:
vm_profile="ubuntuserver-x86-16.04"

# this is one-string additional info strings in dialogue menu
long_description="Linux UbuntuServer LTS 16.04 x86-64 (64 bit) architecture"

# custom settings:
fetch=1
bhyve_flags="-W" # Additional bhyve(8) flags

# grub-bhyve command to boot from IMG
grub_boot_cmd="/usr/bin/lockf -s -t0 /tmp/bhyveload.${jname}.lock grub-bhyve -r hd0,msdos1 -m ${_devicemap} -M ${grubmem} ${jname}"

# grub-bhyve command to boot from ISO
grub_iso_cmd="/usr/bin/lockf -s -t0 /tmp/bhyveload.${jname}.lock grub-bhyve -r cd0 -m ${_devicemap} -M ${grubmem} ${jname}"

iso_site="http://mirror.corbina.net/ubuntu-cd/16.04/ \
http://mirror.yandex.ru/ubuntu-releases/16.04/ \
http://de.releases.ubuntu.com/16.04/ \
http://releases.ubuntu.com/16.04/"

iso_img="ubuntu-16.04-server-amd64.iso"

default_jailname="ubuntusrv"
imgsize="6g"
boot_from_grub=1

# disable profile?
active=1
7 changes: 7 additions & 0 deletions jailctl/bstart
Expand Up @@ -222,6 +222,12 @@ start_bhyve()
unset lpc_args
fi

# init pci_passthru_args
if ! compile_pci_passthru_args; then
${ECHO} "${MAGENTA}No such pci_passthru for VMs: ${GREEN}${jname}${NORMAL}"
unset pci_passthru_args
fi

# init efi_args
if ! compile_efi_args; then
${ECHO} "${MAGENTA}No such efi for VMs: ${GREEN}${jname}${NORMAL}"
Expand Down Expand Up @@ -301,6 +307,7 @@ vm_console='${vm_console}'
hostbridge_args='${hostbridge_args}'
passthr='${passthr}'
lpc_args='${lpc_args}'
pci_passthru_args='${pci_passthru_args}'
virtiornd_args='${virtiornd_args}'
nic_args='${nic_args}'
dsk_args='${dsk_args}'
Expand Down
31 changes: 24 additions & 7 deletions jailctl/bstop
@@ -1,5 +1,5 @@
#!/usr/local/bin/cbsd
#v10.0.3
#v10.2.3
globalconf="${workdir}/cbsd.conf";
MYARG=""
MYOPTARG="jname"
Expand Down Expand Up @@ -43,12 +43,29 @@ fi
#[ ${jid} -eq 0 ] && err 1 "${MAGENTA}Not Running: ${GREEN}${jname}${NORMAL}"
[ "${emulator}" != "bhyve" ] && err 1 "${MAGENTA}Not in bhyve mode${NORMAL}"

/bin/ps axopid,ucomm,command|while read pid comm cmd; do
if [ "${comm}" = "bhyve" -o "${comm}" = "grub-bhyve" ]; then
_res=$( echo $cmd|grep " ${jname}$" 2>/dev/null)
[ -n "${_res}" ] && kill $pid
fi
done
pid=

pid=$( /bin/ps axopid,ucomm,command|while read pid comm cmd; do
case "${comm}" in
bhyve|grub-bhyve)
_res=$( echo $cmd|/usr/bin/grep " ${jname}" 2>/dev/null)
[ -n "${_res}" ] && echo "${pid}" && exit 0
;;
esac
done 2>/dev/null)

if [ -n "${pid}" ]; then
# soft stop, send SIGTERM
printf "${MAGENTA}Send SIGTERM to VM: ${GREEN}${jname}${NORMAL}"
/bin/kill -15 ${pid}
for i in $( /usr/bin/seq 1 30 ); do
cbsd_pwait --pid=${pid} --timeout=1 > /dev/null 2>&1
printf "${MAGENTA}."
done
printf "${NORMAL}\n"
else
${ECHO} "${MAGENTA}Warning: unable to determine bhyve pid for: ${GREEN}${jname}${NORMAL}"
fi

/usr/sbin/bhyvectl --destroy --vm="${jname}"

Expand Down
9 changes: 8 additions & 1 deletion jailctl/jmkrctlconf
Expand Up @@ -31,7 +31,14 @@ tofile()
for i in ${RCTL}; do
VAL=$( cbsdsql local SELECT ${i} FROM rctl WHERE jname=\"${jname}\" )
[ "${VAL}" = "(null)" -o -z "${VAL}" -o "${VAL}" = "0" ] && continue
echo "${i}:deny=${VAL}" > ${file}
case "${i}" in
readbps|writebps|readiops|writeiops)
echo "${i}:throttle=${VAL}" > ${file}
;;
*)
echo "${i}:deny=${VAL}" > ${file}
;;
esac
done
;;
"extra")
Expand Down
4 changes: 2 additions & 2 deletions jailctl/jrctl
Expand Up @@ -26,10 +26,10 @@ init $*
[ "${shownode}" = "1" ] && display="nodename,${display}"

#remove commas for loop action on header
mydisplay=$( echo ${display} |tr ',' ' ' )
mydisplay=$( echo ${display} |/usr/bin/tr ',' ' ' )

# upper for header
myheader=$( echo ${mydisplay} |tr '[:lower:]' '[:upper:]' )
myheader=$( echo ${mydisplay} |/usr/bin/tr '[:lower:]' '[:upper:]' )
JLS=""

show_header()
Expand Down
9 changes: 8 additions & 1 deletion jailctl/jrctl-tui
Expand Up @@ -48,7 +48,14 @@ choice_commit()
cbsdsql local UPDATE rctl SET ${_items}=\"${_myval}\" WHERE jname=\"${jname}\"

if [ "${_myval}" != "0" ]; then
echo "${_items}:deny=${_myval}" >> ${LIMITS}
case "${_items}" in
readbps|writebps|readiops|writeiops)
echo "${_items}:throttle=${_myval}" > ${LIMITS}
;;
*)
echo "${_items}:deny=${_myval}" > ${LIMITS}
;;
esac
_num=$((_num+1))
fi
done
Expand Down
2 changes: 2 additions & 0 deletions securecmd
Expand Up @@ -24,6 +24,7 @@ buildkernel \
buildworld \
carpcfg \
delete-old-libs \
expose \
geli \
getnics-by-ip \
help \
Expand Down Expand Up @@ -96,6 +97,7 @@ retrinv \
rexe \
rsyncdoff \
rsyncdon \
sockstat \
srcls \
summary \
srcpatch \
Expand Down
9 changes: 6 additions & 3 deletions share/bhyverun.sh
Expand Up @@ -49,14 +49,17 @@ while [ ! -f /tmp/bhyvestop.${jname}.lock ]; do
fi
fi

echo "[debug] /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${passthr} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname};"
logger -t CBSD "[debug] /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${passthr} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname};"
#passthru
#echo "[debug] /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${passthr} ${lpc_args} ${pci_passthru_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname};"
echo "[debug] /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname};"

logger -t CBSD "[debug] /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname};"

for i in ${mytap}; do
/sbin/ifconfig ${i} up
done

/usr/bin/lockf -s -t0 /tmp/bhyveload.${jname}.lock /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${passthr} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname} || touch /tmp/bhyvestop.${jname}.lock
/usr/bin/lockf -s -t0 /tmp/bhyveload.${jname}.lock /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -A -H -P ${hostbridge_args} ${lpc_args} ${efi_args} ${virtiornd_args} ${nic_args} ${dsk_args} ${cd_args} ${console_args} ${jname} || touch /tmp/bhyvestop.${jname}.lock
# /usr/bin/lockf -s -t0 /tmp/bhyveload.${jname}.lock /usr/sbin/bhyve ${bhyve_flags} -c ${vm_cpus} -m ${vm_ram} -H ${passthr} ${lpc_args} ${efi_args} ${cd_args} ${console_args} ${jname} || touch /tmp/bhyvestop.${jname}.lock

# /usr/sbin/bhyvectl --get-vmcs-exit-reason --vm ${jname} >> /tmp/reason.txt
Expand Down
7 changes: 6 additions & 1 deletion share/jrctl-arg
Expand Up @@ -23,4 +23,9 @@ wallclock \
pcpu \
fsquota \
nice \
bw"
bw \
readbps \
writebps \
readiops \
writeiops"

4 changes: 4 additions & 0 deletions share/local-rctl.schema
Expand Up @@ -30,6 +30,10 @@ pcpu="integer default 0"
fsquota="integer default 0"
nice="integer default 0"
bw="integer default 0"
readbps="integer default 0"
writebps="integer default 0"
readiops="integer default 0"
writeiops="integer default 0"

CONSTRAINT=", FOREIGN KEY(jname) REFERENCES jails(jname)"

Expand Down
15 changes: 14 additions & 1 deletion share/rctl.conf
Expand Up @@ -21,7 +21,11 @@ nsemop \
nshm \
shmsize \
wallclock \
pcpu"
pcpu \
readbps \
writebps \
readiops \
writeiops"

# non-RCTL data
RCTL_EXTRA="fsquota \
Expand Down Expand Up @@ -68,6 +72,10 @@ nshm_desc="number of SysV shared memory segments"
shmsize_desc="SysV shared memory size, in bytes or ^m ^g suffix"
wallclock_desc="wallclock time, in seconds"
pcpu_desc="%CPU, in percents of a single CPU core"
readbps_desc="filesystem reads, in bytes per second"
writebps_desc="filesystem writes, in bytes per second"
readiops_desc="filesystem reads, in operations per second"
writeiops_desc="filesystem writes, in operations per second"
#
fsquota_desc="Limit jail filesystem, in ^m ^g suffix"
nice_desc="Priority for nice: from -20 (higher pri) to 20 (lower pri)"
Expand Down Expand Up @@ -95,7 +103,12 @@ nshm_default="0"
shmsize_default="0"
wallclock_default="0"
pcpu_default="0"
readbps_default="0"
writeiops_default="0"
readiops_default="0"
writebps_default="0"
#

fsquota_default="0"
nice_default="0"
bw_default="0"
11 changes: 11 additions & 0 deletions share/system-expose.schema
@@ -0,0 +1,11 @@
# Default SQL scheme for DB nodes::nodelist
#MYTABLE="expose"
MYCOL="pin pout proto inaddr"

pin="INTEGER UNIQUE PRIMARY KEY"
pout="TEXT"
proto="VARCHAR(5) DEFAULT 'tcp'"
inaddr="VARCHAR(128) DEFAULT 'nodeip'"

INITDB=""
CONSTRAINT=""
1 change: 1 addition & 0 deletions sudoexec/initenv
Expand Up @@ -393,6 +393,7 @@ EOF
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/cbsdtaskd-taskd.schema ${sharedir}/cbsdtaskd-taskd.schema
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/zrepd.schema ${sharedir}/zrepd.schema
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/node-nodelist.schema ${sharedir}/node-nodelist.schema
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/system-expose.schema ${sharedir}/system-expose.schema
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/DragonFly-git_branches.conf ${sharedir}/DragonFly-git_branches.conf
installne "-o ${cbsduser} -g ${cbsduser} -m 444" ${distdir}/share/FreeBSD-git_branches.conf ${sharedir}/FreeBSD-git_branches.conf

Expand Down
6 changes: 3 additions & 3 deletions sudoexec/jstart
Expand Up @@ -110,7 +110,6 @@ exec_cbsdjail_first_boot()
fi
}


exec_master_prestart()
{
eval CMD=\${exec_master_prestart}
Expand Down Expand Up @@ -564,7 +563,8 @@ else
status="0"
fi
cbsdsql local UPDATE jails SET jid=$myjid,status=$status where jname=\"${jname}\"
rm -f ${ftmpdir}/${jname}.conf
/bin/rm -f ${ftmpdir}/${jname}.conf
fwcounter
[ ${myjid} -gt 0 -a ${cpuset} != "0" ] && cpuset -c -l ${cpuset} -j ${myjid}
expose jname=${jname} mode=apply
[ ${myjid} -gt 0 -a ${cpuset} != "0" ] && /usr/bin/cpuset -c -l ${cpuset} -j ${myjid}
exit 0
1 change: 1 addition & 0 deletions sudoexec/jstop
Expand Up @@ -156,6 +156,7 @@ eval multiips4=\"\$ip\"
[ $baserw -eq 1 ] && path=$data

fwcounters jname=${jname} mode=remove
expose jname=${jname} mode=clear

external_exec_master_script "master_prestop.d"
exec_master_prestop
Expand Down

0 comments on commit 3ca1c87

Please sign in to comment.