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.Pp 644Supported options for 645.Ar type : 646.Bl -tag -width 10n 647.It Cm passthru 648pass a physical TPM device through to the guest 649.El 650.Pp 651The 652.Ar tpm-device-options 653are: 654.Bl -tag -width 10n 655.It Cm version= Ns Ar version 656Version of the TPM device according to the TCG specification. 657Defaults to 658.Cm 2.0 659.El 660.Ss Boot ROM device backends 661.Sm off 662.Bl -bullet 663.It 664.Ar romfile Ns Op Cm \&, Ns Ar varfile 665.El 666.Sm on 667.Pp 668Map 669.Ar romfile 670in the guest address space reserved for boot firmware. 671.Pp 672If 673.Ar varfile 674is provided, that file is also mapped in the boot firmware guest 675address space, and any modifications the guest makes will be saved 676to that file. 677.Pp 678Fwcfg types: 679.Bl -tag -width 10n 680.It Ar fwcfg 681The fwcfg interface is used to pass information such as the CPU count 682or ACPI tables to the guest firmware. 683Supported values are 684.Ql bhyve 685and 686.Ql qemu . 687Due to backward compatibility reasons, 688.Ql bhyve 689is the default option. 690When 691.Ql bhyve 692is used, bhyve's fwctl interface is used. 693It currently reports only the CPU count to the guest firmware. 694The 695.Ql qemu 696option uses QEMU's fwcfg interface. 697This interface is widely used and allows user-defined information to 698be passed to the guest. 699It is used for passing the CPU count, ACPI tables, a boot order and 700many other things to the guest. 701Some operating systems such as Fedora CoreOS can be configured by 702qemu's fwcfg interface as well. 703.El 704.Ss Pass-through device backends 705.Sm off 706.Bl -bullet 707.It 708.Cm ppt Ar N Oo , Ar passthru-device-options Oc 709.It 710.Ns Ar bus Cm \&/ Ar slot Cm \&/ Ar function 711.Op , Ar passthru-device-options 712.It 713.Cm pci Ar bus Cm : Ar slot Cm : Ns Ar function 714.Op , Ar passthru-device-options 715.El 716.Sm on 717.Pp 718Connect to a PCI device on the host either named ppt 719.Ns Ar N 720or at the selector described by 721.Ar slot , 722.Ar bus , 723and 724.Ar function 725numbers. 726.Pp 727The 728.Ar passthru-device-options 729are: 730.Bl -tag -width 10n 731.It Cm rom= Ns Ar romfile 732Add 733.Ar romfile 734as option ROM to the PCI device. 735The ROM will be loaded by firmware and should be capable of 736initializing the device. 737.It Li bootindex= Ns Ar index 738Add the device to the bootorder at 739.Ar index . 740A fwcfg file is used to specify the bootorder. 741The guest firmware may ignore or doesn't support this fwcfg file. 742In that case, this feature doesn't work as expected. 743.El 744.Pp 745Guest memory must be wired using the 746.Fl S 747option when a pass-through device is configured. 748.Pp 749The host device must have been reserved at boot-time using the 750.Va pptdevs 751loader variable as described in 752.Xr vmm 4 . 753.Ss Virtio console device backends 754.Bl -bullet 755.Sm off 756.It 757.Cm port1= Ns Ar /path/to/port1.sock Ns Op Cm ,port Ns Ar N Cm \&= Ns Ar /path/to/port2.sock No \~ Ar ... 758.Sm on 759.El 760.Pp 761A maximum of 16 ports per device can be created. 762Every port is named and corresponds to a Unix domain socket created by 763.Nm . 764.Nm 765accepts at most one connection per port at a time. 766.Pp 767Limitations: 768.Bl -bullet 769.It 770Due to the lack of destructors in 771.Nm , 772sockets on the filesystem must be cleaned up manually after 773.Nm 774exits. 775.It 776There is no way to use the 777.Dq console port 778feature, nor the console port 779resize at present. 780.It 781Emergency write is advertised, but no-op at present. 782.El 783.Ss Virtio input device backends: 784.Bl -bullet 785.Sm off 786.It 787.Ar /dev/input/eventX 788.Sm on 789.El 790.Pp 791Send input events of 792.Ar /dev/input/eventX 793to guest by VirtIO Input Interface. 794.Ss Framebuffer device backends 795.Bl -bullet 796.Sm off 797.It 798.Op Cm rfb= Ar ip-and-port 799.Op Cm ,w= Ar width 800.Op Cm ,h= Ar height 801.Op Cm ,vga= Ar vgaconf 802.Op Cm ,wait 803.Op Cm ,password= Ar password 804.Sm on 805.El 806.Pp 807Configuration options are defined as follows: 808.Bl -tag -width 10n 809.It Cm rfb= Ns Ar ip-and-port Pq or Cm tcp= Ns Ar ip-and-port 810An IP address and a port VNC should listen on. 811There are two formats: 812.Pp 813.Bl -bullet -compact 814.It 815.Sm off 816.Op Ar IPv4 Cm \&: 817.Ar port 818.Sm on 819.It 820.Sm off 821.Cm \&[ Ar IPv6%zone Cm \&] Cm \&: Ar port 822.Sm on 823.El 824.Pp 825The default is to listen on localhost IPv4 address and default VNC port 5900. 826An IPv6 address must be enclosed in square brackets and may contain an 827optional zone identifier. 828.It Cm w= Ns Ar width No and Cm h= Ns Ar height 829A display resolution, width and height, respectively. 830If not specified, a default resolution of 1024x768 pixels will be used. 831Minimal supported resolution is 640x480 pixels, 832and maximum is 3840x2160 pixels. 833.It Cm vga= Ns Ar vgaconf 834Possible values for this option are 835.Cm io 836(default), 837.Cm on , 838and 839.Cm off . 840PCI graphics cards have a dual personality in that they are 841standard PCI devices with BAR addressing, but may also 842implicitly decode legacy VGA I/O space 843.Pq Ad 0x3c0-3df 844and memory space 845.Pq 64KB at Ad 0xA0000 . 846The default 847.Cm io 848option should be used for guests that attempt to issue BIOS calls which result 849in I/O port queries, and fail to boot if I/O decode is disabled. 850.Pp 851The 852.Cm on 853option should be used along with the CSM BIOS capability in UEFI 854to boot traditional BIOS guests that require the legacy VGA I/O and 855memory regions to be available. 856.Pp 857The 858.Cm off 859option should be used for the UEFI guests that assume that 860VGA adapter is present if they detect the I/O ports. 861An example of such a guest is 862.Ox 863in UEFI mode. 864.Pp 865Please refer to the 866.Nm 867.Fx 868wiki page 869.Pq Lk https://wiki.freebsd.org/bhyve 870for configuration notes of particular guests. 871.It Cm wait 872Instruct 873.Nm 874to only boot upon the initiation of a VNC connection, simplifying the 875installation of operating systems that require immediate keyboard input. 876This can be removed for post-installation use. 877.It Cm password= Ns Ar password 878This type of authentication is known to be cryptographically weak and is not 879intended for use on untrusted networks. 880Many implementations will want to use stronger security, such as running 881the session over an encrypted channel provided by IPsec or SSH. 882.El 883.Ss xHCI USB device backends 884.Bl -bullet 885.Sm off 886.It 887.Ar tablet 888.Sm on 889.El 890.Pp 891A USB tablet device that provides precise cursor synchronization 892when using VNC. 893.Ss NVMe device backends 894.Bl -bullet 895.Sm off 896.It 897.Ar devpath 898.Op Cm ,maxq= Ar # 899.Op Cm ,qsz= Ar # 900.Op Cm ,ioslots= Ar # 901.Op Cm ,sectsz= Ar # 902.Op Cm ,ser= Ar # 903.Op Cm ,eui64= Ar # 904.Op Cm ,dsm= Ar opt 905.Sm on 906.El 907.Pp 908Configuration options are defined as follows: 909.Bl -tag -width 10n 910.It Ar devpath 911Accepted device paths are: 912.Ar /dev/blockdev 913or 914.Ar /path/to/image 915or 916.Cm ram= Ns Ar size_in_MiB . 917.It Cm maxq 918Max number of queues. 919.It Cm qsz 920Max elements in each queue. 921.It Cm ioslots 922Max number of concurrent I/O requests. 923.It Cm sectsz 924Sector size (defaults to blockif sector size). 925.It Cm ser 926Serial number with maximum 20 characters. 927.It Cm eui64 928IEEE Extended Unique Identifier (8 byte value). 929.It Cm dsm 930DataSet Management support. 931Supported values are: 932.Cm auto , enable , 933and 934.Cm disable . 935.El 936.Ss AHCI device backends 937.Bl -bullet 938.It 939.Sm off 940.Op Oo Cm hd\&: | cd\&: Oc Ar path 941.Op Cm ,nmrr= Ar nmrr 942.Op Cm ,ser= Ar # 943.Op Cm ,rev= Ar # 944.Op Cm ,model= Ar # 945.Sm on 946.El 947.Pp 948Configuration options are defined as follows: 949.Bl -tag -width 10n 950.It Cm nmrr 951Nominal Media Rotation Rate, known as RPM. 952Value 1 will indicate device as Solid State Disk. 953Default value is 0, not report. 954.It Cm ser 955Serial Number with maximum 20 characters. 956.It Cm rev 957Revision Number with maximum 8 characters. 958.It Cm model 959Model Number with maximum 40 characters. 960.El 961.Ss HD Audio device backends 962.Bl -bullet 963.It 964.Sm off 965.Op Cm play= Ar playback 966.Op Cm ,rec= Ar recording 967.Sm on 968.El 969.Pp 970Configuration options are defined as follows: 971.Bl -tag -width 10n 972.It Cm play 973Playback device, typically 974.Ar /dev/dsp0 . 975.It Cm rec 976Recording device, typically 977.Ar /dev/dsp0 . 978.El 979.Sh CONFIGURATION VARIABLES 980.Nm 981uses an internal tree of configuration variables to describe global and 982per-device settings. 983When 984.Nm 985starts, 986it parses command line options (including config files) in the order given 987on the command line. 988Each command line option sets one or more configuration variables. 989For example, 990the 991.Fl s 992option creates a new tree node for a PCI device and sets one or more variables 993under that node including the device model and device model-specific variables. 994Variables may be set multiple times during this parsing stage with the final 995value overriding previous values. 996.Pp 997Once all of the command line options have been processed, 998the configuration values are frozen. 999.Nm 1000then uses the value of configuration values to initialize device models 1001and global settings. 1002.Pp 1003More details on configuration variables can be found in 1004.Xr bhyve_config 5 . 1005.Sh CONFIGURATION FILE CREATION 1006The 1007.Fl k 1008flag allows one to provide a path to a configuration file holding all 1009settings, which otherwise would need to be defined by providing a long 1010list of program arguments to 1011.Nm . 1012.Pp 1013There is a very simple way to translate a complex set of program 1014arguments to an equivalent configuration file in 1015.Xr bhyve_config 5 1016format. 1017.Pp 1018Use 1019.Fl o 1020.Ar config.dump=1 1021to make 1022.Nm 1023dump a configuration file representing the used flags and arguments to 1024stdout. You can pipe the output into a file to persist the generated settings. 1025.Pp 1026Make sure to remove the 1027.Ar config.dump 1028line from the resulting configuration file before using it to start 1029.Nm . 1030.Sh DEBUG SERVER 1031The current debug server provides limited support for debuggers. 1032.Ss Registers 1033Each virtual CPU is exposed to the debugger as a thread. 1034.Pp 1035General purpose registers can be queried for each virtual CPU, but other 1036registers such as floating-point and system registers cannot be queried. 1037.Ss Memory 1038Memory (including memory mapped I/O regions) can be read and written 1039by the debugger. 1040Memory operations use virtual addresses that are resolved to physical 1041addresses via the current virtual CPU's active address translation. 1042.Ss Control 1043The running guest can be interrupted by the debugger at any time 1044.Pq for example, by pressing Ctrl-C in the debugger . 1045.Pp 1046Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit. 1047.Pp 1048Breakpoints are supported on Intel CPUs that support single stepping. 1049Note that continuing from a breakpoint while interrupts are enabled in the 1050guest may not work as expected due to timer interrupts firing while single 1051stepping over the breakpoint. 1052.Sh SIGNAL HANDLING 1053.Nm 1054deals with the following signals: 1055.Pp 1056.Bl -tag -width SIGTERM -compact 1057.It SIGTERM 1058Trigger ACPI poweroff for a VM 1059.El 1060.Sh EXIT STATUS 1061Exit status indicates how the VM was terminated: 1062.Pp 1063.Bl -tag -width indent -compact 1064.It 0 1065rebooted 1066.It 1 1067powered off 1068.It 2 1069halted 1070.It 3 1071triple fault 1072.It 4 1073exited due to an error 1074.El 1075.Sh EXAMPLES 1076If not using a boot ROM, the guest operating system must have been loaded with 1077.Xr bhyveload 8 1078or a similar boot loader before 1079.Xr bhyve 4 1080can be run. 1081Otherwise, the boot loader is not needed. 1082.Pp 1083To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio 1084block device backed by the 1085.Pa /my/image 1086filesystem image, and a serial port for the console: 1087.Bd -literal -offset indent 1088bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\ 1089 -l com1,stdio -H -P -m 1G vm1 1090.Ed 1091.Pp 1092To do the same on arm64: 1093.Bd -literal -offset indent 1094.Ed 1095bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -o console=stdio \\ 1096 -o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1 1097.Pp 1098Run a 24GB single-CPU virtual machine with three network ports, one of which 1099has a MAC address specified: 1100.Bd -literal -offset indent 1101bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\ 1102 -s 2:1,virtio-net,tap1 \\ 1103 -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\ 1104 -s 3,virtio-blk,/my/image -l com1,stdio \\ 1105 -H -P -m 24G bigvm 1106.Ed 1107.Pp 1108Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI 1109CD-ROM, a single virtio network port, an AMD hostbridge, and the console 1110port connected to an 1111.Xr nmdm 4 1112null-modem device. 1113.Bd -literal -offset indent 1114bhyve -c 4 \\ 1115 -s 0,amd_hostbridge -s 1,lpc \\ 1116 -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\ 1117hd:/images/disk.3,hd:/images/disk.4,\\ 1118hd:/images/disk.5,hd:/images/disk.6,\\ 1119hd:/images/disk.7,hd:/images/disk.8,\\ 1120cd:/images/install.iso \\ 1121 -s 3,virtio-net,tap0 \\ 1122 -l com1,/dev/nmdm0A \\ 1123 -H -P -m 8G 1124.Ed 1125.Pp 1126Run a UEFI virtual machine with a display resolution of 800 by 600 pixels 1127that can be accessed via VNC at: 0.0.0.0:5900 or via serial console over 1128TCP at: 127.0.0.1:1234 (unsafe if you expose serial console without protection). 1129.Bd -literal -offset indent 1130bhyve -c 2 -m 4G -w -H \\ 1131 -s 0,hostbridge \\ 1132 -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\ 1133 -s 4,ahci-hd,disk.img \\ 1134 -s 5,virtio-net,tap0 \\ 1135 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\ 1136 -s 30,xhci,tablet \\ 1137 -s 31,lpc -l com1,tcp=127.0.0.1:1234 \\ 1138 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\ 1139 uefivm 1140.Ed 1141.Pp 1142Run a UEFI virtual machine with a VNC display that is bound to all IPv6 1143addresses on port 5900 and a serial I/O port bound to TCP port 1234 of 1144loopback address (unsafe if you expose serial console without protection). 1145.Bd -literal -offset indent 1146bhyve -c 2 -m 4G -w -H \\ 1147 -s 0,hostbridge \\ 1148 -s 4,ahci-hd,disk.img \\ 1149 -s 5,virtio-net,tap0 \\ 1150 -s 29,fbuf,tcp=[::]:5900,w=800,h=600 \\ 1151 -s 30,xhci,tablet \\ 1152 -s 31,lpc -l com1,tcp=[::1]:1234 \\ 1153 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\ 1154 uefivm 1155.Ed 1156.Pp 1157Run a UEFI virtual machine with a VARS file to save EFI variables. 1158Note that 1159.Nm 1160will write guest modifications to the given VARS file. 1161Be sure to create a per-guest copy of the template VARS file from 1162.Pa /usr . 1163.Bd -literal -offset indent 1164bhyve -c 2 -m 4g -w -H \\ 1165 -s 0,hostbridge \\ 1166 -s 31,lpc -l com1,stdio \\ 1167 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd 1168 uefivm 1169.Ed 1170.Pp 1171To create a configuration file 1172.Pa configfile 1173for a virtual machine, use 1174.Fl o 1175.Ar config.dump=1 : 1176.Bd -literal -offset indent 1177/usr/sbin/bhyve -c 2 -m 256 -H -P \\ 1178 -s 0:0,hostbridge -s 1:0,virtio-net,tap0 \\ 1179 -s 2:0,ahci-hd,./vm0.img \\ 1180 -s 31,lpc -l com1,stdio \\ 1181 -o config.dump=1 vm0 > configfile 1182.Ed 1183.Pp 1184Then use an editor of your choice to remove the line "config.dump=1" 1185from the newly generated 1186.Pa configfile . 1187.Pp 1188To start 1189.Nm 1190using this configuration file, use flag 1191.Fl k : 1192.Bd -literal -offset indent 1193/usr/sbin/bhyve -k configfile vm0 1194.Ed 1195.Sh SEE ALSO 1196.Xr bhyve 4 , 1197.Xr netgraph 4 , 1198.Xr ng_socket 4 , 1199.Xr nmdm 4 , 1200.Xr vmm 4 , 1201.Xr bhyve_config 5 , 1202.Xr ethers 5 , 1203.Xr bhyvectl 8 , 1204.Xr bhyveload 8 1205.Pp 1206.Rs 1207.%A Intel 1208.%B 64 and IA-32 Architectures Software Developer’s Manual 1209.%V Volume 3 1210.Re 1211.Sh HISTORY 1212.Nm 1213first appeared in 1214.Fx 10.0 . 1215.Sh AUTHORS 1216.An Neel Natu Aq Mt neel@freebsd.org 1217.An Peter Grehan Aq Mt grehan@freebsd.org 1218