vagrant-libvirt/configuration.html

274 lines
133 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <title>Configuration - Vagrant Libvirt Documentation</title> <link rel="shortcut icon" href="/vagrant-libvirt/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-default.css"> <script type="text/javascript" src="/vagrant-libvirt/assets/js/vendor/lunr.min.js"></script> <script type="text/javascript" src="/vagrant-libvirt/assets/js/just-the-docs.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Begin Jekyll SEO tag v2.8.0 --> <title>Configuration | Vagrant Libvirt Documentation</title> <meta name="generator" content="Jekyll v3.9.3" /> <meta property="og:title" content="Configuration" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Create and manage Vagrant machines using Libvirt/QEMU" /> <meta property="og:description" content="Create and manage Vagrant machines using Libvirt/QEMU" /> <link rel="canonical" href="https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html" /> <meta property="og:url" content="https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html" /> <meta property="og:site_name" content="Vagrant Libvirt Documentation" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="Configuration" /> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"WebPage","description":"Create and manage Vagrant machines using Libvirt/QEMU","headline":"Configuration","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://vagrant-libvirt.github.io/vagrant-libvirt/assets/images/logo.png"}},"url":"https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html"}</script> <!-- End Jekyll SEO tag --> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-light.css" media="(prefers-color-scheme: light)"> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-dark.css" media="(prefers-color-scheme: dark)"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-link" viewBox="0 0 24 24"> <title>Link</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path> </svg> </symbol> <symbol id="svg-search" viewBox="0 0 24 24"> <title>Search</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> </svg> </symbol> <symbol id="svg-menu" viewBox="0 0 24 24"> <title>Menu</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"> <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line> </svg> </symbol> <symbol id="svg-arrow-right" viewBox="0 0 24 24"> <title>Expand</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> <polyline points="9 18 15 12 9 6"></polyline> </svg> </symbol> <symbol id="svg-doc" viewBox="0 0 24 24"> <title>Document</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> </svg> <div class="side-bar"> <div class="site-header"> <a href="https://vagrant-libvirt.github.io/vagrant-libvirt/" class="site-title lh-tight"> <div class="site-logo"></div> Vagrant Libvirt Documentation </a> <a href="#" id="menu-button" class="site-button"> <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-menu"></use></svg> </a> </div> <nav role="navigation" aria-label="Main" id="site-nav" class="site-nav"> <ul class="nav-list"><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/" class="nav-list-link">Quickstart</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html" class="nav-list-link">Installation</a> </li><li class="nav-list-item active"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html" class="nav-list-link active">Configuration</a> <ul id="toc" class="section-nav"> <li class="toc-entry toc-h2"><a href="#provider-options">Provider Options</a> <ul> <li class="toc-entry toc-h3"><a href="#connection-options">Connection Options</a></li> <li class="toc-entry toc-h3"><a href="#domain-specific-options">Domain Specific Options</a></li> <li class="toc-entry toc-h3"><a href="#reload-behavior">Reload behavior</a></li> </ul> </li> <li class="toc-entry toc-h2"><a href="#networks">Networks</a> <ul> <li class="toc-entry toc-h3"><a href="#private-network-options">Private Network Options</a></li> <li class="toc-entry toc-h3"><a href="#public-network-options">Public Network Options</a></li> <li class="toc-entry toc-h3"><a href="#management-network">Management Network</a></li> </ul> </li> <li class="toc-entry toc-h2"><a href="#additional-disks">Additional Disks</a> <ul> <li class="toc-entry toc-h3"><a href="#reload-behavior-1">Reload behavior</a></li> </ul> </li> <li class="toc-entry toc-h2"><a href="#cdroms">CDROMs</a></li> <li class="toc-entry toc-h2"><a href="#floppies">Floppies</a></li> <li class="toc-entry toc-h2"><a href="#input">Input</a></li> <li class="toc-entry toc-h2"><a href="#pci-device-passthrough">PCI device passthrough</a></li> <li class="toc-entry toc-h2"><a href="#using-usb-devices">Using USB Devices</a> <ul> <li class="toc-entry toc-h3"><a href="#usb-controller-configuration">USB Controller Configuration</a></li> <li class="toc-entry toc-h3"><a href="#usb-device-passthrough">USB Device Passthrough</a></li> <li class="toc-entry toc-h3"><a href="#usb-redirector-devices">USB Redirector Devices</a></li> </ul> </li> <li class="toc-entry toc-h2"><a href="#serial-console-devices">Serial Console Devices</a></li> <li class="toc-entry toc-h2"><a href="#random-number-generator-passthrough">Random number generator passthrough</a></li> <li class="toc-entry toc-h2"><a href="#watchdog-device">Watchdog device</a></li> <li class="toc-entry toc-h2"><a href="#smartcard-device">Smartcard device</a></li> <li class="toc-entry toc-h2"><a href="#hypervisor-features">Hypervisor Features</a></li> <li class="toc-entry toc-h2"><a href="#clock">Clock</a></li> <li class="toc-entry toc-h2"><a href="#cpu-features">CPU features</a></li> <li class="toc-entry toc-h2"><a href="#memory-backing">Memory Backing</a></li> </ul> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/boxes.html" class="nav-list-link">Boxes</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/examples.html" class="nav-list-link">Examples</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/packaging.html" class="nav-list-link">Packaging</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/troubleshooting.html" class="nav-list-link">Troubleshooting</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/about/" class="nav-list-link">About</a> </li></ul> </nav> <footer class="site-footer"> This site uses <a href="https://github.com/pmarsceill/just-the-docs">Just the Docs</a>, a documentation theme for Jekyll. </footer> </div> <div class="main" id="top"> <div id="main-header" class="main-header"> <div class="search"> <div class="search-input-wrap"> <input type="text" id="search-input" class="search-input" tabindex="0" placeholder="Search Vagrant Libvirt Documentation" aria-label="Search Vagrant Libvirt Documentation" autocomplete="off"> <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#svg-search"></use></svg></label> </div> <div id="search-results" class="search-results"></div> </div> <script src="/vagrant-libvirt/assets/js/site_constants-e1ac483f8cbbb2d44940348129b4f096317606c1e27aa57fe14734259e395fe6.js"></script> <div id="plugin-version-menu" class="site-footer"></div> <script src="/vagrant-libvirt/assets/js/plugin_versions_menu.js"></script> </div> <div id="main-content-wrap" class="main-content-wrap"> <div id="main-content" class="main-content" role="main"> <p>Although it should work without any configuration for most people, this provider exposes quite a few provider-specific configuration options.</p> <h2 id="provider-options"> <a href="#provider-options" class="anchor-heading" aria-labelledby="provider-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Provider Options </h2> <h3 id="connection-options"> <a href="#connection-options" class="anchor-heading" aria-labelledby="connection-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Connection Options </h3> <p>The following options allow you to configure how vagrant-libvirt connects to Libvirt, and are used to generate the <a href="http://libvirt.org/uri.html">Libvirt connection URI</a>:</p> <ul> <li><code class="language-plaintext highlighter-rouge">driver</code> - A hypervisor name to access. For now only KVM and QEMU are supported</li> <li><code class="language-plaintext highlighter-rouge">host</code> - The name of the server, where Libvirtd is running</li> <li><code class="language-plaintext highlighter-rouge">connect_via_ssh</code> - If use ssh tunnel to connect to Libvirt. Absolutely needed to access Libvirt on remote host. It will not be able to get the IP address of a started VM otherwise.</li> <li><code class="language-plaintext highlighter-rouge">username</code> - Username and password to access Libvirt</li> <li><code class="language-plaintext highlighter-rouge">password</code> - Password to access Libvirt</li> <li><code class="language-plaintext highlighter-rouge">id_ssh_key_file</code> - If not nil, uses this ssh private key to access Libvirt. Default is <code class="language-plaintext highlighter-rouge">$HOME/.ssh/id_rsa</code>. Prepends <code class="language-plaintext highlighter-rouge">$HOME/.ssh/</code> if no directory</li> <li><code class="language-plaintext highlighter-rouge">socket</code> - Path to the Libvirt unix socket (e.g. <code class="language-plaintext highlighter-rouge">/var/run/libvirt/libvirt-sock</code>)</li> <li><code class="language-plaintext highlighter-rouge">uri</code> - For advanced usage. Directly specifies what Libvirt connection URI vagrant-libvirt should use. Overrides all above connection configuration options</li> <li><code class="language-plaintext highlighter-rouge">proxy_command</code> - For advanced usage. When connecting to remote libvirt instances, if the default constructed proxy_command which uses <code class="language-plaintext highlighter-rouge">-W %h:%p</code> does not work, set this as needed. It performs interpolation using <code class="language-plaintext highlighter-rouge">{key}</code> and supports only <code class="language-plaintext highlighter-rouge">{host}</code>, <code class="language-plaintext highlighter-rouge">{username}</code>, and <code class="language-plaintext highlighter-rouge">{id_ssh_key_file}</code>. This is to try and avoid issues with escaping <code class="language-plaintext highlighter-rouge">%</code> and <code class="language-plaintext highlighter-rouge">$</code> which might be necessary to the ssh command itself. e.g.: <code class="language-plaintext highlighter-rouge">libvirt.proxy_command = "ssh {host} -l {username} -i {id_ssh_key_file} nc %h %p"</code></li> </ul> <p>In the event that none of these are set (excluding the <code class="language-plaintext highlighter-rouge">driver</code> option) the provider will attempt to retrieve the uri from the environment variable <code class="language-plaintext highlighter-rouge">LIBVIRT_DEFAULT_URI</code> similar to how virsh works. If any of them are set, it will ignore the environment variable. The reason the driver option is ignored is that it is not uncommon for this to be explicitly set on the box itself and there is no easily to determine whether it is being set by the user or the box packager.</p> <p>Connection-independent options:</p> <ul> <li><code class="language-plaintext highlighter-rouge">storage_pool_name</code> - Libvirt storage pool name, where box image and instance snapshots (if <code class="language-plaintext highlighter-rouge">snapshot_pool_name</code> is not set) will be stored.</li> <li><code class="language-plaintext highlighter-rouge">snapshot_pool_name</code> - Libvirt storage pool name. If set, the created snapshot of the instance will be stored at this location instead of <code class="language-plaintext highlighter-rouge">storage_pool_name</code>.</li> </ul> <p>Connection example:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">host</span> <span class="o">=</span> <span class="s2">"example.com"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h3 id="domain-specific-options"> <a href="#domain-specific-options" class="anchor-heading" aria-labelledby="domain-specific-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Domain Specific Options </h3> <ul> <li><code class="language-plaintext highlighter-rouge">title</code> - A short description of the domain.</li> <li><code class="language-plaintext highlighter-rouge">description</code> - A human readable description of the virtual machine.</li> <li><code class="language-plaintext highlighter-rouge">random_hostname</code> - To create a domain name with extra information on the end to prevent hostname conflicts.</li> <li><code class="language-plaintext highlighter-rouge">default_prefix</code> - The default Libvirt guest name becomes a concatenation of the <code class="language-plaintext highlighter-rouge">&lt;current_directory&gt;_&lt;guest_name&gt;</code>. The current working directory is the default prefix to the guest name. The <code class="language-plaintext highlighter-rouge">default_prefix</code> options allow you to set the guest name prefix.</li> <li><code class="language-plaintext highlighter-rouge">disk_bus</code> - The type of disk device to emulate. Defaults to virtio if not set. Possible values are documented in Libvirts <a href="http://libvirt.org/formatdomain.html#hard-drives-floppy-disks-cdroms">description for <em>target</em></a>. NOTE: this option applies only to disks associated with a box image. To set the bus type on additional disks, see the <a href="#additional-disks">Additional Disks</a> section.</li> <li><code class="language-plaintext highlighter-rouge">disk_controller_model</code> - the controller model to use. Ignored unless either <code class="language-plaintext highlighter-rouge">disk_bus</code> is set to <code class="language-plaintext highlighter-rouge">scsi</code> or <code class="language-plaintext highlighter-rouge">disk_device</code> starts with <code class="language-plaintext highlighter-rouge">sd</code>, which is a hint to use scsi. Defaults to <code class="language-plaintext highlighter-rouge">virtio-scsi</code> when it encounters either of the config values for <code class="language-plaintext highlighter-rouge">disk_bus</code> or <code class="language-plaintext highlighter-rouge">disk_device</code>. See <a href="https://libvirt.org/formatdomain.html#controllers">libvirt controller models</a> for other possible values. NOTE: this option applies only to the disks associated with a box image.</li> <li><code class="language-plaintext highlighter-rouge">disk_device</code> - The disk device to emulate. Defaults to vda if not set, which should be fine for paravirtualized guests, but some fully virtualized guests may require hda. NOTE: this option also applies only to disks associated with a box image.</li> <li><code class="language-plaintext highlighter-rouge">disk_address_type</code> - The address type of disk device to emulate. Libvirt uses a sensible default if not set, but some fully virtualized guests may need to override this (e.g. Debian on <em>virt</em> machine may need <em>virtio-mmio</em>). Possible values are documented in libvirts <a href="https://libvirt.org/formatdomain.html#device-addresses">description for <em>address</em></a>.</li> <li><code class="language-plaintext highlighter-rouge">disk_driver</code> - Extra options for the main disk driver (<a href="http://libvirt.org/formatdomain.html#hard-drives-floppy-disks-cdroms">see Libvirt documentation</a>). NOTE: this option also applies only to disks associated with a box image. In all cases, the value <code class="language-plaintext highlighter-rouge">nil</code> can be used to force the hypervisor default behaviour (e.g. to override settings defined in top-level Vagrantfiles). Supported options include: <ul> <li><code class="language-plaintext highlighter-rouge">:cache</code> - Controls the cache mechanism. Possible values are “default”, “none”, “writethrough”, “writeback”, “directsync” and “unsafe”.</li> <li><code class="language-plaintext highlighter-rouge">:io</code> - Controls specific policies on I/O. Possible values are “threads” and “native”.</li> <li><code class="language-plaintext highlighter-rouge">:copy_on_read</code> - Controls whether to copy read backing file into the image file. The value can be either “on” or “off”.</li> <li><code class="language-plaintext highlighter-rouge">:discard</code> - Controls whether discard requests (also known as “trim” or “unmap”) are ignored or passed to the filesystem. Possible values are “unmap” or “ignore”. Note: for discard to work, you will likely also need to set <code class="language-plaintext highlighter-rouge">disk_bus = 'scsi'</code></li> <li><code class="language-plaintext highlighter-rouge">:detect_zeroes</code> - Controls whether to detect zero write requests. The value can be “off”, “on” or “unmap”.</li> <li><code class="language-plaintext highlighter-rouge">address_type</code> - Address type of disk device to emulate. If unspecified, Libvirt uses a sensible default.</li> </ul> </li> <li><code class="language-plaintext highlighter-rouge">nic_model_type</code> - parameter specifies the model of the network adapter when you create a domain, default is virtio. For possible values, see the <a href="https://libvirt.org/formatdomain.html#setting-the-nic-model">documentation for Libvirt</a>.</li> <li><code class="language-plaintext highlighter-rouge">shares</code> - Proportional weighted share for the domain relative to others. For more details see <a href="https://libvirt.org/formatdomain.html#cpu-tuning">documentation</a>.</li> <li><code class="language-plaintext highlighter-rouge">memory</code> - Amount of memory in MBytes. Defaults to 512 if not set.</li> <li><code class="language-plaintext highlighter-rouge">cpus</code> - Number of virtual cpus. Defaults to 1 if not set.</li> <li><code class="language-plaintext highlighter-rouge">cpuset</code> - Physical cpus to which the vcpus can be pinned. For more details see <a href="https://libvirt.org/formatdomain.html#cpu-allocation">documentation</a>.</li> <li> <p><code class="language-plaintext highlighter-rouge">cputopology</code> - Number of CPU sockets, cores and threads running per core. All fields of <code class="language-plaintext highlighter-rouge">:sockets</code>, <code class="language-plaintext highlighter-rouge">:cores</code> and <code class="language-plaintext highlighter-rouge">:threads</code> are mandatory, <code class="language-plaintext highlighter-rouge">cpus</code> domain option must be present and must be equal to total count of <strong>sockets * cores * threads</strong>. For more details see <a href="https://libvirt.org/formatdomain.html#cpu-model-and-topology">documentation</a>.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpus</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpuset</span> <span class="o">=</span> <span class="s1">'1-4,^3,6'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cputopology</span> <span class="ss">:sockets</span> <span class="o">=&gt;</span> <span class="s1">'2'</span><span class="p">,</span> <span class="ss">:cores</span> <span class="o">=&gt;</span> <span class="s1">'2'</span><span class="p">,</span> <span class="ss">:threads</span> <span class="o">=&gt;</span> <span class="s1">'1'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div> </div> </li> <li> <p><code class="language-plaintext highlighter-rouge">cpuaffinitiy</code> - Mapping of vCPUs to host CPUs. <a href="https://libvirt.org/formatdomain.html#cpu-tuning">See <code class="language-plaintext highlighter-rouge">vcpupin</code></a>.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpus</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpuaffinitiy</span> <span class="mi">0</span> <span class="o">=&gt;</span> <span class="s1">'0-4,^3'</span><span class="p">,</span> <span class="mi">1</span> <span class="o">=&gt;</span> <span class="s1">'5'</span><span class="p">,</span> <span class="mi">2</span> <span class="o">=&gt;</span> <span class="s1">'6,7'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div> </div> </li> <li><code class="language-plaintext highlighter-rouge">nodeset</code> - Physical NUMA nodes where virtual memory can be pinned. For more details see <a href="https://libvirt.org/formatdomain.html#numa-node-tuning">documentation</a>.</li> <li><code class="language-plaintext highlighter-rouge">nested</code> - <a href="https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/">Enable nested virtualization</a>. Default is false.</li> <li><code class="language-plaintext highlighter-rouge">cpu_mode</code> - <a href="https://libvirt.org/formatdomain.html#cpu-model-and-topology">CPU emulation mode</a>. Defaults to host-model if not set. Allowed values: host-model, host-passthrough, custom.</li> <li><code class="language-plaintext highlighter-rouge">cpu_model</code> - CPU Model. Defaults to qemu64 if not set and <code class="language-plaintext highlighter-rouge">cpu_mode</code> is <code class="language-plaintext highlighter-rouge">custom</code> and to otherwise. This can really only be used when setting <code class="language-plaintext highlighter-rouge">cpu_mode</code> to <code class="language-plaintext highlighter-rouge">custom</code>.</li> <li><code class="language-plaintext highlighter-rouge">cpu_fallback</code> - Whether to allow Libvirt to fall back to a CPU model close to the specified model if features in the guest CPU are not supported on the host. Defaults to allow if not set. Allowed values: <code class="language-plaintext highlighter-rouge">allow</code>, <code class="language-plaintext highlighter-rouge">forbid</code>.</li> <li> <p><code class="language-plaintext highlighter-rouge">numa_nodes</code> - Specify an array of NUMA nodes for the guest. The syntax is similar to what would be set in the domain XML. <code class="language-plaintext highlighter-rouge">memory</code> must be in MB. Symmetrical and asymmetrical topologies are supported but make sure your total count of defined CPUs adds up to <code class="language-plaintext highlighter-rouge">v.cpus</code>.</p> <p>The sum of all the memory defined here will act as your total memory for your guest VM. <strong>This sum will override what is set in <code class="language-plaintext highlighter-rouge">v.memory</code></strong></p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>v.cpus = 4
v.numa_nodes = [
{:cpus =&gt; "0-1", :memory =&gt; "1024"},
{:cpus =&gt; "2-3", :memory =&gt; "4096"}
]
</code></pre></div> </div> </li> <li><code class="language-plaintext highlighter-rouge">launchsecurity</code> - Configure Secure Encryption Virtualization for the guest, requires additional components to be configured to work, see <a href="./examples.html#secure-encryption-virtualization">examples</a>. For more information look at <a href="https://libvirt.org/kbase/launch_security_sev.html">libvirt documentation</a>. <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>libvirt.launchsecurity :type =&gt; 'sev', :cbitpos =&gt; 47, :reducedPhysBits =&gt; 1, :policy =&gt; "0x0003"
</code></pre></div> </div> </li> <li><code class="language-plaintext highlighter-rouge">memtune</code> - Configure the memtune settings for the guest, primarily exposed to facilitate enabling Secure Encryption Virtualization. Note that when configuring <code class="language-plaintext highlighter-rouge">hard_limit</code> that the value is in kB as opposed to <code class="language-plaintext highlighter-rouge">libvirt.memory</code> which is in Mb. Additionally it must be set to be higher than <code class="language-plaintext highlighter-rouge">libvirt.memory</code>, see <a href="https://libvirt.org/kbase/launch_security_sev.html">libvirt documentation</a> for details on why. <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>libvirt.memtune :type =&gt; "hard_limit", :value =&gt; 2500000 # Note here the value in kB (not in Mb)
</code></pre></div> </div> </li> <li><code class="language-plaintext highlighter-rouge">loader</code> - Sets path to custom UEFI loader.</li> <li><code class="language-plaintext highlighter-rouge">kernel</code> - To launch the guest with a kernel residing on host filesystems. Equivalent to qemu <code class="language-plaintext highlighter-rouge">-kernel</code>.</li> <li><code class="language-plaintext highlighter-rouge">initrd</code> - To specify the initramfs/initrd to use for the guest. Equivalent to qemu <code class="language-plaintext highlighter-rouge">-initrd</code>.</li> <li><code class="language-plaintext highlighter-rouge">cmd_line</code> - Arguments passed on to the guest kernel initramfs or initrd to use. Equivalent to qemu <code class="language-plaintext highlighter-rouge">-append</code>, only possible to use in combination with <code class="language-plaintext highlighter-rouge">initrd</code> and <code class="language-plaintext highlighter-rouge">kernel</code>.</li> <li><code class="language-plaintext highlighter-rouge">graphics_type</code> - Sets the protocol used to expose the guest display. Defaults to <code class="language-plaintext highlighter-rouge">vnc</code>. Possible values are “sdl”, “curses”, “none”, “gtk”, “vnc” or “spice”.</li> <li><code class="language-plaintext highlighter-rouge">graphics_port</code> - Sets the port for the display protocol to bind to. Defaults to <code class="language-plaintext highlighter-rouge">-1</code>, which will be set automatically by libvirt.</li> <li><code class="language-plaintext highlighter-rouge">graphics_websocket</code> - Sets the websocket port for the display protocol to bind to. Defaults to <code class="language-plaintext highlighter-rouge">-1</code>, which will be set automatically by libvirt. The autoport configuration has no effect on the websocket port due to security reasons.</li> <li><code class="language-plaintext highlighter-rouge">graphics_ip</code> - Sets the IP for the display protocol to bind to. Defaults to “127.0.0.1”.</li> <li><code class="language-plaintext highlighter-rouge">graphics_passwd</code> - Sets the password for the display protocol. Working for vnc and Spice. by default working without passsword.</li> <li><code class="language-plaintext highlighter-rouge">graphics_autoport</code> - Sets autoport for graphics, Libvirt in this case ignores graphics_port value, Defaults to yes. Possible value are “yes” and “no”</li> <li><code class="language-plaintext highlighter-rouge">graphics_gl</code> - Set to <code class="language-plaintext highlighter-rouge">true</code> to enable OpenGL. Defaults to <code class="language-plaintext highlighter-rouge">true</code> if <code class="language-plaintext highlighter-rouge">video_accel3d</code> is <code class="language-plaintext highlighter-rouge">true</code>.</li> <li><code class="language-plaintext highlighter-rouge">keymap</code> - Set keymap for vm. default: en-us</li> <li><code class="language-plaintext highlighter-rouge">kvm_hidden</code> - <a href="https://libvirt.org/formatdomain.html#hypervisor-features">Hide the hypervisor from the guest</a>. Useful for <a href="#pci-device-passthrough">GPU passthrough</a> on stubborn drivers. Default is false.</li> <li><code class="language-plaintext highlighter-rouge">video_type</code> - Sets the graphics card type exposed to the guest. Defaults to “cirrus”. <a href="http://libvirt.org/formatdomain.html#video-devices">Possible values</a> are “vga”, “cirrus”, “vmvga”, “xen”, “vbox”, or “qxl”.</li> <li><code class="language-plaintext highlighter-rouge">video_vram</code> - Used by some graphics card types to vary the amount of RAM dedicated to video. Defaults to 16384.</li> <li><code class="language-plaintext highlighter-rouge">video_accel3d</code> - Set to <code class="language-plaintext highlighter-rouge">true</code> to enable 3D acceleration. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</li> <li><code class="language-plaintext highlighter-rouge">sound_type</code> - <a href="https://libvirt.org/formatdomain.html#sound-devices">Set the virtual sound card</a> Defaults to “ich6”.</li> <li><code class="language-plaintext highlighter-rouge">machine_type</code> - Sets machine type. Equivalent to qemu <code class="language-plaintext highlighter-rouge">-machine</code>. Use <code class="language-plaintext highlighter-rouge">qemu-system-x86_64 -machine help</code> to get a list of supported machines.</li> <li><code class="language-plaintext highlighter-rouge">machine_arch</code> - Sets machine architecture. This helps Libvirt to determine the correct emulator type. Possible values depend on your version of QEMU. For possible values, see which emulator executable <code class="language-plaintext highlighter-rouge">qemu-system-*</code> your system provides. Common examples are <code class="language-plaintext highlighter-rouge">aarch64</code>, <code class="language-plaintext highlighter-rouge">alpha</code>, <code class="language-plaintext highlighter-rouge">arm</code>, <code class="language-plaintext highlighter-rouge">cris</code>, <code class="language-plaintext highlighter-rouge">i386</code>, <code class="language-plaintext highlighter-rouge">lm32</code>, <code class="language-plaintext highlighter-rouge">m68k</code>, <code class="language-plaintext highlighter-rouge">microblaze</code>, <code class="language-plaintext highlighter-rouge">microblazeel</code>, <code class="language-plaintext highlighter-rouge">mips</code>, <code class="language-plaintext highlighter-rouge">mips64</code>, <code class="language-plaintext highlighter-rouge">mips64el</code>, <code class="language-plaintext highlighter-rouge">mipsel</code>, <code class="language-plaintext highlighter-rouge">moxie</code>, <code class="language-plaintext highlighter-rouge">or32</code>, <code class="language-plaintext highlighter-rouge">ppc</code>, <code class="language-plaintext highlighter-rouge">ppc64</code>, <code class="language-plaintext highlighter-rouge">ppcemb</code>, <code class="language-plaintext highlighter-rouge">s390x</code>, <code class="language-plaintext highlighter-rouge">sh4</code>, <code class="language-plaintext highlighter-rouge">sh4eb</code>, <code class="language-plaintext highlighter-rouge">sparc</code>, <code class="language-plaintext highlighter-rouge">sparc64</code>, <code class="language-plaintext highlighter-rouge">tricore</code>, <code class="language-plaintext highlighter-rouge">unicore32</code>, <code class="language-plaintext highlighter-rouge">x86_64</code>, <code class="language-plaintext highlighter-rouge">xtensa</code>, <code class="language-plaintext highlighter-rouge">xtensaeb</code>.</li> <li><code class="language-plaintext highlighter-rouge">machine_virtual_size</code> - Sets the disk size in GB for the machine overriding the default specified in the box. Allows boxes to defined with a minimal size disk by default and to be grown to a larger size at creation time. Will ignore sizes smaller than the size specified by the box metadata. Note that currently there is no support for automatically resizing the filesystem to take advantage of the larger disk.</li> <li><code class="language-plaintext highlighter-rouge">emulator_path</code> - Explicitly select which device model emulator to use by providing the path, e.g. <code class="language-plaintext highlighter-rouge">/usr/bin/qemu-system-x86_64</code>. This is especially useful on systems that fail to select it automatically based on <code class="language-plaintext highlighter-rouge">machine_arch</code> which then results in a capability error.</li> <li><code class="language-plaintext highlighter-rouge">boot</code> - Change the boot order and enables the boot menu. Possible options are “hd”, “network”, “cdrom”. Defaults to “hd” with boot menu disabled. When “network” is set without “hd”, only all NICs will be tried; see below for more detail. Defining this in subsequent provider blocks or latter Vagrantfiles (see <a href="https://www.vagrantup.com/docs/vagrantfile">Load Order and Merging</a>) will result in the definition in the last block being used.</li> <li><code class="language-plaintext highlighter-rouge">nic_adapter_count</code> - Defaults to 8. Only use case for increasing this count is for VMs that virtualize switches such as Cumulus Linux. Max value for Cumulus Linux VMs is 33.</li> <li><code class="language-plaintext highlighter-rouge">uuid</code> - Force a domain UUID. Defaults to autogenerated value by Libvirt if not set.</li> <li><code class="language-plaintext highlighter-rouge">suspend_mode</code> - What is done on vagrant suspend. Possible values: pause, managedsave. Pause mode executes a la <code class="language-plaintext highlighter-rouge">virsh suspend</code>, which just pauses execution of a VM, not freeing resources. Managed save mode does a la <code class="language-plaintext highlighter-rouge">virsh managedsave</code> which frees resources suspending a domain.</li> <li><code class="language-plaintext highlighter-rouge">tpm_model</code> - The model of the TPM to which you wish to connect.</li> <li><code class="language-plaintext highlighter-rouge">tpm_type</code> - The type of TPM device to which you are connecting.</li> <li><code class="language-plaintext highlighter-rouge">tpm_path</code> - The path to the TPM device on the host system.</li> <li><code class="language-plaintext highlighter-rouge">tpm_version</code> - The TPM version to use.</li> <li><code class="language-plaintext highlighter-rouge">sysinfo</code> - The <a href="https://libvirt.org/formatdomain.html#smbios-system-information">SMBIOS System Information</a> to use. This is a hash with key names aligning with the different section XML tags of bios, system, base board, chassis, and oem strings. Nested hashes then use entry attribute names as the keys for the values to assign, except for oem strings which is a simple array of strings.</li> <li><code class="language-plaintext highlighter-rouge">dtb</code> - The device tree blob file, mostly used for non-x86 platforms. In case the device tree isnt added in-line to the kernel, it can be manually specified here.</li> <li><code class="language-plaintext highlighter-rouge">autostart</code> - Automatically start the domain when the host boots. Defaults to false.</li> <li><code class="language-plaintext highlighter-rouge">channel</code> - <a href="https://libvirt.org/formatdomain.html#channel">Libvirt channels</a>. Configure a private communication channel between the host and guest, e.g. for use by the <a href="http://wiki.libvirt.org/page/Qemu_guest_agent">QEMU guest agent</a> and the Spice/QXL graphics type.</li> <li><code class="language-plaintext highlighter-rouge">mgmt_attach</code> - Decide if VM has interface in mgmt network. If set to false it is not possible to communicate with VM through <code class="language-plaintext highlighter-rouge">vagrant ssh</code> or run provisioning. Setting to false is only possible when VM doesnt use box or vagrant is told not to connect via ssh. Defaults set to true.</li> <li><code class="language-plaintext highlighter-rouge">serial</code> - <a href="https://libvirt.org/formatdomain.html#consoles-serial-parallel-channel-devices">libvirt serial devices</a>. Configure a serial/console port to communicate with the guest. Can be used to log to file boot time messages sent to ttyS0 console by the guest.</li> </ul> <p>Specific domain settings can be set for each domain separately in multi-VM environment. Example below shows a part of Vagrantfile, where specific options are set for dbserver domain.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:dbserver</span> <span class="k">do</span> <span class="o">|</span><span class="n">dbserver</span><span class="o">|</span>
<span class="n">dbserver</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">box</span> <span class="o">=</span> <span class="s2">"centos64"</span>
<span class="n">dbserver</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">domain</span><span class="o">|</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">memory</span> <span class="o">=</span> <span class="mi">2048</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">cpus</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">nested</span> <span class="o">=</span> <span class="kp">true</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">disk_driver</span> <span class="ss">:cache</span> <span class="o">=&gt;</span> <span class="s1">'none'</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># ...</span>
</code></pre></div></div> <p>The following example shows part of a Vagrantfile that enables the VM to boot from a network interface first and a hard disk second. This could be used to run VMs that are meant to be a PXE booted machines. Be aware that if <code class="language-plaintext highlighter-rouge">hd</code> is not specified as a boot option, it will never be tried.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:pxeclient</span> <span class="k">do</span> <span class="o">|</span><span class="n">pxeclient</span><span class="o">|</span>
<span class="n">pxeclient</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">box</span> <span class="o">=</span> <span class="s2">"centos64"</span>
<span class="n">pxeclient</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">domain</span><span class="o">|</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">boot</span> <span class="s1">'network'</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">boot</span> <span class="s1">'hd'</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># ...</span>
</code></pre></div></div> <h3 id="reload-behavior"> <a href="#reload-behavior" class="anchor-heading" aria-labelledby="reload-behavior"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Reload behavior </h3> <p>On <code class="language-plaintext highlighter-rouge">vagrant reload</code> the following domain specific attributes are updated in defined domain:</p> <ul> <li><code class="language-plaintext highlighter-rouge">disk_bus</code> - Is updated only on disks. It skips CDROMs</li> <li><code class="language-plaintext highlighter-rouge">nic_model_type</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">memory</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">cpus</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">nested</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">cpu_mode</code> - Updated. Pay attention that custom mode is not supported</li> <li><code class="language-plaintext highlighter-rouge">graphics_type</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">graphics_port</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">graphics_websocket</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">graphics_ip</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">graphics_passwd</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">graphics_autoport</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">keymap</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">video_type</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">video_vram</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">tpm_model</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">tpm_type</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">tpm_path</code> - Updated</li> <li><code class="language-plaintext highlighter-rouge">tpm_version</code> - Updated</li> </ul> <h2 id="networks"> <a href="#networks" class="anchor-heading" aria-labelledby="networks"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Networks </h2> <p>Networking features in the form of <code class="language-plaintext highlighter-rouge">config.vm.network</code> support private networks concept. It supports both the virtual network switch routing types and the point to point Guest OS to Guest OS setting using UDP/Mcast/TCP tunnel interfaces.</p> <p>http://wiki.libvirt.org/page/VirtualNetworking</p> <p>https://libvirt.org/formatdomain.html#tcp-tunnel</p> <p>http://libvirt.org/formatdomain.html#multicast-tunnel</p> <p>http://libvirt.org/formatdomain.html#udp-unicast-tunnel <em>(in Libvirt v1.2.20 and higher)</em></p> <p>Public Network interfaces are currently implemented using the macvtap driver. The macvtap driver is only available with the Linux Kernel version &gt;= 2.6.24. See the following Libvirt documentation for the details of the macvtap usage.</p> <p>http://www.libvirt.org/formatdomain.html#direct-attachment-to-physical-interface</p> <p>An examples of network interface definitions:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="c1"># Private network using virtual network switching</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm1</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm1</span><span class="o">|</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span> <span class="ss">:ip</span> <span class="o">=&gt;</span> <span class="s2">"10.20.30.40"</span>
<span class="k">end</span>
<span class="c1"># Private network using DHCP and a custom network</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm1</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm1</span><span class="o">|</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"dhcp"</span><span class="p">,</span>
<span class="ss">:libvirt__network_address</span> <span class="o">=&gt;</span> <span class="s1">'10.20.30.0'</span>
<span class="k">end</span>
<span class="c1"># Private network (as above) using a domain name</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm1</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm1</span><span class="o">|</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:ip</span> <span class="o">=&gt;</span> <span class="s2">"10.20.30.40"</span><span class="p">,</span>
<span class="ss">:libvirt__domain_name</span> <span class="o">=&gt;</span> <span class="s2">"test.local"</span>
<span class="k">end</span>
<span class="c1"># Private network. Point to Point between 2 Guest OS using a TCP tunnel</span>
<span class="c1"># Guest 1</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm1</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm1</span><span class="o">|</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:libvirt__tunnel_type</span> <span class="o">=&gt;</span> <span class="s1">'server'</span><span class="p">,</span>
<span class="c1"># default is 127.0.0.1 if omitted</span>
<span class="c1"># :libvirt__tunnel_ip =&gt; '127.0.0.1',</span>
<span class="ss">:libvirt__tunnel_port</span> <span class="o">=&gt;</span> <span class="s1">'11111'</span>
<span class="c1"># network with ipv6 support</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:ip</span> <span class="o">=&gt;</span> <span class="s2">"10.20.5.42"</span><span class="p">,</span>
<span class="ss">:libvirt__guest_ipv6</span> <span class="o">=&gt;</span> <span class="s2">"yes"</span><span class="p">,</span>
<span class="ss">:libvirt__ipv6_address</span> <span class="o">=&gt;</span> <span class="s2">"2001:db8:ca2:6::1"</span><span class="p">,</span>
<span class="ss">:libvirt__ipv6_prefix</span> <span class="o">=&gt;</span> <span class="s2">"64"</span>
<span class="c1"># Guest 2</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm2</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm2</span><span class="o">|</span>
<span class="n">test_vm2</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:libvirt__tunnel_type</span> <span class="o">=&gt;</span> <span class="s1">'client'</span><span class="p">,</span>
<span class="c1"># default is 127.0.0.1 if omitted</span>
<span class="c1"># :libvirt__tunnel_ip =&gt; '127.0.0.1',</span>
<span class="ss">:libvirt__tunnel_port</span> <span class="o">=&gt;</span> <span class="s1">'11111'</span>
<span class="c1"># network with ipv6 support</span>
<span class="n">test_vm2</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:private_network</span><span class="p">,</span>
<span class="ss">:ip</span> <span class="o">=&gt;</span> <span class="s2">"10.20.5.45"</span><span class="p">,</span>
<span class="ss">:libvirt__guest_ipv6</span> <span class="o">=&gt;</span> <span class="s2">"yes"</span><span class="p">,</span>
<span class="ss">:libvirt__ipv6_address</span> <span class="o">=&gt;</span> <span class="s2">"2001:db8:ca2:6::1"</span><span class="p">,</span>
<span class="ss">:libvirt__ipv6_prefix</span> <span class="o">=&gt;</span> <span class="s2">"64"</span>
<span class="c1"># Public Network</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm1</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm1</span><span class="o">|</span>
<span class="n">test_vm1</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">network</span> <span class="ss">:public_network</span><span class="p">,</span>
<span class="ss">:dev</span> <span class="o">=&gt;</span> <span class="s2">"virbr0"</span><span class="p">,</span>
<span class="ss">:mode</span> <span class="o">=&gt;</span> <span class="s2">"bridge"</span><span class="p">,</span>
<span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"bridge"</span>
<span class="k">end</span>
</code></pre></div></div> <p>In example below, one network interface is configured for VM <code class="language-plaintext highlighter-rouge">test_vm1</code>. After you run <code class="language-plaintext highlighter-rouge">vagrant up</code>, VM will be accessible on IP address <code class="language-plaintext highlighter-rouge">10.20.30.40</code>. So if you install a web server via provisioner, you will be able to access your testing server on <code class="language-plaintext highlighter-rouge">http://10.20.30.40</code> URL. But beware that this address is private to Libvirt host only. Its not visible outside of the hypervisor box.</p> <p>If network <code class="language-plaintext highlighter-rouge">10.20.30.0/24</code> doesnt exist, provider will create it. By default created networks are NATed to outside world, so your VM will be able to connect to the internet (if hypervisor can). And by default, DHCP is offering addresses on newly created networks.</p> <p>The second interface is created and bridged into the physical device <code class="language-plaintext highlighter-rouge">eth0</code>. This mechanism uses the macvtap Kernel driver and therefore does not require an existing bridge device. This configuration assumes that DHCP and DNS services are being provided by the public network. This public interface should be reachable by anyone with access to the public network.</p> <h3 id="private-network-options"> <a href="#private-network-options" class="anchor-heading" aria-labelledby="private-network-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Private Network Options </h3> <p><em>Note: These options are not applicable to public network interfaces.</em></p> <p>There is a way to pass specific options for Libvirt provider when using <code class="language-plaintext highlighter-rouge">config.vm.network</code> to configure new network interface. Each parameter name starts with <code class="language-plaintext highlighter-rouge">libvirt__</code> string. Here is a list of those options:</p> <ul> <li><code class="language-plaintext highlighter-rouge">:libvirt__network_name</code> - Name of Libvirt network to connect to. By default, network default is used.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__netmask</code> - Used only together with <code class="language-plaintext highlighter-rouge">:ip</code> option. Default is 255.255.255.0.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__network_address</code> - Used only when <code class="language-plaintext highlighter-rouge">:type</code> is set to <code class="language-plaintext highlighter-rouge">dhcp</code>. Only <code class="language-plaintext highlighter-rouge">/24</code> subnet is supported. Default is <code class="language-plaintext highlighter-rouge">172.28.128.0</code>.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__host_ip</code> - Address to use for the host (not guest). Default is first possible address (after network address).</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__domain_name</code> - DNS domain of the DHCP server. Used only when creating new network.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__dhcp_enabled</code> - If DHCP will offer addresses, or not. Used only when creating new network. Default is true.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__dhcp_start</code> - First address given out via DHCP. Default is third address in range (after network name and gateway).</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__dhcp_stop</code> - Last address given out via DHCP. Default is last possible address in range (before broadcast address).</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__dhcp_bootp_file</code> - The file to be used for the boot image. Used only when dhcp is enabled.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__dhcp_bootp_server</code> - The server that runs the DHCP server. Used only when dhcp is enabled.By default is the same host that runs the DHCP server.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tftp_root</code> - Path to the root directory served via TFTP.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__adapter</code> - Number specifying sequence number of interface.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__forward_mode</code> - Specify one of <code class="language-plaintext highlighter-rouge">veryisolated</code>, <code class="language-plaintext highlighter-rouge">none</code>, <code class="language-plaintext highlighter-rouge">open</code>, <code class="language-plaintext highlighter-rouge">nat</code> or <code class="language-plaintext highlighter-rouge">route</code> options. This option is used only when creating new network. Mode <code class="language-plaintext highlighter-rouge">none</code> will create isolated network without NATing or routing outside. You will want to use NATed forwarding typically to reach networks outside of hypervisor. Routed forwarding is typically useful to reach other networks within hypervisor. <code class="language-plaintext highlighter-rouge">veryisolated</code> described <a href="https://libvirt.org/formatnetwork.html#examplesNoGateway">here</a>. By default, option <code class="language-plaintext highlighter-rouge">nat</code> is used.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__forward_device</code> - Name of interface/device, where network should be forwarded (NATed or routed). Used only when creating new network. By default, all physical interfaces are used.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tunnel_type</code> - Set to udp if using UDP unicast tunnel mode (libvirt v1.2.20 or higher). Set this to either “server” or “client” for tcp tunneling. Set this to mcast if using multicast tunneling. This configuration type uses tunnels to generate point to point connections between Guests. Useful for Switch VMs like Cumulus Linux. No virtual switch setting like <code class="language-plaintext highlighter-rouge">libvirt__network_name</code> applies with tunnel interfaces and will be ignored if configured.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tunnel_ip</code> - Sets the source IP of the Libvirt tunnel interface. By default this is <code class="language-plaintext highlighter-rouge">127.0.0.1</code> for TCP and UDP tunnels and <code class="language-plaintext highlighter-rouge">239.255.1.1</code> for Multicast tunnels. It populates the address field in the <code class="language-plaintext highlighter-rouge">&lt;source address="XXX"&gt;</code> of the interface xml configuration.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tunnel_port</code> - Sets the source port the tcp/udp/mcast tunnel with use. This port information is placed in the <code class="language-plaintext highlighter-rouge">&lt;source port=XXX/&gt;</code> section of interface xml configuration.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tunnel_local_port</code> - Sets the local port used by the udp tunnel interface type. It populates the port field in the <code class="language-plaintext highlighter-rouge">&lt;local port=XXX"&gt;</code> section of the interface xml configuration. <em>(This feature only works in Libvirt 1.2.20 and higher)</em></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__tunnel_local_ip</code> - Sets the local IP used by the udp tunnel interface type. It populates the ip entry of the <code class="language-plaintext highlighter-rouge">&lt;local address=XXX"&gt;</code> section of the interface xml configuration. <em>(This feature only works in Libvirt 1.2.20 and higher)</em></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__guest_ipv6</code> - Enable or disable guest-to-guest IPv6 communication. See <a href="https://libvirt.org/formatnetwork.html#examplesPrivate6">here</a>, and <a href="http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8">here</a> for for more information. <em>Note: takes either yes or no for value</em></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__ipv6_address</code> - Define ipv6 address, require also prefix.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__ipv6_prefix</code> - Define ipv6 prefix. generate string <code class="language-plaintext highlighter-rouge">&lt;ip family="ipv6" address="address" prefix="prefix" &gt;</code></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__iface_name</code> - Define a name for the corresponding network interface created on the host. With this feature one can <a href="https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498">simulate physical link failures</a>. Note that you cannot use names reserved for libvirts usage based on <a href="https://libvirt.org/formatdomain.html#overriding-the-target-element">documentation</a>.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__mac</code> - MAC address for the interface. <em>Note: specify this in lowercase since Vagrant network scripts assume it will be!</em></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__mtu</code> - MTU size for the Libvirt network, if not defined, the created network will use the Libvirt default (1500). VMs still need to set the MTU accordingly.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__model_type</code> - parameter specifies the model of the network adapter when you create a domain value by default virtio KVM believe possible values, see the documentation for Libvirt</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__driver_name</code> - Define which network driver to use. <a href="https://libvirt.org/formatdomain.html#setting-nic-driver-specific-options">More info</a></li> <li><code class="language-plaintext highlighter-rouge">:libvirt__driver_queues</code> - Define a number of queues to be used for network interface. Set equal to number of vCPUs for best performance. <a href="http://www.linux-kvm.org/page/Multiqueue">More info</a></li> <li><code class="language-plaintext highlighter-rouge">:autostart</code> - Automatic startup of network by the Libvirt daemon. If not specified the default is false.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__bus</code> - The bus of the PCI device. Both :bus and :slot have to be defined.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__slot</code> - The slot of the PCI device. Both :bus and :slot have to be defined.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__always_destroy</code> - Allow domains that use but did not create a network to destroy it when the domain is destroyed (default: <code class="language-plaintext highlighter-rouge">true</code>). Set to <code class="language-plaintext highlighter-rouge">false</code> to only allow the domain that created the network to destroy it.</li> </ul> <p>When the option <code class="language-plaintext highlighter-rouge">:libvirt__dhcp_enabled</code> is to to false it shouldnt matter whether the virtual network contains a DHCP server or not and vagrant-libvirt should not fail on it. The only situation where vagrant-libvirt should fail is when DHCP is requested but isnt configured on a matching already existing virtual network.</p> <h3 id="public-network-options"> <a href="#public-network-options" class="anchor-heading" aria-labelledby="public-network-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Public Network Options </h3> <ul> <li><code class="language-plaintext highlighter-rouge">:dev</code> - Physical device that the public interface should use. Default is eth0.</li> <li><code class="language-plaintext highlighter-rouge">:mode</code> - The mode in which the public interface should operate in. Supported modes are available from the <a href="http://www.libvirt.org/formatdomain.html#direct-attachment-to-physical-interface">libvirt documentation</a>. Default mode is bridge.</li> <li><code class="language-plaintext highlighter-rouge">:type</code> - is type of interface.(<code class="language-plaintext highlighter-rouge">&lt;interface type="#{@type}"&gt;</code>)</li> <li><code class="language-plaintext highlighter-rouge">:mac</code> - MAC address for the interface.</li> <li><code class="language-plaintext highlighter-rouge">:network_name</code> - Name of Libvirt network to connect to.</li> <li><code class="language-plaintext highlighter-rouge">:portgroup</code> - Name of Libvirt portgroup to connect to.</li> <li><code class="language-plaintext highlighter-rouge">:ovs</code> - Support to connect to an Open vSwitch bridge device. Default is false.</li> <li>:ovs_interfaceid - Add Open vSwitch interfaceid parameter.</li> <li><code class="language-plaintext highlighter-rouge">:trust_guest_rx_filters</code> - Support trustGuestRxFilters attribute. Details are listed <a href="http://www.libvirt.org/formatdomain.html#direct-attachment-to-physical-interface">here</a>. Default is false.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__iface_name</code> - Define a name for the corresponding network interface that is created on the host connected to the bridge dev. This can be used to help attach VLAN tags to specific VMs by adjusting the pattern to match. Note that you cannot use names reserved for libvirts usage based on <a href="https://libvirt.org/formatdomain.html#overriding-the-target-element">documentation</a>.</li> <li><code class="language-plaintext highlighter-rouge">:libvirt__mtu</code> - MTU size for the Libvirt interface, if not defined, the created network will use the Libvirt default (1500). VMs still need to configure their internal interface MTUs.</li> </ul> <p>Additionally for public networks, to facilitate validating if the device provided can be used, vagrant-libvirt will check both the host interfaces visible to libvirt and the existing networks for any existing bridge names. While some name patterns are automatically excluded as presumed incorrect, if this pattern list is incorrect it may be overridden by setting the option:</p> <ul> <li><code class="language-plaintext highlighter-rouge">host_device_exclude_prefixes</code> - ignore any device starting with any of these string patterns as a valid bridge device for a public network definition.</li> </ul> <h3 id="management-network"> <a href="#management-network" class="anchor-heading" aria-labelledby="management-network"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Management Network </h3> <p>vagrant-libvirt uses a private network to perform some management operations on VMs. All VMs will have an interface connected to this network and an IP address dynamically assigned by Libvirt unless you set <code class="language-plaintext highlighter-rouge">:mgmt_attach</code> to false. This is in addition to any networks you configure. The name and address used by this network are configurable at the provider level.</p> <ul> <li><code class="language-plaintext highlighter-rouge">management_network_name</code> - Name of Libvirt network to which all VMs will be connected. If not specified the default is vagrant-libvirt.</li> <li><code class="language-plaintext highlighter-rouge">management_network_address</code> - Address of network to which all VMs will be connected. Must include the address and subnet mask. If not specified the default is 192.168.121.0/24.</li> <li><code class="language-plaintext highlighter-rouge">management_network_mode</code> - Network mode for the Libvirt management network. Specify one of veryisolated, none, open, nat or route options. Further documented under <a href="#private-network-options">Private Networks</a></li> <li><code class="language-plaintext highlighter-rouge">management_network_guest_ipv6</code> - Enable or disable guest-to-guest IPv6 communication. See <a href="https://libvirt.org/formatnetwork.html#examplesPrivate6">here</a>, and <a href="http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8">here</a> for for more information.</li> <li><code class="language-plaintext highlighter-rouge">management_network_autostart</code> - Automatic startup of mgmt network, if not specified the default is false.</li> <li><code class="language-plaintext highlighter-rouge">management_network_pci_bus</code> - The bus of the PCI device.</li> <li><code class="language-plaintext highlighter-rouge">management_network_pci_slot</code> - The slot of the PCI device.</li> <li><code class="language-plaintext highlighter-rouge">management_network_mac</code> - MAC address of management network interface.</li> <li><code class="language-plaintext highlighter-rouge">management_network_domain</code> - Domain name assigned to the management network.</li> <li><code class="language-plaintext highlighter-rouge">management_network_mtu</code> - MTU size of management network. If not specified, the Libvirt default (1500) will be used.</li> <li><code class="language-plaintext highlighter-rouge">management_network_keep</code> - Starting from version <em>0.7.0</em>, <em>always_destroy</em> is set to <em>true</em> by default for any network. This option allows to change this behaviour for the management network.</li> <li><code class="language-plaintext highlighter-rouge">management_network_iface_name</code> - Allow controlling of the network device name that appears on the host for the management network, same as <code class="language-plaintext highlighter-rouge">:libvirt__iface_name</code> for public and private network definitions. (unreleased).</li> <li><code class="language-plaintext highlighter-rouge">management_network_model_type</code> - Model of the network adapter to use for the management interface. Default is <code class="language-plaintext highlighter-rouge">nic_model_type</code>, which in turn defaults to virtio.</li> </ul> <p>You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt doesnt provide a standard way to find out the IP address of a running domain. But we do know the MAC address of the virtual machines interface on the management network. Libvirt is closely connected with dnsmasq, which acts as a DHCP server. dnsmasq writes lease information in the <code class="language-plaintext highlighter-rouge">/var/lib/libvirt/dnsmasq</code> directory. Vagrant-libvirt looks for the MAC address in this file and extracts the corresponding IP address.</p> <p>It is also possible to use the Qemu Agent to extract the management interface configuration from the booted virtual machine. This is helpful in libvirt environments where no local dnsmasq is used for automatic address assignment, but external dhcp services via bridged libvirt networks.</p> <p>Prerequisite is to enable the qemu agent channel via (<a href="#libvirt-communication-channels">Libvirt communication channels</a>) and the virtual machine image must have the agent pre-installed before deploy. The agent will start automatically if it detects an attached channel during boot.</p> <ul> <li><code class="language-plaintext highlighter-rouge">qemu_use_agent</code> - false by default, if set to true, attempt to extract configured ip address via qemu agent.</li> </ul> <p>By default if <code class="language-plaintext highlighter-rouge">qemu_use_agent</code> is set to <code class="language-plaintext highlighter-rouge">true</code> the code will automatically inject a suitable channel unless there already exists an entry with a <code class="language-plaintext highlighter-rouge">:target_name</code> matching <code class="language-plaintext highlighter-rouge">'org.qemu.guest_agent.'</code>. Alternatively if setting <code class="language-plaintext highlighter-rouge">qemu_use_agent</code> but, needing to disable the addition of the channel, simply use a disabled flag as follows:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">channel</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'unix'</span><span class="p">,</span> <span class="ss">:target_name</span> <span class="o">=&gt;</span> <span class="s1">'org.qemu.guest_agent.0'</span><span class="p">,</span> <span class="ss">:disabled</span> <span class="o">=&gt;</span> <span class="kp">true</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>To use the management network interface with an external dhcp service you need to setup a bridged host network manually and define it via <code class="language-plaintext highlighter-rouge">management_network_name</code> in your Vagrantfile.</p> <h2 id="additional-disks"> <a href="#additional-disks" class="anchor-heading" aria-labelledby="additional-disks"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Additional Disks </h2> <p>You can create and attach additional disks to a VM via <code class="language-plaintext highlighter-rouge">libvirt.storage :file</code>. It has a number of options:</p> <ul> <li><code class="language-plaintext highlighter-rouge">path</code> - Location of the disk image. If unspecified, a path is automatically chosen in the same storage pool as the VMs primary disk.</li> <li><code class="language-plaintext highlighter-rouge">device</code> - Name of the device node the disk image will have in the VM, e.g. <em>vdb</em>. If unspecified, the next available device is chosen.</li> <li><code class="language-plaintext highlighter-rouge">size</code> - Size of the disk image. If unspecified, defaults to 10G.</li> <li><code class="language-plaintext highlighter-rouge">type</code> - Type of disk image to create. Defaults to <em>qcow2</em>.</li> <li><code class="language-plaintext highlighter-rouge">bus</code> - Type of bus to connect device to. Defaults to <em>virtio</em>.</li> <li><code class="language-plaintext highlighter-rouge">allow_existing</code> - Set to true if you want to allow the VM to use a pre-existing disk. If the disk doesnt exist it will be created. Disks with this option set to true need to be removed manually.</li> <li><code class="language-plaintext highlighter-rouge">shareable</code> - Set to true if you want to simulate shared SAN storage.</li> <li><code class="language-plaintext highlighter-rouge">serial</code> - Serial number of the disk device.</li> <li><code class="language-plaintext highlighter-rouge">wwn</code> - WWN number of the disk device.</li> </ul> <p>The following disk performance options can also be configured (see the <a href="http://libvirt.org/formatdomain.html#hard-drives-floppy-disks-cdroms">libvirt documentation for possible values</a> or <a href="https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html">here</a> for a fuller explanation). In all cases, the options use the hypervisor default if not specified, or if set to <code class="language-plaintext highlighter-rouge">nil</code>.</p> <ul> <li><code class="language-plaintext highlighter-rouge">cache</code> - Cache mode to use. Value may be <code class="language-plaintext highlighter-rouge">default</code>, <code class="language-plaintext highlighter-rouge">none</code>, <code class="language-plaintext highlighter-rouge">writeback</code>, <code class="language-plaintext highlighter-rouge">writethrough</code>, <code class="language-plaintext highlighter-rouge">directsync</code> or <code class="language-plaintext highlighter-rouge">unsafe</code>.</li> <li><code class="language-plaintext highlighter-rouge">io</code> - Controls specific policies on I/O. Value may be <code class="language-plaintext highlighter-rouge">threads</code> or <code class="language-plaintext highlighter-rouge">native</code>.</li> <li><code class="language-plaintext highlighter-rouge">copy_on_read</code> - Controls whether to copy read backing file into the image file. Value may be <code class="language-plaintext highlighter-rouge">on</code> or <code class="language-plaintext highlighter-rouge">off</code>.</li> <li><code class="language-plaintext highlighter-rouge">discard</code> - Controls whether discard requests (also known as “trim” or “unmap”) are ignored or passed to the filesystem. Value may be <code class="language-plaintext highlighter-rouge">unmap</code> or <code class="language-plaintext highlighter-rouge">ignore</code>. Note: for discard to work, you will likely also need to set <code class="language-plaintext highlighter-rouge">:bus =&gt; 'scsi'</code></li> <li><code class="language-plaintext highlighter-rouge">detect_zeroes</code> - Controls whether to detect zero write requests. Value may be <code class="language-plaintext highlighter-rouge">off</code>, <code class="language-plaintext highlighter-rouge">on</code> or <code class="language-plaintext highlighter-rouge">unmap</code>.</li> </ul> <p>The following example creates two additional disks.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:size</span> <span class="o">=&gt;</span> <span class="s1">'20G'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:size</span> <span class="o">=&gt;</span> <span class="s1">'40G'</span><span class="p">,</span> <span class="ss">:bus</span> <span class="o">=&gt;</span> <span class="s1">'scsi'</span><span class="p">,</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'raw'</span><span class="p">,</span> <span class="ss">:discard</span> <span class="o">=&gt;</span> <span class="s1">'unmap'</span><span class="p">,</span> <span class="ss">:detect_zeroes</span> <span class="o">=&gt;</span> <span class="s1">'on'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>For shared SAN storage to work the following example can be used:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:size</span> <span class="o">=&gt;</span> <span class="s1">'20G'</span><span class="p">,</span> <span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s1">'my_shared_disk.img'</span><span class="p">,</span> <span class="ss">:allow_existing</span> <span class="o">=&gt;</span> <span class="kp">true</span><span class="p">,</span> <span class="ss">:shareable</span> <span class="o">=&gt;</span> <span class="kp">true</span><span class="p">,</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'raw'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h3 id="reload-behavior-1"> <a href="#reload-behavior-1" class="anchor-heading" aria-labelledby="reload-behavior-1"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Reload behavior </h3> <p>On <code class="language-plaintext highlighter-rouge">vagrant reload</code> the following additional disk attributes are updated in defined domain:</p> <ul> <li><code class="language-plaintext highlighter-rouge">bus</code> - Updated. Uses <code class="language-plaintext highlighter-rouge">device</code> as a search marker. It is not required to define <code class="language-plaintext highlighter-rouge">device</code>, but its recommended. If <code class="language-plaintext highlighter-rouge">device</code> is defined then the order of additional disk definition becomes irrelevant.</li> </ul> <h2 id="cdroms"> <a href="#cdroms" class="anchor-heading" aria-labelledby="cdroms"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> CDROMs </h2> <p>You can attach up to four CDROMs to a VM via <code class="language-plaintext highlighter-rouge">libvirt.storage :file, :device =&gt; :cdrom</code>. Available options are:</p> <ul> <li><code class="language-plaintext highlighter-rouge">path</code> - The path to the iso to be used for the CDROM drive.</li> <li><code class="language-plaintext highlighter-rouge">dev</code> - The device to use (<code class="language-plaintext highlighter-rouge">hda</code>, <code class="language-plaintext highlighter-rouge">hdb</code>, <code class="language-plaintext highlighter-rouge">hdc</code>, or <code class="language-plaintext highlighter-rouge">hdd</code>). This will be automatically determined if unspecified.</li> <li><code class="language-plaintext highlighter-rouge">bus</code> - The bus to use for the CDROM drive. Defaults to <code class="language-plaintext highlighter-rouge">ide</code></li> </ul> <p>The following example creates three CDROM drives in the VM:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:device</span> <span class="o">=&gt;</span> <span class="ss">:cdrom</span><span class="p">,</span> <span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s1">'/path/to/iso1.iso'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:device</span> <span class="o">=&gt;</span> <span class="ss">:cdrom</span><span class="p">,</span> <span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s1">'/path/to/iso2.iso'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:device</span> <span class="o">=&gt;</span> <span class="ss">:cdrom</span><span class="p">,</span> <span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s1">'/path/to/iso3.iso'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="floppies"> <a href="#floppies" class="anchor-heading" aria-labelledby="floppies"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Floppies </h2> <p>You can attach up to two floppies to a VM via <code class="language-plaintext highlighter-rouge">libvirt.storage :file, :device =&gt; :floppy</code>. Available options are:</p> <ul> <li><code class="language-plaintext highlighter-rouge">path</code> - The path to the vfd image to be used for the floppy drive.</li> <li><code class="language-plaintext highlighter-rouge">dev</code> - The device to use (<code class="language-plaintext highlighter-rouge">fda</code> or <code class="language-plaintext highlighter-rouge">fdb</code>). This will be automatically determined if unspecified.</li> </ul> <p>The following example creates a floppy drive in the VM:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">storage</span> <span class="ss">:file</span><span class="p">,</span> <span class="ss">:device</span> <span class="o">=&gt;</span> <span class="ss">:floppy</span><span class="p">,</span> <span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s1">'/path/to/floppy.vfs'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="input"> <a href="#input" class="anchor-heading" aria-labelledby="input"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Input </h2> <p>You can specify multiple inputs to the VM via <code class="language-plaintext highlighter-rouge">libvirt.input</code>. Available options are listed below. Note that both options are required:</p> <ul> <li><code class="language-plaintext highlighter-rouge">type</code> - The type of the input</li> <li><code class="language-plaintext highlighter-rouge">bus</code> - The bus of the input</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># this is the default</span>
<span class="c1"># libvirt.input :type =&gt; "mouse", :bus =&gt; "ps2"</span>
<span class="c1"># very useful when having mouse issues when viewing VM via VNC</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">input</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"tablet"</span><span class="p">,</span> <span class="ss">:bus</span> <span class="o">=&gt;</span> <span class="s2">"usb"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="pci-device-passthrough"> <a href="#pci-device-passthrough" class="anchor-heading" aria-labelledby="pci-device-passthrough"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> PCI device passthrough </h2> <p>You can specify multiple PCI devices to passthrough to the VM via <code class="language-plaintext highlighter-rouge">libvirt.pci</code>. Available options are listed below. Note that all options are required, except domain, which defaults to <code class="language-plaintext highlighter-rouge">0x0000</code>:</p> <ul> <li><code class="language-plaintext highlighter-rouge">domain</code> - The domain of the PCI device</li> <li><code class="language-plaintext highlighter-rouge">bus</code> - The bus of the PCI device</li> <li><code class="language-plaintext highlighter-rouge">slot</code> - The slot of the PCI device</li> <li><code class="language-plaintext highlighter-rouge">function</code> - The function of the PCI device</li> </ul> <p>You can extract that information from output of <code class="language-plaintext highlighter-rouge">lspci</code> command. First characters of each line are in format <code class="language-plaintext highlighter-rouge">[&lt;domain&gt;]:[&lt;bus&gt;]:[&lt;slot&gt;].[&lt;func&gt;]</code>. For example:</p> <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>lspci| <span class="nb">grep </span>NVIDIA
0000:03:00.0 VGA compatible controller: NVIDIA Corporation GK110B <span class="o">[</span>GeForce GTX TITAN Black] <span class="o">(</span>rev a1<span class="o">)</span>
</code></pre></div></div> <p>In that case <code class="language-plaintext highlighter-rouge">domain</code> is <code class="language-plaintext highlighter-rouge">0x0000</code>, <code class="language-plaintext highlighter-rouge">bus</code> is <code class="language-plaintext highlighter-rouge">0x03</code>, <code class="language-plaintext highlighter-rouge">slot</code> is <code class="language-plaintext highlighter-rouge">0x00</code> and <code class="language-plaintext highlighter-rouge">function</code> is <code class="language-plaintext highlighter-rouge">0x0</code>.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">pci</span> <span class="ss">:domain</span> <span class="o">=&gt;</span> <span class="s1">'0x0000'</span><span class="p">,</span> <span class="ss">:bus</span> <span class="o">=&gt;</span> <span class="s1">'0x06'</span><span class="p">,</span> <span class="ss">:slot</span> <span class="o">=&gt;</span> <span class="s1">'0x12'</span><span class="p">,</span> <span class="ss">:function</span> <span class="o">=&gt;</span> <span class="s1">'0x5'</span>
<span class="c1"># Add another one if it is necessary</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">pci</span> <span class="ss">:domain</span> <span class="o">=&gt;</span> <span class="s1">'0x0000'</span><span class="p">,</span> <span class="ss">:bus</span> <span class="o">=&gt;</span> <span class="s1">'0x03'</span><span class="p">,</span> <span class="ss">:slot</span> <span class="o">=&gt;</span> <span class="s1">'0x00'</span><span class="p">,</span> <span class="ss">:function</span> <span class="o">=&gt;</span> <span class="s1">'0x0'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>Note! Above options affect configuration only at domain creation. It wont change VM behaviour on <code class="language-plaintext highlighter-rouge">vagrant reload</code> after domain was created.</p> <p>Dont forget to <a href="#domain-specific-options">set</a> <code class="language-plaintext highlighter-rouge">kvm_hidden</code> option to <code class="language-plaintext highlighter-rouge">true</code> especially if you are passthroughing NVIDIA GPUs. Otherwise GPU is visible from VM but cannot be operated.</p> <h2 id="using-usb-devices"> <a href="#using-usb-devices" class="anchor-heading" aria-labelledby="using-usb-devices"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Using USB Devices </h2> <p>There are several ways to pass a USB device through to a running instance:</p> <ul> <li>Use <code class="language-plaintext highlighter-rouge">libvirt.usb</code> to <a href="#usb-device-passthrough">attach a USB device at boot</a>, with the device ID specified in the Vagrantfile</li> <li>Use a client (such as <code class="language-plaintext highlighter-rouge">virt-viewer</code> or <code class="language-plaintext highlighter-rouge">virt-manager</code>) to attach the device at runtime <a href="#usb-redirector-devices">via USB redirectors</a></li> <li>Use <code class="language-plaintext highlighter-rouge">virsh attach-device</code> once the VM is running (however, this is outside the scope of this readme)</li> </ul> <p>In all cases, if you wish to use a high-speed USB device, you will need to use <code class="language-plaintext highlighter-rouge">libvirt.usb_controller</code> to specify a USB2 or USB3 controller, as the default configuration only exposes a USB1.1 controller.</p> <h3 id="usb-controller-configuration"> <a href="#usb-controller-configuration" class="anchor-heading" aria-labelledby="usb-controller-configuration"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> USB Controller Configuration </h3> <p>The USB controller can be configured using <code class="language-plaintext highlighter-rouge">libvirt.usb_controller</code>, with the following options:</p> <ul> <li><code class="language-plaintext highlighter-rouge">model</code> - The USB controller device model to emulate. (mandatory)</li> <li><code class="language-plaintext highlighter-rouge">ports</code> - The number of devices that can be connected to the controller.</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Set up a USB3 controller</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">usb_controller</span> <span class="ss">:model</span> <span class="o">=&gt;</span> <span class="s2">"qemu-xhci"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>See the <a href="https://libvirt.org/formatdomain.html#controllers">libvirt documentation</a> for a list of valid models.</p> <p>If any USB devices are passed through by setting <code class="language-plaintext highlighter-rouge">libvirt.usb</code> or <code class="language-plaintext highlighter-rouge">libvirt.redirdev</code>, a default controller will be added using the model <code class="language-plaintext highlighter-rouge">qemu-xhci</code> in the absence of a user specified one. This should help ensure more devices work out of the box as the default configured by libvirt is pii3-uhci, which appears to only work for USB 1 devices and does not work as expected when connected via a USB 2 controller, while the xhci stack should work for all versions of USB.</p> <h3 id="usb-device-passthrough"> <a href="#usb-device-passthrough" class="anchor-heading" aria-labelledby="usb-device-passthrough"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> USB Device Passthrough </h3> <p>You can specify multiple USB devices to passthrough to the VM via <code class="language-plaintext highlighter-rouge">libvirt.usb</code>. The device can be specified by the following options:</p> <ul> <li><code class="language-plaintext highlighter-rouge">bus</code> - The USB bus ID, e.g. “1”</li> <li><code class="language-plaintext highlighter-rouge">device</code> - The USB device ID, e.g. “2”</li> <li><code class="language-plaintext highlighter-rouge">vendor</code> - The USB devices vendor ID (VID), e.g. “0x1234”</li> <li><code class="language-plaintext highlighter-rouge">product</code> - The USB devices product ID (PID), e.g. “0xabcd”</li> </ul> <p>At least one of these has to be specified, and <code class="language-plaintext highlighter-rouge">bus</code> and <code class="language-plaintext highlighter-rouge">device</code> may only be used together.</p> <p>The example values above match the device from the following output of <code class="language-plaintext highlighter-rouge">lsusb</code>:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Bus 001 Device 002: ID 1234:abcd Example device
</code></pre></div></div> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># pass through specific device based on identifying it</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">usb</span> <span class="ss">:vendor</span> <span class="o">=&gt;</span> <span class="s1">'0x1234'</span><span class="p">,</span> <span class="ss">:product</span> <span class="o">=&gt;</span> <span class="s1">'0xabcd'</span>
<span class="c1"># pass through a host device where multiple of the same vendor/product exist</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">usb</span> <span class="ss">:bus</span> <span class="o">=&gt;</span> <span class="s1">'1'</span><span class="p">,</span> <span class="ss">:device</span> <span class="o">=&gt;</span> <span class="s1">'1'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>Additionally, the following options can be used:</p> <ul> <li><code class="language-plaintext highlighter-rouge">startupPolicy</code> - Is passed through to Libvirt and controls if the device has to exist. Libvirt currently allows the following values: “mandatory”, “requisite”, “optional”.</li> </ul> <h3 id="usb-redirector-devices"> <a href="#usb-redirector-devices" class="anchor-heading" aria-labelledby="usb-redirector-devices"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> USB Redirector Devices </h3> <p>You can specify multiple redirect devices via <code class="language-plaintext highlighter-rouge">libvirt.redirdev</code>. There are two types, <code class="language-plaintext highlighter-rouge">tcp</code> and <code class="language-plaintext highlighter-rouge">spicevmc</code> supported, for forwarding USB-devices to the guest. Available options are listed below.</p> <ul> <li><code class="language-plaintext highlighter-rouge">type</code> - The type of the USB redirector device. (<code class="language-plaintext highlighter-rouge">tcp</code> or <code class="language-plaintext highlighter-rouge">spicevmc</code>)</li> <li><code class="language-plaintext highlighter-rouge">host</code> - The host where the device is attached to. (mandatory for type <code class="language-plaintext highlighter-rouge">tcp</code>)</li> <li><code class="language-plaintext highlighter-rouge">port</code> - The port where the device is listening. (mandatory for type <code class="language-plaintext highlighter-rouge">tcp</code>)</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># add two devices using spicevmc channel</span>
<span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">2</span><span class="p">).</span><span class="nf">each</span> <span class="k">do</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">redirdev</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"spicevmc"</span>
<span class="k">end</span>
<span class="c1"># add device, provided by localhost:4000</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">redirdev</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"tcp"</span><span class="p">,</span> <span class="ss">:host</span> <span class="o">=&gt;</span> <span class="s2">"localhost"</span><span class="p">,</span> <span class="ss">:port</span> <span class="o">=&gt;</span> <span class="s2">"4000"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>Note that in order to enable USB redirection with Spice clients, you may need to also set <code class="language-plaintext highlighter-rouge">libvirt.graphics_type = "spice"</code></p> <h4 id="filter-for-usb-redirector-devices"> <a href="#filter-for-usb-redirector-devices" class="anchor-heading" aria-labelledby="filter-for-usb-redirector-devices"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Filter for USB Redirector Devices </h4> <p>You can define filter for redirected devices. These filters can be positive or negative, by setting the mandatory option <code class="language-plaintext highlighter-rouge">allow=yes</code> or <code class="language-plaintext highlighter-rouge">allow=no</code>. All available options are listed below. Note the option <code class="language-plaintext highlighter-rouge">allow</code> is mandatory.</p> <ul> <li><code class="language-plaintext highlighter-rouge">class</code> - The device class of the USB device. A list of device classes is available on <a href="https://en.wikipedia.org/wiki/USB#Device_classes">Wikipedia</a>.</li> <li><code class="language-plaintext highlighter-rouge">vendor</code> - The vendor of the USB device.</li> <li><code class="language-plaintext highlighter-rouge">product</code> - The product id of the USB device.</li> <li><code class="language-plaintext highlighter-rouge">version</code> - The version of the USB device. Note that this is the version of <code class="language-plaintext highlighter-rouge">bcdDevice</code></li> <li><code class="language-plaintext highlighter-rouge">allow</code> - allow or disallow redirecting this device. (mandatory)</li> </ul> <p>You can extract that information from output of <code class="language-plaintext highlighter-rouge">lsusb</code> command. Every line contains the information in format <code class="language-plaintext highlighter-rouge">Bus [&lt;bus&gt;] Device [&lt;device&gt;]: ID [&lt;vendor&gt;:[&lt;product&gt;]</code>. The <code class="language-plaintext highlighter-rouge">version</code> can be extracted from the detailed output of the device using <code class="language-plaintext highlighter-rouge">lsusb -D /dev/usb/[&lt;bus&gt;]/[&lt;device&gt;]</code>. For example:</p> <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># get bcdDevice from</span>
<span class="nv">$:</span> lsusb
Bus 001 Device 009: ID 08e6:3437 Gemalto <span class="o">(</span>was Gemplus<span class="o">)</span> GemPC Twin SmartCard Reader
<span class="nv">$:</span> lsusb <span class="nt">-D</span> /dev/bus/usb/001/009 | <span class="nb">grep </span>bcdDevice
bcdDevice 2.00
</code></pre></div></div> <p>In this case, the USB device with <code class="language-plaintext highlighter-rouge">class 0x0b</code>, <code class="language-plaintext highlighter-rouge">vendor 0x08e6</code>, <code class="language-plaintext highlighter-rouge">product 0x3437</code> and <code class="language-plaintext highlighter-rouge">bcdDevice version 2.00</code> is allowed to be redirected to the guest. All other devices will be refused.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">redirdev</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"spicevmc"</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">redirfilter</span> <span class="ss">:class</span> <span class="o">=&gt;</span> <span class="s2">"0x0b"</span><span class="p">,</span> <span class="ss">:vendor</span> <span class="o">=&gt;</span> <span class="s2">"0x08e6"</span><span class="p">,</span> <span class="ss">:product</span> <span class="o">=&gt;</span> <span class="s2">"0x3437"</span><span class="p">,</span> <span class="ss">:version</span> <span class="o">=&gt;</span> <span class="s2">"2.00"</span><span class="p">,</span> <span class="ss">:allow</span> <span class="o">=&gt;</span> <span class="s2">"yes"</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">redirfilter</span> <span class="ss">:allow</span> <span class="o">=&gt;</span> <span class="s2">"no"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="serial-console-devices"> <a href="#serial-console-devices" class="anchor-heading" aria-labelledby="serial-console-devices"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Serial Console Devices </h2> <p>You can define settings to redirect output from the serial console of any VM brought up with libvirt to a file or other devices that are listening. <a href="https://libvirt.org/formatdomain.html#serial-port">See libvirt documentation</a>.</p> <p>Currently only redirecting to a file is supported.</p> <ul> <li><code class="language-plaintext highlighter-rouge">type</code> - only value that has an effect is file, in the future support may be added for virtual console, pty, dev, pipe, tcp, udp, unix socket, spiceport &amp; nmdm.</li> <li><code class="language-plaintext highlighter-rouge">source</code> - options pertaining to how the connection attaches to the host, contains sub-settings dependent on <code class="language-plaintext highlighter-rouge">type</code>. <code class="language-plaintext highlighter-rouge">source</code> options for type <code class="language-plaintext highlighter-rouge">file</code> <ul> <li><code class="language-plaintext highlighter-rouge">path</code> - file on host to connect to the serial port to record all output. May be created by qemu system user causing some permissions issues.</li> </ul> </li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test</span> <span class="k">do</span> <span class="o">|</span><span class="nb">test</span><span class="o">|</span>
<span class="nb">test</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">domain</span><span class="o">|</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">serial</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s2">"file"</span><span class="p">,</span> <span class="ss">:source</span> <span class="o">=&gt;</span> <span class="p">{</span><span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s2">"/var/log/vm_consoles/test.log"</span><span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="random-number-generator-passthrough"> <a href="#random-number-generator-passthrough" class="anchor-heading" aria-labelledby="random-number-generator-passthrough"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Random number generator passthrough </h2> <p>You can pass through <code class="language-plaintext highlighter-rouge">/dev/random</code> to your VM by configuring the domain like this:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Pass through /dev/random from the host to the VM</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">random</span> <span class="ss">:model</span> <span class="o">=&gt;</span> <span class="s1">'random'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>At the moment only the <code class="language-plaintext highlighter-rouge">random</code> backend is supported.</p> <h2 id="watchdog-device"> <a href="#watchdog-device" class="anchor-heading" aria-labelledby="watchdog-device"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Watchdog device </h2> <p>A virtual hardware watchdog device can be added to the guest via the <code class="language-plaintext highlighter-rouge">libvirt.watchdog</code> element. The option <code class="language-plaintext highlighter-rouge">model</code> is mandatory and could have on of the following values.</p> <ul> <li><code class="language-plaintext highlighter-rouge">i6300esb</code> - the recommended device, emulating a PCI Intel 6300ESB</li> <li>ib700` - emulating an ISA iBase IB700</li> <li><code class="language-plaintext highlighter-rouge">diag288</code> - emulating an S390 DIAG288 device</li> </ul> <p>The optional action attribute describes what <code class="language-plaintext highlighter-rouge">action</code> to take when the watchdog expires. Valid values are specific to the underlying hypervisor. The default behavior is <code class="language-plaintext highlighter-rouge">reset</code>.</p> <ul> <li><code class="language-plaintext highlighter-rouge">reset</code> - default, forcefully reset the guest</li> <li><code class="language-plaintext highlighter-rouge">shutdown</code> - gracefully shutdown the guest (not recommended)</li> <li><code class="language-plaintext highlighter-rouge">poweroff</code> - forcefully power off the guest</li> <li><code class="language-plaintext highlighter-rouge">pause</code> - pause the guest</li> <li><code class="language-plaintext highlighter-rouge">none</code> - do nothing</li> <li><code class="language-plaintext highlighter-rouge">dump</code> - automatically dump the guest</li> <li><code class="language-plaintext highlighter-rouge">inject-nmi</code> - inject a non-maskable interrupt into the guest</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Add Libvirt watchdog device model i6300esb</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">watchdog</span> <span class="ss">:model</span> <span class="o">=&gt;</span> <span class="s1">'i6300esb'</span><span class="p">,</span> <span class="ss">:action</span> <span class="o">=&gt;</span> <span class="s1">'reset'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="smartcard-device"> <a href="#smartcard-device" class="anchor-heading" aria-labelledby="smartcard-device"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Smartcard device </h2> <p>A virtual smartcard device can be supplied to the guest via the <code class="language-plaintext highlighter-rouge">libvirt.smartcard</code> element. The option <code class="language-plaintext highlighter-rouge">mode</code> is mandatory and currently only value <code class="language-plaintext highlighter-rouge">passthrough</code> is supported. The value <code class="language-plaintext highlighter-rouge">spicevmc</code> for option <code class="language-plaintext highlighter-rouge">type</code> is default value and can be suppressed. On using <code class="language-plaintext highlighter-rouge">type = tcp</code>, the options <code class="language-plaintext highlighter-rouge">source_mode</code>, <code class="language-plaintext highlighter-rouge">source_host</code> and <code class="language-plaintext highlighter-rouge">source_service</code> are mandatory.</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Add smartcard device with type 'spicevmc'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">smartcard</span> <span class="ss">:mode</span> <span class="o">=&gt;</span> <span class="s1">'passthrough'</span><span class="p">,</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'spicevmc'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Add smartcard device with type 'tcp'</span>
<span class="n">domain</span><span class="p">.</span><span class="nf">smartcard</span> <span class="ss">:mode</span> <span class="o">=&gt;</span> <span class="s1">'passthrough'</span><span class="p">,</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'tcp'</span><span class="p">,</span> <span class="ss">:source_mode</span> <span class="o">=&gt;</span> <span class="s1">'bind'</span><span class="p">,</span> <span class="ss">:source_host</span> <span class="o">=&gt;</span> <span class="s1">'127.0.0.1'</span><span class="p">,</span> <span class="ss">:source_service</span> <span class="o">=&gt;</span> <span class="s1">'2001'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="hypervisor-features"> <a href="#hypervisor-features" class="anchor-heading" aria-labelledby="hypervisor-features"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Hypervisor Features </h2> <p>Hypervisor features can be specified via <code class="language-plaintext highlighter-rouge">libvirt.features</code> as a list. The default options that are enabled are <code class="language-plaintext highlighter-rouge">acpi</code>, <code class="language-plaintext highlighter-rouge">apic</code> and <code class="language-plaintext highlighter-rouge">pae</code>. If you define <code class="language-plaintext highlighter-rouge">libvirt.features</code> you overwrite the defaults, so keep that in mind.</p> <p>An example:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Specify the default hypervisor features</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">features</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'acpi'</span><span class="p">,</span> <span class="s1">'apic'</span><span class="p">,</span> <span class="s1">'pae'</span> <span class="p">]</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>A different example for ARM boards:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Specify the default hypervisor features</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">features</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"apic"</span><span class="p">,</span> <span class="s2">"gic version='2'"</span> <span class="p">]</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <p>You can also specify a special set of features that help improve the behavior of guests running Microsoft Windows.</p> <p>You can specify HyperV features via <code class="language-plaintext highlighter-rouge">libvirt.hyperv_feature</code>. Available options are listed below. Note that both options are required:</p> <ul> <li><code class="language-plaintext highlighter-rouge">name</code> - The name of the feature Hypervisor feature (see Libvirt doc)</li> <li><code class="language-plaintext highlighter-rouge">state</code> - The state for this feature which can be either <code class="language-plaintext highlighter-rouge">on</code> or <code class="language-plaintext highlighter-rouge">off</code>.</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Relax constraints on timers</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">hyperv_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'relaxed'</span><span class="p">,</span> <span class="ss">:state</span> <span class="o">=&gt;</span> <span class="s1">'on'</span>
<span class="c1"># Enable virtual APIC</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">hyperv_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'vapic'</span><span class="p">,</span> <span class="ss">:state</span> <span class="o">=&gt;</span> <span class="s1">'on'</span>
<span class="c1"># Enable spinlocks (requires retries to be specified)</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">hyperv_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'spinlocks'</span><span class="p">,</span> <span class="ss">:state</span> <span class="o">=&gt;</span> <span class="s1">'on'</span><span class="p">,</span> <span class="ss">:retries</span> <span class="o">=&gt;</span> <span class="s1">'8191'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="clock"> <a href="#clock" class="anchor-heading" aria-labelledby="clock"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Clock </h2> <p>The clock can be configured using one of the following methods:</p> <ul> <li>Set nothing, and the clock will default to UTC.</li> <li>Set <code class="language-plaintext highlighter-rouge">libvirt.clock_offset</code> to utc or localtime by assigning the respective values.</li> <li>To set the clock to a different timezone, assign the timezone name to <code class="language-plaintext highlighter-rouge">libvirt.clock_timezone</code>.</li> <li>To set the clock to the same absolute time whenever the VM starts, set <code class="language-plaintext highlighter-rouge">libvirt.clock_absolute</code>. The value format is that of an epoch timestamp.</li> <li>To set the clock at an arbitrary offset to realtime, use <code class="language-plaintext highlighter-rouge">libvirt.clock_adjustment</code>. Specify the offset adjustment in seconds. By default, the clock offset is relative to UTC, but this can be changed by setting <code class="language-plaintext highlighter-rouge">libvirt.clock_basis</code> to localtime.</li> </ul> <p>In addition to the above, timers can be specified via <code class="language-plaintext highlighter-rouge">libvirt.clock_timer</code>. Available options for timers are: name, track, tickpolicy, frequency, mode, present</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># Set clock offset to localtime</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">clock_offset</span> <span class="o">=</span> <span class="s1">'localtime'</span>
<span class="c1"># Timers ...</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">clock_timer</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'rtc'</span><span class="p">,</span> <span class="ss">:tickpolicy</span> <span class="o">=&gt;</span> <span class="s1">'catchup'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">clock_timer</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'pit'</span><span class="p">,</span> <span class="ss">:tickpolicy</span> <span class="o">=&gt;</span> <span class="s1">'delay'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">clock_timer</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'hpet'</span><span class="p">,</span> <span class="ss">:present</span> <span class="o">=&gt;</span> <span class="s1">'no'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">clock_timer</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'hypervclock'</span><span class="p">,</span> <span class="ss">:present</span> <span class="o">=&gt;</span> <span class="s1">'yes'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="cpu-features"> <a href="#cpu-features" class="anchor-heading" aria-labelledby="cpu-features"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> CPU features </h2> <p>You can specify CPU feature policies via <code class="language-plaintext highlighter-rouge">libvirt.cpu_feature</code>. Available options are listed below. Note that both options are required:</p> <ul> <li><code class="language-plaintext highlighter-rouge">name</code> - The name of the feature for the chosen CPU (see Libvirts <code class="language-plaintext highlighter-rouge">cpu_map.xml</code>)</li> <li><code class="language-plaintext highlighter-rouge">policy</code> - The policy for this feature (one of <code class="language-plaintext highlighter-rouge">force</code>, <code class="language-plaintext highlighter-rouge">require</code>, <code class="language-plaintext highlighter-rouge">optional</code>, <code class="language-plaintext highlighter-rouge">disable</code> and <code class="language-plaintext highlighter-rouge">forbid</code> - see Libvirt documentation)</li> </ul> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="c1"># The feature will not be supported by virtual CPU.</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpu_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'hypervisor'</span><span class="p">,</span> <span class="ss">:policy</span> <span class="o">=&gt;</span> <span class="s1">'disable'</span>
<span class="c1"># Guest creation will fail unless the feature is supported by host CPU.</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpu_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'vmx'</span><span class="p">,</span> <span class="ss">:policy</span> <span class="o">=&gt;</span> <span class="s1">'require'</span>
<span class="c1"># The virtual CPU will claim the feature is supported regardless of it being supported by host CPU.</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">cpu_feature</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">'pdpe1gb'</span><span class="p">,</span> <span class="ss">:policy</span> <span class="o">=&gt;</span> <span class="s1">'force'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="memory-backing"> <a href="#memory-backing" class="anchor-heading" aria-labelledby="memory-backing"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Memory Backing </h2> <p>You can specify memoryBacking options via <code class="language-plaintext highlighter-rouge">libvirt.memorybacking</code>. Available options are shown below. Full documentation is available at the <a href="https://libvirt.org/formatdomain.html#memory-backing">libvirt <em>memoryBacking</em> section</a>.</p> <p>NOTE: The hugepages <code class="language-plaintext highlighter-rouge">&lt;page&gt;</code> element is not yet supported</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">provider</span> <span class="ss">:libvirt</span> <span class="k">do</span> <span class="o">|</span><span class="n">libvirt</span><span class="o">|</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:hugepages</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:nosharepages</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:locked</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:source</span><span class="p">,</span> <span class="ss">:type</span> <span class="o">=&gt;</span> <span class="s1">'file'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:access</span><span class="p">,</span> <span class="ss">:mode</span> <span class="o">=&gt;</span> <span class="s1">'shared'</span>
<span class="n">libvirt</span><span class="p">.</span><span class="nf">memorybacking</span> <span class="ss">:allocation</span><span class="p">,</span> <span class="ss">:mode</span> <span class="o">=&gt;</span> <span class="s1">'immediate'</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <hr> <footer> <div class="d-flex mt-2"> <p class="text-small text-grey-dk-000 mb-0"> <a href="https://github.com/vagrant-libvirt/vagrant-libvirt/tree/main/docs/configuration.markdown" id="edit-this-page">Edit this page on GitHub</a> </p> </div> </footer> </div> </div> <div class="search-overlay"></div> </div> </body> </html>