[DRE-commits] [vagrant-libvirt] 32/104: nested virtualization

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:55:42 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.

commit c1c360f2cb997a684c33f189183be1c45a07bf0f
Author: dima <pronix.service at gmail.com>
Date:   Mon May 6 19:47:53 2013 +0200

    nested virtualization
---
 README.md                                    | 5 +++--
 lib/vagrant-libvirt/action/create_domain.rb  | 1 +
 lib/vagrant-libvirt/config.rb                | 3 +++
 lib/vagrant-libvirt/templates/domain.xml.erb | 8 ++++++++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index b707efe..465344f 100644
--- a/README.md
+++ b/README.md
@@ -72,11 +72,11 @@ Vagrant.configure("2") do |config|
     libvirt.connect_via_ssh = true
     libvirt.username = "root"
     libvirt.storage_pool_name = "default"
+    libvirt.nested = true
   end
 end
 
 ```
-
 ### Libvirt Configuration Options
 
 This provider exposes quite a few provider-specific configuration options:
@@ -93,6 +93,7 @@ This provider exposes quite a few provider-specific configuration options:
 
 * `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
 * `cpus` - Number of virtual cpus. Defaults to 1 if not set.
+* `nested` - [Enable nested virtualization.Default: false] (https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt)
 
 Specific domain settings can be set for each domain separately in multi-VM
 environment. Example below shows a part of Vagrantfile, where specific options
@@ -130,7 +131,7 @@ Vagrant goes through steps below when creating new project:
 
 1.	Connect to Libvirt localy or remotely via SSH.
 2.	Check if box image is available in Libvirt storage pool. If not, upload it to
-	remote Libvirt storage pool as new volume. 
+	remote Libvirt storage pool as new volume.
 3.	Create COW diff image of base box image for new Libvirt domain.
 4.	Create and start new domain on Libvirt host.
 5.	Check for DHCP lease from dnsmasq server.
diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index cead2f6..a54870b 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -19,6 +19,7 @@ module VagrantPlugins
           # Gather some info about domain
           @name = env[:domain_name]
           @cpus = config.cpus
+          @nested = config.nested
           @memory_size = config.memory*1024
 
           # TODO get type from driver config option
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index f48d630..a8a151f 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -25,6 +25,7 @@ module VagrantPlugins
       # Domain specific settings used while creating new domain.
       attr_accessor :memory
       attr_accessor :cpus
+      attr_accessor :nested
 
       def initialize
         @driver            = UNSET_VALUE
@@ -37,6 +38,7 @@ module VagrantPlugins
         # Domain specific settings.
         @memory            = UNSET_VALUE
         @cpus              = UNSET_VALUE
+        @nested            = UNSET_VALUE
       end
 
       def finalize!
@@ -50,6 +52,7 @@ module VagrantPlugins
         # Domain specific settings.
         @memory = 512 if @memory == UNSET_VALUE
         @cpus = 1 if @cpus == UNSET_VALUE
+        @nested = false if @nested == UNSET_VALUE
       end
 
       def validate(machine)
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index d1eb492..fdb7e4a 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -2,6 +2,14 @@
   <name><%= @name %></name>
   <memory><%= @memory_size %></memory>
   <vcpu><%= @cpus %></vcpu>
+
+  <% if @nested %>
+    <cpu match='exact'>
+      <model>core2duo</model>
+      <feature policy='require' name='vmx'/>
+    </cpu>
+  <% end %>
+
   <os>
     <type arch='x86_64'>hvm</type>
     <boot dev='hd'/>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list