diff --git a/README.md b/README.md index 7c05331..b135119 100644 --- a/README.md +++ b/README.md @@ -1220,6 +1220,20 @@ Vagrant.configure(2) do |config| end ``` +## Custom command line arguments +You can also specify multiple qemuargs arguments for qemu-system + +* `value` - Value + +```ruby +Vagrant.configure("2") do |config| + config.vm.provider :libvirt do |libvirt| + libvirt.qemuargs :value => "-device" + libvirt.qemuargs :value => "intel-iommu" + end +end +``` + ## Box Format You can view an example box in the diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index 66a05cc..38aa909 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -88,9 +88,9 @@ module VagrantPlugins # PCI device passthrough @pcis = config.pcis - + # Watchdog device - @watchdog_dev = config.watchdog_dev + @watchdog_dev = config.watchdog_dev # USB device passthrough @usbs = config.usbs @@ -102,6 +102,9 @@ module VagrantPlugins # smartcard device @smartcard_dev = config.smartcard_dev + # qemuargs + @qemuargs = config.qemuargs + # RNG device passthrough @rng = config.rng @@ -280,6 +283,14 @@ module VagrantPlugins env[:ui].info(" -- smartcard device: mode=#{@smartcard_dev[:mode]}, type=#{@smartcard_dev[:type]}") end + unless @qemuargs.empty? + env[:ui].info(' -- Command line args: ') + @qemuargs.each do |arg| + msg = " -> value=#{arg[:value]}, " + env[:ui].info(msg) + end + end + env[:ui].info(" -- Command line : #{@cmd_line}") # Create libvirt domain. diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 91c7497..63e5532 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -141,6 +141,9 @@ module VagrantPlugins # Attach mgmt network attr_accessor :mgmt_attach + # Additional qemuargs arguments + attr_accessor :qemuargs + def initialize @uri = UNSET_VALUE @driver = UNSET_VALUE @@ -238,6 +241,8 @@ module VagrantPlugins # Attach mgmt network @mgmt_attach = UNSET_VALUE + + @qemuargs = UNSET_VALUE end def boot(device) @@ -489,6 +494,11 @@ module VagrantPlugins @disks << disk # append end + def qemuargs(options = {}) + @qemuargs = [] if @qemuargs == UNSET_VALUE + @qemuargs.push(value: options[:value]) + end + # code to generate URI from a config moved out of the connect action def _generate_uri # builds the libvirt connection URI from the given driver config @@ -651,6 +661,8 @@ module VagrantPlugins # Attach mgmt network @mgmt_attach = true if @mgmt_attach == UNSET_VALUE + + @qemuargs = [] if @qemuargs == UNSET_VALUE end def validate(machine) @@ -676,9 +688,14 @@ module VagrantPlugins c = disks.dup c += other.disks result.disks = c + c = cdroms.dup c += other.cdroms result.cdroms = c + + c = qemuargs.dup + c += other.qemuargs + result.qemuargs = c end end end diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index e3f7838..9bb30a1 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -1,4 +1,4 @@ - + <%= @name %> <%= @uuid %> <%= @memory_size %> @@ -218,4 +218,12 @@ <% end -%> + + <% unless @qemuargs.empty? %> + + <% @qemuargs.each do |arg| %> + + <% end %> + + <% end %> diff --git a/spec/unit/templates/domain_all_settings.xml b/spec/unit/templates/domain_all_settings.xml index 51d7a19..2612e58 100644 --- a/spec/unit/templates/domain_all_settings.xml +++ b/spec/unit/templates/domain_all_settings.xml @@ -1,4 +1,4 @@ - + @@ -125,4 +125,9 @@ + + + + + diff --git a/spec/unit/templates/domain_defaults.xml b/spec/unit/templates/domain_defaults.xml index fdbd1eb..6dabc25 100644 --- a/spec/unit/templates/domain_defaults.xml +++ b/spec/unit/templates/domain_defaults.xml @@ -1,4 +1,4 @@ - + @@ -42,4 +42,5 @@ + diff --git a/spec/unit/templates/domain_spec.rb b/spec/unit/templates/domain_spec.rb index 215339c..9e1fca6 100644 --- a/spec/unit/templates/domain_spec.rb +++ b/spec/unit/templates/domain_spec.rb @@ -62,6 +62,9 @@ describe 'templates/domain' do domain.watchdog(model: 'i6300esb', action: 'reset') domain.smartcard(mode: 'passthrough') domain.tpm_path = '/dev/tpm0' + + domain.qemuargs(value: '-device') + domain.qemuargs(value: 'dummy-device') end let(:test_file) { 'domain_all_settings.xml' } it 'renders template' do