Navigation Menu

Skip to content

Commit

Permalink
Add disk property 'shareable'
Browse files Browse the repository at this point in the history
To simulate shared SAN storage an additional libvirt
disk property needs to be set which disables caching.

Also updated the documentation to document this new
property and added an example on how to simulate
shared SAN storage

Closes #648
  • Loading branch information
epienbroek committed Sep 7, 2016
1 parent 802e666 commit d78d896
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
15 changes: 12 additions & 3 deletions README.md
Expand Up @@ -591,9 +591,9 @@ It has a number of options:
[here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html)
for a fuller explanation). Defaults to *default*.
* `allow_existing` - Set to true if you want to allow the VM to use a
pre-existing disk. This is useful for sharing disks between VMs, e.g. in
order to simulate shared SAN storage. Shared disks removed only manually. If
not exists - will created. If exists - using existed.
pre-existing disk. If the disk doesn't exist it will be created.
Disks with this option set to true need to be removed manually.
* `shareable` - Set to true if you want to simulate shared SAN storage.

The following example creates two additional disks.

Expand All @@ -606,6 +606,15 @@ Vagrant.configure("2") do |config|
end
```

For shared SAN storage to work the following example can be used:
```ruby
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.storage :file, :size => '20G', :path => 'my_shared_disk.img', :allow_existing => true, :shareable => true, :type => 'raw'
end
end
```

### Reload behavior

On `vagrant reload` the following additional disk attributes are updated in
Expand Down
3 changes: 2 additions & 1 deletion lib/vagrant-libvirt/action/create_domain.rb
Expand Up @@ -191,7 +191,8 @@ def call(env)

@disks.each do |disk|
msg = " -- Disk(#{disk[:device]}): #{disk[:absolute_path]}"
msg += ' (shared. Remove only manually)' if disk[:allow_existing]
msg += ' Shared' if disk[:shareable]
msg += ' (Remove only manually)' if disk[:allow_existing]
msg += ' Not created - using existed.' if disk[:preexisting]
env[:ui].info(msg)
end
Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-libvirt/config.rb
Expand Up @@ -376,6 +376,7 @@ def _handle_disk_storage(options={})
:bus => options[:bus],
:cache => options[:cache] || 'default',
:allow_existing => options[:allow_existing],
:shareable => options[:shareable],
}

@disks << disk # append
Expand Down
3 changes: 3 additions & 0 deletions lib/vagrant-libvirt/templates/domain.xml.erb
Expand Up @@ -75,6 +75,9 @@
<driver name='qemu' type='<%= d[:type] %>' cache='<%= d[:cache] %>'/>
<source file='<%= d[:absolute_path] %>'/>
<target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/>
<% if d[:shareable] %>
<shareable/>
<% end %>
<%# this will get auto generated by libvirt
<address type='pci' domain='0x0000' bus='0x00' slot='???' function='0x0'/>
-%>
Expand Down

0 comments on commit d78d896

Please sign in to comment.