any primer on running bhyve guests sharing disk with host ?

John Baldwin jhb at FreeBSD.org
Tue Jan 6 14:55:27 UTC 2015


On 1/3/15 1:43 PM, Craig Rodrigues wrote:
> On Sat, Jan 3, 2015 at 8:15 AM, Luigi Rizzo <rizzo at iet.unipi.it> wrote:
> 
>> Hi,
>> in order to do some kernel testing, I would like to run bhyve guests
>> using (through NFS, probably) the host's file system.
>> diskless(8) is probably one way to go, i was wondering if
>> someone has instructions for that.
>> Specifically:
>> - how to "bhyveload" a kernel (rather than the full disk image);
>>   as an alternative, given a kernel, something to build an image
>>   that can be passed to bhyveload
>>
>> - how to pass the necessary config (rootpath) to the client
>>   without having to rely on a specialized dhcp server
>>
>> I used to be familiar with diskless configs, so i can probably sort
>> out the server side myself.
>>

< Neel already covered -h with bhyveload which you can also use with -H
to vmrun.sh, though the other way I do this is to NFS export my work
tree from the host to the guest so I can run kgdb on the host but do the
build / install in the guest itself. >

> I don't think there is a way to do exactly what you want.
> I would recommend doing the following:
> 
> (1)  Enable bvmdebug in your kernel config:
> https://wiki.freebsd.org/BHyVe/gdb
>       This allows you to do kgdb remote debugging into a bhyve VM.

At this point it is probably simpler to use the serial port instead.  I
have hacked up vmrun.sh locally to always create a /dev/nmdm<vmname>2B
device hooked up to com2 and to add 0x80 to the flags for uart1 in
device.hints in all my VMs.  You can then use kgdb from the host and
'target remote /dev/nmdm<vmname>2A'.

--- /usr/share/examples/bhyve/vmrun.sh	2014-11-20 18:38:34.000000000 -0500
+++ /home/john/bhyve/vmrun.sh	2015-01-06 09:54:47.000000000 -0500
@@ -230,6 +230,9 @@
 	    nextslot=$(($nextslot + 1))
 	    i=$(($i + 1))
 	done
+	if kldstat -qm nmdm; then
+	    devargs="$devargs -l com2,/dev/nmdm${vmname}2B"
+	fi

 	${FBSDRUN} -c ${cpus} -m ${memsize} ${apic_opt} -A -H -P	\
 		-g ${gdbport}						\


-- 
John Baldwin


More information about the freebsd-current mailing list