svn commit: r286980 - user/marcel/libvdsk

Marcel Moolenaar marcel at FreeBSD.org
Fri Aug 21 05:03:04 UTC 2015


Author: marcel
Date: Fri Aug 21 05:03:03 2015
New Revision: 286980
URL: https://svnweb.freebsd.org/changeset/base/286980

Log:
  Add a convenience wrapper around vmrun.sh

Added:
  user/marcel/libvdsk/vmrun.sh   (contents, props changed)

Added: user/marcel/libvdsk/vmrun.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/marcel/libvdsk/vmrun.sh	Fri Aug 21 05:03:03 2015	(r286980)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Set our defaults
+brif=bridge0
+memsz=1024M
+ncpu=`sysctl -n hw.ncpu`
+netif=`netstat -4rn | grep -e '^default ' | awk '{print $NF}'`
+tapif=tap0
+
+netif_exists() {
+    local netif=$1
+    local iflist=`ifconfig -l`
+    for I in $iflist; do
+        if test $I == $netif; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+if ! kldstat -qm vmm; then
+    kldload vmm
+fi
+
+if ! netif_exists $tapif; then
+    ifconfig $tapif create
+    sysctl net.link.tap.up_on_open=1
+fi
+
+if ! netif_exists $brif; then
+    ifconfig $brif create
+    ifconfig $brif addm $netif addm $tapif
+    ifconfig $brif up
+fi
+
+exec sh /usr/share/examples/bhyve/vmrun.sh -c $ncpu -m $memsz -t $tapif "$@"


More information about the svn-src-user mailing list