xref: /freebsd/usr.sbin/bhyve/bhyve.8 (revision ae1a0648b05acf798816e7b83b3c10856de5c8e5)
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.
272.Pp
273The default is 256M.
274.It Fl o Ar var Ns Cm = Ns Ar value
275Set the configuration variable
276.Ar var
277to
278.Ar value .
279See
280.Xr bhyve_config 5
281for configuration options.
282.It Fl P
283Force the guest virtual CPU to exit when a PAUSE instruction is detected.
284This option applies only to the amd64 platform.
285.It Fl p Ar vcpu Ns Cm \& : Ns Ar hostcpu
286Pin guest's virtual CPU
287.Em vcpu
288to
289.Em hostcpu .
290Host CPUs and guest virtual CPUs are numbered starting from 0.
291A
292.Fl p
293option is required for every guest vCPU to be pinned.
294To map a 4 vCPU guest to host CPUs 12-15:
295.Bd -literal
296-p 0:12 -p 1:13 -p 2:14 -p 3:15
297.Ed
298.It Fl r Ar file
299Resume a guest from a snapshot.
300The guest memory contents are restored from
301.Ar file ,
302and the guest device and vCPU state are restored from the file
303.Dq Ar file Ns .kern .
304.Pp
305Note that the current snapshot file format requires that the
306configuration of devices in the new VM match the VM from which the
307snapshot was taken by specifying the same
308.Fl s
309and
310.Fl l
311options.
312The count of vCPUs and memory configuration are read from the snapshot.
313.It Fl S
314Wire guest memory.
315.It Fl s Cm help
316Print a list of supported PCI devices.
317.It Fl s Ar slot Ns Cm \&, Ns Ar emulation Ns Op Cm \&, Ns Ar conf
318Configure a virtual PCI slot and function.
319.Pp
320.Nm
321provides PCI bus emulation and virtual devices that can be attached to
322slots on the bus.
323There are 32 available slots, with the option of providing up to 8 functions
324per slot.
325.Pp
326The
327.Ar slot
328can be specified in one of the following formats:
329.Pp
330.Bl -bullet -compact
331.It
332.Ar pcislot
333.It
334.Sm off
335.Ar pcislot Cm \&: Ar function
336.Sm on
337.It
338.Sm off
339.Ar bus Cm \&: Ar pcislot Cm \&: Ar function
340.Sm on
341.El
342.Pp
343The
344.Ar pcislot
345value is 0 to 31.
346The optional
347.Ar function
348value is 0 to 7.
349The optional
350.Ar bus
351value is 0 to 255.
352If not specified, the
353.Ar function
354value defaults to 0.
355If not specified, the
356.Ar bus
357value defaults to 0.
358.Pp
359See
360.Sx "PCI EMULATION"
361for available options for the
362.Ar emulation
363argument.
364.It Fl U Ar uuid
365Set the universally unique identifier
366.Pq UUID
367in the guest's System Management BIOS System Information structure.
368By default a UUID is generated from the host's hostname and
369.Ar vmname .
370.It Fl u
371RTC keeps UTC time.
372.It Fl W
373Force virtio PCI device emulations to use MSI interrupts instead of MSI-X
374interrupts.
375.It Fl w
376Ignore accesses to unimplemented Model Specific Registers (MSRs).
377This is intended for debug purposes.
378.It Fl x
379The guest's local APIC is configured in x2APIC mode.
380This option applies only to the amd64 platform.
381.It Fl Y
382Disable MPtable generation.
383This option applies only to the amd64 platform.
384.It Ar vmname
385Alphanumeric name of the guest.
386This should be the same as that created by
387.Xr bhyveload 8 .
388.El
389.Sh PCI EMULATION
390.Nm
391provides emulation for various PCI devices.
392They are specified by the
393.Fl s
394.Ar slot,emulation,conf
395configuration's
396.Ar emulation
397argument, which can be one of the following:
398.Bl -tag -width "amd_hostbridge"
399.It Cm hostbridge
400A simple host bridge.
401This is usually configured at slot 0, and is required by most guest
402operating systems.
403.It Cm amd_hostbridge
404Emulation identical to
405.Cm hostbridge
406using a PCI vendor ID of AMD.
407.It Cm passthru
408PCI pass-through device.
409.It Cm virtio-net
410Virtio network interface.
411.It Cm virtio-blk
412Virtio block storage interface.
413.It Cm virtio-scsi
414Virtio SCSI interface.
415.It Cm virtio-9p
416Virtio 9p (VirtFS) interface.
417.It Cm virtio-rnd
418Virtio RNG interface.
419.It Cm virtio-console
420Virtio console interface, which exposes multiple ports
421to the guest in the form of simple char devices for simple IO
422between the guest and host userspaces.
423.It Cm virtio-input
424Virtio input interface.
425.It Cm ahci
426AHCI controller attached to arbitrary devices.
427.It Cm ahci-cd
428AHCI controller attached to an ATAPI CD/DVD.
429.It Cm ahci-hd
430AHCI controller attached to a SATA hard drive.
431.It Cm e1000
432Intel e82545 network interface.
433.It Cm uart
434PCI 16550 serial device.
435.It Cm lpc
436LPC PCI-ISA bridge with COM1, COM2, COM3, and COM4 16550 serial ports,
437a boot ROM, and,
438optionally, a fwcfg type, and the debug/test device.
439The LPC bridge emulation can only be configured on bus 0.
440.It Cm fbuf
441Raw framebuffer device attached to VNC server.
442.It Cm xhci
443eXtensible Host Controller Interface (xHCI) USB controller.
444.It Cm nvme
445NVM Express (NVMe) controller.
446.It Cm hda
447High Definition Audio Controller.
448.El
449.Pp
450The optional parameter
451.Ar conf
452describes the backend for device emulations.
453If
454.Ar conf
455is not specified, the device emulation has no backend and can be
456considered unconnected.
457.Ss Network device backends
458.Sm off
459.Bl -bullet
460.It
461.Xo
462.Cm tap Ar N
463.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
464.Op Cm \&,mtu= Ar N
465.Xc
466.It
467.Xo
468.Cm vmnet Ar N
469.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
470.Op Cm \&,mtu= Ar N
471.Xc
472.It
473.Xo
474.Cm netgraph,path= Ar ADDRESS Cm \&,peerhook= Ar HOOK
475.Op Cm \&,socket= Ar NAME
476.Op Cm \&,hook= Ar HOOK
477.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
478.Op Cm \&,mtu= Ar N
479.Xc
480.It
481.Xo
482.Cm slirp,hostfwd= Ar proto : Ar hostaddr : Ar hostport - Ar guestaddr : Ar guestport
483.Xc
484.El
485.Sm on
486.Pp
487If
488.Cm mac
489is not specified, the MAC address is derived from a fixed OUI, and the
490remaining bytes from an MD5 hash of the slot and function numbers and
491the device name.
492.Pp
493The MAC address is an ASCII string in
494.Xr ethers 5
495format.
496.Pp
497With
498.Cm virtio-net
499devices, the
500.Cm mtu
501parameter can be specified to inform the guest about the largest MTU
502that should be allowed, expressed in bytes.
503.Pp
504With
505.Cm netgraph
506backend, the
507.Cm path
508and
509.Cm peerhook
510parameters must be specified to set the destination node and corresponding hook.
511The optional parameters
512.Cm socket
513and
514.Cm hook
515may be used to set the
516.Xr ng_socket 4
517node name and source hook.
518The
519.Ar ADDRESS ,
520.Ar HOOK ,
521and
522.Ar NAME
523must comply with
524.Xr netgraph 4
525addressing rules.
526.Pp
527The slirp backend can be used to provide a NATed network to the guest.
528This backend has poor performance but does not require any network
529configuration on the host system.
530It depends on the
531.Pa net/libslirp
532port.
533The
534.Cm hostfwd
535option takes a 5-tuple describing how connections from the host are to be
536forwarded to the guest.
537Multiple rules can be specified, separated by semicolons.
538Note that semicolons must be escaped or quoted to prevent the shell from
539interpreting them.
540.Ss Block storage device backends:
541.Bl -bullet
542.Sm off
543.It
544.Ar /filename Op Cm \&, Ar block-device-options
545.It
546.Ar /dev/xxx Op Cm \&, Ar block-device-options
547.Sm on
548.El
549.Pp
550The
551.Ar block-device-options
552are:
553.Bl -tag -width 10n
554.It Cm nocache
555Open the file with
556.Dv O_DIRECT .
557.It Cm direct
558Open the file using
559.Dv O_SYNC .
560.It Cm ro
561Force the file to be opened read-only.
562.It Cm sectorsize= Ns Ar logical Ns Oo Cm \&/ Ns Ar physical Oc
563Specify the logical and physical sector sizes of the emulated disk.
564The physical sector size is optional and is equal to the logical sector size
565if not explicitly specified.
566.It Cm nodelete
567Disable emulation of guest trim requests via
568.Dv DIOCGDELETE
569requests.
570.It Li bootindex= Ns Ar index
571Add the device to the bootorder at
572.Ar index .
573A fwcfg file is used to specify the bootorder.
574The guest firmware may ignore or doesn't support this fwcfg file.
575In that case, this feature doesn't work as expected.
576.El
577.Ss SCSI device backends
578.Bl -bullet
579.Sm off
580.It
581.Pa /dev/cam/ctl Oo Ar pp Cm \&. Ar vp Oc Oo Cm \&, Ar scsi-device-options Oc
582.Sm on
583.El
584.Pp
585The
586.Ar scsi-device-options
587are:
588.Bl -tag -width 10n
589.It Cm iid= Ns Ar IID
590Initiator ID to use when sending requests to specified CTL port.
591The default value is 0.
592.It Li bootindex= Ns Ar index
593Add the device to the bootorder at
594.Ar index .
595A fwcfg file is used to specify the bootorder.
596The guest firmware may ignore or doesn't support this fwcfg file.
597In that case, this feature doesn't work as expected.
598.El
599.Ss 9P device backends
600.Bl -bullet
601.Sm off
602.It
603.Ar sharename Cm = Ar /path/to/share Op Cm \&, Ar 9p-device-options
604.Sm on
605.El
606.Pp
607The
608.Ar 9p-device-options
609are:
610.Bl -tag -width 10n
611.It Cm ro
612Expose the share in read-only mode.
613.El
614.Ss TTY device backends
615.Bl -tag -width 10n
616.It Cm stdio
617Connect the serial port to the standard input and output of
618the
619.Nm
620process.
621.It Ar /dev/xxx
622Use the host TTY device for serial port I/O.
623.It Ar tcp=ip:port
624Use the TCP server for serial port I/O.
625Configuring this option will start a TCP server that waits for connections.
626Only one connection is allowed at any time. Other connection try to connect
627to TCP server will be disconnected immediately. Note that this feature
628allows unprivileged users to access the guest console, so ensure that
629access is appropriately restricted.
630.El
631.Ss TPM device backends
632.Bl -bullet
633.Sm off
634.It
635.Ar type Ns \&, Ns Ar path Ns Op Cm \&, Ns Ar tpm-device-options
636.Sm on
637.El
638.Pp
639Emulate a TPM device. The argument
640.Ar path
641needs to point to a valid TPM device path, i.e.
642.Pa /dev/tpm0 .
643.El
644.Pp
645Supported options for
646.Ar type :
647.Bl -tag -width 10n
648.It Cm passthru
649pass a physical TPM device through to the guest
650.El
651.Pp
652The
653.Ar tpm-device-options
654are:
655.Bl -tag -width 10n
656.It Cm version= Ns Ar version
657Version of the TPM device according to the TCG specification.
658Defaults to
659.Cm 2.0
660.El
661.Ss Boot ROM device backends
662.Sm off
663.Bl -bullet
664.It
665.Ar romfile Ns Op Cm \&, Ns Ar varfile
666.El
667.Sm on
668.Pp
669Map
670.Ar romfile
671in the guest address space reserved for boot firmware.
672.Pp
673If
674.Ar varfile
675is provided, that file is also mapped in the boot firmware guest
676address space, and any modifications the guest makes will be saved
677to that file.
678.Pp
679Fwcfg types:
680.Bl -tag -width 10n
681.It Ar fwcfg
682The fwcfg interface is used to pass information such as the CPU count
683or ACPI tables to the guest firmware.
684Supported values are
685.Ql bhyve
686and
687.Ql qemu .
688Due to backward compatibility reasons,
689.Ql bhyve
690is the default option.
691When
692.Ql bhyve
693is used, bhyve's fwctl interface is used.
694It currently reports only the CPU count to the guest firmware.
695The
696.Ql qemu
697option uses QEMU's fwcfg interface.
698This interface is widely used and allows user-defined information to
699be passed to the guest.
700It is used for passing the CPU count, ACPI tables, a boot order and
701many other things to the guest.
702Some operating systems such as Fedora CoreOS can be configured by
703qemu's fwcfg interface as well.
704.El
705.Ss Pass-through device backends
706.Sm off
707.Bl -bullet
708.It
709.Cm ppt Ar N Oo , Ar passthru-device-options Oc
710.It
711.Ns Ar bus Cm \&/ Ar slot Cm \&/ Ar function
712.Op , Ar passthru-device-options
713.It
714.Cm pci Ar bus Cm : Ar slot Cm : Ns Ar function
715.Op , Ar passthru-device-options
716.El
717.Sm on
718.Pp
719Connect to a PCI device on the host either named ppt
720.Ns Ar N
721or at the selector described by
722.Ar slot ,
723.Ar bus ,
724and
725.Ar function
726numbers.
727.Pp
728The
729.Ar passthru-device-options
730are:
731.Bl -tag -width 10n
732.It Cm rom= Ns Ar romfile
733Add
734.Ar romfile
735as option ROM to the PCI device.
736The ROM will be loaded by firmware and should be capable of
737initializing the device.
738.It Li bootindex= Ns Ar index
739Add the device to the bootorder at
740.Ar index .
741A fwcfg file is used to specify the bootorder.
742The guest firmware may ignore or doesn't support this fwcfg file.
743In that case, this feature doesn't work as expected.
744.El
745.Pp
746Guest memory must be wired using the
747.Fl S
748option when a pass-through device is configured.
749.Pp
750The host device must have been reserved at boot-time using the
751.Va pptdevs
752loader variable as described in
753.Xr vmm 4 .
754.Ss Virtio console device backends
755.Bl -bullet
756.Sm off
757.It
758.Cm port1= Ns Ar /path/to/port1.sock Ns Op Cm ,port Ns Ar N Cm \&= Ns Ar /path/to/port2.sock No \~ Ar ...
759.Sm on
760.El
761.Pp
762A maximum of 16 ports per device can be created.
763Every port is named and corresponds to a Unix domain socket created by
764.Nm .
765.Nm
766accepts at most one connection per port at a time.
767.Pp
768Limitations:
769.Bl -bullet
770.It
771Due to the lack of destructors in
772.Nm ,
773sockets on the filesystem must be cleaned up manually after
774.Nm
775exits.
776.It
777There is no way to use the
778.Dq console port
779feature, nor the console port
780resize at present.
781.It
782Emergency write is advertised, but no-op at present.
783.El
784.Ss Virtio input device backends:
785.Bl -bullet
786.Sm off
787.It
788.Ar /dev/input/eventX
789.Sm on
790.El
791.Pp
792Send input events of
793.Ar /dev/input/eventX
794to guest by VirtIO Input Interface.
795.Ss Framebuffer device backends
796.Bl -bullet
797.Sm off
798.It
799.Op Cm rfb= Ar ip-and-port
800.Op Cm ,w= Ar width
801.Op Cm ,h= Ar height
802.Op Cm ,vga= Ar vgaconf
803.Op Cm ,wait
804.Op Cm ,password= Ar password
805.Sm on
806.El
807.Pp
808Configuration options are defined as follows:
809.Bl -tag -width 10n
810.It Cm rfb= Ns Ar ip-and-port Pq or Cm tcp= Ns Ar ip-and-port
811An IP address and a port VNC should listen on.
812There are two formats:
813.Pp
814.Bl -bullet -compact
815.It
816.Sm off
817.Op Ar IPv4 Cm \&:
818.Ar port
819.Sm on
820.It
821.Sm off
822.Cm \&[ Ar IPv6%zone Cm \&] Cm \&: Ar port
823.Sm on
824.El
825.Pp
826The default is to listen on localhost IPv4 address and default VNC port 5900.
827An IPv6 address must be enclosed in square brackets and may contain an
828optional zone identifier.
829.It Cm w= Ns Ar width No and Cm h= Ns Ar height
830A display resolution, width and height, respectively.
831If not specified, a default resolution of 1024x768 pixels will be used.
832Minimal supported resolution is 640x480 pixels,
833and maximum is 3840x2160 pixels.
834.It Cm vga= Ns Ar vgaconf
835Possible values for this option are
836.Cm io
837(default),
838.Cm on ,
839and
840.Cm off .
841PCI graphics cards have a dual personality in that they are
842standard PCI devices with BAR addressing, but may also
843implicitly decode legacy VGA I/O space
844.Pq Ad 0x3c0-3df
845and memory space
846.Pq 64KB at Ad 0xA0000 .
847The default
848.Cm io
849option should be used for guests that attempt to issue BIOS calls which result
850in I/O port queries, and fail to boot if I/O decode is disabled.
851.Pp
852The
853.Cm on
854option should be used along with the CSM BIOS capability in UEFI
855to boot traditional BIOS guests that require the legacy VGA I/O and
856memory regions to be available.
857.Pp
858The
859.Cm off
860option should be used for the UEFI guests that assume that
861VGA adapter is present if they detect the I/O ports.
862An example of such a guest is
863.Ox
864in UEFI mode.
865.Pp
866Please refer to the
867.Nm
868.Fx
869wiki page
870.Pq Lk https://wiki.freebsd.org/bhyve
871for configuration notes of particular guests.
872.It Cm wait
873Instruct
874.Nm
875to only boot upon the initiation of a VNC connection, simplifying the
876installation of operating systems that require immediate keyboard input.
877This can be removed for post-installation use.
878.It Cm password= Ns Ar password
879This type of authentication is known to be cryptographically weak and is not
880intended for use on untrusted networks.
881Many implementations will want to use stronger security, such as running
882the session over an encrypted channel provided by IPsec or SSH.
883.El
884.Ss xHCI USB device backends
885.Bl -bullet
886.Sm off
887.It
888.Ar tablet
889.Sm on
890.El
891.Pp
892A USB tablet device that provides precise cursor synchronization
893when using VNC.
894.Ss NVMe device backends
895.Bl -bullet
896.Sm off
897.It
898.Ar devpath
899.Op Cm ,maxq= Ar #
900.Op Cm ,qsz= Ar #
901.Op Cm ,ioslots= Ar #
902.Op Cm ,sectsz= Ar #
903.Op Cm ,ser= Ar #
904.Op Cm ,eui64= Ar #
905.Op Cm ,dsm= Ar opt
906.Sm on
907.El
908.Pp
909Configuration options are defined as follows:
910.Bl -tag -width 10n
911.It Ar devpath
912Accepted device paths are:
913.Ar /dev/blockdev
914or
915.Ar /path/to/image
916or
917.Cm ram= Ns Ar size_in_MiB .
918.It Cm maxq
919Max number of queues.
920.It Cm qsz
921Max elements in each queue.
922.It Cm ioslots
923Max number of concurrent I/O requests.
924.It Cm sectsz
925Sector size (defaults to blockif sector size).
926.It Cm ser
927Serial number with maximum 20 characters.
928.It Cm eui64
929IEEE Extended Unique Identifier (8 byte value).
930.It Cm dsm
931DataSet Management support.
932Supported values are:
933.Cm auto , enable ,
934and
935.Cm disable .
936.El
937.Ss AHCI device backends
938.Bl -bullet
939.It
940.Sm off
941.Op Oo Cm hd\&: | cd\&: Oc Ar path
942.Op Cm ,nmrr= Ar nmrr
943.Op Cm ,ser= Ar #
944.Op Cm ,rev= Ar #
945.Op Cm ,model= Ar #
946.Sm on
947.El
948.Pp
949Configuration options are defined as follows:
950.Bl -tag -width 10n
951.It Cm nmrr
952Nominal Media Rotation Rate, known as RPM.
953Value 1 will indicate device as Solid State Disk.
954Default value is 0, not report.
955.It Cm ser
956Serial Number with maximum 20 characters.
957.It Cm rev
958Revision Number with maximum 8 characters.
959.It Cm model
960Model Number with maximum 40 characters.
961.El
962.Ss HD Audio device backends
963.Bl -bullet
964.It
965.Sm off
966.Op Cm play= Ar playback
967.Op Cm ,rec= Ar recording
968.Sm on
969.El
970.Pp
971Configuration options are defined as follows:
972.Bl -tag -width 10n
973.It Cm play
974Playback device, typically
975.Ar /dev/dsp0 .
976.It Cm rec
977Recording device, typically
978.Ar /dev/dsp0 .
979.El
980.Sh CONFIGURATION VARIABLES
981.Nm
982uses an internal tree of configuration variables to describe global and
983per-device settings.
984When
985.Nm
986starts,
987it parses command line options (including config files) in the order given
988on the command line.
989Each command line option sets one or more configuration variables.
990For example,
991the
992.Fl s
993option creates a new tree node for a PCI device and sets one or more variables
994under that node including the device model and device model-specific variables.
995Variables may be set multiple times during this parsing stage with the final
996value overriding previous values.
997.Pp
998Once all of the command line options have been processed,
999the configuration values are frozen.
1000.Nm
1001then uses the value of configuration values to initialize device models
1002and global settings.
1003.Pp
1004More details on configuration variables can be found in
1005.Xr bhyve_config 5 .
1006.Sh CONFIGURATION FILE CREATION
1007The
1008.Fl k
1009flag allows one to provide a path to a configuration file holding all
1010settings, which otherwise would need to be defined by providing a long
1011list of program arguments to
1012.Nm .
1013.Pp
1014There is a very simple way to translate a complex set of program
1015arguments to an equivalent configuration file in
1016.Xr bhyve_config 5
1017format.
1018.Pp
1019Use
1020.Fl o
1021.Ar config.dump=1
1022to make
1023.Nm
1024dump a configuration file representing the used flags and arguments to
1025stdout. You can pipe the output into a file to persist the generated settings.
1026.Pp
1027Make sure to remove the
1028.Ar config.dump
1029line from the resulting configuration file before using it to start
1030.Nm .
1031.Sh DEBUG SERVER
1032The current debug server provides limited support for debuggers.
1033.Ss Registers
1034Each virtual CPU is exposed to the debugger as a thread.
1035.Pp
1036General purpose registers can be queried for each virtual CPU, but other
1037registers such as floating-point and system registers cannot be queried.
1038.Ss Memory
1039Memory (including memory mapped I/O regions) can be read and written
1040by the debugger.
1041Memory operations use virtual addresses that are resolved to physical
1042addresses via the current virtual CPU's active address translation.
1043.Ss Control
1044The running guest can be interrupted by the debugger at any time
1045.Pq for example, by pressing Ctrl-C in the debugger .
1046.Pp
1047Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit.
1048.Pp
1049Breakpoints are supported on Intel CPUs that support single stepping.
1050Note that continuing from a breakpoint while interrupts are enabled in the
1051guest may not work as expected due to timer interrupts firing while single
1052stepping over the breakpoint.
1053.Sh SIGNAL HANDLING
1054.Nm
1055deals with the following signals:
1056.Pp
1057.Bl -tag -width SIGTERM -compact
1058.It SIGTERM
1059Trigger ACPI poweroff for a VM
1060.El
1061.Sh EXIT STATUS
1062Exit status indicates how the VM was terminated:
1063.Pp
1064.Bl -tag -width indent -compact
1065.It 0
1066rebooted
1067.It 1
1068powered off
1069.It 2
1070halted
1071.It 3
1072triple fault
1073.It 4
1074exited due to an error
1075.El
1076.Sh EXAMPLES
1077If not using a boot ROM, the guest operating system must have been loaded with
1078.Xr bhyveload 8
1079or a similar boot loader before
1080.Xr bhyve 4
1081can be run.
1082Otherwise, the boot loader is not needed.
1083.Pp
1084To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio
1085block device backed by the
1086.Pa /my/image
1087filesystem image, and a serial port for the console:
1088.Bd -literal -offset indent
1089bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\
1090  -l com1,stdio -H -P -m 1G vm1
1091.Ed
1092.Pp
1093To do the same on arm64:
1094.Bd -literal -offset indent
1095.Ed
1096bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -o console=stdio \\
1097  -o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1
1098.Pp
1099Run a 24GB single-CPU virtual machine with three network ports, one of which
1100has a MAC address specified:
1101.Bd -literal -offset indent
1102bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\
1103  -s 2:1,virtio-net,tap1 \\
1104  -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\
1105  -s 3,virtio-blk,/my/image -l com1,stdio \\
1106  -H -P -m 24G bigvm
1107.Ed
1108.Pp
1109Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI
1110CD-ROM, a single virtio network port, an AMD hostbridge, and the console
1111port connected to an
1112.Xr nmdm 4
1113null-modem device.
1114.Bd -literal -offset indent
1115bhyve -c 4 \\
1116  -s 0,amd_hostbridge -s 1,lpc \\
1117  -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\
1118hd:/images/disk.3,hd:/images/disk.4,\\
1119hd:/images/disk.5,hd:/images/disk.6,\\
1120hd:/images/disk.7,hd:/images/disk.8,\\
1121cd:/images/install.iso \\
1122  -s 3,virtio-net,tap0 \\
1123  -l com1,/dev/nmdm0A \\
1124  -H -P -m 8G
1125.Ed
1126.Pp
1127Run a UEFI virtual machine with a display resolution of 800 by 600 pixels
1128that can be accessed via VNC at: 0.0.0.0:5900 or via serial console over
1129TCP at: 127.0.0.1:1234 (unsafe if you expose serial console without protection).
1130.Bd -literal -offset indent
1131bhyve -c 2 -m 4G -w -H \\
1132  -s 0,hostbridge \\
1133  -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\
1134  -s 4,ahci-hd,disk.img \\
1135  -s 5,virtio-net,tap0 \\
1136  -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\
1137  -s 30,xhci,tablet \\
1138  -s 31,lpc -l com1,tcp=127.0.0.1:1234 \\
1139  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1140   uefivm
1141.Ed
1142.Pp
1143Run a UEFI virtual machine with a VNC display that is bound to all IPv6
1144addresses on port 5900 and a serial I/O port bound to TCP port 1234 of
1145loopback address (unsafe if you expose serial console without protection).
1146.Bd -literal -offset indent
1147bhyve -c 2 -m 4G -w -H \\
1148  -s 0,hostbridge \\
1149  -s 4,ahci-hd,disk.img \\
1150  -s 5,virtio-net,tap0 \\
1151  -s 29,fbuf,tcp=[::]:5900,w=800,h=600 \\
1152  -s 30,xhci,tablet \\
1153  -s 31,lpc -l com1,tcp=[::1]:1234 \\
1154  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\
1155   uefivm
1156.Ed
1157.Pp
1158Run a UEFI virtual machine with a VARS file to save EFI variables.
1159Note that
1160.Nm
1161will write guest modifications to the given VARS file.
1162Be sure to create a per-guest copy of the template VARS file from
1163.Pa /usr .
1164.Bd -literal -offset indent
1165bhyve -c 2 -m 4g -w -H \\
1166  -s 0,hostbridge \\
1167  -s 31,lpc -l com1,stdio \\
1168  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd
1169   uefivm
1170.Ed
1171.Pp
1172To create a configuration file
1173.Pa configfile
1174for a virtual machine, use
1175.Fl o
1176.Ar config.dump=1 :
1177.Bd -literal -offset indent
1178/usr/sbin/bhyve -c 2 -m 256 -H -P \\
1179  -s 0:0,hostbridge -s 1:0,virtio-net,tap0 \\
1180  -s 2:0,ahci-hd,./vm0.img \\
1181  -s 31,lpc -l com1,stdio \\
1182  -o config.dump=1 vm0 > configfile
1183.Ed
1184.Pp
1185Then use an editor of your choice to remove the line "config.dump=1"
1186from the newly generated
1187.Pa configfile .
1188.Pp
1189To start
1190.Nm
1191using this configuration file, use flag
1192.Fl k :
1193.Bd -literal -offset indent
1194/usr/sbin/bhyve -k configfile vm0
1195.Ed
1196.Sh SEE ALSO
1197.Xr bhyve 4 ,
1198.Xr netgraph 4 ,
1199.Xr ng_socket 4 ,
1200.Xr nmdm 4 ,
1201.Xr vmm 4 ,
1202.Xr bhyve_config 5 ,
1203.Xr ethers 5 ,
1204.Xr bhyvectl 8 ,
1205.Xr bhyveload 8
1206.Pp
1207.Rs
1208.%A Intel
1209.%B 64 and IA-32 Architectures Software Developer’s Manual
1210.%V Volume 3
1211.Re
1212.Sh HISTORY
1213.Nm
1214first appeared in
1215.Fx 10.0 .
1216.Sh AUTHORS
1217.An Neel Natu Aq Mt neel@freebsd.org
1218.An Peter Grehan Aq Mt grehan@freebsd.org
1219