Skip to content

Commit

Permalink
config: virtio_rng addition
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr committed Mar 23, 2014
1 parent 0859785 commit 5b8de4f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ image. This is slower but allows multiple VMs to be booted at the same time.
It keeps resource online but execution is stopped.
When VM has a device that is not supported `hibernate`, automatically use
`pause` regardless of this.
* `virtio_rng` - boolean for optional virtio device of random number generator.
QEMU 1.3.0 and after support this device. default `false`


## Comparison with [Vagrant-libvirt](https://github.com/pradels/vagrant-libvirt)
Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-kvm/action/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def call(env)
:machine_type => provider_config.machine_type,
:network_model => provider_config.network_model,
:video_model => provider_config.video_model,
:virtio_rng => provider_config.virtio_rng
}.merge(args)

args[:disk_bus] = provider_config.disk_bus if provider_config.disk_bus
Expand Down
3 changes: 3 additions & 0 deletions lib/vagrant-kvm/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Config < Vagrant.plugin("2", :config)
attr_accessor :network_model
attr_accessor :video_model
attr_accessor :sound
attr_accessor :virtio_rng

# disk bus type
# sata/virtio
Expand Down Expand Up @@ -92,6 +93,7 @@ def initialize
@sound = UNSET_VALUE
@force_pause = UNSET_VALUE
@enable_virtfs = UNSET_VALUE
@virtio_rng = UNSET_VALUE
end

# Customize the VM by predefined actions.
Expand Down Expand Up @@ -172,6 +174,7 @@ def finalize!
@sound = false if @sound == UNSET_VALUE
@force_pause = false if @force_pause == UNSET_VALUE
@enable_virtfs = false if @enable_virtfs == UNSET_VALUE
@virtio_rng = nil if @virtio_rng == UNSET_VALUE
end

def validate(machine)
Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-kvm/driver/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def import(definition, volume_name, args={})
:disk => volume_path,
:name => @name
}.merge(args)
args.merge!(:virtio_rng => nil) if @conn.version.to_i < 1003000 # virtio_rng supported in 1.3.0+
definition.update(args)
# create vm
@logger.info("Creating new VM")
Expand Down
6 changes: 6 additions & 0 deletions templates/libvirt_domain.erb
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@
</filesystem>
<% end %>
<% end %>
<% if virtio_rng %>
<rng model='virtio'>
<rate period="2000" bytes="1234"/>
<backend model='random'>/dev/random</backend>
</rng>
<% end %>
</devices>
</domain>

0 comments on commit 5b8de4f

Please sign in to comment.