From owner-svn-src-head@freebsd.org Thu Oct 8 02:28:24 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 923EB9D0E80; Thu, 8 Oct 2015 02:28:24 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 4FC33E89; Thu, 8 Oct 2015 02:28:24 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t982SN7S061300; Thu, 8 Oct 2015 02:28:23 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t982SNU5061297; Thu, 8 Oct 2015 02:28:23 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201510080228.t982SNU5061297@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Thu, 8 Oct 2015 02:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289001 - in head: share/examples/bhyve usr.sbin/bhyveload X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2015 02:28:24 -0000 Author: marcel Date: Thu Oct 8 02:28:22 2015 New Revision: 289001 URL: https://svnweb.freebsd.org/changeset/base/289001 Log: Add option -l for specifying which OS loader to dlopen(3). By default this is /boot/userboot.so. This option allows for the development and use of other OS loaders. Modified: head/share/examples/bhyve/vmrun.sh head/usr.sbin/bhyveload/bhyveload.8 head/usr.sbin/bhyveload/bhyveload.c Modified: head/share/examples/bhyve/vmrun.sh ============================================================================== --- head/share/examples/bhyve/vmrun.sh Thu Oct 8 01:17:45 2015 (r289000) +++ head/share/examples/bhyve/vmrun.sh Thu Oct 8 02:28:22 2015 (r289001) @@ -48,8 +48,8 @@ usage() { echo "Usage: vmrun.sh [-ahi] [-c ] [-C ] [-d ]" echo " [-e ] [-g ] [-H ]" - echo " [-I ] [-m ]" - echo " [-t ] " + echo " [-I ] [-l ]" + echo " [-m ] [-t ] " echo "" echo " -h: display this help message" echo " -a: force memory mapped local APIC access" @@ -61,6 +61,7 @@ usage() { 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 " -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 " -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)" @@ -92,7 +93,7 @@ loader_opt="" bhyverun_opt="-H -A -P" pass_total=0 -while getopts ac:C:d:e:g:hH:iI:m:p:t: c ; do +while getopts ac:C:d:e:g:hH:iI:l:m:p:t: c ; do case $c in a) bhyverun_opt="${bhyverun_opt} -a" @@ -125,6 +126,9 @@ while getopts ac:C:d:e:g:hH:iI:m:p:t: c I) isofile=${OPTARG} ;; + l) + loader_opt="${loader_opt} -l ${OPTARG}" + ;; m) memsize=${OPTARG} ;; Modified: head/usr.sbin/bhyveload/bhyveload.8 ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.8 Thu Oct 8 01:17:45 2015 (r289000) +++ head/usr.sbin/bhyveload/bhyveload.8 Thu Oct 8 02:28:22 2015 (r289001) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 2012 +.Dd October 7, 2015 .Dt BHYVELOAD 8 .Os .Sh NAME @@ -40,6 +40,7 @@ guest inside a bhyve virtual machine .Op Fl d Ar disk-path .Op Fl e Ar name=value .Op Fl h Ar host-path +.Op Fl l Ar os-loader .Op Fl m Ar mem-size .Ar vmname .Sh DESCRIPTION @@ -56,6 +57,7 @@ is based on and will present an interface identical to the .Fx loader on the user's terminal. +This behavior can be changed by specifying a different OS loader. .Pp The virtual machine is identified as .Ar vmname @@ -78,7 +80,9 @@ The .Ar disk-path is the pathname of the guest's boot disk image. .It Fl e Ar name=value -Set the FreeBSD loader environment variable +Set the +.Fx +loader environment variable .Ar name to .Ar value . @@ -89,6 +93,15 @@ variable. The .Ar host-path is the directory at the top of the guest's boot filesystem. +.It Fl l Ar os-loader +Specify a different OS loader. +By default +.Nm +will use +.Pa /boot/userboot.so , +which presents a standard +.Fx +loader. .It Fl m Ar mem-size Xo .Sm off .Op Cm K | k | M | m | G | g | T | t Modified: head/usr.sbin/bhyveload/bhyveload.c ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.c Thu Oct 8 01:17:45 2015 (r289000) +++ head/usr.sbin/bhyveload/bhyveload.c Thu Oct 8 02:28:22 2015 (r289001) @@ -639,6 +639,7 @@ usage(void) int main(int argc, char** argv) { + char *loader; void *h; void (*func)(struct loader_callbacks *, void *, int, int); uint64_t mem_size; @@ -646,13 +647,15 @@ main(int argc, char** argv) progname = basename(argv[0]); + loader = NULL; + memflags = 0; mem_size = 256 * MB; consin_fd = STDIN_FILENO; consout_fd = STDOUT_FILENO; - while ((opt = getopt(argc, argv, "Sc:d:e:h:m:")) != -1) { + while ((opt = getopt(argc, argv, "Sc:d:e:h:l:m:")) != -1) { switch (opt) { case 'c': error = altcons_open(optarg); @@ -674,6 +677,14 @@ main(int argc, char** argv) host_base = optarg; break; + case 'l': + if (loader != NULL) + errx(EX_USAGE, "-l can only be given once"); + loader = strdup(optarg); + if (loader == NULL) + err(EX_OSERR, "malloc"); + break; + case 'm': error = vm_parse_memsize(optarg, &mem_size); if (error != 0) @@ -726,26 +737,36 @@ main(int argc, char** argv) exit(1); } - tcgetattr(consout_fd, &term); - oldterm = term; - cfmakeraw(&term); - term.c_cflag |= CLOCAL; - - tcsetattr(consout_fd, TCSAFLUSH, &term); - - h = dlopen("/boot/userboot.so", RTLD_LOCAL); + if (loader == NULL) { + loader = strdup("/boot/userboot.so"); + if (loader == NULL) + err(EX_OSERR, "malloc"); + } + h = dlopen(loader, RTLD_LOCAL); if (!h) { printf("%s\n", dlerror()); + free(loader); return (1); } func = dlsym(h, "loader_main"); if (!func) { printf("%s\n", dlerror()); + free(loader); return (1); } + tcgetattr(consout_fd, &term); + oldterm = term; + cfmakeraw(&term); + term.c_cflag |= CLOCAL; + + tcsetattr(consout_fd, TCSAFLUSH, &term); + addenv("smbios.bios.vendor=BHYVE"); addenv("boot_serial=1"); func(&cb, NULL, USERBOOT_VERSION_3, ndisks); + + free(loader); + return (0); }