xref: /freebsd/usr.sbin/bhyve/bhyve.8 (revision 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2013 Peter Grehan
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd October 28, 2025
29.Dt BHYVE 8
30.Os
31.Sh NAME
32.Nm bhyve
33.Nd "run a guest operating system inside a virtual machine"
34.Sh SYNOPSIS
35.Nm
36.Op Fl aCDeHhPSuWwxY
37.Oo
38.Sm off
39.Fl c\~
40.Oo
41.Op Cm cpus=
42.Ar numcpus
43.Oc
44.Op Cm ,sockets= Ar n
45.Op Cm ,cores= Ar n
46.Op Cm ,threads= Ar n
47.Oc
48.Sm on
49.Oo Fl f
50.Sm off
51.Ar name Cm \&,
52.Oo
53.Cm string No | Cm file
54.Oc
55.Cm \&= Ar data
56.Sm on
57.Oc
58.Oo
59.Sm off
60.Fl G\~
61.Oo Ar w Oc
62.Oo Ar bind_address Cm \&: Oc
63.Ar port
64.Sm on
65.Oc
66.Op Fl k Ar config_file
67.Op Fl K Ar layout
68.Oo Fl l
69.Sm off
70.Ar lpcdev Op Cm \&, Ar conf
71.Sm on
72.Oc
73.Sm off
74.Oo Fl m\~
75.Ar memsize
76.Oo
77.Cm K | Cm k | Cm M | Cm m | Cm G | Cm g | Cm T | Cm t
78.Oc
79.Sm on
80.Oc
81.Op Fl o Ar var Ns Cm = Ns Ar value
82.Op Fl p Ar vcpu Ns Cm \&: Ns Ar hostcpu
83.Op Fl r Ar file
84.Sm off
85.Oo Fl s\~
86.Ar slot Cm \&, Ar emulation Op Cm \&, Ar conf
87.Sm on
88.Oc
89.Op Fl U Ar uuid
90.Ar vmname
91.Nm
92.Fl l Cm help
93.Nm
94.Fl s Cm help
95.Sh DESCRIPTION
96.Nm
97is a hypervisor that runs guest operating systems inside a
98virtual machine.
99It can run guests on amd64 and arm64 platforms with suitable hardware support.
100.Pp
101Parameters such as the number of virtual CPUs, amount of guest memory, and
102I/O connectivity can be specified with command-line parameters.
103.Pp
104.Nm
105is typically used with a boot ROM that can load the guest operating system.
106On arm64 platforms, this is currently required.
107If not using a boot ROM, the guest operating system must be loaded with
108.Xr bhyveload 8
109or a similar boot loader before running
110.Nm ,
111otherwise.
112On amd64, the
113.Pa edk2-bhyve
114package provides a UEFI firmware that can be used to boot the guest;
115on arm64 the
116.Pa u-boot-bhyve-arm64
117package provides a U-Boot image that can be used to boot the guest.
118.Pp
119.Nm
120runs until the guest operating system reboots or an unhandled hypervisor
121exit is detected.
122.Sh OPTIONS
123.Bl -tag -width 10n
124.It Fl a
125The guest's local APIC is configured in xAPIC mode.
126This option only applies to the amd64 platform.
127xAPIC mode is the default setting so this option is redundant.
128It will be deprecated in a future version.
129.It Fl C
130Include guest memory in core files.
131.It Fl c Oo Oo Cm cpus= Oc Ns Ar numcpus Oc Ns Oo Cm ,sockets= Ns Ar n Oc Ns Oo Cm ,cores= Ns Ar n Oc Ns Oo Cm ,threads= Ns Ar n Oc
132Number of guest virtual CPUs
133and/or the CPU topology.
134The default value for each of
135.Ar numcpus ,
136.Ar sockets ,
137.Ar cores ,
138and
139.Ar threads
140is 1.
141If
142.Ar numcpus
143is not specified then it will be calculated from the other arguments.
144The topology must be consistent in that the
145.Ar numcpus
146must equal the product of
147.Ar sockets ,
148.Ar cores ,
149and
150.Ar threads .
151If a
152.Ar setting
153is specified more than once the last one has precedence.
154.Pp
155The maximum number of virtual CPUs defaults to the number of active
156physical CPUs in the system available via the
157.Va hw.vmm.maxcpu
158.Xr sysctl 8
159variable.
160The limit can be adjusted via the
161.Va hw.vmm.maxcpu
162loader tunable.
163.It Fl D
164Destroy the VM on guest initiated power-off.
165.It Fl e
166Force
167.Nm
168to exit when a guest issues an access to an I/O port that is not emulated.
169This is intended for debug purposes and only applies to the amd64 platform.
170.It Fl f Ar name Ns Cm \&, Ns Oo Cm string Ns No | Ns Cm file Ns Oc Ns Cm \&= Ns Ar data
171Add a fw_cfg file
172.Ar name
173to the fw_cfg interface.
174If a
175.Cm string
176is specified, the fw_cfg file contains the string as data.
177If a
178.Cm file
179is specified, bhyve reads the file and adds the file content as fw_cfg data.
180.It Fl G Xo
181.Sm off
182.Oo Ar w Oc
183.Oo Ar bind_address Cm \&: Oc
184.Ar port
185.Sm on
186.Xc
187Start a debug server that uses the GDB protocol to export guest state to a
188debugger.
189An IPv4 TCP socket will be bound to the supplied
190.Ar bind_address
191and
192.Ar port
193to listen for debugger connections.
194Only a single debugger may be attached to the debug server at a time.
195If the option begins with
196.Sq w ,
197.Nm
198will pause execution at the first instruction waiting for a debugger to attach.
199.It Fl H
200Yield the virtual CPU thread when a HLT instruction is detected.
201If this option is not specified, virtual CPUs will use 100% of a host CPU.
202This option applies only to the amd64 platform.
203.It Fl h
204Print help message and exit.
205.It Fl k Ar config_file
206Set configuration variables from a simple, key-value config file.
207Each line of the config file is expected to consist of a config variable
208name, an equals sign
209.Pq Sq = ,
210and a value.
211No spaces are permitted between the variable name, equals sign, or
212value.
213Blank lines and lines starting with
214.Sq #
215are ignored.
216See
217.Xr bhyve_config 5
218for more details.
219.It Fl K Ar layout
220Specify the keyboard layout.
221The value that can be specified sets the file name in
222.Ar /usr/share/bhyve/kbdlayout .
223This specification only works when loaded with UEFI mode for VNC.
224When using a VNC client that supports QEMU Extended Key Event Message (e.g.
225TigerVNC), this option isn't needed.
226When using a VNC client that doesn't support QEMU Extended Key Event Message
227(e.g. tightVNC), the layout defaults to the US keyboard unless specified
228otherwise.
229.It Fl l Cm help
230Print a list of supported LPC devices.
231.It Fl l Ar lpcdev Ns Op Cm \&, Ns Ar conf
232Allow devices behind the LPC PCI-ISA bridge to be configured.
233The only supported devices are the TTY-class devices
234.Cm com1 , com2 , com3 ,
235and
236.Cm com4 ,
237the TPM module
238.Cm tpm ,
239the boot ROM device
240.Cm bootrom ,
241the
242.Cm fwcfg
243type and the debug/test device
244.Cm pc-testdev .
245.Pp
246The possible values for the
247.Ar conf
248argument are listed in the
249.Fl s
250flag description.
251.Pp
252This option applies only to the amd64 platform.
253On arm64, the console and boot ROM devices are configured using the
254more generic
255.Fl o
256option.
257.It Xo
258.Fl m Ar memsize Ns Oo
259.Sm off
260.Cm K | k | M | m | G | g | T | t
261.Sm on
262.Oc
263.Xc
264Set the guest physical memory size.
265This must be the same size that was given to
266.Xr bhyveload 8 .
267.Pp
268The size argument may be suffixed with one of
269.Cm K , M , G
270or
271.Cm T
272(either upper or lower case)
273to indicate a multiple of kilobytes, megabytes, gigabytes, or terabytes.
274If no suffix is given, the value is assumed to be in megabytes.
275The default is 256M.
276.Pp
277.It Fl n Ar id Ns Cm \&, Ns Ar size Ns Cm \&, Ns Ar cpus Ns Op Cm \&, Ns Ar domain_policy
278Configure guest NUMA domains.
279This option applies only to the amd64 platform.
280.Pp
281The
282.Fl n
283option allows the guest physical address space to be partitioned into domains.
284The layout of each domain is encoded in an ACPI table
285visible to the guest operating system.
286The
287.Fl n
288option also allows the specification of a
289.Xr domainset 9
290memory allocation policy for the host memory backing a given NUMA domain.
291A guest can have up to 8 NUMA domains.
292This feature requires that the guest use a boot ROM, and in
293particular cannot be used if the guest was initialized using
294.Xr bhyveload 8 .
295.Pp
296Each domain is identified by a numerical
297.Em id .
298The domain memory
299.Em size
300is specified using the same format as the
301.Fl m
302flag.
303The sum of all
304.Em size
305parameters overrides the total VM memory size specified by the
306.Fl m
307flag.
308However, if at least one domain memory size parameter is
309missing, the total VM memory size will be equally distributed across
310all emulated domains.
311The
312.Em cpuset
313parameter specifies the set of CPUs that are part of the domain.
314The
315.Em domain_policy
316parameter may be optionally used to configure the
317.Xr domainset 9
318host NUMA memory allocation policy for an emulated
319domain.
320See the
321.Ar -n
322flag in
323.Xr cpuset 1
324for a list of valid NUMA memory allocation policies and their formats.
325.It Fl o Ar var Ns Cm = Ns Ar value
326Set the configuration variable
327.Ar var
328to
329.Ar value .
330See
331.Xr bhyve_config 5
332for configuration options.
333.It Fl P
334Force the guest virtual CPU to exit when a PAUSE instruction is detected.
335This option applies only to the amd64 platform.
336.It Fl p Ar vcpu Ns Cm \& : Ns Ar hostcpu
337Pin guest's virtual CPU
338.Em vcpu
339to
340.Em hostcpu .
341Host CPUs and guest virtual CPUs are numbered starting from 0.
342A
343.Fl p
344option is required for every guest vCPU to be pinned.
345To map a 4 vCPU guest to host CPUs 12-15:
346.Bd -literal
347-p 0:12 -p 1:13 -p 2:14 -p 3:15
348.Ed
349.It Fl r Ar file
350Resume a guest from a snapshot.
351The guest memory contents are restored from
352.Ar file ,
353and the guest device and vCPU state are restored from the file
354.Dq Ar file Ns .kern .
355.Pp
356Note that the current snapshot file format requires that the
357configuration of devices in the new VM match the VM from which the
358snapshot was taken by specifying the same
359.Fl s
360and
361.Fl l
362options.
363The count of vCPUs and memory configuration are read from the snapshot.
364.It Fl S
365Wire guest memory.
366.It Fl s Cm help
367Print a list of supported PCI devices.
368.It Fl s Ar slot Ns Cm \&, Ns Ar emulation Ns Op Cm \&, Ns Ar conf
369Configure a virtual PCI slot and function.
370.Pp
371.Nm
372provides PCI bus emulation and virtual devices that can be attached to
373slots on the bus.
374There are 32 available slots, with the option of providing up to 8 functions
375per slot.
376.Pp
377The
378.Ar slot
379can be specified in one of the following formats:
380.Pp
381.Bl -bullet -compact
382.It
383.Ar pcislot
384.It
385.Sm off
386.Ar pcislot Cm \&: Ar function
387.Sm on
388.It
389.Sm off
390.Ar bus Cm \&: Ar pcislot Cm \&: Ar function
391.Sm on
392.El
393.Pp
394The
395.Ar pcislot
396value is 0 to 31.
397The optional
398.Ar function
399value is 0 to 7.
400The optional
401.Ar bus
402value is 0 to 255.
403If not specified, the
404.Ar function
405value defaults to 0.
406If not specified, the
407.Ar bus
408value defaults to 0.
409.Pp
410See
411.Sx "PCI EMULATION"
412for available options for the
413.Ar emulation
414argument.
415.It Fl U Ar uuid
416Set the universally unique identifier
417.Pq UUID
418in the guest's System Management BIOS System Information structure.
419By default a UUID is generated from the host's hostname and
420.Ar vmname .
421.It Fl u
422RTC keeps UTC time.
423.It Fl W
424Force virtio PCI device emulations to use MSI interrupts instead of MSI-X
425interrupts.
426.It Fl w
427Ignore accesses to unimplemented Model Specific Registers (MSRs).
428This is intended for debug purposes.
429.It Fl x
430The guest's local APIC is configured in x2APIC mode.
431This option applies only to the amd64 platform.
432.It Fl Y
433Disable MPtable generation.
434This option applies only to the amd64 platform.
435.It Ar vmname
436Alphanumeric name of the guest.
437This should be the same as that created by
438.Xr bhyveload 8 .
439.El
440.Sh PCI EMULATION
441.Nm
442provides emulation for various PCI devices.
443They are specified by the
444.Fl s
445.Ar slot,emulation,conf
446configuration's
447.Ar emulation
448argument, which can be one of the following:
449.Bl -tag -width "amd_hostbridge"
450.It Cm hostbridge
451A simple host bridge.
452This is usually configured at slot 0, and is required by most guest
453operating systems.
454.It Cm amd_hostbridge
455Emulation identical to
456.Cm hostbridge
457using a PCI vendor ID of AMD.
458.It Cm passthru
459PCI pass-through device.
460.It Cm virtio-net
461Virtio network interface.
462.It Cm virtio-blk
463Virtio block storage interface.
464.It Cm virtio-scsi
465Virtio SCSI interface.
466.It Cm virtio-9p
467Virtio 9p (VirtFS) interface.
468.It Cm virtio-rnd
469Virtio RNG interface.
470.It Cm virtio-console
471Virtio console interface, which exposes multiple ports
472to the guest in the form of simple char devices for simple IO
473between the guest and host userspaces.
474.It Cm virtio-input
475Virtio input interface.
476.It Cm ahci
477AHCI controller attached to arbitrary devices.
478.It Cm ahci-cd
479AHCI controller attached to an ATAPI CD/DVD.
480.It Cm ahci-hd
481AHCI controller attached to a SATA hard drive.
482.It Cm e1000
483Intel e82545 network interface.
484.It Cm uart
485PCI 16550 serial device.
486.It Cm lpc
487LPC PCI-ISA bridge with COM1, COM2, COM3, and COM4 16550 serial ports,
488a boot ROM, and,
489optionally, a TPM module, a fwcfg type, and the debug/test device.
490The LPC bridge emulation can only be configured on bus 0.
491.It Cm fbuf
492Raw framebuffer device attached to VNC server.
493.It Cm xhci
494eXtensible Host Controller Interface (xHCI) USB controller.
495.It Cm nvme
496NVM Express (NVMe) controller.
497.It Cm hda
498High Definition Audio Controller.
499.El
500.Pp
501The optional parameter
502.Ar conf
503describes the backend for device emulations.
504If
505.Ar conf
506is not specified, the device emulation has no backend and can be
507considered unconnected.
508.Ss Network device backends
509.Sm off
510.Bl -bullet
511.It
512.Xo
513.Cm tap Ar N
514.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
515.Op Cm \&,mtu= Ar N
516.Xc
517.It
518.Xo
519.Cm vmnet Ar N
520.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
521.Op Cm \&,mtu= Ar N
522.Xc
523.It
524.Cm ngd Ar N
525.It
526.Xo
527.Cm netgraph,path= Ar ADDRESS Cm \&,peerhook= Ar HOOK
528.Op Cm \&,socket= Ar NAME
529.Op Cm \&,hook= Ar HOOK
530.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
531.Op Cm \&,mtu= Ar N
532.Xc
533.It
534.Xo
535.Cm slirp
536.Op Cm \&,open
537.Op Cm \&,hostfwd= Ar proto : Ar hostaddr : Ar hostport - Ar guestaddr : Ar guestport
538.Xc
539.El
540.Sm on
541.Pp
542If
543.Cm mac
544is not specified, the MAC address is derived from a fixed OUI, and the
545remaining bytes from an MD5 hash of the slot and function numbers and
546the device name.
547.Pp
548The MAC address is an ASCII string in
549.Xr ethers 5
550format.
551.Pp
552A
553.Cm ngd
554device can be used to connect a guest to a
555.Xr netgraph 4
556through a
557.Xr ng_device 4
558node.
559This can be used to run bhyve in a
560.Xr VNET 9
561jail, and give it access to the host's netgraph, that cannot be reached
562directly, by exposing the ng_device through
563.Xr devfs 8 .
564.Pp
565With
566.Cm virtio-net
567devices, the
568.Cm mtu
569parameter can be specified to inform the guest about the largest MTU
570that should be allowed, expressed in bytes.
571.Pp
572With
573.Cm netgraph
574backend, the
575.Cm path
576and
577.Cm peerhook
578parameters must be specified to set the destination node and corresponding hook.
579The optional parameters
580.Cm socket
581and
582.Cm hook
583may be used to set the
584.Xr ng_socket 4
585node name and source hook.
586The
587.Ar ADDRESS ,
588.Ar HOOK ,
589and
590.Ar NAME
591must comply with
592.Xr netgraph 4
593addressing rules.
594.Pp
595The
596.Cm slirp
597backend can be used to provide a NATed network to the guest.
598This backend has poor performance but does not require any network
599configuration on the host system.
600It depends on the
601.Pa net/libslirp
602port.
603If the
604.Cm open
605keyword is set, the guest will be able to make outbound network
606connections, and
607.Nm
608will transparently handle the necessary address translation.
609The
610.Cm hostfwd
611option takes a 5-tuple describing how connections from the host are to be
612forwarded to the guest.
613Multiple rules can be specified, separated by semicolons.
614Note that semicolons must be escaped or quoted to prevent the shell from
615interpreting them.
616The backend will provide DHCP and DNS service to the guest.
617.Ss Block storage device backends:
618.Bl -bullet
619.Sm off
620.It
621.Ar /filename Op Cm \&, Ar block-device-options
622.It
623.Ar /dev/xxx Op Cm \&, Ar block-device-options
624.Sm on
625.El
626.Pp
627The
628.Ar block-device-options
629are:
630.Bl -tag -width 10n
631.It Cm nocache
632Open the file with
633.Dv O_DIRECT .
634.It Cm direct
635Open the file using
636.Dv O_SYNC .
637.It Cm ro
638Force the file to be opened read-only.
639.It Cm sectorsize= Ns Ar logical Ns Oo Cm \&/ Ns Ar physical Oc
640Specify the logical and physical sector sizes of the emulated disk.
641The physical sector size is optional and is equal to the logical sector size
642if not explicitly specified.
643.It Cm nodelete
644Disable emulation of guest trim requests via
645.Dv DIOCGDELETE
646requests.
647.It Li bootindex= Ns Ar index
648Add the device to the bootorder at
649.Ar index .
650A fwcfg file is used to specify the bootorder.
651The guest firmware may ignore or doesn't support this fwcfg file.
652In that case, this feature doesn't work as expected.
653.El
654.Ss SCSI device backends
655.Bl -bullet
656.Sm off
657.It
658.Pa /dev/cam/ctl Oo Ar pp Cm \&. Ar vp Oc Oo Cm \&, Ar scsi-device-options Oc
659.Sm on
660.El
661.Pp
662The
663.Ar scsi-device-options
664are:
665.Bl -tag -width 10n
666.It Cm iid= Ns Ar IID
667Initiator ID to use when sending requests to specified CTL port.
668The default value is 0.
669.It Li bootindex= Ns Ar index
670Add the device to the bootorder at
671.Ar index .
672A fwcfg file is used to specify the bootorder.
673The guest firmware may ignore or doesn't support this fwcfg file.
674In that case, this feature doesn't work as expected.
675.El
676.Ss 9P device backends
677.Bl -bullet
678.Sm off
679.It
680.Ar sharename Cm = Ar /path/to/share Op Cm \&, Ar 9p-device-options
681.Sm on
682.El
683.Pp
684The
685.Ar 9p-device-options
686are:
687.Bl -tag -width 10n
688.It Cm ro
689Expose the share in read-only mode.
690.El
691.Ss TTY device backends
692.Bl -tag -width 10n
693.It Cm stdio
694Connect the serial port to the standard input and output of
695the
696.Nm
697process.
698.It Ar /dev/xxx
699Use the host TTY device for serial port I/O.
700.It Ar tcp=ip:port
701Use the TCP server for serial port I/O.
702Configuring this option will start a TCP server that waits for connections.
703Only one connection is allowed at any time. Other connection try to connect
704to TCP server will be disconnected immediately. Note that this feature
705allows unprivileged users to access the guest console, so ensure that
706access is appropriately restricted.
707.El
708.Ss TPM device backends
709.Bl -bullet
710.Sm off
711.It
712.Ar type Ns \&, Ns Ar path Ns Op Cm \&, Ns Ar tpm-device-options
713.Sm on
714.El
715.Pp
716Emulate a TPM device.
717Supported options for
718.Ar type :
719.Bl -tag -width 10n
720.It Cm passthru
721Use a physical TPM device.
722The argument
723.Ar path
724needs to point to a valid TPM device path, i.e.
725.Pa /dev/tpm0 .
726.It Cm swtpm
727Connect to a running
728.Cm swtpm
729instance.
730The argument
731.Ar path
732needs to point to a UNIX domain socket that a
733.Cm swtpm
734process is listening on.
735.El
736.Pp
737The
738.Ar tpm-device-options
739are:
740.Bl -tag -width 10n
741.It Cm version= Ns Ar version
742Version of the TPM device according to the TCG specification.
743Defaults to
744.Cm 2.0 ,
745which is the only version currently supported.
746.El
747.Ss Boot ROM device backends
748.Sm off
749.Bl -bullet
750.It
751.Ar romfile Ns Op Cm \&, Ns Ar varfile
752.El
753.Sm on
754.Pp
755Map
756.Ar romfile
757in the guest address space reserved for boot firmware.
758.Pp
759If
760.Ar varfile
761is provided, that file is also mapped in the boot firmware guest
762address space, and any modifications the guest makes will be saved
763to that file.
764.Pp
765Fwcfg types:
766.Bl -tag -width 10n
767.It Ar fwcfg
768The fwcfg interface is used to pass information such as the CPU count
769or ACPI tables to the guest firmware.
770Supported values are
771.Ql bhyve
772and
773.Ql qemu .
774Due to backward compatibility reasons,
775.Ql bhyve
776is the default option.
777When
778.Ql bhyve
779is used, bhyve's fwctl interface is used.
780It currently reports only the CPU count to the guest firmware.
781The
782.Ql qemu
783option uses QEMU's fwcfg interface.
784This interface is widely used and allows user-defined information to
785be passed to the guest.
786It is used for passing the CPU count, ACPI tables, a boot order and
787many other things to the guest.
788Some operating systems such as Fedora CoreOS can be configured by
789qemu's fwcfg interface as well.
790.El
791.Ss Pass-through device backends
792.Sm off
793.Bl -bullet
794.It
795.Cm ppt Ar N Oo , Ar passthru-device-options Oc
796.It
797.Ns Ar bus Cm \&/ Ar slot Cm \&/ Ar function
798.Op , Ar passthru-device-options
799.It
800.Cm pci Ar bus Cm : Ar slot Cm : Ns Ar function
801.Op , Ar passthru-device-options
802.El
803.Sm on
804.Pp
805Connect to a PCI device on the host either named ppt
806.Ns Ar N
807or at the selector described by
808.Ar slot ,
809.Ar bus ,
810and
811.Ar function
812numbers.
813.Pp
814The
815.Ar passthru-device-options
816are:
817.Bl -tag -width 10n
818.It Cm rom= Ns Ar romfile
819Add
820.Ar romfile
821as option ROM to the PCI device.
822The ROM will be loaded by firmware and should be capable of
823initializing the device.
824.It Li bootindex= Ns Ar index
825Add the device to the bootorder at
826.Ar index .
827A fwcfg file is used to specify the bootorder.
828The guest firmware may ignore or doesn't support this fwcfg file.
829In that case, this feature doesn't work as expected.
830.El
831.Pp
832Guest memory must be wired using the
833.Fl S
834option when a pass-through device is configured.
835.Pp
836The host device must have been reserved at boot-time using the
837.Va pptdevs
838loader variable as described in
839.Xr vmm 4 .
840.Ss Virtio console device backends
841.Bl -bullet
842.Sm off
843.It
844.Cm port1= Ns Ar /path/to/port1.sock Ns Op Cm ,port Ns Ar N Cm \&= Ns Ar /path/to/port2.sock No \~ Ar ...
845.Sm on
846.El
847.Pp
848A maximum of 16 ports per device can be created.
849Every port is named and corresponds to a Unix domain socket created by
850.Nm .
851.Nm
852accepts at most one connection per port at a time.
853.Pp
854Limitations:
855.Bl -bullet
856.It
857Due to the lack of destructors in
858.Nm ,
859sockets on the filesystem must be cleaned up manually after
860.Nm
861exits.
862.It
863There is no way to use the
864.Dq console port
865feature, nor the console port
866resize at present.
867.It
868Emergency write is advertised, but no-op at present.
869.El
870.Ss Virtio input device backends:
871.Bl -bullet
872.Sm off
873.It
874.Ar /dev/input/eventX
875.Sm on
876.El
877.Pp
878Send input events of
879.Ar /dev/input/eventX
880to guest by VirtIO Input Interface.
881.Ss Framebuffer device backends
882.Bl -bullet
883.Sm off
884.It
885.Op Cm rfb= Ar ip-and-port
886.Op Cm ,w= Ar width
887.Op Cm ,h= Ar height
888.Op Cm ,vga= Ar vgaconf
889.Op Cm ,wait
890.Op Cm ,password= Ar password
891.Sm on
892.El
893.Pp
894Configuration options are defined as follows:
895.Bl -tag -width 10n
896.It Cm rfb= Ns Ar ip-and-port Pq or Cm tcp= Ns Ar ip-and-port
897An IP address and a port VNC should listen on.
898There are two formats:
899.Pp
900.Bl -bullet -compact
901.It
902.Sm off
903.Op Ar IPv4 Cm \&:
904.Ar port
905.Sm on
906.It
907.Sm off
908.Cm \&[ Ar IPv6%zone Cm \&] Cm \&: Ar port
909.Sm on
910.El
911.Pp
912The default is to listen on localhost IPv4 address and default VNC port 5900.
913An IPv6 address must be enclosed in square brackets and may contain an
914optional zone identifier.
915.It Cm w= Ns Ar width No and Cm h= Ns Ar height
916A display resolution, width and height, respectively.
917If not specified, a default resolution of 1024x768 pixels will be used.
918Minimal supported resolution is 640x480 pixels,
919and maximum is 3840x2160 pixels.
920.It Cm vga= Ns Ar vgaconf
921Possible values for this option are
922.Cm io
923(default),
924.Cm on ,
925and
926.Cm off .
927PCI graphics cards have a dual personality in that they are
928standard PCI devices with BAR addressing, but may also
929implicitly decode legacy VGA I/O space
930.Pq Ad 0x3c0-3df
931and memory space
932.Pq 64KB at Ad 0xA0000 .
933The default
934.Cm io
935option should be used for guests that attempt to issue BIOS calls which result
936in I/O port queries, and fail to boot if I/O decode is disabled.
937.Pp
938The
939.Cm on
940option should be used along with the CSM BIOS capability in UEFI
941to boot traditional BIOS guests that require the legacy VGA I/O and
942memory regions to be available.
943.Pp
944The
945.Cm off
946option should be used for the UEFI guests that assume that
947VGA adapter is present if they detect the I/O ports.
948An example of such a guest is
949.Ox
950in UEFI mode.
951.Pp
952Please refer to the
953.Nm
954.Fx
955wiki page
956.Pq Lk https://wiki.freebsd.org/bhyve
957for configuration notes of particular guests.
958.It Cm wait
959Instruct
960.Nm
961to only boot upon the initiation of a VNC connection, simplifying the
962installation of operating systems that require immediate keyboard input.
963This can be removed for post-installation use.
964.It Cm password= Ns Ar password
965This type of authentication is known to be cryptographically weak and is not
966intended for use on untrusted networks.
967Many implementations will want to use stronger security, such as running
968the session over an encrypted channel provided by IPsec or SSH.
969.El
970.Ss xHCI USB device backends
971.Bl -bullet
972.Sm off
973.It
974.Ar tablet
975.Sm on
976.El
977.Pp
978A USB tablet device that provides precise cursor synchronization
979when using VNC.
980.Ss NVMe device backends
981.Bl -bullet
982.Sm off
983.It
984.Ar devpath
985.Op Cm ,maxq= Ar #
986.Op Cm ,qsz= Ar #
987.Op Cm ,ioslots= Ar #
988.Op Cm ,sectsz= Ar #
989.Op Cm ,ser= Ar #
990.Op Cm ,eui64= Ar #
991.Op Cm ,dsm= Ar opt
992.Sm on
993.El
994.Pp
995Configuration options are defined as follows:
996.Bl -tag -width 10n
997.It Ar devpath
998Accepted device paths are:
999.Ar /dev/blockdev
1000or
1001.Ar /path/to/image
1002or
1003.Cm ram= Ns Ar size_in_MiB .
1004.It Cm maxq
1005Max number of queues.
1006.It Cm qsz
1007Max elements in each queue.
1008.It Cm ioslots
1009Max number of concurrent I/O requests.
1010.It Cm sectsz
1011Sector size (defaults to blockif sector size).
1012.It Cm ser
1013Serial number with maximum 20 characters.
1014.It Cm eui64
1015IEEE Extended Unique Identifier (8 byte value).
1016.It Cm dsm
1017DataSet Management support.
1018Supported values are:
1019.Cm auto , enable ,
1020and
1021.Cm disable .
1022.El
1023.Ss AHCI device backends
1024.Bl -bullet
1025.It
1026.Sm off
1027.Op Oo Cm hd\&: | cd\&: Oc Ar path
1028.Op Cm ,nmrr= Ar nmrr
1029.Op Cm ,ser= Ar #
1030.Op Cm ,rev= Ar #
1031.Op Cm ,model= Ar #
1032.Sm on
1033.El
1034.Pp
1035Configuration options are defined as follows:
1036.Bl -tag -width 10n
1037.It Cm nmrr
1038Nominal Media Rotation Rate, known as RPM.
1039Value 1 will indicate device as Solid State Disk.
1040Default value is 0, not report.
1041.It Cm ser
1042Serial Number with maximum 20 characters.
1043.It Cm rev
1044Revision Number with maximum 8 characters.
1045.It Cm model
1046Model Number with maximum 40 characters.
1047.El
1048.Ss HD Audio device backends
1049.Bl -bullet
1050.It
1051.Sm off
1052.Op Cm play= Ar playback
1053.Op Cm ,rec= Ar recording
1054.Sm on
1055.El
1056.Pp
1057Configuration options are defined as follows:
1058.Bl -tag -width 10n
1059.It Cm play
1060Playback device, typically
1061.Ar /dev/dsp0 .
1062.It Cm rec
1063Recording device, typically
1064.Ar /dev/dsp0 .
1065.El
1066.Sh CONFIGURATION VARIABLES
1067.Nm
1068uses an internal tree of configuration variables to describe global and
1069per-device settings.
1070When
1071.Nm
1072starts,
1073it parses command line options (including config files) in the order given
1074on the command line.
1075Each command line option sets one or more configuration variables.
1076For example,
1077the
1078.Fl s
1079option creates a new tree node for a PCI device and sets one or more variables
1080under that node including the device model and device model-specific variables.
1081Variables may be set multiple times during this parsing stage with the final
1082value overriding previous values.
1083.Pp
1084Once all of the command line options have been processed,
1085the configuration values are frozen.
1086.Nm
1087then uses the value of configuration values to initialize device models
1088and global settings.
1089.Pp
1090More details on configuration variables can be found in
1091.Xr bhyve_config 5 .
1092.Sh CONFIGURATION FILE CREATION
1093The
1094.Fl k
1095flag allows one to provide a path to a configuration file holding all
1096settings, which otherwise would need to be defined by providing a long
1097list of program arguments to
1098.Nm .
1099.Pp
1100There is a very simple way to translate a complex set of program
1101arguments to an equivalent configuration file in
1102.Xr bhyve_config 5
1103format.
1104.Pp
1105Use
1106.Fl o
1107.Ar config.dump=1
1108to make
1109.Nm
1110dump a configuration file representing the used flags and arguments to
1111stdout. You can pipe the output into a file to persist the generated settings.
1112.Pp
1113Make sure to remove the
1114.Ar config.dump
1115line from the resulting configuration file before using it to start
1116.Nm .
1117.Sh DEBUG SERVER
1118The current debug server provides limited support for debuggers.
1119.Ss Registers
1120Each virtual CPU is exposed to the debugger as a thread.
1121.Pp
1122General purpose registers can be queried for each virtual CPU, but other
1123registers such as floating-point and system registers cannot be queried.
1124.Ss Memory
1125Memory (including memory mapped I/O regions) can be read and written
1126by the debugger.
1127Memory operations use virtual addresses that are resolved to physical
1128addresses via the current virtual CPU's active address translation.
1129.Ss Control
1130The running guest can be interrupted by the debugger at any time
1131.Pq for example, by pressing Ctrl-C in the debugger .
1132.Pp
1133Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit.
1134.Pp
1135Breakpoints are supported on Intel CPUs that support single stepping.
1136Note that continuing from a breakpoint while interrupts are enabled in the
1137guest may not work as expected due to timer interrupts firing while single
1138stepping over the breakpoint.
1139.Sh SIGNAL HANDLING
1140.Nm
1141deals with the following signals:
1142.Pp
1143.Bl -tag -width SIGTERM -compact
1144.It SIGTERM
1145Trigger ACPI poweroff for a VM
1146.El
1147.Sh EXIT STATUS
1148Exit status indicates how the VM was terminated:
1149.Pp
1150.Bl -tag -width indent -compact
1151.It 0
1152rebooted
1153.It 1
1154powered off
1155.It 2
1156halted
1157.It 3
1158triple fault (amd64 only)
1159.It 4
1160exited due to an error
1161.El
1162.Sh EXAMPLES
1163If not using a boot ROM, the guest operating system must have been loaded with
1164.Xr bhyveload 8
1165or a similar boot loader before
1166.Xr bhyve 4
1167can be run.
1168Otherwise, the boot loader is not needed.
1169.Pp
1170To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio
1171block device backed by the
1172.Pa /my/image
1173filesystem image, and a serial port for the console:
1174.Bd -literal -offset indent
1175bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\
1176  -l com1,stdio -H -P -m 1G vm1
1177.Ed
1178.Pp
1179To do the same on arm64:
1180.Bd -literal -offset indent
1181.Ed
1182bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -o console=stdio \\
1183  -o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1
1184.Pp
1185Run a 24GB single-CPU virtual machine with three network ports, one of which
1186has a MAC address specified:
1187.Bd -literal -offset indent
1188bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\
1189  -s 2:1,virtio-net,tap1 \\
1190  -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\
1191  -s 3,virtio-blk,/my/image -l com1,stdio \\
1192  -H -P -m 24G bigvm
1193.Ed
1194.Pp
1195Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI
1196CD-ROM, a single virtio network port, an AMD hostbridge, and the console
1197port connected to an
1198.Xr nmdm 4
1199null-modem device.
1200.Bd -literal -offset indent
1201bhyve -c 4 \\
1202  -s 0,amd_hostbridge -s 1,lpc \\
1203  -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\
1204hd:/images/disk.3,hd:/images/disk.4,\\
1205hd:/images/disk.5,hd:/images/disk.6,\\
1206hd:/images/disk.7,hd:/images/disk.8,\\
1207cd:/images/install.iso \\
1208  -s 3,virtio-net,tap0 \\
1209  -l com1,/dev/nmdm0A \\
1210  -H -P -m 8G
1211.Ed
1212.Pp
1213Run a UEFI virtual machine with a display resolution of 800 by 600 pixels
1214that can be accessed via VNC at: 0.0.0.0:5900 or via serial console over
1215TCP at: 127.0.0.1:1234 (unsafe if you expose serial console without protection).
1216.Bd -literal -offset indent
1217bhyve -c 2 -m 4G -w -H \\
1218  -s 0,hostbridge \\
1219  -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\
1220  -s 4,ahci-hd,disk.img \\
1221  -s 5,virtio-net,tap0 \\
1222  -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\
1223  -s 30,xhci,tablet \\
1224  -s 31,lpc -l com1,tcp=127.0.0.1:1234 \\
1225  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1226   uefivm
1227.Ed
1228.Pp
1229Run a UEFI virtual machine with a VNC display that is bound to all IPv6
1230addresses on port 5900 and a serial I/O port bound to TCP port 1234 of
1231loopback address (unsafe if you expose serial console without protection).
1232.Bd -literal -offset indent
1233bhyve -c 2 -m 4G -w -H \\
1234  -s 0,hostbridge \\
1235  -s 4,ahci-hd,disk.img \\
1236  -s 5,virtio-net,tap0 \\
1237  -s 29,fbuf,tcp=[::]:5900,w=800,h=600 \\
1238  -s 30,xhci,tablet \\
1239  -s 31,lpc -l com1,tcp=[::1]:1234 \\
1240  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1241   uefivm
1242.Ed
1243.Pp
1244Run a UEFI virtual machine with a VARS file to save EFI variables.
1245Note that
1246.Nm
1247will write guest modifications to the given VARS file.
1248Be sure to create a per-guest copy of the template VARS file from
1249.Pa /usr .
1250.Bd -literal -offset indent
1251bhyve -c 2 -m 4g -w -H \\
1252  -s 0,hostbridge \\
1253  -s 31,lpc -l com1,stdio \\
1254  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd
1255   uefivm
1256.Ed
1257.Pp
1258To create a configuration file
1259.Pa configfile
1260for a virtual machine, use
1261.Fl o
1262.Ar config.dump=1 :
1263.Bd -literal -offset indent
1264/usr/sbin/bhyve -c 2 -m 256 -H -P \\
1265  -s 0:0,hostbridge -s 1:0,virtio-net,tap0 \\
1266  -s 2:0,ahci-hd,./vm0.img \\
1267  -s 31,lpc -l com1,stdio \\
1268  -o config.dump=1 vm0 > configfile
1269.Ed
1270.Pp
1271Then use an editor of your choice to remove the line "config.dump=1"
1272from the newly generated
1273.Pa configfile .
1274.Pp
1275To start
1276.Nm
1277using this configuration file, use flag
1278.Fl k :
1279.Bd -literal -offset indent
1280/usr/sbin/bhyve -k configfile vm0
1281.Ed
1282.Pp
1283Run a UEFI virtual machine with four CPUs and two emulated NUMA domains:
1284.Bd -literal -offset indent
1285bhyve -c 4 -w -H \\
1286  -s 0,hostbridge \\
1287  -s 4,ahci-hd,disk.img \\
1288  -s 31,lpc -l com1,stdio \\
1289  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1290  -n id=0,size=4G,cpus=0-1 \\
1291  -n id=1,size=4G,cpus=2-3 \\
1292   numavm
1293.Ed
1294.Pp
1295Assuming a host machine with two NUMA domains,
1296run a UEFI virtual machine with four CPUs using a
1297.Ar prefer
1298.Xr domainset 9
1299policy to allocate guest memory from the first host NUMA domain only.
1300.Bd -literal -offset indent
1301bhyve -c 2 -w -H \\
1302  -s 0,hostbridge \\
1303  -s 4,ahci-hd,disk.img \\
1304  -s 31,lpc -l com1,stdio \\
1305  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1306  -n id=0,size=4G,cpus=0-1,domain_policy=prefer:0 \\
1307   numavm
1308.Ed
1309.Sh SEE ALSO
1310.Xr bhyve 4 ,
1311.Xr netgraph 4 ,
1312.Xr ng_socket 4 ,
1313.Xr nmdm 4 ,
1314.Xr vmm 4 ,
1315.Xr bhyve_config 5 ,
1316.Xr ethers 5 ,
1317.Xr bhyvectl 8 ,
1318.Xr bhyveload 8 ,
1319.Xr domainset 9
1320.Pp
1321.Rs
1322.%A Intel
1323.%B 64 and IA-32 Architectures Software Developer’s Manual
1324.%V Volume 3
1325.Re
1326.Sh HISTORY
1327.Nm
1328first appeared in
1329.Fx 10.0 .
1330.Sh AUTHORS
1331.An Neel Natu Aq Mt neel@freebsd.org
1332.An Peter Grehan Aq Mt grehan@freebsd.org
1333