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.\" $FreeBSD$ 26.\" 27.Dd May 5, 2020 28.Dt BHYVE 8 29.Os 30.Sh NAME 31.Nm bhyve 32.Nd "run a guest operating system inside a virtual machine" 33.Sh SYNOPSIS 34.Nm 35.Op Fl AabCeHhPSuWwxY 36.Oo 37.Sm off 38.Fl c\~ 39.Oo 40.Op Cm cpus= 41.Ar numcpus 42.Oc 43.Op Cm ,sockets= Ar n 44.Op Cm ,cores= Ar n 45.Op Cm ,threads= Ar n 46.Oc 47.Sm on 48.Op Fl G Ar port 49.Op Fl g Ar gdbport 50.Oo Fl l 51.Sm off 52.Cm help | Ar lpcdev Op Cm \&, Ar conf 53.Sm on 54.Oc 55.Oo Fl m 56.Sm off 57.Ar memsize 58.Oo 59.Cm K No | Cm k No | Cm M No | Cm m No | Cm G No | Cm g No | Cm T No | Cm t 60.Oc 61.Sm on 62.Oc 63.Op Fl p Ar vcpu Ns Cm \&: Ns Ar hostcpu 64.Op Fl r Ar file 65.Oo Fl s 66.Sm off 67.Cm help | Ar slot Cm \&, Ar emulation Op Cm \&, Ar conf 68.Sm on 69.Oc 70.Op Fl U Ar uuid 71.Ar vmname 72.Sh DESCRIPTION 73.Nm 74is a hypervisor that runs guest operating systems inside a 75virtual machine. 76.Pp 77Parameters such as the number of virtual CPUs, amount of guest memory, and 78I/O connectivity can be specified with command-line parameters. 79.Pp 80If not using a boot ROM, the guest operating system must be loaded with 81.Xr bhyveload 8 82or a similar boot loader before running 83.Nm , 84otherwise, it is enough to run 85.Nm 86with a boot ROM of choice. 87.Pp 88.Nm 89runs until the guest operating system reboots or an unhandled hypervisor 90exit is detected. 91.Sh OPTIONS 92.Bl -tag -width 10n 93.It Fl a 94The guest's local APIC is configured in xAPIC mode. 95The xAPIC mode is the default setting so this option is redundant. 96It will be deprecated in a future version. 97.It Fl A 98Generate ACPI tables. 99Required for 100.Fx Ns /amd64 101guests. 102.It Fl b 103Enable a low-level console device supported by 104.Fx 105kernels compiled with 106.Cd "device bvmconsole" . 107This option will be deprecated in a future version. 108.It Fl c Op Ar setting ... 109Number of guest virtual CPUs 110and/or the CPU topology. 111The default value for each of 112.Ar numcpus , 113.Ar sockets , 114.Ar cores , 115and 116.Ar threads 117is 1. 118The current maximum number of guest virtual CPUs is 16. 119If 120.Ar numcpus 121is not specified then it will be calculated from the other arguments. 122The topology must be consistent in that the 123.Ar numcpus 124must equal the product of 125.Ar sockets , 126.Ar cores , 127and 128.Ar threads . 129If a 130.Ar setting 131is specified more than once the last one has precedence. 132.It Fl C 133Include guest memory in core file. 134.It Fl e 135Force 136.Nm 137to exit when a guest issues an access to an I/O port that is not emulated. 138This is intended for debug purposes. 139.It Fl g Ar gdbport 140For 141.Fx 142kernels compiled with 143.Cd "device bvmdebug" , 144allow a remote kernel kgdb to be relayed to the guest kernel gdb stub 145via a local IPv4 address and this port. 146This option will be deprecated in a future version. 147.It Fl G Ar port 148Start a debug server that uses the GDB protocol to export guest state to a 149debugger. 150An IPv4 TCP socket will be bound to the supplied 151.Ar port 152to listen for debugger connections. 153Only a single debugger may be attached to the debug server at a time. 154If 155.Ar port 156begins with 157.Sq w , 158.Nm 159will pause execution at the first instruction waiting for a debugger to attach. 160.It Fl h 161Print help message and exit. 162.It Fl H 163Yield the virtual CPU thread when a HLT instruction is detected. 164If this option is not specified, virtual CPUs will use 100% of a host CPU. 165.It Fl l Op Ar help|lpcdev Ns Op , Ns Ar conf 166Allow devices behind the LPC PCI-ISA bridge to be configured. 167The only supported devices are the TTY-class devices 168.Ar com1 169and 170.Ar com2 171and the boot ROM device 172.Ar bootrom . 173.Pp 174.Ar help 175print a list of supported LPC devices. 176.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t 177Guest physical memory size in bytes. 178This must be the same size that was given to 179.Xr bhyveload 8 . 180.Pp 181The size argument may be suffixed with one of K, M, G or T (either upper 182or lower case) to indicate a multiple of kilobytes, megabytes, gigabytes, 183or terabytes. 184If no suffix is given, the value is assumed to be in megabytes. 185.Pp 186.Ar memsize 187defaults to 256M. 188.It Fl p Ar vcpu:hostcpu 189Pin guest's virtual CPU 190.Em vcpu 191to 192.Em hostcpu . 193.It Fl P 194Force the guest virtual CPU to exit when a PAUSE instruction is detected. 195.It Fl r Ar file 196Resume a guest from a snapshot. 197The guest memory contents are restored from 198.Ar file , 199and the guest device and vCPU state are restored from the file 200.Dq Ar file Ns .kern . 201.Pp 202Note that the current snapshot file format requires that the configuration of 203devices in the new VM match the VM from which the snapshot was taken by specifying the 204same 205.Op Fl s 206and 207.Op Fl l 208options. 209The count of vCPUs and memory configuration are read from the snapshot. 210.It Fl s Op Ar help|slot,emulation Ns Op , Ns Ar conf 211Configure a virtual PCI slot and function. 212.Pp 213.Nm 214provides PCI bus emulation and virtual devices that can be attached to 215slots on the bus. 216There are 32 available slots, with the option of providing up to 8 functions 217per slot. 218.Bl -tag -width 10n 219.It Ar help 220print a list of supported PCI devices. 221.It Ar slot 222.Ar pcislot[:function] 223.Ar bus:pcislot:function 224.Pp 225The 226.Ar pcislot 227value is 0 to 31. 228The optional 229.Ar function 230value is 0 to 7. 231The optional 232.Ar bus 233value is 0 to 255. 234If not specified, the 235.Ar function 236value defaults to 0. 237If not specified, the 238.Ar bus 239value defaults to 0. 240.It Ar emulation 241.Bl -tag -width 10n 242.It Li hostbridge | Li amd_hostbridge 243.Pp 244Provide a simple host bridge. 245This is usually configured at slot 0, and is required by most guest 246operating systems. 247The 248.Li amd_hostbridge 249emulation is identical but uses a PCI vendor ID of 250.Li AMD . 251.It Li passthru 252PCI pass-through device. 253.It Li virtio-net 254Virtio network interface. 255.It Li virtio-blk 256Virtio block storage interface. 257.It Li virtio-scsi 258Virtio SCSI interface. 259.It Li virtio-rnd 260Virtio RNG interface. 261.It Li virtio-console 262Virtio console interface, which exposes multiple ports 263to the guest in the form of simple char devices for simple IO 264between the guest and host userspaces. 265.It Li ahci 266AHCI controller attached to arbitrary devices. 267.It Li ahci-cd 268AHCI controller attached to an ATAPI CD/DVD. 269.It Li ahci-hd 270AHCI controller attached to a SATA hard-drive. 271.It Li e1000 272Intel e82545 network interface. 273.It Li uart 274PCI 16550 serial device. 275.It Li lpc 276LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports and a boot ROM. 277The LPC bridge emulation can only be configured on bus 0. 278.It Li fbuf 279Raw framebuffer device attached to VNC server. 280.It Li xhci 281eXtensible Host Controller Interface (xHCI) USB controller. 282.It Li nvme 283NVM Express (NVMe) controller. 284.It Li hda 285High Definition Audio Controller. 286.El 287.It Op Ar conf 288This optional parameter describes the backend for device emulations. 289If 290.Ar conf 291is not specified, the device emulation has no backend and can be 292considered unconnected. 293.Pp 294Network devices: 295.Bl -tag -width 10n 296.It Ar tapN Ns Oo , Ns Ar mac=xx:xx:xx:xx:xx:xx Oc Ns Oo , Ns Ar mtu=N Oc 297.It Ar vmnetN Ns Oo , Ns Ar mac=xx:xx:xx:xx:xx:xx Oc Ns Oo , Ns Ar mtu=N Oc 298.Pp 299If 300.Ar mac 301is not specified, the MAC address is derived from a fixed OUI and the 302remaining bytes from an MD5 hash of the slot and function numbers and 303the device name. 304.Pp 305The MAC address is an ASCII string in 306.Xr ethers 5 307format. 308.Pp 309With virtio-net devices, the 310.Ar mtu 311parameter can be specified to inform the guest about the largest MTU 312that should be allowed, expressed in bytes. 313.El 314.Pp 315Block storage devices: 316.Bl -tag -width 10n 317.It Pa /filename Ns Oo , Ns Ar block-device-options Oc 318.It Pa /dev/xxx Ns Oo , Ns Ar block-device-options Oc 319.El 320.Pp 321The 322.Ar block-device-options 323are: 324.Bl -tag -width 8n 325.It Li nocache 326Open the file with 327.Dv O_DIRECT . 328.It Li direct 329Open the file using 330.Dv O_SYNC . 331.It Li ro 332Force the file to be opened read-only. 333.It Li sectorsize= Ns Ar logical Ns Oo / Ns Ar physical Oc 334Specify the logical and physical sector sizes of the emulated disk. 335The physical sector size is optional and is equal to the logical sector size 336if not explicitly specified. 337.El 338.Pp 339SCSI devices: 340.Bl -tag -width 10n 341.It Pa /dev/cam/ctl Ns Oo Ar pp . Ns Ar vp Oc Ns Oo , Ns Ar scsi-device-options Oc 342.El 343.Pp 344The 345.Ar scsi-device-options 346are: 347.Bl -tag -width 10n 348.It Li iid= Ns Ar IID 349Initiator ID to use when sending requests to specified CTL port. 350The default value is 0. 351.El 352.Pp 353TTY devices: 354.Bl -tag -width 10n 355.It Li stdio 356Connect the serial port to the standard input and output of 357the 358.Nm 359process. 360.It Pa /dev/xxx 361Use the host TTY device for serial port I/O. 362.El 363.Pp 364Boot ROM device: 365.Bl -tag -width 10n 366.It Pa romfile 367Map 368.Ar romfile 369in the guest address space reserved for boot firmware. 370.El 371.Pp 372Pass-through devices: 373.Bl -tag -width 10n 374.It Ns Ar slot Ns / Ns Ar bus Ns / Ns Ar function 375Connect to a PCI device on the host at the selector described by 376.Ar slot , 377.Ar bus , 378and 379.Ar function 380numbers. 381.El 382.Pp 383Guest memory must be wired using the 384.Fl S 385option when a pass-through device is configured. 386.Pp 387The host device must have been reserved at boot-time using the 388.Va pptdevs 389loader variable as described in 390.Xr vmm 4 . 391.Pp 392Virtio console devices: 393.Bl -tag -width 10n 394.It Li port1= Ns Pa /path/to/port1.sock Ns ,anotherport= Ns Pa ... 395A maximum of 16 ports per device can be created. 396Every port is named and corresponds to a Unix domain socket created by 397.Nm . 398.Nm 399accepts at most one connection per port at a time. 400.Pp 401Limitations: 402.Bl -bullet -offset 2n 403.It 404Due to lack of destructors in 405.Nm , 406sockets on the filesystem must be cleaned up manually after 407.Nm 408exits. 409.It 410There is no way to use the "console port" feature, nor the console port 411resize at present. 412.It 413Emergency write is advertised, but no-op at present. 414.El 415.El 416.Pp 417Framebuffer devices: 418.Bl -tag -width 10n 419.It Xo 420.Oo rfb= Ns Oo Ar IP\&: Oc Ns Ar port Oc Ns Oo ,w= Ns Ar width Oc Ns Oo ,h= Ns 421.Ar height Oc Ns Oo ,vga= Ns Ar vgaconf Oc Ns Oo Ns ,wait Oc Ns Oo ,password= Ns 422.Ar password Oc 423.Xc 424.Bl -tag -width 8n 425.It Ar IPv4:port No or Ar [IPv6%zone]:port 426An 427.Ar IP 428address and a 429.Ar port 430VNC should listen on. 431The default is to listen on localhost IPv4 address and default VNC port 5900. 432An IPv6 address must be enclosed in square brackets and may contain an 433optional zone identifier. 434.It Ar width No and Ar height 435A display resolution, width and height, respectively. 436If not specified, a default resolution of 1024x768 pixels will be used. 437Minimal supported resolution is 640x480 pixels, 438and maximum is 1920x1200 pixels. 439.It Ar vgaconf 440Possible values for this option are 441.Dq io 442(default), 443.Dq on 444, and 445.Dq off . 446PCI graphics cards have a dual personality in that they are 447standard PCI devices with BAR addressing, but may also 448implicitly decode legacy VGA I/O space 449.Pq Ad 0x3c0-3df 450and memory space 451.Pq 64KB at Ad 0xA0000 . 452The default 453.Dq io 454option should be used for guests that attempt to issue BIOS calls which result 455in I/O port queries, and fail to boot if I/O decode is disabled. 456.Pp 457The 458.Dq on 459option should be used along with the CSM BIOS capability in UEFI 460to boot traditional BIOS guests that require the legacy VGA I/O and 461memory regions to be available. 462.Pp 463The 464.Dq off 465option should be used for the UEFI guests that assume that 466VGA adapter is present if they detect the I/O ports. 467An example of such a guest is 468.Ox 469in UEFI mode. 470.Pp 471Please refer to the 472.Nm 473.Fx 474wiki page 475.Pq Lk https://wiki.freebsd.org/bhyve 476for configuration notes of particular guests. 477.It wait 478Instruct 479.Nm 480to only boot upon the initiation of a VNC connection, simplifying the 481installation of operating systems that require immediate keyboard input. 482This can be removed for post-installation use. 483.It password 484This type of authentication is known to be cryptographically weak and is not 485intended for use on untrusted networks. 486Many implementations will want to use stronger security, such as running 487the session over an encrypted channel provided by IPsec or SSH. 488.El 489.El 490.Pp 491xHCI USB devices: 492.Bl -tag -width 10n 493.It Li tablet 494A USB tablet device which provides precise cursor synchronization 495when using VNC. 496.El 497.Pp 498NVMe devices: 499.Bl -tag -width 10n 500.It Li devpath 501Accepted device paths are: 502.Ar /dev/blockdev 503or 504.Ar /path/to/image 505or 506.Ar ram=size_in_MiB . 507.It Li maxq 508Max number of queues. 509.It Li qsz 510Max elements in each queue. 511.It Li ioslots 512Max number of concurrent I/O requests. 513.It Li sectsz 514Sector size (defaults to blockif sector size). 515.It Li ser 516Serial number with maximum 20 characters. 517.El 518.Pp 519HD Audio devices: 520.Bl -tag -width 10n 521.It Li play 522Playback device, typically 523.Ar /dev/dsp0 . 524.It Li rec 525Recording device, typically 526.Ar /dev/dsp0 . 527.El 528.El 529.It Fl S 530Wire guest memory. 531.It Fl u 532RTC keeps UTC time. 533.It Fl U Ar uuid 534Set the universally unique identifier 535.Pq UUID 536in the guest's System Management BIOS System Information structure. 537By default a UUID is generated from the host's hostname and 538.Ar vmname . 539.It Fl w 540Ignore accesses to unimplemented Model Specific Registers (MSRs). 541This is intended for debug purposes. 542.It Fl W 543Force virtio PCI device emulations to use MSI interrupts instead of MSI-X 544interrupts. 545.It Fl x 546The guest's local APIC is configured in x2APIC mode. 547.It Fl Y 548Disable MPtable generation. 549.It Ar vmname 550Alphanumeric name of the guest. 551This should be the same as that created by 552.Xr bhyveload 8 . 553.El 554.Sh DEBUG SERVER 555The current debug server provides limited support for debuggers. 556.Ss Registers 557Each virtual CPU is exposed to the debugger as a thread. 558.Pp 559General purpose registers can be queried for each virtual CPU, but other 560registers such as floating-point and system registers cannot be queried. 561.Ss Memory 562Memory (including memory mapped I/O regions) can be read and written by the debugger. 563Memory operations use virtual addresses that are resolved to physical addresses 564via the current virtual CPU's active address translation. 565.Ss Control 566The running guest can be interrupted by the debugger at any time 567.Pq for example, by pressing Ctrl-C in the debugger . 568.Pp 569Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit. 570.Pp 571Breakpoints are supported on Intel CPUs that support single stepping. 572Note that continuing from a breakpoint while interrupts are enabled in the 573guest may not work as expected due to timer interrupts firing while single 574stepping over the breakpoint. 575.Sh SIGNAL HANDLING 576.Nm 577deals with the following signals: 578.Pp 579.Bl -tag -width indent -compact 580.It SIGTERM 581Trigger ACPI poweroff for a VM 582.El 583.Sh EXIT STATUS 584Exit status indicates how the VM was terminated: 585.Pp 586.Bl -tag -width indent -compact 587.It 0 588rebooted 589.It 1 590powered off 591.It 2 592halted 593.It 3 594triple fault 595.It 4 596exited due to an error 597.El 598.Sh EXAMPLES 599If not using a boot ROM, the guest operating system must have been loaded with 600.Xr bhyveload 8 601or a similar boot loader before 602.Xr bhyve 4 603can be run. 604Otherwise, the boot loader is not needed. 605.Pp 606To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio 607block device backed by the 608.Pa /my/image 609filesystem image, and a serial port for the console: 610.Bd -literal -offset indent 611bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\ 612 -l com1,stdio -A -H -P -m 1G vm1 613.Ed 614.Pp 615Run a 24GB single-CPU virtual machine with three network ports, one of which 616has a MAC address specified: 617.Bd -literal -offset indent 618bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\ 619 -s 2:1,virtio-net,tap1 \\ 620 -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\ 621 -s 3,virtio-blk,/my/image -l com1,stdio \\ 622 -A -H -P -m 24G bigvm 623.Ed 624.Pp 625Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI 626CD-ROM, a single virtio network port, an AMD hostbridge, and the console 627port connected to an 628.Xr nmdm 4 629null-modem device. 630.Bd -literal -offset indent 631bhyve -c 4 \\ 632 -s 0,amd_hostbridge -s 1,lpc \\ 633 -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\ 634hd:/images/disk.3,hd:/images/disk.4,\\ 635hd:/images/disk.5,hd:/images/disk.6,\\ 636hd:/images/disk.7,hd:/images/disk.8,\\ 637cd:/images/install.iso \\ 638 -s 3,virtio-net,tap0 \\ 639 -l com1,/dev/nmdm0A \\ 640 -A -H -P -m 8G 641.Ed 642.Pp 643Run a UEFI virtual machine with a display resolution of 800 by 600 pixels 644that can be accessed via VNC at: 0.0.0.0:5900. 645.Bd -literal -offset indent 646bhyve -c 2 -m 4G -w -H \\ 647 -s 0,hostbridge \\ 648 -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\ 649 -s 4,ahci-hd,disk.img \\ 650 -s 5,virtio-net,tap0 \\ 651 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\ 652 -s 30,xhci,tablet \\ 653 -s 31,lpc -l com1,stdio \\ 654 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\ 655 uefivm 656.Ed 657.Pp 658Run a UEFI virtual machine with a VNC display that is bound to all IPv6 659addresses on port 5900. 660.Bd -literal -offset indent 661bhyve -c 2 -m 4G -w -H \\ 662 -s 0,hostbridge \\ 663 -s 4,ahci-hd,disk.img \\ 664 -s 5,virtio-net,tap0 \\ 665 -s 29,fbuf,tcp=[::]:5900,w=800,h=600 \\ 666 -s 30,xhci,tablet \\ 667 -s 31,lpc -l com1,stdio \\ 668 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\ 669 uefivm 670.Ed 671.Sh SEE ALSO 672.Xr bhyve 4 , 673.Xr nmdm 4 , 674.Xr vmm 4 , 675.Xr ethers 5 , 676.Xr bhyvectl 8 , 677.Xr bhyveload 8 678.Pp 679.Rs 680.%A Intel 681.%B 64 and IA-32 Architectures Software Developer’s Manual 682.%V Volume 3 683.Re 684.Sh HISTORY 685.Nm 686first appeared in 687.Fx 10.0 . 688.Sh AUTHORS 689.An Neel Natu Aq Mt neel@freebsd.org 690.An Peter Grehan Aq Mt grehan@freebsd.org 691