mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Guest PCI address options for passthrough devices (#1481)
When assigning a pci passthrough device, the domain, bus, slot and function parameters pertain to the host device address. Add guest_ flavours of these to allow setting the address of the device in the guest as well. Fixes: #1475
This commit is contained in:
@@ -528,10 +528,14 @@ module VagrantPlugins
|
||||
pci_domain = options[:domain]
|
||||
end
|
||||
|
||||
@pcis.push(domain: pci_domain,
|
||||
bus: options[:bus],
|
||||
slot: options[:slot],
|
||||
function: options[:function])
|
||||
@pcis.push(domain: pci_domain,
|
||||
bus: options[:bus],
|
||||
slot: options[:slot],
|
||||
function: options[:function],
|
||||
guest_domain: options[:guest_domain],
|
||||
guest_bus: options[:guest_bus],
|
||||
guest_slot: options[:guest_slot],
|
||||
guest_function: options[:guest_function])
|
||||
end
|
||||
|
||||
def watchdog(options = {})
|
||||
|
||||
@@ -230,15 +230,20 @@
|
||||
<backend model='random'>/dev/random</backend>
|
||||
</rng>
|
||||
<%- end -%>
|
||||
<%- @pcis.each do |pci| -%>
|
||||
<%-
|
||||
@pcis.each do |pci|
|
||||
pci = pci.reject { |k,v| v.nil? }
|
||||
guest_prefix = "guest_"
|
||||
pci_host = pci.select { |k,_| !k.to_s.start_with?(guest_prefix) }
|
||||
pci_guest = pci.select { |k,_| k.to_s.start_with?(guest_prefix) }
|
||||
-%>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<source>
|
||||
<address <%= pci.select { |k,_| [:domain, :bus, :slot, :function].include? k }
|
||||
.reject { |k,v| v.nil? }
|
||||
.map { |k,v| "#{k.to_s}='#{v}'" }
|
||||
.join(' ')
|
||||
-%>/>
|
||||
<address <%= pci_host.map { |k,v| "#{k.to_s}='#{v}'" } .join(' ') -%>/>
|
||||
</source>
|
||||
<%- if !pci_guest.empty? -%>
|
||||
<address type='pci' <%= pci_guest.map { |k,v| "#{k.to_s[guest_prefix.length..-1]}='#{v}'" } .join(' ') -%>/>
|
||||
<%- end -%>
|
||||
</hostdev>
|
||||
<%- end -%>
|
||||
<%- @usbs.each do |usb| -%>
|
||||
|
||||
Reference in New Issue
Block a user