[DRE-commits] [vagrant-libvirt] 71/163: honour path parameter of storage directive

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:57:07 UTC 2016


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

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

commit 8f6e2326c8ed860a80063d32b23119184a24178d
Author: Adam Spiers <vagrant-libvirt at adamspiers.org>
Date:   Wed Oct 15 23:56:01 2014 +0100

    honour path parameter of storage directive
    
    Fix use of the `:path` parameter to the `storage` directive:
    
        config.vm.provider :libvirt do |libvirt|
          libvirt.storage :file, :path => 'my-disk.qcow2'
        end
    
    The value of the `:path` parameter was being correctly used in
    `domain.xml.erb` for defining the VM, but it was not passed to libvirt
    via fog's volume creation mechanism:
    
        lib/fog/libvirt/models/compute/templates/volume.xml.erb
    
    Instead, libvirt determines the backing file from the `<name>` element,
    so we ensure that the `:name` parameter contains the correct filename.
---
 lib/vagrant-libvirt/action/create_domain.rb | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 123cb08..0a7d2ef 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -66,15 +66,28 @@ module VagrantPlugins
           storage_prefix = File.dirname(@domain_volume_path)+'/'	# steal
 
           @disks.each do |disk|
-            disk[:name] = _disk_name(@name, disk)
-            if disk[:path].nil?
-              disk[:path] = "#{storage_prefix}#{_disk_name(@name, disk)}"	# automatically chosen!
+            if disk[:path] and disk[:path][0] == '/'
+              raise Errors::FogCreateVolumeError,
+                :error_message =>
+                  "absolute volume path '#{disk[:path]}' not yet supported"
+            end
+
+            disk[:path] ||= _disk_name(@name, disk)
+
+            # On volume creation, the <path> element inside <target>
+            # is oddly ignored; instead the path is taken from the
+            # <name> element:
+            # http://www.redhat.com/archives/libvir-list/2008-August/msg00329.html
+            disk[:name] = disk[:path]
+
+            # Prefix relative paths by storage pool path
+            unless disk[:path][0] == '/'
+              disk[:path] = storage_prefix + disk[:path]
             end
 
             # make the disk. equivalent to:
             # qemu-img create -f qcow2 <path> 5g
             begin
-              #puts "Making disk: #{d}, #{t}, #{p}"
               domain_volume_disk = env[:libvirt_compute].volumes.create(
                 :name => disk[:name],
                 :format_type => disk[:type],

-- 
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