BHYVE(8)
๐ bhyve โ System Manager's Manual ๐
okay bestie, welcome to bhyve(8), straight out of the System Manager's Manual. This is the hypervisor one. Buckle up ๐
๐ธ NAME ๐ธ
bhyve โ run a guest operating system inside a virtual machine โจ
๐ฆ SYNOPSIS ๐ฆ
bhyve [-aCDeHhPSuWwxY]
[-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]] [-f
name,[string|file]=data] [-G [w][bind_address:]port]
[-k config_file] [-K layout] [-l lpcdev[,conf]]
[-m memsize[K|k|M|m|G|g|T|t]] [-o var=value] [-p vcpu:hostcpu]
[-r file] [-s slot,emulation[,conf]] [-U uuid] vmname
bhyve -l help
bhyve -s help
๐ DESCRIPTION ๐
so bhyve is a hypervisor โ it runs guest operating systems inside a virtual machine. It can run guests on amd64 and arm64 platforms, as long as you've got the suitable hardware support. no cap ๐ซถ
Stuff like the number of virtual CPUs, how much guest memory you get, and I/O connectivity? All of that is set with command-line parameters. iconic.
bhyve is typically used with a boot ROM that can load the guest operating system. On arm64 platforms, this is currently required. If you're not using a boot ROM, the guest operating system must be loaded with bhyveload(8) or a similar boot loader before running bhyve, otherwise. On amd64, the edk2-bhyve package provides a UEFI firmware that can be used to boot the guest; on arm64 the u-boot-bhyve-arm64 package provides a U-Boot image that can be used to boot the guest. ๐ง
bhyve runs until the guest operating system reboots or an unhandled hypervisor exit is detected. that's the whole lifecycle, periodt.
โจ OPTIONS โจ
-aโ the guest's local APIC is configured in xAPIC mode. This option only applies to the amd64 platform. Heads up though: xAPIC mode is the default setting, so this option is redundant ๐ and it will be deprecated in a future version.-Cโ include guest memory in core files.-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]โ number of guest virtual CPUs and/or the CPU topology. The default value for each ofnumcpus,sockets,cores, andthreadsis 1. Ifnumcpusis not specified then it gets calculated from the other arguments. The topology has to be consistent โ meaningnumcpusmust equal the product ofsockets,cores, andthreads. And if a setting is specified more than once, the last one has precedence (last one wins, always ๐ ).
The maximum number of virtual CPUs defaults to the number of active physical CPUs in the system, available via the hw.vmm.maxcpu sysctl(8) variable. That limit can be adjusted via the hw.vmm.maxcpu loader tunable.
-Dโ destroy the VM on guest initiated power-off. bye bye ๐-eโ forcebhyveto exit when a guest issues an access to an I/O port that is not emulated. This is intended for debug purposes and only applies to the amd64 platform.-f name,[string|file]=dataโ add afw_cfgfilenameto thefw_cfginterface. If astringis specified, thefw_cfgfile contains the string as data. If afileis specified,bhyvereads the file and adds the file content asfw_cfgdata.-G [w][bind_address:]portโ start a debug server that uses the GDB protocol to export guest state to a debugger. An IPv4 TCP socket will be bound to the suppliedbind_addressandportto listen for debugger connections. Only a single debugger may be attached to the debug server at a time. And if the option begins withw,bhyvewill pause execution at the first instruction, waiting for a debugger to attach ๐ซถ-Hโ yield the virtual CPU thread when a HLT instruction is detected. If this option is not specified, virtual CPUs will use 100% of a host CPU ๐ญ. This option applies only to the amd64 platform.-hโ print help message and exit.-k config_fileโ set configuration variables from a simple, key-value config file. Each line of the config file is expected to consist of a config variable name, an equals sign (=), and a value. No spaces are permitted between the variable name, equals sign, or value. Blank lines and lines starting with#are ignored. Seebhyve_config(5)for more details.-K layoutโ specify the keyboard layout. The value you can specify sets the file name in/usr/share/bhyve/kbdlayout. This specification only works when loaded with UEFI mode for VNC. When using a VNC client that supports QEMU Extended Key Event Message (e.g. TigerVNC), this option isn't needed. When using a VNC client that doesn't support QEMU Extended Key Event Message (e.g. TightVNC), the layout defaults to the US keyboard unless specified otherwise. ty keyboard girlies ๐-l helpโ print a list of supported LPC devices.-l lpcdev[,conf]โ allow devices behind the LPC PCI-ISA bridge to be configured. The only supported devices are the TTY-class devicescom1,com2,com3, andcom4, the TPM moduletpm, the boot ROM devicebootrom, thefwcfgtype and the debug/test devicepc-testdev.
The possible values for the conf argument are listed in the -s flag description.
This option applies only to the amd64 platform. On arm64, the console and boot ROM devices are configured using the more generic -o option.
-m memsize[K|k|M|m|G|g|T|t]โ set the guest physical memory size. This must be the same size that was given tobhyveload(8).
The size argument may be suffixed with one of K, M, G or T (either upper or lower case) to indicate a multiple of kilobytes, megabytes, gigabytes, or terabytes. If no suffix is given, the value is assumed to be in megabytes. The default is 256M.
-n id,size,cpus[,domain_policy]โ configure guest NUMA domains. This option applies only to the amd64 platform.
The -n option allows the guest physical address space to be partitioned into domains. The layout of each domain is encoded in an ACPI table visible to the guest operating system. The -n option also allows the specification of a domainset(9) memory allocation policy for the host memory backing a given NUMA domain. A guest can have up to 8 NUMA domains. This feature requires that the guest use a boot ROM, and in particular cannot be used if the guest was initialized using bhyveload(8). ๐
Each domain is identified by a numerical id. The domain memory size is specified using the same format as the -m flag. The sum of all size parameters overrides the total VM memory size specified by the -m flag. However, if at least one domain memory size parameter is missing, the total VM memory size will be equally distributed across all emulated domains. The cpuset parameter specifies the set of CPUs that are part of the domain. The domain_policy parameter may be optionally used to configure the domainset(9) host NUMA memory allocation policy for an emulated domain. See the -n flag in cpuset(1) for a list of valid NUMA memory allocation policies and their formats.
-o var=valueโ set the configuration variablevartovalue. Seebhyve_config(5)for configuration options.-Pโ force the guest virtual CPU to exit when a PAUSE instruction is detected. This option applies only to the amd64 platform.-p vcpu:hostcpuโ pin guest's virtual CPUvcputohostcpu. Host CPUs and guest virtual CPUs are numbered starting from 0. A-poption is required for every guest vCPU to be pinned. To map a 4 vCPU guest to host CPUs 12-15:
-p 0:12 -p 1:13 -p 2:14 -p 3:15
match made in heaven, honestly ๐ฅฐ
-r fileโ resume a guest from a snapshot. The guest memory contents are restored fromfile, and the guest device and vCPU state are restored from the file โfile.kernโ.
Note that the current snapshot file format requires that the configuration of devices in the new VM match the VM from which the snapshot was taken by specifying the same-sand-loptions. The count of vCPUs and memory configuration are read from the snapshot.
-Sโ wire guest memory.-s helpโ print a list of supported PCI devices.-s slot,emulation[,conf]โ configure a virtual PCI slot and function.
bhyve provides PCI bus emulation and virtual devices that can be attached to slots on the bus. There are 32 available slots, with the option of providing up to 8 functions per slot.
The slot can be specified in one of the following formats:
pcislotpcislot:functionbus:pcislot:function
The pcislot value is 0 to 31. The optional function value is 0 to 7. The optional bus value is 0 to 255. If not specified, the function value defaults to 0. If not specified, the bus value defaults to 0.
See โPCI EMULATIONโ for available options for the emulation argument. ๐
-U uuidโ set the universally unique identifier (UUID) in the guest's System Management BIOS System Information structure. By default a UUID is generated from the host'shostnameandvmname.-uโ RTC keeps UTC time. ๐ฐ๏ธ-Wโ force virtio PCI device emulations to use MSI interrupts instead of MSI-X interrupts.-wโ ignore accesses to unimplemented Model Specific Registers (MSRs). This is intended for debug purposes.-xโ the guest's local APIC is configured in x2APIC mode. This option applies only to the amd64 platform.-Yโ disable MPtable generation. This option applies only to the amd64 platform.vmnameโ alphanumeric name of the guest. This should be the same as that created bybhyveload(8).
๐ PCI EMULATION ๐
bhyve provides emulation for various PCI devices. They are specified by the -s slot,emulation,conf configuration's emulation argument, which can be one of the following:
hostbridgeโ a simple host bridge. This is usually configured at slot 0, and is required by most guest operating systems. lowkey the main character of PCI slots ๐amd_hostbridgeโ literally the same emulation ashostbridge, except the PCI vendor ID says AMD instead. bestie branding, that's it ๐passthruโ a PCI pass-through device. yes, the real one.virtio-netโ virtio network interface ๐virtio-blkโ virtio block storage interface ๐พvirtio-scsiโ virtio SCSI interfacevirtio-9pโ virtio 9p (VirtFS) interfacevirtio-rndโ virtio RNG interface ๐ฒvirtio-consoleโ virtio console interface, which exposes multiple ports to the guest in the form of simple char devices for simple IO between the guest and host userspacesvirtio-inputโ virtio input interfaceahciโ an AHCI controller attached to arbitrary devicesahci-cdโ an AHCI controller attached to an ATAPI CD/DVD ๐ฟahci-hdโ an AHCI controller attached to a SATA hard drivee1000โ Intel e82545 network interfaceuartโ PCI 16550 serial devicelpcโ LPC PCI-ISA bridge withCOM1,COM2,COM3, andCOM416550 serial ports, a boot ROM, and, optionally, a TPM module, a fw_cfg type, and the debug/test device. ngl the LPC bridge emulation can only be configured on bus 0 โ that's the rule, no cap ๐ซfbufโ raw framebuffer device attached to a VNC server ๐ผ๏ธxhciโ eXtensible Host Controller Interface (xHCI) USB controller ๐nvmeโ NVM Express (NVMe) controller โกhdaโ High Definition Audio Controller ๐
okay so the optional parameter conf describes the backend for device emulations. If conf is not specified, the device emulation has no backend and can be considered unconnected. it's giving "ghosted, but in a hardware way" ๐
๐ Network device backends ๐
tapN[,mac=xx:xx:xx:xx:xx:xx][,mtu=N]vmnetN[,mac=xx:xx:xx:xx:xx:xx][,mtu=N]ngdNnetgraph,path=ADDRESS,peerhook=HOOK[,socket=NAME][,hook=HOOK][,mac=xx:xx:xx:xx:xx:xx][,mtu=N]slirp[,open][,hostfwd=proto:hostaddr:hostport-guestaddr:guestport][,mac=xx:xx:xx:xx:xx:xx][,mtu=N]
If mac is not specified, the MAC address is derived from a fixed OUI, and the remaining bytes from an MD5 hash of the slot and function numbers and the device name. If specified, it must be a unicast MAC address. (no multicast shenanigans, bestie โจ)
The MAC address is an ASCII string in ethers(5) format.
A ngd device can be used to connect a guest to a netgraph(4) through a ng_device(4) node. This can be used to run bhyve in a VNET(9) jail, and give it access to the host's netgraph, that cannot be reached directly, by exposing the ng_device through devfs(8). lowkey genius ๐
With virtio-net devices, the mtu parameter can be specified to inform the guest about the largest MTU that should be allowed, expressed in bytes.
With the netgraph backend, the path and peerhook parameters must be specified to set the destination node and corresponding hook. The optional parameters socket and hook may be used to set the ng_socket(4) node name and source hook. The ADDRESS, HOOK, and NAME must comply with netgraph(4) addressing rules ๐
The slirp backend can be used to provide a NATed network to the guest. This backend has poor performance but does not require any network configuration on the host system ๐ญ it depends on the net/libslirp port. If the open keyword is set, the guest will be able to make outbound network connections, and bhyve will transparently handle the necessary address translation. The hostfwd option takes a 5-tuple describing how connections from the host are to be forwarded to the guest. Multiple rules can be specified, separated by semicolons. Note that semicolons must be escaped or quoted to prevent the shell from interpreting them ๐ The backend will provide DHCP and DNS service to the guest.
๐พ Block storage device backends ๐พ
/filename[,block-device-options]/dev/xxx[,block-device-options]
The block-device-options are:
nocacheโ open the file withO_DIRECT.directโ open the file usingO_SYNC.roโ force the file to be opened read-only ๐sectorsize=logical[/physical]โ specify the logical and physical sector sizes of the emulated disk. The physical sector size is optional and is equal to the logical sector size if not explicitly specified. math is mathing ๐nodeleteโ disable emulation of guest trim requests viaDIOCGDELETErequests.bootindex=indexโ add the device to the boot order atindex. A fw_cfg file is used to specify the boot order. The guest firmware may ignore or doesn't support this fw_cfg file. In that case, this feature doesn't work as expected ๐ซ (fr fr, don't be shocked when it does nothing)
๐งต SCSI device backends ๐งต
/dev/cam/ctl[pp.vp][,scsi-device-options]
The scsi-device-options are:
iid=IIDโ initiator ID to use when sending requests to specified CTL port. The default value is0.bootindex=indexโ add the device to the boot order atindex. A fw_cfg file is used to specify the boot order. The guest firmware may ignore or not support this fw_cfg file. In that case, this feature doesn't work as expected ๐ญ (yes, same disclaimer, it's a whole vibe)
๐ 9P device backends ๐
sharename=/path/to/share[,9p-device-options]
The 9p-device-options are:
roโ expose the share in read-only mode ๐
๐ฅ๏ธ TTY device backends ๐ฅ๏ธ
stdioโ connect the serial port to the standard input and output of the bhyve process./dev/xxxโ use the host TTY device for serial port I/O.tcp=ip:portโ use the TCP server for serial port I/O. Configuring this option will start a TCP server that waits for connections. Only one connection is allowed at any time. The TCP server will immediately close new connections while an existing connection is active. Note that this feature allows unprivileged users to access the guest console, so ensure that access is appropriately restricted.
โ ๏ธ bestie read that again โ unprivileged users + guest console = lock it down. this is not a drill ๐จ
๐ TPM device backends ๐
type,path[,tpm-device-options]
Emulate a TPM device. Supported options for type:
passthruโ use a physical TPM device. The argument path needs to point to a valid TPM device path, i.e./dev/tpm0.swtpmโ connect to a runningswtpminstance. The argument path needs to point to a UNIX domain socket that aswtpmprocess is listening on.
The tpm-device-options are:
version=versionโ version of the TPM device according to the TCG specification. Defaults to2.0, which is the only version currently supported. (so... yeah,2.0. that's the whole menu ๐)
๐ Boot ROM device backends ๐
romfile[,varfile]
Map romfile in the guest address space reserved for boot firmware.
If varfile is provided, that file is also mapped in the boot firmware guest address space, and any modifications the guest makes will be saved to that file. it's giving persistent memory, love that for you ๐
fw_cfg types:
fwcfgโ thefw_cfginterface is used to pass information such as the CPU count or ACPI tables to the guest firmware. Supported values arebhyveandqemu. Due to backward compatibility reasons,bhyveis the default option. Whenbhyveis used, bhyve's fwctl interface is used. It currently reports only the CPU count to the guest firmware. Theqemuoption uses QEMU'sfw_cfginterface. This interface is widely used and allows user-defined information to be passed to the guest. It is used for passing the CPU count, ACPI tables, a boot order and many other things to the guest. Some operating systems such as Fedora CoreOS can be configured by QEMU'sfw_cfginterface as well ๐ฅ
๐ฆ Pass-through device backends ๐ฆ
pptN[,passthru-device-options]bus/slot/function[,passthru-device-options]pcibus:slot:function[,passthru-device-options]
Connect to a PCI device on the host either named pptN or at the selector described by slot, bus, and function numbers.
The passthru-device-options are:
rom=romfileโ add romfile as option ROM to the PCI device. The ROM will be loaded by firmware and should be capable of initializing the device.bootindex=indexโ add the device to the boot order atindex. A fw_cfg file is used to specify the boot order. The guest firmware may ignore or doesn't support this fw_cfg file. In that case, this feature doesn't work as expected ๐
๐ Guest memory must be wired using the -S option when a pass-through device is configured.
๐ The host device must have been reserved at boot time using the pptdevs loader variable as described in vmm(4).
๐ Virtio console device backends ๐
port1=/path/to/port1.sock[,portN=/path/to/port2.sock ...]
A maximum of 16 ports per device can be created. Every port is named and corresponds to a Unix domain socket created by bhyve. bhyve accepts at most one connection per port at a time ๐ซถ
Limitations:
- Due to the lack of destructors in bhyve, sockets on the filesystem must be cleaned up manually after bhyve exits. (yes you, personally. go clean them up ๐งน)
- There is no way to use the "console port" feature, nor the console port resize at present.
- Emergency write is advertised, but no-op at present. iconic behavior honestly ๐
๐ธ Virtio input device backends ๐ธ
/dev/input/eventX
Send input events of /dev/input/eventX to guest by VirtIO Input Interface.
๐ Framebuffer device backends ๐
[rfb=address][,w=width][,h=height][,vga=vgaconf][,wait][,password=password]
Configuration options are defined as follows:
rfb=address(ortcp=address) โ a UNIX domain socket or IP address and a port VNC should listen on. There are three possible formats:[IPv4:]port[IPv6%zone]:portunix:my/unix.sock
The default is to listen on localhost IPv4 address and default VNC port 5900. An IPv6 address must be enclosed in square brackets and may contain an optional zone identifier.
w=widthandh=heightโ a display resolution, width and height, respectively. If not specified, a default resolution of1024x768pixels will be used. Minimal supported resolution is640x480pixels, and maximum is3840x2160pixels ๐บvga=vgaconfโ the VGA personality dial ๐๏ธ. Possible values areio(that's the default, bestie),on, andoff. So here's the lore: PCI graphics cards are lowkey dual-personality โ they're standard PCI devices with BAR addressing, but they can also implicitly decode legacy VGA I/O space (0x3c0-0xdf) and memory space (64 KiB at0xA0000). Wild, right?- The default
iooption is the one you want for guests that try to issue BIOS calls which result in I/O port queries, and then straight up fail to boot if I/O decode is disabled. Like, they literally cannot function ๐. - The
onoption goes hand-in-hand with the CSM BIOS capability in UEFI, so you can boot traditional BIOS guests that require the legacy VGA I/O and memory regions to be available. Old school, but make it work โจ. - The
offoption is for UEFI guests that assume a VGA adapter is present if they detect the I/O ports. The iconic example of such a guest is OpenBSD in UEFI mode. Noted ๐.
- The default
Please refer to the bhyve FreeBSD wiki page (https://wiki.freebsd.org/bhyve) for configuration notes of particular guests. iykyk ๐ซถ
waitโ tellsbhyveto only boot upon the initiation of a VNC connection. Why? Because it simplifies the installation of operating systems that require immediate keyboard input โ no more missing the boot prompt while you're still alt-tabbing, queen ๐ . This can be removed for post-installation use.password=passwordโ okay so real talk: this type of authentication is known to be cryptographically weak and is not intended for use on untrusted networks. Many implementations will want to use stronger security, such as running the session over an encrypted channel provided by IPsec or SSH. Protect yourself, bestie ๐.
๐ xHCI USB device backends
tablet
A USB tablet device that provides precise cursor synchronization when using VNC. Cursor lines up perfectly, no cap ๐ฑ๏ธโจ.
๐พ NVMe device backends
devpath[,maxq=#][,qsz=#][,ioslots=#][,sectsz=#][,ser=#][,eui64=#][,dsm=opt]
Configuration options are defined as follows:
devpathโ accepted device paths are:/dev/blockdevor/path/to/imageorram=size_in_MiB.maxqโ max number of queues.qszโ max elements in each queue.ioslotsโ max number of concurrent I/O requests.sectszโ sector size (defaults to blockif sector size).serโ serial number with maximum 20 characters.eui64โ IEEE Extended Unique Identifier (8 byte value).dsmโ Dataset Management support. Supported values are:auto,enable, anddisable.
๐๏ธ AHCI device backends
[[hd:|cd:]path][,nmrr=nmrr][,ser=#][,rev=#][,model=#]
Configuration options are defined as follows:
nmrrโ Nominal Media Rotation Rate, known as RPM. A value of1indicates that the device is a solid state drive, i.e., non-rotational. Default value is0.serโ serial number with maximum 20 characters.revโ revision number with maximum 8 characters.modelโ model number with maximum 40 characters.
๐ HD Audio device backends
[play=playback][,rec=recording]
Configuration options are defined as follows:
playโ playback device, typically/dev/dsp0.recโ recording device, typically/dev/dsp0.
๐ณ CONFIGURATION VARIABLES
So bhyve uses an internal tree of configuration variables to describe global and per-device settings, and honestly? It's giving file system but make it settings ๐ฒ.
When bhyve starts, it parses command line options (including config files) in the order given on the command line. Each command line option sets one or more configuration variables. For example, the -s option creates a new tree node for a PCI device and sets one or more variables under that node โ including the device model and device model-specific variables. Variables may be set multiple times during this parsing stage, with the final value overriding previous values. Last one wins, periodt ๐
.
Once all of the command line options have been processed, the configuration values are frozen. bhyve then uses the value of configuration values to initialize device models and global settings. No take-backs, the vibes are locked in โ๏ธ.
More details on configuration variables can be found in bhyve_config(5).
๐ CONFIGURATION FILE CREATION
The -k flag lets you provide a path to a configuration file holding all the settings, which otherwise would need to be defined by providing a long list of program arguments to bhyve. Like, imagine typing all of that out. No thanks ๐ญ.
There is a very simple way to translate a complex set of program arguments to an equivalent configuration file in bhyve_config(5) format. Iconic behaviour, honestly ๐.
Use -o config.dump=1 to make bhyve dump a configuration file representing the used flags and arguments to stdout. You can pipe the output into a file to persist the generated settings. Chef's kiss ๐.
โ ๏ธ Make sure to remove theconfig.dumpline from the resulting configuration file before using it to startbhyve. Do not skip this step, bestie, I'm begging ๐.
๐ DEBUG SERVER
The current debug server provides limited support for debuggers. It's giving "we have a debugger at home" energy, but it still works ๐.
๐งฎ Registers
Each virtual CPU is exposed to the debugger as a thread.
General purpose registers can be queried for each virtual CPU, but other registers such as floating-point and system registers cannot be queried. Sad but true ๐.
๐ง Memory
Memory (including memory mapped I/O regions) can be read and written by the debugger. Memory operations use virtual addresses that are resolved to physical addresses via the current virtual CPU's active address translation. So it's virtual โ physical, the classic glow-up โจ.
๐ฎ Control
The running guest can be interrupted by the debugger at any time (for example, by pressing Ctrl+C in the debugger). Gotcha, you're paused now ๐ .
Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit. Intel girls only for that one, sorry ๐ธ.
Breakpoints are supported on Intel CPUs that support single stepping. Note that continuing from a breakpoint while interrupts are enabled in the guest may not work as expected due to timer interrupts firing while single stepping over the breakpoint. Lowkey chaotic, but now you know ๐ซ .
๐จ SIGNAL HANDLING
bhyve deals with the following signals:
SIGTERMโ trigger ACPI poweroff for a VM. Politely asking the VM to go night-night ๐ด.
๐ช EXIT STATUS
Exit status indicates how the VM was terminated:
0โ rebooted1โ powered off2โ halted3โ triple fault (amd64 only)4โ exited due to an error5โ suspended
๐ EXAMPLES
If not using a boot ROM, the guest operating system must have been loaded with bhyveload(8) or a similar boot loader before bhyve(4) can be run. Otherwise, the boot loader is not needed. Choose your fighter ๐ฅ.
To run a virtual machine with 1 GiB of memory, two virtual CPUs, a virtio block device backed by the /my/image filesystem image, and a serial port for the console:
bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \
-l com1,stdio -H -P -m 1G vm1
To do the same on arm64:
bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -o console=stdio \
-o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1
Run a 24 GiB single-CPU virtual machine with three network ports, one of which has a MAC address specified:
bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \
-s 2:1,virtio-net,tap1 \
-s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \
-s 3,virtio-blk,/my/image -l com1,stdio \
-H -P -m 24G bigvm
Run an 8 GiB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI CD-ROM, a single virtio network port, an AMD hostbridge, and the console port connected to an nmdm(4) null-modem device.
bhyve -c 4 \
-s 0,amd_hostbridge -s 1,lpc \
-s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\
hd:/images/disk.3,hd:/images/disk.4,\
hd:/images/disk.5,hd:/images/disk.6,\
hd:/images/disk.7,hd:/images/disk.8,\
cd:/images/install.iso \
-s 3,virtio-net,tap0 \
-l com1,/dev/nmdm0A \
-H -P -m 8G
Run a UEFI virtual machine with a display resolution of 800 by 600 pixels that can be accessed via VNC at: 0.0.0.0:5900 or via serial console over TCP at: 127.0.0.1:1234 (unsafe if you expose serial console without protection).
bhyve -c 2 -m 4G -w -H \
-s 0,hostbridge \
-s 3,ahci-cd,/path/to/uefi-OS-install.iso \
-s 4,ahci-hd,disk.img \
-s 5,virtio-net,tap0 \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \
-s 30,xhci,tablet \
-s 31,lpc -l com1,tcp=127.0.0.1:1234 \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
uefivm
Run a UEFI virtual machine with a VNC display that is bound to all IPv6 addresses on port 5900 and a serial I/O port bound to TCP port 1234 of loopback address (unsafe if you expose serial console without protection).
bhyve -c 2 -m 4G -w -H \
-s 0,hostbridge \
-s 4,ahci-hd,disk.img \
-s 5,virtio-net,tap0 \
-s 29,fbuf,tcp=[::]:5900,w=800,h=600 \
-s 30,xhci,tablet \
-s 31,lpc -l com1,tcp=[::1]:1234 \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
uefivm
Run a UEFI virtual machine with a VARS file to save EFI variables. Note that bhyve will write guest modifications to the given VARS file. Be sure to create a per-guest copy of the template VARS file from /usr. Like, don't share your VARS file, that's not giving boundaries ๐ฉ.
bhyve -c 2 -m 4g -w -H \
-s 0,hostbridge \
-s 31,lpc -l com1,stdio \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd
uefivm
To create a configuration file configfile for a virtual machine, use -o config.dump=1:
/usr/sbin/bhyve -c 2 -m 256 -H -P \
-s 0:0,hostbridge -s 1:0,virtio-net,tap0 \
-s 2:0,ahci-hd,./vm0.img \
-s 31,lpc -l com1,stdio \
-o config.dump=1 vm0 > configfile
Then use an editor of your choice to remove the line "config.dump=1" from the newly generated configfile. Yes, actually remove it โ I said what I said ๐
.
To start bhyve using this configuration file, use flag -k:
/usr/sbin/bhyve -k configfile vm0
Run a UEFI virtual machine with four CPUs and two emulated NUMA domains:
bhyve -c 4 -w -H \
-s 0,hostbridge \
-s 4,ahci-hd,disk.img \
-s 31,lpc -l com1,stdio \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-n id=0,size=4G,cpus=0-1 \
-n id=1,size=4G,cpus=2-3 \
numavm
Assuming a host machine with two NUMA domains, run a UEFI virtual machine with four CPUs using a prefer domainset(9) policy to allocate guest memory from the first host NUMA domain only.
bhyve -c 2 -w -H \
-s 0,hostbridge \
-s 4,ahci-hd,disk.img \
-s 31,lpc -l com1,stdio \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-n id=0,size=4G,cpus=0-1,domain_policy=prefer:0 \
numavm
โจ SEE ALSO โจ
okay bestie, here's the squad โ all the other pages that live in the same friend group, go read them if you want the full lore ๐
bhyve(4)netgraph(4)ng_socket(4)nmdm(4)vmm(4)bhyve_config(5)ethers(5)bhyvectl(8)bhyveload(8)domainset(9)
also! Intel, 64 and IA-32 Architectures Software Developer's Manual, Volume 3. โ literally the sacred text, the big book, the one you keep open in another window at 2am ๐ซถ
๐ธ HISTORY ๐ธ
bhyve first appeared in FreeBSD 10.0 โ so she's been on the scene for a minute, and she's still main character energy ๐
๐ AUTHORS ๐
the icons who actually made this happen, give them their flowers fr fr ๐ท
- Neel Natu
<neel@freebsd.org> - Peter Grehan
<grehan@freebsd.org>
so yeah, that's the whole page bestie โ go spin up a VM, be careful with -H because that's genuinely no going back, and text me if it doesn't boot ๐โจ
<nmdm>ich</nmdm>
Debian January 5, 2026 BHYVE(8) โ that's the source and the date, mwah, bye! ๐
๐๐ฆ
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- ๐ the page's license: BSD-2-Clause
- Copyright (c) 2013 Peter Grehan
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms