Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Feb 2018 19:08:17 +0000 (UTC)
From:      "Rodney W. Grimes" <rgrimes@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r329179 - stable/11/share/examples/bhyve
Message-ID:  <201802121908.w1CJ8H5i017826@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rgrimes
Date: Mon Feb 12 19:08:17 2018
New Revision: 329179
URL: https://svnweb.freebsd.org/changeset/base/329179

Log:
  MFC:	r328695,r328720,r328784,r328795 share/examples/bhyve/vmrun.sh additions
  	and cleanups
  
  r328695:
  	Add option '-n' network device emulation type which has a default
  	of virtio-net
  	PR:		225558
  	Submitted by:	Johannes Lundberg <johalun0@gmail.com>
  
  r328720:
  	Add -n <network device emulation type> to usage synopsis
  	forgotten in r328695.
  
  	Fix long lines in usage.
  	Consistently use "default:" rather than "default is"
  
  r328784:
  	Clean up long lines.
  
  r328795:
  	Fold constants and unify vnc variable names.
  
  Approved by:	grehan (mentor)
  
  PR:		225558

Modified:
  stable/11/share/examples/bhyve/vmrun.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/examples/bhyve/vmrun.sh
==============================================================================
--- stable/11/share/examples/bhyve/vmrun.sh	Mon Feb 12 18:52:59 2018	(r329178)
+++ stable/11/share/examples/bhyve/vmrun.sh	Mon Feb 12 19:08:17 2018	(r329179)
@@ -36,9 +36,15 @@ DEFAULT_CPUS=2
 DEFAULT_TAPDEV=tap0
 DEFAULT_CONSOLE=stdio
 
+DEFAULT_NIC=virtio-net
+DEFAULT_DISK=virtio-blk
 DEFAULT_VIRTIO_DISK="./diskdev"
 DEFAULT_ISOFILE="./release.iso"
 
+DEFAULT_VNCHOST="127.0.0.1"
+DEFAULT_VNCPORT=5900
+DEFAULT_VNCSIZE="w=1024,h=768"
+
 errmsg() {
 	echo "*** $1"
 }
@@ -46,33 +52,43 @@ errmsg() {
 usage() {
 	local msg=$1
 
-	echo "Usage: vmrun.sh [-aAEhiTv] [-c <CPUs>] [-C <console>] [-d <disk file>]"
-	echo "                [-e <name=value>] [-f <path of firmware>] [-F <size>]"
+	echo "Usage: vmrun.sh [-aAEhiTv] [-c <CPUs>] [-C <console>]" \
+	    "[-d <disk file>]"
+	echo "                [-e <name=value>] [-f <path of firmware>]" \
+	    "[-F <size>]"
 	echo "                [-g <gdbport> ] [-H <directory>]"
 	echo "                [-I <location of installation iso>] [-l <loader>]"
 	echo "                [-L <VNC IP for UEFI framebuffer>]"
-	echo "                [-m <memsize>] [-P <port>] [-t <tapdev>] <vmname>"
+	echo "                [-m <memsize>]" \
+	    "[-n <network adapter emulation type>]"
+	echo "                [-P <port>] [-t <tapdev>] <vmname>"
 	echo ""
 	echo "       -h: display this help message"
 	echo "       -a: force memory mapped local APIC access"
-	echo "       -A: use AHCI disk emulation instead of virtio"
-	echo "       -c: number of virtual cpus (default is ${DEFAULT_CPUS})"
-	echo "       -C: console device (default is ${DEFAULT_CONSOLE})"
-	echo "       -d: virtio diskdev file (default is ${DEFAULT_VIRTIO_DISK})"
+	echo "       -A: use AHCI disk emulation instead of ${DEFAULT_DISK}"
+	echo "       -c: number of virtual cpus (default: ${DEFAULT_CPUS})"
+	echo "       -C: console device (default: ${DEFAULT_CONSOLE})"
+	echo "       -d: virtio diskdev file (default: ${DEFAULT_VIRTIO_DISK})"
 	echo "       -e: set FreeBSD loader environment variable"
 	echo "       -E: Use UEFI mode"
 	echo "       -f: Use a specific UEFI firmware"
-	echo "       -F: Use a custom UEFI GOP framebuffer size (default: w=1024,h=768)"
+	echo "       -F: Use a custom UEFI GOP framebuffer size" \
+	    "(default: ${DEFAULT_VNCSIZE}"
 	echo "       -g: listen for connection from kgdb at <gdbport>"
 	echo "       -H: host filesystem to export to the loader"
 	echo "       -i: force boot of the Installation CDROM image"
-	echo "       -I: Installation CDROM image location (default is ${DEFAULT_ISOFILE})"
-	echo "       -l: the OS loader to use (default is /boot/userboot.so)"
-	echo "       -L: IP address for UEFI GOP VNC server (default: 127.0.0.1)"
-	echo "       -m: memory size (default is ${DEFAULT_MEMSIZE})"
-	echo "       -p: pass-through a host PCI device at bus/slot/func (e.g. 10/0/0)"
-	echo "       -P: UEFI GOP VNC port (default: 5900)"
-	echo "       -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)"
+	echo "       -I: Installation CDROM image location" \
+	    "(default: ${DEFAULT_ISOFILE})"
+	echo "       -l: the OS loader to use (default: /boot/userboot.so)"
+	echo "       -L: IP address for UEFI GOP VNC server" \
+	    "(default: ${DEFAULT_VNCHOST}"
+	echo "       -m: memory size (default: ${DEFAULT_MEMSIZE})"
+	echo "       -n: network adapter emulation type" \
+	    "(default: ${DEFAULT_NIC})"
+	echo "       -p: pass-through a host PCI device at bus/slot/func" \
+	    "(e.g. 10/0/0)"
+	echo "       -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})"
+	echo "       -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)"
 	echo "       -T: Enable tablet device (for UEFI GOP)"
 	echo "       -u: RTC keeps UTC time"
 	echo "       -v: Wait for VNC client connection before booting VM"
@@ -98,9 +114,10 @@ isofile=${DEFAULT_ISOFILE}
 memsize=${DEFAULT_MEMSIZE}
 console=${DEFAULT_CONSOLE}
 cpus=${DEFAULT_CPUS}
+nic=${DEFAULT_NIC}
 tap_total=0
 disk_total=0
-disk_emulation="virtio-blk"
+disk_emulation=${DEFAULT_DISK}
 gdbport=0
 loader_opt=""
 bhyverun_opt="-H -A -P"
@@ -110,12 +127,12 @@ pass_total=0
 efi_mode=0
 efi_firmware="/usr/local/share/uefi-firmware/BHYVE_UEFI.fd"
 vncwait=""
-vnchost="127.0.0.1"
-vncport=5900
-fbsize="w=1024,h=768"
+vnchost=${DEFAULT_VNCHOST}
+vncport=${DEFAULT_VNCPORT}
+vncsize=${DEFAULT_VNCSIZE}
 tablet=""
 
-while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:m:p:P:t:Tuvw c ; do
+while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:m:n:p:P:t:Tuvw c ; do
 	case $c in
 	a)
 		bhyverun_opt="${bhyverun_opt} -a"
@@ -146,7 +163,7 @@ while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:m:p:P:t:Tuvw c 
 		efi_firmware="${OPTARG}"
 		;;
 	F)
-		fbsize="${OPTARG}"
+		vncsize="${OPTARG}"
 		;;
 	g)	
 		gdbport=${OPTARG}
@@ -169,6 +186,9 @@ while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:m:p:P:t:Tuvw c 
 	m)
 		memsize=${OPTARG}
 		;;
+	n)
+		nic=${OPTARG}
+		;;
 	p)
 		eval "pass_dev${pass_total}=\"${OPTARG}\""
 		pass_total=$(($pass_total + 1))
@@ -227,7 +247,8 @@ fi
 
 if [ ${efi_mode} -gt 0 ]; then
 	if [ ! -f ${efi_firmware} ]; then
-		echo "Error: EFI Firmware ${efi_firmware} doesn't exist. Try: pkg install uefi-edk2-bhyve"
+		echo "Error: EFI Firmware ${efi_firmware} doesn't exist." \
+		    "Try: pkg install uefi-edk2-bhyve"
 		exit 1
 	fi
 fi
@@ -264,7 +285,8 @@ while [ 1 ]; do
 	file -s ${first_diskdev} | grep "boot sector" > /dev/null
 	rc=$?
 	if [ $rc -ne 0 ]; then
-		file -s ${first_diskdev} | grep ": Unix Fast File sys" > /dev/null
+		file -s ${first_diskdev} | \
+		    grep ": Unix Fast File sys" > /dev/null
 		rc=$?
 	fi
 	if [ $rc -ne 0 ]; then
@@ -295,8 +317,8 @@ while [ 1 ]; do
 	fi
 
 	if [ ${efi_mode} -eq 0 ]; then
-		${LOADER} -c ${console} -m ${memsize} ${BOOTDISKS} ${loader_opt} \
-			${vmname}
+		${LOADER} -c ${console} -m ${memsize} ${BOOTDISKS} \
+		    ${loader_opt} ${vmname}
 		bhyve_exit=$?
 		if [ $bhyve_exit -ne 0 ]; then
 			break
@@ -311,7 +333,7 @@ while [ 1 ]; do
 	i=0
 	while [ $i -lt $tap_total ] ; do
 	    eval "tapname=\$tap_dev${i}"
-	    devargs="$devargs -s $nextslot:0,virtio-net,${tapname} "
+	    devargs="$devargs -s $nextslot:0,${nic},${tapname} "
 	    nextslot=$(($nextslot + 1))
 	    i=$(($i + 1))
 	done
@@ -336,7 +358,8 @@ while [ 1 ]; do
 
 	efiargs=""
 	if [ ${efi_mode} -gt 0 ]; then
-		efiargs="-s 29,fbuf,tcp=${vnchost}:${vncport},${fbsize}${vncwait}"
+		efiargs="-s 29,fbuf,tcp=${vnchost}:${vncport},"
+		efiargs="${efiargs}${vncsize}${vncwait}"
 		efiargs="${efiargs} -l bootrom,${efi_firmware}"
 		efiargs="${efiargs} ${tablet}"
 	fi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802121908.w1CJ8H5i017826>