From owner-svn-src-all@FreeBSD.ORG Wed Apr 23 20:55:08 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 81599EA6; Wed, 23 Apr 2014 20:55:08 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E1311718; Wed, 23 Apr 2014 20:55:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3NKt8Tp036691; Wed, 23 Apr 2014 20:55:08 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3NKt8Of036690; Wed, 23 Apr 2014 20:55:08 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201404232055.s3NKt8Of036690@svn.freebsd.org> From: John Baldwin Date: Wed, 23 Apr 2014 20:55:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264837 - head/share/examples/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2014 20:55:08 -0000 Author: jhb Date: Wed Apr 23 20:55:07 2014 New Revision: 264837 URL: http://svnweb.freebsd.org/changeset/base/264837 Log: - Format the usage so that it fits in 80 cols and follows the standard convention for long usage lines in manpages. - Sort the option string passed to getopts and the case statements for the option returned by getopts. - Add a -C option to specify the device to be used for the console (defaults to 'stdio') (This could be let vmrun be run in the background by using /dev/nmdm0B or the like) - Add a -H option to specify a host path to pass to bhyveload(8) via -h to back the host0: filesystem in bhyveload(8) (useful for loading kernels from the host into the guest without having to copy them into the guest's disk image first) Reviewed by: neel MFC after: 2 weeks Modified: head/share/examples/bhyve/vmrun.sh Modified: head/share/examples/bhyve/vmrun.sh ============================================================================== --- head/share/examples/bhyve/vmrun.sh Wed Apr 23 20:32:39 2014 (r264836) +++ head/share/examples/bhyve/vmrun.sh Wed Apr 23 20:55:07 2014 (r264837) @@ -34,18 +34,25 @@ FBSDRUN=/usr/sbin/bhyve DEFAULT_MEMSIZE=512M DEFAULT_CPUS=2 DEFAULT_TAPDEV=tap0 +DEFAULT_CONSOLE=stdio DEFAULT_VIRTIO_DISK="./diskdev" DEFAULT_ISOFILE="./release.iso" usage() { - echo "Usage: vmrun.sh [-hai][-g ][-m ][-d ][-e ][-I ][-t ] " + echo "Usage: vmrun.sh [-ahi] [-c ] [-C ] [-d ]" + echo " [-e ] [-g ] [-H ]" + echo " [-I ] [-m ]" + echo " [-t ] " + echo "" echo " -h: display this help message" - echo " -a: force memory mapped local apic access" + echo " -a: force memory mapped local APIC access" 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 " -e: set FreeBSD loader environment variable" echo " -g: listen for connection from kgdb at " + 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 " -m: memory size (default is ${DEFAULT_MEMSIZE})" @@ -69,28 +76,36 @@ fi force_install=0 isofile=${DEFAULT_ISOFILE} memsize=${DEFAULT_MEMSIZE} +console=${DEFAULT_CONSOLE} cpus=${DEFAULT_CPUS} virtio_diskdev=${DEFAULT_VIRTIO_DISK} tapdev=${DEFAULT_TAPDEV} apic_opt="" gdbport=0 -env_opt="" +loader_opt="" -while getopts haic:e:g:I:m:d:t: c ; do +while getopts ac:C:d:e:g:hH:iI:m:t: c ; do case $c in - h) - usage - ;; a) apic_opt="-a" ;; + c) + cpus=${OPTARG} + ;; + C) + console=${OPTARG} + ;; d) virtio_diskdev=${OPTARG} ;; e) - env_opt="${env_opt} -e ${OPTARG}" + loader_opt="${loader_opt} -e ${OPTARG}" ;; - g) gdbport=${OPTARG} + g) + gdbport=${OPTARG} + ;; + H) + host_base=`realpath ${OPTARG}` ;; i) force_install=1 @@ -98,16 +113,13 @@ while getopts haic:e:g:I:m:d:t: c ; do I) isofile=${OPTARG} ;; - c) - cpus=${OPTARG} - ;; m) memsize=${OPTARG} ;; t) tapdev=${OPTARG} ;; - \?) + *) usage ;; esac @@ -120,6 +132,9 @@ if [ $# -ne 1 ]; then fi vmname="$1" +if [ -n "${host_base}" ]; then + loader_opt="${loader_opt} -h ${host_base}" +fi # Create the virtio diskdev file if needed if [ ! -f ${virtio_diskdev} ]; then @@ -168,7 +183,8 @@ while [ 1 ]; do installer_opt="" fi - ${LOADER} -m ${memsize} -d ${BOOTDISK} ${env_opt} ${vmname} + ${LOADER} -c ${console} -m ${memsize} -d ${BOOTDISK} ${loader_opt} \ + ${vmname} if [ $? -ne 0 ]; then break fi @@ -179,7 +195,7 @@ while [ 1 ]; do -s 1:0,lpc \ -s 2:0,virtio-net,${tapdev} \ -s 3:0,virtio-blk,${virtio_diskdev} \ - -l com1,stdio \ + -l com1,${console} \ ${installer_opt} \ ${vmname} if [ $? -ne 0 ]; then