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