Date: Mon, 5 May 2014 18:55:20 +0000 (UTC) From: Dru Lavigne <dru@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r44764 - head/en_US.ISO8859-1/books/handbook/virtualization Message-ID: <201405051855.s45ItK7m051485@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dru Date: Mon May 5 18:55:19 2014 New Revision: 44764 URL: http://svnweb.freebsd.org/changeset/doc/44764 Log: Editorial review of bhyve chapter. Reviewed by: Allan Jude Sponsored by: iXsystems Modified: head/en_US.ISO8859-1/books/handbook/virtualization/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/virtualization/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/virtualization/chapter.xml Mon May 5 18:37:48 2014 (r44763) +++ head/en_US.ISO8859-1/books/handbook/virtualization/chapter.xml Mon May 5 18:55:19 2014 (r44764) @@ -69,6 +69,11 @@ </listitem> <listitem> + <para>How to install &os; as a guest in + <application>byhve</application>.</para> + </listitem> + + <listitem> <para>How to tune a &os; system for best performance under virtualization.</para> </listitem> @@ -1289,36 +1294,35 @@ perm pass* 0660</programlisting> <title>&os; as a Host with <application>bhyve</application></title> - <para>Starting with &os; 10.0-RELEASE the BSD licensed hypervisor - <application>bhyve</application> is part of the base system. - <application>bhyve</application> supports a number of guests - including &os;, OpenBSD, and many flavors of &linux;. - <application>bhyve</application> currently only supports a + <para>Starting with &os; 10.0-RELEASE, the <application>bhyve</application> + <acronym>BSD</acronym>-licensed hypervisor is part of the base system. + This hypervisor supports a number of guests, + including &os;, OpenBSD, and many &linux; distributions. + Currently, <application>bhyve</application> only supports a serial console and does not emulate a graphical console. - <application>bhyve</application> is a legacy-free hypervisor, - meaning that instead of translating instructions, and manually - managing memory mappings, it relies on the virtualization - offload features of newer <acronym>CPU</acronym>s. - <application>bhyve</application> also avoids emulating - compatible hardware for the guest, and instead relies on the - paravirtualization drivers, called - <literal>VirtIO</literal>.</para> - - <para>Due to the design of <application>bhyve</application>, it is - only possible to use <application>bhyve</application> on - computers with newer processors that support &intel; - <acronym>EPT</acronym> (Extended Page Tables) or &amd; - <acronym>RVI</acronym> (Rapid Virtualization Indexing, also know - as <acronym>NPT</acronym> or Nested Page Tables). Most newer + As a legacy-free hypervisor, it relies on the virtualization + offload features of newer <acronym>CPU</acronym>s, + instead of translating instructions and manually + managing memory mappings. + It also avoids emulating + compatible hardware for the guest and instead relies on + para-virtualization drivers. In &os;, these are provided by the + &man.virtio.4; driver.</para> + + <para>Due to the design of <application>bhyve</application>, it + requires a computer with a newer processor that supports &intel; + Extended Page Tables (<acronym>EPT</acronym>) or &amd; + Rapid Virtualization Indexing (<acronym>RVI</acronym>), also know + as Nested Page Tables (<acronym>NPT</acronym>). Most newer processors, specifically the &intel; &core; i3/i5/i7 and - &intel; &xeon; E3/E5/E7 support this feature, for a + &intel; &xeon; E3/E5/E7, support this feature. For a complete list of &intel; processors that support - <acronym>EPT</acronym> see the <link - xlink:href="http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true">&intel; - ARK</link>. <acronym>RVI</acronym> is found on the 3rd + <acronym>EPT</acronym>, refer to <link + xlink:href="http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true">http://ark.intel.com/search/advanced?s=t&ExtendedPageTables=true</link>. + <acronym>RVI</acronym> is found on the 3rd generation and later of the &amd.opteron; (Barcelona) processors. The easiest way to check for support of - <acronym>EPT</acronym> or <acronym>RVI</acronym> on a system is + <acronym>EPT</acronym> or <acronym>RVI</acronym> is to look for the <literal>POPCNT</literal> processor feature flag on the <literal>Features2</literal> line in <command>dmesg</command> or @@ -1329,32 +1333,34 @@ perm pass* 0660</programlisting> <para>The first step to creating a virtual machine in <application>bhyve</application> is configuring the host - system. Load the <application>bhyve</application> kernel - module called vmm. Create a <filename>tap</filename> + system. First, load the <application>bhyve</application> kernel + module:</para> + + <screen>&prompt.root; <userinput>kldload vmm</userinput></screen> + + <para>Then, create a <filename>tap</filename> interface for the network device in the virtual machine to - attach to. Optionally create a bridge interface and add the - <filename>tap</filename> interface as well as the physical - interface as members to allow the virtual machine to have - access to the network.</para> - - <screen>&prompt.root; <userinput>kldload vmm</userinput> -&prompt.root; <userinput>kldload nmdm</userinput> -&prompt.root; <userinput>ifconfig <replaceable>tap0</replaceable> create</userinput> + attach to. In order for the network device to participate in + the network, also create a bridge interface containing the + <filename>tap</filename> interface ane the physical + interface as members. In this example, the physical interface + is <replaceable>igb0</replaceable>:</para> + +<screen>&prompt.root; <userinput>ifconfig <replaceable>tap0</replaceable> create</userinput> &prompt.root; <userinput>sysctl net.link.tap.up_on_open=1</userinput> net.link.tap.up_on_open: 0 -> 1 &prompt.root; <userinput>ifconfig <replaceable>bridge0</replaceable> create</userinput> &prompt.root; <userinput>ifconfig <replaceable>bridge0</replaceable> addm <replaceable>igb0</replaceable> addm <replaceable>tap0</replaceable></userinput> &prompt.root; <userinput>ifconfig <replaceable>bridge0</replaceable> up</userinput></screen> - </sect2> <sect2 xml:id="virtualization-bhyve-freebsd"> <title>Creating a FreeBSD Guest</title> <para>Create a file to use as the virtual disk for the guest - machine.</para> + machine. Specify the size and name of the virtual disk:</para> - <screen>&prompt.root; <userinput>truncate -s <replaceable>16G</replaceable> <filename>guest.img</filename></userinput></screen> + <screen>&prompt.root; <userinput>truncate -s <replaceable>16G</replaceable> <replaceable>guest.img</replaceable></userinput></screen> <para>Download an installation image of &os; to install:</para> @@ -1365,21 +1371,21 @@ FreeBSD-10.0-RELEASE-amd64-bootonly.iso machine in <application>bhyve</application>. The script will start the virtual machine and run it in a loop, so it will automatically restart if it crashes. The script takes a - number of options to control the configuration of the machine. - <option>-c</option> controls the number of virtual CPUs. + number of options to control the configuration of the machine: + <option>-c</option> controls the number of virtual CPUs, <option>-m</option> limits the amount of memory available to - the guest. <option>-t</option> defines which - <filename>tap</filename> device to use. <option>-d</option> - indicates which disk image to use. <option>-i</option> tells - <application>bhyve</application> to boot from the CD image - instead of the disk, and <option>-I</option> defines which CD - image to use. Finally the last parameter is the name of the - virtual machine, used to track the running machines. Start + the guest, <option>-t</option> defines which + <filename>tap</filename> device to use, <option>-d</option> + indicates which disk image to use, <option>-i</option> tells + <application>bhyve</application> to boot from the <acronym>CD</acronym> image + instead of the disk, and <option>-I</option> defines which <acronym>CD</acronym> + image to use. The last parameter is the name of the + virtual machine, used to track the running machines. This example starts the virtual machine in installation mode:</para> - <screen>&prompt.root; <userinput>sh <filename>/usr/share/examples/bhyve/vmrun.sh</filename> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <filename>guest.img</filename> -i -I <filename>FreeBSD-10.0-RELEASE-amd64-bootonly.iso</filename> <replaceable>guestname</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <replaceable>guest.img</replaceable> -i -I <replaceable>FreeBSD-10.0-RELEASE-amd64-bootonly.iso</replaceable> <replaceable>guestname</replaceable></userinput></screen> - <para>The system will boot and start the installer. After + <para>The virtual machine will boot and start the installer. After installing a system in the virtual machine, when the system asks about dropping in to a shell at the end of the installation, choose <guibutton>Yes</guibutton>. A small @@ -1389,34 +1395,35 @@ FreeBSD-10.0-RELEASE-amd64-bootonly.iso <programlisting>console "/usr/libexec/getty std.9600" xterm on secure</programlisting> - <para>Reboot the virtual machine. Rebooting the virtual machine - causes <application>bhyve</application> to exit. However the + <para>Reboot the virtual machine. While rebooting the virtual machine + causes <application>bhyve</application> to exit, the <filename>vmrun.sh</filename> script runs <command>bhyve</command> in a loop and will automatically restart it. When this happens, choose the reboot option from - the boot loader menu, and this will escape the loop. Now the + the boot loader menu in order to escape the loop. Now the guest can be started from the virtual disk:</para> - <screen>&prompt.root; <userinput>sh <filename>/usr/share/examples/bhyve/vmrun.sh</filename> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <filename>guest.img</filename> <replaceable>guestname</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>sh /usr/share/examples/bhyve/vmrun.sh -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> -t tap0 -d <replaceable>guest.img</replaceable> <replaceable>guestname</replaceable></userinput></screen> </sect2> <sect2 xml:id="virtualization-bhyve-linux"> <title>Creating a &linux; Guest</title> - <note><para><application>bhyve</application> requires - <package>sysutils/grub2-bhyve</package> in order to boot - operating systems other than &os;.</para></note> + <para>In order to boot operating systems other than &os;, the + <package>sysutils/grub2-bhyve</package> port must be first + installed.</para> - <para>Create a file to use as the virtual disk for the guest - machine.</para> + <para>Next, create a file to use as the virtual disk for the guest + machine:</para> - <screen>&prompt.root; <userinput>truncate -s <replaceable>16G</replaceable> <filename>linux.img</filename></userinput></screen> + <screen>&prompt.root; <userinput>truncate -s <replaceable>16G</replaceable> <replaceable>linux.img</replaceable></userinput></screen> <para>Starting a virtual machine with <application>bhyve</application> is a two step process. First a kernel must be loaded, then the guest can be started. - <package>sysutils/grub2-bhyve</package> is used to load the - &linux; kernel. Create a <filename>device.map</filename> that + The &linux; kernel is loaded with + <package>sysutils/grub2-bhyve</package>. + Create a <filename>device.map</filename> that <application>grub</application> will use to map the virtual devices to the files on the host system:</para> @@ -1426,10 +1433,10 @@ FreeBSD-10.0-RELEASE-amd64-bootonly.iso <para>Use <package>sysutils/grub2-bhyve</package> to load the &linux; kernel from the <acronym>ISO</acronym> image:</para> - <screen>&prompt.root; <userinput>grub-bhyve -m <filename>device.map</filename> -r cd0 -M <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>grub-bhyve -m device.map -r cd0 -M <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> - <para>This will start grub. If the installation CD contains a - <filename>grub.cfg</filename> then a menu will be displayed. + <para>This will start grub. If the installation <acronym>CD</acronym> contains a + <filename>grub.cfg</filename>, a menu will be displayed. If not, the <literal>vmlinuz</literal> and <literal>initrd</literal> files must be located and loaded manually:</para> @@ -1446,14 +1453,8 @@ grub> <userinput>boot</userinput></scree <para>Now that the &linux; kernel is loaded, the guest can be started:</para> - <screen>&prompt.root; <userinput>bhyve -AI -H -P \ --s 0:0,hostbridge \ --s 1:0,lpc \ --s 2:0,virtio-net,tap1 \ --s 3:0,virtio-blk,./linux.img \ --s 4:0,ahci-cd,./somelinux.iso \ --l com1,stdio \ --c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./linux.img \ +-s 4:0,ahci-cd,./somelinux.iso -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> <para>The system will boot and start the installer. After installing a system in the virtual machine, reboot the virtual @@ -1466,7 +1467,7 @@ grub> <userinput>boot</userinput></scree <para>Now the guest can be started directly from the virtual disk. Load the kernel:</para> - <screen>&prompt.root; <userinput>grub-bhyve -m <filename>device.map</filename> -r hd0,msdos1 -M <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> + <screen>&prompt.root; <userinput>grub-bhyve -m device.map -r hd0,msdos1 -M <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> grub> <userinput>ls</userinput> (hd0) (hd0,msdos2) (hd0,msdos1) (cd0) (cd0,msdos1) (host) (lvm/VolGroup-lv_swap) (lvm/VolGroup-lv_root) @@ -1480,13 +1481,8 @@ grub> <userinput>boot</userinput></scree <para>Boot the virtual machine:</para> - <screen>&prompt.root; <userinput>bhyve -AI -H -P \ --s 0:0,hostbridge \ --s 1:0,lpc \ --s 2:0,virtio-net,tap1 \ --s 3:0,virtio-blk,./linux.img \ --l com1,stdio \ --c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 \ +-s 3:0,virtio-blk,./linux.img -l com1,stdio -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput></screen> <para>&linux; will now boot in the virtual machine and eventually present you with the login prompt. Login and use @@ -1498,7 +1494,7 @@ grub> <userinput>boot</userinput></scree </sect2> <sect2 xml:id="virtualization-bhyve-nmdm"> - <title>Virtual Machines Consoles</title> + <title>Virtual Machine Consoles</title> <para>It is advantageous to wrap the <application>bhyve</application> console in a session @@ -1506,24 +1502,20 @@ grub> <userinput>boot</userinput></scree <package>sysutils/screen</package> in order to detach and reattach to the console. It is also possible to have the console of <application>bhyve</application> be a null modem - device that can be accessed with <command>cu</command>. Load - the <filename>nmdm</filename> kernel module, and replace + device that can be accessed with <command>cu</command>. To do this, load + the <filename>nmdm</filename> kernel module and replace <option>-l com1,stdio</option> with <option>-l com1,/dev/nmdm0A</option>. The <filename>/dev/nmdm</filename> devices are created - automatically as needed, each is a pair, - <filename>/dev/nmdm1A</filename> and - <filename>/dev/nmdm1B</filename> corresponding to the two ends - of the null modem cable. See &man.nmdm.4; for more + automatically as needed, where each is a pair, corresponding to the two ends + of the null modem cable + (<filename>/dev/nmdm1A</filename> and + <filename>/dev/nmdm1B</filename>). See &man.nmdm.4; for more information.</para> - <screen>&prompt.root; <userinput>bhyve -AI -H -P \ --s 0:0,hostbridge \ --s 1:0,lpc \ --s 2:0,virtio-net,tap1 \ --s 3:0,virtio-blk,./linux.img \ --l com1,<replaceable>/dev/nmdm0A</replaceable> \ --c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> + <screen>&prompt.root; <userinput>kldload nmdm</userinput> +&prompt.root; <userinput>bhyve -AI -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./linux.img \ +-l com1,<replaceable>/dev/nmdm0A</replaceable> -c <replaceable>4</replaceable> -m <replaceable>1024M</replaceable> <replaceable>linuxguest</replaceable></userinput> &prompt.root; <userinput>cu -l /dev/nmdm0B -s 9600</userinput> Connected @@ -1549,18 +1541,18 @@ crw------- 1 root wheel 0x1a2 Mar 17 crw------- 1 root wheel 0x19f Mar 17 12:19 linuxguest crw------- 1 root wheel 0x1a1 Mar 17 12:19 otherguest</screen> - <para>Virtual machines can be destroyed using + <para>A specified virtual machine can be destroyed using <command>bhyvectl</command>:</para> - <screen>&prompt.root; bhyvectl --destroy --vm=guestname</screen> + <screen>&prompt.root; bhyvectl --destroy --vm=<replaceable>guestname</replaceable></screen> </sect2> <sect2 xml:id="virtualization-bhyve-onboot"> <title>Persistent Configuration</title> - <para>In order to make the system able to start - <application>bhyve</application> guests at boot time, the - following configurations must be made in the specified + <para>In order to configure the system to start + <application>bhyve</application> guests at boot time, add + the following entries to in the following files:</para> <procedure> @@ -1582,8 +1574,8 @@ if_tap_load="YES"</programlisting> <step> <title><filename>/etc/rc.conf</filename></title> - <programlisting>cloned_interfaces="bridge0 tap0" -ifconfig_bridge0="addm igb0 addm tap0"</programlisting> + <programlisting>cloned_interfaces="<replaceable>bridge0</replaceable> <replaceable>tap0</replaceable>" +ifconfig_bridge0="addm <replaceable>igb0</replaceable> addm <replaceable>tap0</replaceable>"</programlisting> </step> </procedure> </sect2>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405051855.s45ItK7m051485>