xref: /freebsd/usr.sbin/bhyve/bhyve.8 (revision df21a004be237a1dccd03c7b47254625eea62fa9)
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,hostfwd= Ar proto : Ar hostaddr : Ar hostport - Ar guestaddr : Ar guestport
536.Xc
537.El
538.Sm on
539.Pp
540If
541.Cm mac
542is not specified, the MAC address is derived from a fixed OUI, and the
543remaining bytes from an MD5 hash of the slot and function numbers and
544the device name.
545.Pp
546The MAC address is an ASCII string in
547.Xr ethers 5
548format.
549.Pp
550A
551.Cm ngd
552device can be used to connect a guest to a
553.Xr netgraph 4
554through a
555.Xr ng_device 4
556node.
557This can be used to run bhyve in a
558.Xr VNET 9
559jail, and give it access to the host's netgraph, that cannot be reached
560directly, by exposing the ng_device through
561.Xr devfs 8 .
562.Pp
563With
564.Cm virtio-net
565devices, the
566.Cm mtu
567parameter can be specified to inform the guest about the largest MTU
568that should be allowed, expressed in bytes.
569.Pp
570With
571.Cm netgraph
572backend, the
573.Cm path
574and
575.Cm peerhook
576parameters must be specified to set the destination node and corresponding hook.
577The optional parameters
578.Cm socket
579and
580.Cm hook
581may be used to set the
582.Xr ng_socket 4
583node name and source hook.
584The
585.Ar ADDRESS ,
586.Ar HOOK ,
587and
588.Ar NAME
589must comply with
590.Xr netgraph 4
591addressing rules.
592.Pp
593The
594.Cm slirp
595backend can be used to provide a NATed network to the guest.
596This backend has poor performance but does not require any network
597configuration on the host system.
598It depends on the
599.Pa net/libslirp
600port.
601The
602.Cm hostfwd
603option takes a 5-tuple describing how connections from the host are to be
604forwarded to the guest.
605Multiple rules can be specified, separated by semicolons.
606Note that semicolons must be escaped or quoted to prevent the shell from
607interpreting them.
608.Ss Block storage device backends:
609.Bl -bullet
610.Sm off
611.It
612.Ar /filename Op Cm \&, Ar block-device-options
613.It
614.Ar /dev/xxx Op Cm \&, Ar block-device-options
615.Sm on
616.El
617.Pp
618The
619.Ar block-device-options
620are:
621.Bl -tag -width 10n
622.It Cm nocache
623Open the file with
624.Dv O_DIRECT .
625.It Cm direct
626Open the file using
627.Dv O_SYNC .
628.It Cm ro
629Force the file to be opened read-only.
630.It Cm sectorsize= Ns Ar logical Ns Oo Cm \&/ Ns Ar physical Oc
631Specify the logical and physical sector sizes of the emulated disk.
632The physical sector size is optional and is equal to the logical sector size
633if not explicitly specified.
634.It Cm nodelete
635Disable emulation of guest trim requests via
636.Dv DIOCGDELETE
637requests.
638.It Li bootindex= Ns Ar index
639Add the device to the bootorder at
640.Ar index .
641A fwcfg file is used to specify the bootorder.
642The guest firmware may ignore or doesn't support this fwcfg file.
643In that case, this feature doesn't work as expected.
644.El
645.Ss SCSI device backends
646.Bl -bullet
647.Sm off
648.It
649.Pa /dev/cam/ctl Oo Ar pp Cm \&. Ar vp Oc Oo Cm \&, Ar scsi-device-options Oc
650.Sm on
651.El
652.Pp
653The
654.Ar scsi-device-options
655are:
656.Bl -tag -width 10n
657.It Cm iid= Ns Ar IID
658Initiator ID to use when sending requests to specified CTL port.
659The default value is 0.
660.It Li bootindex= Ns Ar index
661Add the device to the bootorder at
662.Ar index .
663A fwcfg file is used to specify the bootorder.
664The guest firmware may ignore or doesn't support this fwcfg file.
665In that case, this feature doesn't work as expected.
666.El
667.Ss 9P device backends
668.Bl -bullet
669.Sm off
670.It
671.Ar sharename Cm = Ar /path/to/share Op Cm \&, Ar 9p-device-options
672.Sm on
673.El
674.Pp
675The
676.Ar 9p-device-options
677are:
678.Bl -tag -width 10n
679.It Cm ro
680Expose the share in read-only mode.
681.El
682.Ss TTY device backends
683.Bl -tag -width 10n
684.It Cm stdio
685Connect the serial port to the standard input and output of
686the
687.Nm
688process.
689.It Ar /dev/xxx
690Use the host TTY device for serial port I/O.
691.It Ar tcp=ip:port
692Use the TCP server for serial port I/O.
693Configuring this option will start a TCP server that waits for connections.
694Only one connection is allowed at any time. Other connection try to connect
695to TCP server will be disconnected immediately. Note that this feature
696allows unprivileged users to access the guest console, so ensure that
697access is appropriately restricted.
698.El
699.Ss TPM device backends
700.Bl -bullet
701.Sm off
702.It
703.Ar type Ns \&, Ns Ar path Ns Op Cm \&, Ns Ar tpm-device-options
704.Sm on
705.El
706.Pp
707Emulate a TPM device.
708Supported options for
709.Ar type :
710.Bl -tag -width 10n
711.It Cm passthru
712Use a physical TPM device.
713The argument
714.Ar path
715needs to point to a valid TPM device path, i.e.
716.Pa /dev/tpm0 .
717.It Cm swtpm
718Connect to a running
719.Cm swtpm
720instance.
721The argument
722.Ar path
723needs to point to a UNIX domain socket that a
724.Cm swtpm
725process is listening on.
726.El
727.Pp
728The
729.Ar tpm-device-options
730are:
731.Bl -tag -width 10n
732.It Cm version= Ns Ar version
733Version of the TPM device according to the TCG specification.
734Defaults to
735.Cm 2.0 ,
736which is the only version currently supported.
737.El
738.Ss Boot ROM device backends
739.Sm off
740.Bl -bullet
741.It
742.Ar romfile Ns Op Cm \&, Ns Ar varfile
743.El
744.Sm on
745.Pp
746Map
747.Ar romfile
748in the guest address space reserved for boot firmware.
749.Pp
750If
751.Ar varfile
752is provided, that file is also mapped in the boot firmware guest
753address space, and any modifications the guest makes will be saved
754to that file.
755.Pp
756Fwcfg types:
757.Bl -tag -width 10n
758.It Ar fwcfg
759The fwcfg interface is used to pass information such as the CPU count
760or ACPI tables to the guest firmware.
761Supported values are
762.Ql bhyve
763and
764.Ql qemu .
765Due to backward compatibility reasons,
766.Ql bhyve
767is the default option.
768When
769.Ql bhyve
770is used, bhyve's fwctl interface is used.
771It currently reports only the CPU count to the guest firmware.
772The
773.Ql qemu
774option uses QEMU's fwcfg interface.
775This interface is widely used and allows user-defined information to
776be passed to the guest.
777It is used for passing the CPU count, ACPI tables, a boot order and
778many other things to the guest.
779Some operating systems such as Fedora CoreOS can be configured by
780qemu's fwcfg interface as well.
781.El
782.Ss Pass-through device backends
783.Sm off
784.Bl -bullet
785.It
786.Cm ppt Ar N Oo , Ar passthru-device-options Oc
787.It
788.Ns Ar bus Cm \&/ Ar slot Cm \&/ Ar function
789.Op , Ar passthru-device-options
790.It
791.Cm pci Ar bus Cm : Ar slot Cm : Ns Ar function
792.Op , Ar passthru-device-options
793.El
794.Sm on
795.Pp
796Connect to a PCI device on the host either named ppt
797.Ns Ar N
798or at the selector described by
799.Ar slot ,
800.Ar bus ,
801and
802.Ar function
803numbers.
804.Pp
805The
806.Ar passthru-device-options
807are:
808.Bl -tag -width 10n
809.It Cm rom= Ns Ar romfile
810Add
811.Ar romfile
812as option ROM to the PCI device.
813The ROM will be loaded by firmware and should be capable of
814initializing the device.
815.It Li bootindex= Ns Ar index
816Add the device to the bootorder at
817.Ar index .
818A fwcfg file is used to specify the bootorder.
819The guest firmware may ignore or doesn't support this fwcfg file.
820In that case, this feature doesn't work as expected.
821.El
822.Pp
823Guest memory must be wired using the
824.Fl S
825option when a pass-through device is configured.
826.Pp
827The host device must have been reserved at boot-time using the
828.Va pptdevs
829loader variable as described in
830.Xr vmm 4 .
831.Ss Virtio console device backends
832.Bl -bullet
833.Sm off
834.It
835.Cm port1= Ns Ar /path/to/port1.sock Ns Op Cm ,port Ns Ar N Cm \&= Ns Ar /path/to/port2.sock No \~ Ar ...
836.Sm on
837.El
838.Pp
839A maximum of 16 ports per device can be created.
840Every port is named and corresponds to a Unix domain socket created by
841.Nm .
842.Nm
843accepts at most one connection per port at a time.
844.Pp
845Limitations:
846.Bl -bullet
847.It
848Due to the lack of destructors in
849.Nm ,
850sockets on the filesystem must be cleaned up manually after
851.Nm
852exits.
853.It
854There is no way to use the
855.Dq console port
856feature, nor the console port
857resize at present.
858.It
859Emergency write is advertised, but no-op at present.
860.El
861.Ss Virtio input device backends:
862.Bl -bullet
863.Sm off
864.It
865.Ar /dev/input/eventX
866.Sm on
867.El
868.Pp
869Send input events of
870.Ar /dev/input/eventX
871to guest by VirtIO Input Interface.
872.Ss Framebuffer device backends
873.Bl -bullet
874.Sm off
875.It
876.Op Cm rfb= Ar ip-and-port
877.Op Cm ,w= Ar width
878.Op Cm ,h= Ar height
879.Op Cm ,vga= Ar vgaconf
880.Op Cm ,wait
881.Op Cm ,password= Ar password
882.Sm on
883.El
884.Pp
885Configuration options are defined as follows:
886.Bl -tag -width 10n
887.It Cm rfb= Ns Ar ip-and-port Pq or Cm tcp= Ns Ar ip-and-port
888An IP address and a port VNC should listen on.
889There are two formats:
890.Pp
891.Bl -bullet -compact
892.It
893.Sm off
894.Op Ar IPv4 Cm \&:
895.Ar port
896.Sm on
897.It
898.Sm off
899.Cm \&[ Ar IPv6%zone Cm \&] Cm \&: Ar port
900.Sm on
901.El
902.Pp
903The default is to listen on localhost IPv4 address and default VNC port 5900.
904An IPv6 address must be enclosed in square brackets and may contain an
905optional zone identifier.
906.It Cm w= Ns Ar width No and Cm h= Ns Ar height
907A display resolution, width and height, respectively.
908If not specified, a default resolution of 1024x768 pixels will be used.
909Minimal supported resolution is 640x480 pixels,
910and maximum is 3840x2160 pixels.
911.It Cm vga= Ns Ar vgaconf
912Possible values for this option are
913.Cm io
914(default),
915.Cm on ,
916and
917.Cm off .
918PCI graphics cards have a dual personality in that they are
919standard PCI devices with BAR addressing, but may also
920implicitly decode legacy VGA I/O space
921.Pq Ad 0x3c0-3df
922and memory space
923.Pq 64KB at Ad 0xA0000 .
924The default
925.Cm io
926option should be used for guests that attempt to issue BIOS calls which result
927in I/O port queries, and fail to boot if I/O decode is disabled.
928.Pp
929The
930.Cm on
931option should be used along with the CSM BIOS capability in UEFI
932to boot traditional BIOS guests that require the legacy VGA I/O and
933memory regions to be available.
934.Pp
935The
936.Cm off
937option should be used for the UEFI guests that assume that
938VGA adapter is present if they detect the I/O ports.
939An example of such a guest is
940.Ox
941in UEFI mode.
942.Pp
943Please refer to the
944.Nm
945.Fx
946wiki page
947.Pq Lk https://wiki.freebsd.org/bhyve
948for configuration notes of particular guests.
949.It Cm wait
950Instruct
951.Nm
952to only boot upon the initiation of a VNC connection, simplifying the
953installation of operating systems that require immediate keyboard input.
954This can be removed for post-installation use.
955.It Cm password= Ns Ar password
956This type of authentication is known to be cryptographically weak and is not
957intended for use on untrusted networks.
958Many implementations will want to use stronger security, such as running
959the session over an encrypted channel provided by IPsec or SSH.
960.El
961.Ss xHCI USB device backends
962.Bl -bullet
963.Sm off
964.It
965.Ar tablet
966.Sm on
967.El
968.Pp
969A USB tablet device that provides precise cursor synchronization
970when using VNC.
971.Ss NVMe device backends
972.Bl -bullet
973.Sm off
974.It
975.Ar devpath
976.Op Cm ,maxq= Ar #
977.Op Cm ,qsz= Ar #
978.Op Cm ,ioslots= Ar #
979.Op Cm ,sectsz= Ar #
980.Op Cm ,ser= Ar #
981.Op Cm ,eui64= Ar #
982.Op Cm ,dsm= Ar opt
983.Sm on
984.El
985.Pp
986Configuration options are defined as follows:
987.Bl -tag -width 10n
988.It Ar devpath
989Accepted device paths are:
990.Ar /dev/blockdev
991or
992.Ar /path/to/image
993or
994.Cm ram= Ns Ar size_in_MiB .
995.It Cm maxq
996Max number of queues.
997.It Cm qsz
998Max elements in each queue.
999.It Cm ioslots
1000Max number of concurrent I/O requests.
1001.It Cm sectsz
1002Sector size (defaults to blockif sector size).
1003.It Cm ser
1004Serial number with maximum 20 characters.
1005.It Cm eui64
1006IEEE Extended Unique Identifier (8 byte value).
1007.It Cm dsm
1008DataSet Management support.
1009Supported values are:
1010.Cm auto , enable ,
1011and
1012.Cm disable .
1013.El
1014.Ss AHCI device backends
1015.Bl -bullet
1016.It
1017.Sm off
1018.Op Oo Cm hd\&: | cd\&: Oc Ar path
1019.Op Cm ,nmrr= Ar nmrr
1020.Op Cm ,ser= Ar #
1021.Op Cm ,rev= Ar #
1022.Op Cm ,model= Ar #
1023.Sm on
1024.El
1025.Pp
1026Configuration options are defined as follows:
1027.Bl -tag -width 10n
1028.It Cm nmrr
1029Nominal Media Rotation Rate, known as RPM.
1030Value 1 will indicate device as Solid State Disk.
1031Default value is 0, not report.
1032.It Cm ser
1033Serial Number with maximum 20 characters.
1034.It Cm rev
1035Revision Number with maximum 8 characters.
1036.It Cm model
1037Model Number with maximum 40 characters.
1038.El
1039.Ss HD Audio device backends
1040.Bl -bullet
1041.It
1042.Sm off
1043.Op Cm play= Ar playback
1044.Op Cm ,rec= Ar recording
1045.Sm on
1046.El
1047.Pp
1048Configuration options are defined as follows:
1049.Bl -tag -width 10n
1050.It Cm play
1051Playback device, typically
1052.Ar /dev/dsp0 .
1053.It Cm rec
1054Recording device, typically
1055.Ar /dev/dsp0 .
1056.El
1057.Sh CONFIGURATION VARIABLES
1058.Nm
1059uses an internal tree of configuration variables to describe global and
1060per-device settings.
1061When
1062.Nm
1063starts,
1064it parses command line options (including config files) in the order given
1065on the command line.
1066Each command line option sets one or more configuration variables.
1067For example,
1068the
1069.Fl s
1070option creates a new tree node for a PCI device and sets one or more variables
1071under that node including the device model and device model-specific variables.
1072Variables may be set multiple times during this parsing stage with the final
1073value overriding previous values.
1074.Pp
1075Once all of the command line options have been processed,
1076the configuration values are frozen.
1077.Nm
1078then uses the value of configuration values to initialize device models
1079and global settings.
1080.Pp
1081More details on configuration variables can be found in
1082.Xr bhyve_config 5 .
1083.Sh CONFIGURATION FILE CREATION
1084The
1085.Fl k
1086flag allows one to provide a path to a configuration file holding all
1087settings, which otherwise would need to be defined by providing a long
1088list of program arguments to
1089.Nm .
1090.Pp
1091There is a very simple way to translate a complex set of program
1092arguments to an equivalent configuration file in
1093.Xr bhyve_config 5
1094format.
1095.Pp
1096Use
1097.Fl o
1098.Ar config.dump=1
1099to make
1100.Nm
1101dump a configuration file representing the used flags and arguments to
1102stdout. You can pipe the output into a file to persist the generated settings.
1103.Pp
1104Make sure to remove the
1105.Ar config.dump
1106line from the resulting configuration file before using it to start
1107.Nm .
1108.Sh DEBUG SERVER
1109The current debug server provides limited support for debuggers.
1110.Ss Registers
1111Each virtual CPU is exposed to the debugger as a thread.
1112.Pp
1113General purpose registers can be queried for each virtual CPU, but other
1114registers such as floating-point and system registers cannot be queried.
1115.Ss Memory
1116Memory (including memory mapped I/O regions) can be read and written
1117by the debugger.
1118Memory operations use virtual addresses that are resolved to physical
1119addresses via the current virtual CPU's active address translation.
1120.Ss Control
1121The running guest can be interrupted by the debugger at any time
1122.Pq for example, by pressing Ctrl-C in the debugger .
1123.Pp
1124Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit.
1125.Pp
1126Breakpoints are supported on Intel CPUs that support single stepping.
1127Note that continuing from a breakpoint while interrupts are enabled in the
1128guest may not work as expected due to timer interrupts firing while single
1129stepping over the breakpoint.
1130.Sh SIGNAL HANDLING
1131.Nm
1132deals with the following signals:
1133.Pp
1134.Bl -tag -width SIGTERM -compact
1135.It SIGTERM
1136Trigger ACPI poweroff for a VM
1137.El
1138.Sh EXIT STATUS
1139Exit status indicates how the VM was terminated:
1140.Pp
1141.Bl -tag -width indent -compact
1142.It 0
1143rebooted
1144.It 1
1145powered off
1146.It 2
1147halted
1148.It 3
1149triple fault (amd64 only)
1150.It 4
1151exited due to an error
1152.El
1153.Sh EXAMPLES
1154If not using a boot ROM, the guest operating system must have been loaded with
1155.Xr bhyveload 8
1156or a similar boot loader before
1157.Xr bhyve 4
1158can be run.
1159Otherwise, the boot loader is not needed.
1160.Pp
1161To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio
1162block device backed by the
1163.Pa /my/image
1164filesystem image, and a serial port for the console:
1165.Bd -literal -offset indent
1166bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\
1167  -l com1,stdio -H -P -m 1G vm1
1168.Ed
1169.Pp
1170To do the same on arm64:
1171.Bd -literal -offset indent
1172.Ed
1173bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -o console=stdio \\
1174  -o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1
1175.Pp
1176Run a 24GB single-CPU virtual machine with three network ports, one of which
1177has a MAC address specified:
1178.Bd -literal -offset indent
1179bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\
1180  -s 2:1,virtio-net,tap1 \\
1181  -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\
1182  -s 3,virtio-blk,/my/image -l com1,stdio \\
1183  -H -P -m 24G bigvm
1184.Ed
1185.Pp
1186Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI
1187CD-ROM, a single virtio network port, an AMD hostbridge, and the console
1188port connected to an
1189.Xr nmdm 4
1190null-modem device.
1191.Bd -literal -offset indent
1192bhyve -c 4 \\
1193  -s 0,amd_hostbridge -s 1,lpc \\
1194  -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\
1195hd:/images/disk.3,hd:/images/disk.4,\\
1196hd:/images/disk.5,hd:/images/disk.6,\\
1197hd:/images/disk.7,hd:/images/disk.8,\\
1198cd:/images/install.iso \\
1199  -s 3,virtio-net,tap0 \\
1200  -l com1,/dev/nmdm0A \\
1201  -H -P -m 8G
1202.Ed
1203.Pp
1204Run a UEFI virtual machine with a display resolution of 800 by 600 pixels
1205that can be accessed via VNC at: 0.0.0.0:5900 or via serial console over
1206TCP at: 127.0.0.1:1234 (unsafe if you expose serial console without protection).
1207.Bd -literal -offset indent
1208bhyve -c 2 -m 4G -w -H \\
1209  -s 0,hostbridge \\
1210  -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\
1211  -s 4,ahci-hd,disk.img \\
1212  -s 5,virtio-net,tap0 \\
1213  -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\
1214  -s 30,xhci,tablet \\
1215  -s 31,lpc -l com1,tcp=127.0.0.1:1234 \\
1216  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1217   uefivm
1218.Ed
1219.Pp
1220Run a UEFI virtual machine with a VNC display that is bound to all IPv6
1221addresses on port 5900 and a serial I/O port bound to TCP port 1234 of
1222loopback address (unsafe if you expose serial console without protection).
1223.Bd -literal -offset indent
1224bhyve -c 2 -m 4G -w -H \\
1225  -s 0,hostbridge \\
1226  -s 4,ahci-hd,disk.img \\
1227  -s 5,virtio-net,tap0 \\
1228  -s 29,fbuf,tcp=[::]:5900,w=800,h=600 \\
1229  -s 30,xhci,tablet \\
1230  -s 31,lpc -l com1,tcp=[::1]:1234 \\
1231  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1232   uefivm
1233.Ed
1234.Pp
1235Run a UEFI virtual machine with a VARS file to save EFI variables.
1236Note that
1237.Nm
1238will write guest modifications to the given VARS file.
1239Be sure to create a per-guest copy of the template VARS file from
1240.Pa /usr .
1241.Bd -literal -offset indent
1242bhyve -c 2 -m 4g -w -H \\
1243  -s 0,hostbridge \\
1244  -s 31,lpc -l com1,stdio \\
1245  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd
1246   uefivm
1247.Ed
1248.Pp
1249To create a configuration file
1250.Pa configfile
1251for a virtual machine, use
1252.Fl o
1253.Ar config.dump=1 :
1254.Bd -literal -offset indent
1255/usr/sbin/bhyve -c 2 -m 256 -H -P \\
1256  -s 0:0,hostbridge -s 1:0,virtio-net,tap0 \\
1257  -s 2:0,ahci-hd,./vm0.img \\
1258  -s 31,lpc -l com1,stdio \\
1259  -o config.dump=1 vm0 > configfile
1260.Ed
1261.Pp
1262Then use an editor of your choice to remove the line "config.dump=1"
1263from the newly generated
1264.Pa configfile .
1265.Pp
1266To start
1267.Nm
1268using this configuration file, use flag
1269.Fl k :
1270.Bd -literal -offset indent
1271/usr/sbin/bhyve -k configfile vm0
1272.Ed
1273.Pp
1274Run a UEFI virtual machine with four CPUs and two emulated NUMA domains:
1275.Bd -literal -offset indent
1276bhyve -c 4 -w -H \\
1277  -s 0,hostbridge \\
1278  -s 4,ahci-hd,disk.img \\
1279  -s 31,lpc -l com1,stdio \\
1280  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1281  -n id=0,size=4G,cpus=0-1 \\
1282  -n id=1,size=4G,cpus=2-3 \\
1283   numavm
1284.Ed
1285.Pp
1286Assuming a host machine with two NUMA domains,
1287run a UEFI virtual machine with four CPUs using a
1288.Ar prefer
1289.Xr domainset 9
1290policy to allocate guest memory from the first host NUMA domain only.
1291.Bd -literal -offset indent
1292bhyve -c 2 -w -H \\
1293  -s 0,hostbridge \\
1294  -s 4,ahci-hd,disk.img \\
1295  -s 31,lpc -l com1,stdio \\
1296  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1297  -n id=0,size=4G,cpus=0-1,domain_policy=prefer:0 \\
1298   numavm
1299.Ed
1300.Sh SEE ALSO
1301.Xr bhyve 4 ,
1302.Xr netgraph 4 ,
1303.Xr ng_socket 4 ,
1304.Xr nmdm 4 ,
1305.Xr vmm 4 ,
1306.Xr bhyve_config 5 ,
1307.Xr ethers 5 ,
1308.Xr bhyvectl 8 ,
1309.Xr bhyveload 8 ,
1310.Xr domainset 9
1311.Pp
1312.Rs
1313.%A Intel
1314.%B 64 and IA-32 Architectures Software Developer’s Manual
1315.%V Volume 3
1316.Re
1317.Sh HISTORY
1318.Nm
1319first appeared in
1320.Fx 10.0 .
1321.Sh AUTHORS
1322.An Neel Natu Aq Mt neel@freebsd.org
1323.An Peter Grehan Aq Mt grehan@freebsd.org
1324