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 June 2, 2017 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 abehuwxACHPSWY 36.Op Fl c Ar numcpus 37.Op Fl g Ar gdbport 38.Op Fl l Ar lpcdev Ns Op , Ns Ar conf 39.Op Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t 40.Op Fl p Ar vcpu:hostcpu 41.Op Fl s Ar slot,emulation Ns Op , Ns Ar conf 42.Op Fl U Ar uuid 43.Ar vmname 44.Sh DESCRIPTION 45.Nm 46is a hypervisor that runs guest operating systems inside a 47virtual machine. 48.Pp 49Parameters such as the number of virtual CPUs, amount of guest memory, and 50I/O connectivity can be specified with command-line parameters. 51.Pp 52If not using a boot ROM, the guest operating system must be loaded with 53.Xr bhyveload 8 54or a similar boot loader before running 55.Nm , 56otherwise, it is enough to run 57.Nm 58with a boot ROM of choice. 59.Pp 60.Nm 61runs until the guest operating system reboots or an unhandled hypervisor 62exit is detected. 63.Sh OPTIONS 64.Bl -tag -width 10n 65.It Fl a 66The guest's local APIC is configured in xAPIC mode. 67The xAPIC mode is the default setting so this option is redundant. 68It will be deprecated in a future version. 69.It Fl A 70Generate ACPI tables. 71Required for 72.Fx Ns /amd64 73guests. 74.It Fl b 75Enable a low-level console device supported by 76.Fx 77kernels compiled with 78.Cd "device bvmconsole" . 79This option will be deprecated in a future version. 80.It Fl c Ar numcpus 81Number of guest virtual CPUs. 82The default is 1 and the maximum is 16. 83.It Fl C 84Include guest memory in core file. 85.It Fl e 86Force 87.Nm 88to exit when a guest issues an access to an I/O port that is not emulated. 89This is intended for debug purposes. 90.It Fl g Ar gdbport 91For 92.Fx 93kernels compiled with 94.Cd "device bvmdebug" , 95allow a remote kernel kgdb to be relayed to the guest kernel gdb stub 96via a local IPv4 address and this port. 97This option will be deprecated in a future version. 98.It Fl h 99Print help message and exit. 100.It Fl H 101Yield the virtual CPU thread when a HLT instruction is detected. 102If this option is not specified, virtual CPUs will use 100% of a host CPU. 103.It Fl l Ar lpcdev Ns Op , Ns Ar conf 104Allow devices behind the LPC PCI-ISA bridge to be configured. 105The only supported devices are the TTY-class devices 106.Ar com1 107and 108.Ar com2 109and the boot ROM device 110.Ar bootrom . 111.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t 112Guest physical memory size in bytes. 113This must be the same size that was given to 114.Xr bhyveload 8 . 115.Pp 116The size argument may be suffixed with one of K, M, G or T (either upper 117or lower case) to indicate a multiple of kilobytes, megabytes, gigabytes, 118or terabytes. 119If no suffix is given, the value is assumed to be in megabytes. 120.Pp 121.Ar memsize 122defaults to 256M. 123.It Fl p Ar vcpu:hostcpu 124Pin guest's virtual CPU 125.Em vcpu 126to 127.Em hostcpu . 128.It Fl P 129Force the guest virtual CPU to exit when a PAUSE instruction is detected. 130.It Fl s Ar slot,emulation Ns Op , Ns Ar conf 131Configure a virtual PCI slot and function. 132.Pp 133.Nm 134provides PCI bus emulation and virtual devices that can be attached to 135slots on the bus. 136There are 32 available slots, with the option of providing up to 8 functions 137per slot. 138.Bl -tag -width 10n 139.It Ar slot 140.Ar pcislot[:function] 141.Ar bus:pcislot:function 142.Pp 143The 144.Ar pcislot 145value is 0 to 31. 146The optional 147.Ar function 148value is 0 to 7. 149The optional 150.Ar bus 151value is 0 to 255. 152If not specified, the 153.Ar function 154value defaults to 0. 155If not specified, the 156.Ar bus 157value defaults to 0. 158.It Ar emulation 159.Bl -tag -width 10n 160.It Li hostbridge | Li amd_hostbridge 161.Pp 162Provide a simple host bridge. 163This is usually configured at slot 0, and is required by most guest 164operating systems. 165The 166.Li amd_hostbridge 167emulation is identical but uses a PCI vendor ID of 168.Li AMD . 169.It Li passthru 170PCI pass-through device. 171.It Li virtio-net 172Virtio network interface. 173.It Li virtio-blk 174Virtio block storage interface. 175.It Li virtio-rnd 176Virtio RNG interface. 177.It Li virtio-console 178Virtio console interface, which exposes multiple ports 179to the guest in the form of simple char devices for simple IO 180between the guest and host userspaces. 181.It Li ahci 182AHCI controller attached to arbitrary devices. 183.It Li ahci-cd 184AHCI controller attached to an ATAPI CD/DVD. 185.It Li ahci-hd 186AHCI controller attached to a SATA hard-drive. 187.It Li e1000 188Intel e82545 network interface. 189.It Li uart 190PCI 16550 serial device. 191.It Li lpc 192LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports and a boot ROM. 193The LPC bridge emulation can only be configured on bus 0. 194.It Li fbuf 195Raw framebuffer device attached to VNC server. 196.It Li xhci 197eXtensible Host Controller Interface (xHCI) USB controller. 198.El 199.It Op Ar conf 200This optional parameter describes the backend for device emulations. 201If 202.Ar conf 203is not specified, the device emulation has no backend and can be 204considered unconnected. 205.Pp 206Network devices: 207.Bl -tag -width 10n 208.It Ar tapN Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx 209.It Ar vmnetN Ns Op , Ns Ar mac=xx:xx:xx:xx:xx:xx 210.Pp 211If 212.Ar mac 213is not specified, the MAC address is derived from a fixed OUI and the 214remaining bytes from an MD5 hash of the slot and function numbers and 215the device name. 216.Pp 217The MAC address is an ASCII string in 218.Xr ethers 5 219format. 220.El 221.Pp 222Block storage devices: 223.Bl -tag -width 10n 224.It Pa /filename Ns Oo , Ns Ar block-device-options Oc 225.It Pa /dev/xxx Ns Oo , Ns Ar block-device-options Oc 226.El 227.Pp 228The 229.Ar block-device-options 230are: 231.Bl -tag -width 8n 232.It Li nocache 233Open the file with 234.Dv O_DIRECT . 235.It Li direct 236Open the file using 237.Dv O_SYNC . 238.It Li ro 239Force the file to be opened read-only. 240.It Li sectorsize= Ns Ar logical Ns Oo / Ns Ar physical Oc 241Specify the logical and physical sector sizes of the emulated disk. 242The physical sector size is optional and is equal to the logical sector size 243if not explicitly specified. 244.El 245.Pp 246TTY devices: 247.Bl -tag -width 10n 248.It Li stdio 249Connect the serial port to the standard input and output of 250the 251.Nm 252process. 253.It Pa /dev/xxx 254Use the host TTY device for serial port I/O. 255.El 256.Pp 257Boot ROM device: 258.Bl -tag -width 10n 259.It Pa romfile 260Map 261.Ar romfile 262in the guest address space reserved for boot firmware. 263.El 264.Pp 265Pass-through devices: 266.Bl -tag -width 10n 267.It Ns Ar slot Ns / Ns Ar bus Ns / Ns Ar function 268Connect to a PCI device on the host at the selector described by 269.Ar slot , 270.Ar bus , 271and 272.Ar function 273numbers. 274.El 275.Pp 276Guest memory must be wired using the 277.Fl S 278option when a pass-through device is configured. 279.Pp 280The host device must have been reserved at boot-time using the 281.Va pptdev 282loader variable as described in 283.Xr vmm 4 . 284.Pp 285Virtio console devices: 286.Bl -tag -width 10n 287.It Li port1= Ns Pa /path/to/port1.sock Ns ,anotherport= Ns Pa ... 288A maximum of 16 ports per device can be created. 289Every port is named and corresponds to a Unix domain socket created by 290.Nm . 291.Nm 292accepts at most one connection per port at a time. 293.Pp 294Limitations: 295.Bl -bullet -offset 2n 296.It 297Due to lack of destructors in 298.Nm , 299sockets on the filesystem must be cleaned up manually after 300.Nm 301exits. 302.It 303There is no way to use the "console port" feature, nor the console port 304resize at present. 305.It 306Emergency write is advertised, but no-op at present. 307.El 308.El 309.Pp 310Framebuffer devices: 311.Bl -tag -width 10n 312.It Oo rfb= Ns Oo Ar IP: Oc Ns Ar port Oc Ns Oo ,w= Ns Ar width Oc Ns Oo ,h= Ns Ar height Oc Ns Oo ,vga= Ns Ar vgaconf Oc Ns Oo Ns ,wait Oc Ns Oo ,password= Ns Ar password Oc 313.Bl -tag -width 8n 314.It Ar IP:port 315An 316.Ar IP 317address and a 318.Ar port 319VNC should listen on. 320The default is to listen on localhost IPv4 address and default VNC port 5900. 321Listening on an IPv6 address is not supported. 322.It Ar width No and Ar height 323A display resolution, width and height, respectively. 324If not specified, a default resolution of 1024x768 pixels will be used. 325Minimal supported resolution is 640x480 pixels, 326and maximum is 1920x1200 pixels. 327.It Ar vgaconf 328Possible values for this option are 329.Dq io 330(default), 331.Dq on 332, and 333.Dq off . 334PCI graphics cards have a dual personality in that they are 335standard PCI devices with BAR addressing, but may also 336implicitly decode legacy VGA I/O space 337.Pq Ad 0x3c0-3df 338and memory space 339.Pq 64KB at Ad 0xA0000 . 340The default 341.Dq io 342option should be used for guests that attempt to issue BIOS 343calls which result in I/O port queries, and fail to boot if I/O decode is disabled. 344.Pp 345The 346.Dq on 347option should be used along with the CSM BIOS capability in UEFI 348to boot traditional BIOS guests that require the legacy VGA I/O and 349memory regions to be available. 350.Pp 351The 352.Dq off 353option should be used for the UEFI guests that assume that 354VGA adapter is present if they detect the I/O ports. 355An example of such a guest is 356.Ox 357in UEFI mode. 358.Pp 359Please refer to the 360.Nm 361.Fx 362wiki page 363.Pq Lk https://wiki.freebsd.org/bhyve 364for configuration notes of particular guests. 365.It wait 366Instruct 367.Nm 368to only boot upon the initiation of a VNC connection, simplifying the installation 369of operating systems that require immediate keyboard input. 370This can be removed for post-installation use. 371.It password 372This type of authentication is known to be cryptographically weak and is not 373intended for use on untrusted networks. 374Many implementations will want to use stronger security, such as running 375the session over an encrypted channel provided by IPsec or SSH. 376.El 377.El 378.Pp 379xHCI USB devices: 380.Bl -tag -width 10n 381.It Li tablet 382A USB tablet device which provides precise cursor synchronization 383when using VNC. 384.El 385.El 386.It Fl S 387Wire guest memory. 388.It Fl u 389RTC keeps UTC time. 390.It Fl U Ar uuid 391Set the universally unique identifier 392.Pq UUID 393in the guest's System Management BIOS System Information structure. 394By default a UUID is generated from the host's hostname and 395.Ar vmname . 396.It Fl w 397Ignore accesses to unimplemented Model Specific Registers (MSRs). 398This is intended for debug purposes. 399.It Fl W 400Force virtio PCI device emulations to use MSI interrupts instead of MSI-X 401interrupts. 402.It Fl x 403The guest's local APIC is configured in x2APIC mode. 404.It Fl Y 405Disable MPtable generation. 406.It Ar vmname 407Alphanumeric name of the guest. 408This should be the same as that created by 409.Xr bhyveload 8 . 410.El 411.Sh SIGNAL HANDLING 412.Nm 413deals with the following signals: 414.Pp 415.Bl -tag -width indent -compact 416.It SIGTERM 417Trigger ACPI poweroff for a VM 418.El 419.Sh EXIT STATUS 420Exit status indicates how the VM was terminated: 421.Pp 422.Bl -tag -width indent -compact 423.It 0 424rebooted 425.It 1 426powered off 427.It 2 428halted 429.It 3 430triple fault 431.El 432.Sh EXAMPLES 433If not using a boot ROM, the guest operating system must have been loaded with 434.Xr bhyveload 8 435or a similar boot loader before 436.Xr bhyve 4 437can be run. 438Otherwise, the boot loader is not needed. 439.Pp 440To run a virtual machine with 1GB of memory, two virtual CPUs, a virtio 441block device backed by the 442.Pa /my/image 443filesystem image, and a serial port for the console: 444.Bd -literal -offset indent 445bhyve -c 2 -s 0,hostbridge -s 1,lpc -s 2,virtio-blk,/my/image \\ 446 -l com1,stdio -A -H -P -m 1G vm1 447.Ed 448.Pp 449Run a 24GB single-CPU virtual machine with three network ports, one of which 450has a MAC address specified: 451.Bd -literal -offset indent 452bhyve -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\ 453 -s 2:1,virtio-net,tap1 \\ 454 -s 2:2,virtio-net,tap2,mac=00:be:fa:76:45:00 \\ 455 -s 3,virtio-blk,/my/image -l com1,stdio \\ 456 -A -H -P -m 24G bigvm 457.Ed 458.Pp 459Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI 460CD-ROM, a single virtio network port, an AMD hostbridge, and the console 461port connected to an 462.Xr nmdm 4 463null-modem device. 464.Bd -literal -offset indent 465bhyve -c 4 \\ 466 -s 0,amd_hostbridge -s 1,lpc \\ 467 -s 1:0,ahci,hd:/images/disk.1,hd:/images/disk.2,\\ 468hd:/images/disk.3,hd:/images/disk.4,\\ 469hd:/images/disk.5,hd:/images/disk.6,\\ 470hd:/images/disk.7,hd:/images/disk.8,\\ 471cd:/images/install.iso \\ 472 -s 3,virtio-net,tap0 \\ 473 -l com1,/dev/nmdm0A \\ 474 -A -H -P -m 8G 475.Ed 476.Pp 477Run a UEFI virtual machine with a display resolution of 800 by 600 pixels 478that can be accessed via VNC at: 0.0.0.0:5900. 479.Bd -literal -offset indent 480bhyve -c 2 -m 4G -w -H \\ 481 -s 0,hostbridge \\ 482 -s 3,ahci-cd,/path/to/uefi-OS-install.iso \\ 483 -s 4,ahci-hd,disk.img \\ 484 -s 5,virtio-net,tap0 \\ 485 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \\ 486 -s 30,xhci,tablet \\ 487 -s 31,lpc -l com1,stdio \\ 488 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \\ 489 uefivm 490.Ed 491.Sh SEE ALSO 492.Xr bhyve 4 , 493.Xr nmdm 4 , 494.Xr vmm 4 , 495.Xr ethers 5 , 496.Xr bhyvectl 8 , 497.Xr bhyveload 8 498.Sh HISTORY 499.Nm 500first appeared in 501.Fx 10.0 . 502.Sh AUTHORS 503.An Neel Natu Aq Mt neel@freebsd.org 504.An Peter Grehan Aq Mt grehan@freebsd.org 505